kt_path
stringlengths
35
167
kt_source
stringlengths
626
28.9k
classes
listlengths
1
17
ummen-sherry__adventofcode2023__c91c1b6/src/main/kotlin/Day2.kt
import java.util.Locale import java.util.Optional import kotlin.jvm.optionals.getOrDefault data class GameLimit(val redLimit: Int = 12, val greenLimit: Int = 13, val blueLimit: Int = 14) fun GameLimit.isValid(color: String, count: Int): Boolean { return when (color.lowercase(Locale.getDefault())) { "red" ...
[ { "class_path": "ummen-sherry__adventofcode2023__c91c1b6/Day2Kt.class", "javap": "Compiled from \"Day2.kt\"\npublic final class Day2Kt {\n private static final GameLimit gameLimit;\n\n public static final boolean isValid(GameLimit, java.lang.String, int);\n Code:\n 0: aload_0\n 1: ldc ...
ShuffleZZZ__ITMO__29db54d/ParallelProgramming/possible-executions-analysis/src/PossibleExecutionsVerifier.kt
import java.io.* import java.util.* const val SOLUTION_FILE_NAME = "solution.txt" val STATE_REGEX = Regex("\\[P([1-4]),Q([1-4]),([01]),([01])]") fun main() { val transitions = mutableSetOf<Transition>() File(SOLUTION_FILE_NAME).readLines().forEachIndexed { index, line -> val trim = line.substringBefor...
[ { "class_path": "ShuffleZZZ__ITMO__29db54d/PossibleExecutionsVerifierKt.class", "javap": "Compiled from \"PossibleExecutionsVerifier.kt\"\npublic final class PossibleExecutionsVerifierKt {\n public static final java.lang.String SOLUTION_FILE_NAME;\n\n private static final kotlin.text.Regex STATE_REGEX;\n\...
andrewrlee__adventOfCode2020__a9c21a6/src/main/kotlin/File09.kt
import java.io.File import java.nio.charset.StandardCharsets.UTF_8 private class Challenge09 { val numbers = File("src/main/resources/09-input.txt").readLines(UTF_8).map { it.toLong() } fun <A, B> cartesianProduct(listA: Iterable<A>, listB: Iterable<B>): Sequence<Pair<A, B>> = sequence { list...
[ { "class_path": "andrewrlee__adventOfCode2020__a9c21a6/File09Kt.class", "javap": "Compiled from \"File09.kt\"\npublic final class File09Kt {\n public static final void main();\n Code:\n 0: new #8 // class Challenge09\n 3: dup\n 4: invokespecial #11 ...
andrewrlee__adventOfCode2020__a9c21a6/src/main/kotlin/File08.kt
import Challenge08.Operation.* import java.io.File import java.nio.charset.StandardCharsets.UTF_8 private class Challenge08 { enum class Operation { acc, jmp, nop } enum class Mode { ALLOW_MODIFY, NO_MODIFY } data class Instruction(val index: Int, val op: Operation, val value: Int) { constructor(...
[ { "class_path": "andrewrlee__adventOfCode2020__a9c21a6/File08Kt.class", "javap": "Compiled from \"File08.kt\"\npublic final class File08Kt {\n public static final void main();\n Code:\n 0: new #8 // class Challenge08\n 3: dup\n 4: invokespecial #11 ...
andrewrlee__adventOfCode2020__a9c21a6/src/main/kotlin/File02.kt
import java.io.File import java.nio.charset.StandardCharsets.UTF_8 private class Challenge02 { data class Policy(val low: Int, val high: Int, val v: Char) val pattern = "(\\d+)-(\\d+) (\\w): (\\w+)".toRegex() fun readPoliciesAndPasswords() = File("src/main/resources/02-input.txt").readLines(UTF_8) ...
[ { "class_path": "andrewrlee__adventOfCode2020__a9c21a6/File02Kt.class", "javap": "Compiled from \"File02.kt\"\npublic final class File02Kt {\n public static final void main();\n Code:\n 0: new #8 // class Challenge02\n 3: dup\n 4: invokespecial #11 ...
andrewrlee__adventOfCode2020__a9c21a6/src/main/kotlin/File07.kt
import java.io.File import java.nio.charset.StandardCharsets.UTF_8 private class Challenge07 { data class Bag(val description: String, val quantity: Int, val children: List<Bag> = emptyList()) { constructor(args: List<String>) : this(args[2], args[1].toInt()) companion object { val fu...
[ { "class_path": "andrewrlee__adventOfCode2020__a9c21a6/File07Kt.class", "javap": "Compiled from \"File07.kt\"\npublic final class File07Kt {\n public static final void main();\n Code:\n 0: new #8 // class Challenge07\n 3: dup\n 4: invokespecial #11 ...
ahampriyanshu__algo-ds-101__ea880b1/Data-Structures/Graph/GraphUsingList.kt
import kotlin.collections.ArrayList class Node<T>(val value: T) { val neighbors = ArrayList<Node<T>>() fun addNeighbor(node: Node<T>) = neighbors.add(node) override fun toString(): String = value.toString() } class Graph<T> { private val nodes = HashSet<Node<T>>() fun addNode(value: T) { ...
[ { "class_path": "ahampriyanshu__algo-ds-101__ea880b1/GraphUsingListKt.class", "javap": "Compiled from \"GraphUsingList.kt\"\npublic final class GraphUsingListKt {\n public static final <T> java.util.List<T> bfs(Graph<T>, T);\n Code:\n 0: aload_0\n 1: ldc #10 // Stri...
ahampriyanshu__algo-ds-101__ea880b1/Algorithms/Array/twoSum.kt
import java.util.* /*Naive Approach: Check for all pairs if they adds up to the target or not TC: O(n*n) SC: O(1) */ fun findTwoSumNaive(nums: List<Int>, target: Int): IntArray{ val n = nums.size for(i in 0 until n){ for(j in (i+1) until n){ if(nums[i] + nums[j] == target) r...
[ { "class_path": "ahampriyanshu__algo-ds-101__ea880b1/TwoSumKt.class", "javap": "Compiled from \"twoSum.kt\"\npublic final class TwoSumKt {\n public static final int[] findTwoSumNaive(java.util.List<java.lang.Integer>, int);\n Code:\n 0: aload_0\n 1: ldc #10 // Strin...
namyxc__adventOfCode2020__60fa699/src/main/kotlin/Puzzle19.kt
object Puzzle19 { @JvmStatic fun main(args: Array<String>) { val input = Puzzle19::class.java.getResource("puzzle19.txt").readText() val calculatedMatchingStringCount = countMatchingStrings(input,Puzzle19::useSameRules) println(calculatedMatchingStringCount) val calculatedMatchi...
[ { "class_path": "namyxc__adventOfCode2020__60fa699/Puzzle19$main$calculatedMatchingStringCount$1.class", "javap": "Compiled from \"Puzzle19.kt\"\nfinal class Puzzle19$main$calculatedMatchingStringCount$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<java.lang.In...
namyxc__adventOfCode2020__60fa699/src/main/kotlin/Puzzle16.kt
import java.math.BigInteger object Puzzle16 { @JvmStatic fun main(args: Array<String>) { val input = Puzzle16::class.java.getResource("puzzle16.txt").readText() val ticketInfo = TicketInfo(input) println(ticketInfo.sumInvalidNumbers()) println(ticketInfo.getProdOfDepartmentFie...
[ { "class_path": "namyxc__adventOfCode2020__60fa699/Puzzle16$Rules$Rule.class", "javap": "Compiled from \"Puzzle16.kt\"\nfinal class Puzzle16$Rules$Rule {\n private final java.lang.String name;\n\n private final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> ranges;\n\n private java.uti...
namyxc__adventOfCode2020__60fa699/src/main/kotlin/Puzzle22.kt
object Puzzle22 { @JvmStatic fun main(args: Array<String>) { val input = Puzzle22::class.java.getResource("puzzle22.txt").readText() val decksNormalPlay = Decks(input) println(decksNormalPlay.calculateWinnerScoreNormalPlay()) val decksRecursivePlay = Decks(input) printl...
[ { "class_path": "namyxc__adventOfCode2020__60fa699/Puzzle22.class", "javap": "Compiled from \"Puzzle22.kt\"\npublic final class Puzzle22 {\n public static final Puzzle22 INSTANCE;\n\n private Puzzle22();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object....
namyxc__adventOfCode2020__60fa699/src/main/kotlin/Puzzle12.kt
import kotlin.math.absoluteValue object Puzzle12 { @JvmStatic fun main(args: Array<String>) { val input = Puzzle12::class.java.getResource("puzzle12.txt").readText() val calculatedDistance = calculateDistance(input) println(calculatedDistance) val calculateDistanceWithWaypoint ...
[ { "class_path": "namyxc__adventOfCode2020__60fa699/Puzzle12$ShipData.class", "javap": "Compiled from \"Puzzle12.kt\"\npublic final class Puzzle12$ShipData {\n private Puzzle12$Direction headTo;\n\n private int posEast;\n\n private int posNorth;\n\n private int waypointPosEast;\n\n private int waypointP...
namyxc__adventOfCode2020__60fa699/src/main/kotlin/Puzzle7.kt
object Puzzle7 { @JvmStatic fun main(args: Array<String>) { val rules = Rules(Puzzle7::class.java.getResource("puzzle7.txt").readText().split("\n")) val sumOfAvailableOuterColors = rules.countContainingBags("shiny gold") println(sumOfAvailableOuterColors) val sumOfAvailableIn...
[ { "class_path": "namyxc__adventOfCode2020__60fa699/Puzzle7.class", "javap": "Compiled from \"Puzzle7.kt\"\npublic final class Puzzle7 {\n public static final Puzzle7 INSTANCE;\n\n private Puzzle7();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<in...
namyxc__adventOfCode2020__60fa699/src/main/kotlin/Puzzle14.kt
import java.math.BigInteger import kotlin.math.pow object Puzzle14 { @JvmStatic fun main(args: Array<String>) { val input = Puzzle14::class.java.getResource("puzzle14.txt").readText() val program1 = Program(input) program1.run() println(program1.sumOfUsedMemoryAddresses()) ...
[ { "class_path": "namyxc__adventOfCode2020__60fa699/Puzzle14$Program$SubProgram.class", "javap": "Compiled from \"Puzzle14.kt\"\npublic final class Puzzle14$Program$SubProgram {\n private final java.lang.String mask;\n\n private final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> statem...
namyxc__adventOfCode2020__60fa699/src/main/kotlin/Puzzle21.kt
object Puzzle21 { @JvmStatic fun main(args: Array<String>) { val input = Puzzle21::class.java.getResource("puzzle21.txt").readText() val allergicData = AllergicData(input) println(allergicData.countNonAllergicIngredients()) println(allergicData.listIngredientsByAllergens()) ...
[ { "class_path": "namyxc__adventOfCode2020__60fa699/Puzzle21.class", "javap": "Compiled from \"Puzzle21.kt\"\npublic final class Puzzle21 {\n public static final Puzzle21 INSTANCE;\n\n private Puzzle21();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object....
namyxc__adventOfCode2020__60fa699/src/main/kotlin/Puzzle13.kt
import java.math.BigInteger object Puzzle13 { @JvmStatic fun main(args: Array<String>) { val input = Puzzle13::class.java.getResource("puzzle13.txt").readText() val earliestBusNumberMultipledByWaitTime = earliestBusNumberMultipledByWaitTime(input) println(earliestBusNumberMultipledByWa...
[ { "class_path": "namyxc__adventOfCode2020__60fa699/Puzzle13$Eucledian.class", "javap": "Compiled from \"Puzzle13.kt\"\npublic final class Puzzle13$Eucledian {\n private java.util.List<java.math.BigInteger> q;\n\n private java.util.List<java.math.BigInteger> r;\n\n private java.util.List<java.math.BigInte...
namyxc__adventOfCode2020__60fa699/src/main/kotlin/Puzzle17.kt
object Puzzle17 { @JvmStatic fun main(args: Array<String>) { val input = Puzzle17::class.java.getResource("puzzle17.txt").readText() val calculatedActiveCountIn3D = calculateActiveCountIn3D(input) println(calculatedActiveCountIn3D) val calculatedActiveCountIn4D = calculateActive...
[ { "class_path": "namyxc__adventOfCode2020__60fa699/Puzzle17$State3D.class", "javap": "Compiled from \"Puzzle17.kt\"\npublic final class Puzzle17$State3D {\n private final java.util.List<java.util.List<char[]>> grid;\n\n public Puzzle17$State3D(java.lang.String);\n Code:\n 0: aload_1\n 1: ld...
namyxc__adventOfCode2020__60fa699/src/main/kotlin/Puzzle11.kt
object Puzzle11 { @JvmStatic fun main(args: Array<String>) { val input = Puzzle11::class.java.getResource("puzzle11.txt").readText() val calculateOccupiedSeats = calculateOccupiedSeats(input, Puzzle11::countImmediatelyAdjacentSeats, 4) println(calculateOccupiedSeats) val calc...
[ { "class_path": "namyxc__adventOfCode2020__60fa699/Puzzle11$main$calculateOccupiedSeats$1.class", "javap": "Compiled from \"Puzzle11.kt\"\nfinal class Puzzle11$main$calculateOccupiedSeats$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function5<java.lang.Integer, java.la...
namyxc__adventOfCode2020__60fa699/src/main/kotlin/Puzzle10.kt
import java.math.BigInteger object Puzzle10 { @JvmStatic fun main(args: Array<String>) { val input = Puzzle10::class.java.getResource("puzzle10.txt").readText() val count1and3diffInInput = count1and3diffInInput(input) println(count1and3diffInInput.first * count1and3diffInInput.secon...
[ { "class_path": "namyxc__adventOfCode2020__60fa699/Puzzle10.class", "javap": "Compiled from \"Puzzle10.kt\"\npublic final class Puzzle10 {\n public static final Puzzle10 INSTANCE;\n\n private Puzzle10();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object....
xieweiking__leetcode-cn__a7a1fc3/problems/0005_longest-palindromic-substring/manacher/Solution.kt
class Solution { fun longestPalindrome(s: String): String { if (s.length <= 1) return s val size = 2 * s.length + 1; val t = CharArray(size) for (i in 0..(s.length - 1)) t[2 * i + 1] = s[i] val pLens = IntArray(size) var c = 0 var r = 0...
[ { "class_path": "xieweiking__leetcode-cn__a7a1fc3/Solution.class", "javap": "Compiled from \"Solution.kt\"\npublic final class Solution {\n public Solution();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public f...
ggsant__algorithms_analysis_and_data_structure__8ebed6d/algorithms_and_data_structure/with_kotlin/algoritms/LinearSearchAlgorithms.kt
/** * Idea: Go through the vector, analyzing each position i. If A[i].key equals K, then it found the * position and returns i. If you went through the entire vector and no element equal to K exists, * then return -1. * * Linear search is an algorithm which finds the position of a target value within an array (Usu...
[ { "class_path": "ggsant__algorithms_analysis_and_data_structure__8ebed6d/LinearSearchAlgorithmsKt.class", "javap": "Compiled from \"LinearSearchAlgorithms.kt\"\npublic final class LinearSearchAlgorithmsKt {\n public static final void main();\n Code:\n 0: bipush 9\n 2: newarray i...
ggsant__algorithms_analysis_and_data_structure__8ebed6d/algorithms_and_data_structure/with_kotlin/algoritms/BinarySearch.kt
class BinarySearchSolution fun main() { print(binarySearch(arrayOf(12, 3, 24, 5, 10, 23, 9), 23)) } /** * @param array is an array where the element should be found * @param key is an element which should be found * @return index of the element */ fun <T : Comparable<T>> binarySearch(array: Array<T>, key: T): ...
[ { "class_path": "ggsant__algorithms_analysis_and_data_structure__8ebed6d/BinarySearchKt.class", "javap": "Compiled from \"BinarySearch.kt\"\npublic final class BinarySearchKt {\n public static final void main();\n Code:\n 0: bipush 7\n 2: anewarray #8 // class jav...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/SortCharactersByFrequency.kt
/** * Given a string s, sort it in decreasing order based on the frequency of the characters. * The frequency of a character is the number of times it appears in the string. * * Return the sorted string. If there are multiple answers, return any of them. * * * * Example 1: * * Input: s = "tree" * Output: "ee...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/SortCharactersByFrequencyKt.class", "javap": "Compiled from \"SortCharactersByFrequency.kt\"\npublic final class SortCharactersByFrequencyKt {\n public static final java.lang.String frequencySort(java.lang.String);\n Code:\n 0: aload_0\n 1: ld...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/PartitionArrayForMaximumSum.kt
/** * Given an integer array arr, partition the array into (contiguous) subarrays of length at most k. * After partitioning, each subarray has their values changed to become the maximum value of that subarray. * * Return the largest sum of the given array after partitioning. * Test cases are generated so that the ...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/PartitionArrayForMaximumSumKt.class", "javap": "Compiled from \"PartitionArrayForMaximumSum.kt\"\npublic final class PartitionArrayForMaximumSumKt {\n public static final int maxSumAfterPartitioning(int[], int);\n Code:\n 0: aload_0\n 1: ldc ...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/SequentialDigits.kt
/** * An integer has sequential digits if and only if each digit in the number is one more than the previous digit. * * Return a sorted list of all the integers in the range [low, high] inclusive that have sequential digits. * * * * Example 1: * * Input: low = 100, high = 300 * Output: [123,234] * Example 2:...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/SequentialDigitsKt.class", "javap": "Compiled from \"SequentialDigits.kt\"\npublic final class SequentialDigitsKt {\n public static final java.util.List<java.lang.Integer> sequentialDigits(int, int);\n Code:\n 0: new #10 //...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/DailyTemperatures.kt
/** * Given an array of integers temperatures represents the daily temperatures, * return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. * If there is no future day for which this is possible, keep answer[i] == 0 instead. * * * * Example ...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/DailyTemperaturesKt.class", "javap": "Compiled from \"DailyTemperatures.kt\"\npublic final class DailyTemperaturesKt {\n public static final int[] dailyTemperatures(int[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String ...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/QuicksortDualPivot.kt
/** * Swap two elements in an array. */ private fun swap(arr: Array<Int>, i: Int, j: Int) { val temp = arr[i] arr[i] = arr[j] arr[j] = temp } /** * Partition the array around two pivots. * Return the indices of the pivots. */ private fun partition(arr: Array<Int>, left: Int, right: Int): Pair<Int, Int...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/QuicksortDualPivotKt.class", "javap": "Compiled from \"QuicksortDualPivot.kt\"\npublic final class QuicksortDualPivotKt {\n private static final void swap(java.lang.Integer[], int, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: aaload\n ...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/LargestDivisibleSubset.kt
/** * Given a set of distinct positive integers nums, * return the largest subset answer such that every pair (answer[i], answer[j]) of elements in this subset satisfies: * * answer[i] % answer[j] == 0, or * answer[j] % answer[i] == 0 * If there are multiple solutions, return any of them. * * * * Example 1: ...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/LargestDivisibleSubsetKt.class", "javap": "Compiled from \"LargestDivisibleSubset.kt\"\npublic final class LargestDivisibleSubsetKt {\n public static final java.util.List<java.lang.Integer> largestDivisibleSubset(int[]);\n Code:\n 0: aload_0\n ...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/EvaluateReversePolishNotation.kt
/** * You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation. * * Evaluate the expression. Return an integer that represents the value of the expression. * * Note that: * * The valid operators are '+', '-', '*', and '/'. * Each operand may be an integer or...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/EvaluateReversePolishNotationKt.class", "javap": "Compiled from \"EvaluateReversePolishNotation.kt\"\npublic final class EvaluateReversePolishNotationKt {\n public static final int evalRPN(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc ...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/KInversePairsArray.kt
/** * For an integer array nums, an inverse pair is a pair of integers [i, j] where 0 <= i < j < nums.length and nums[i] > nums[j]. * * Given two integers n and k, return the number of different arrays consist of numbers from 1 to n such that there are exactly k inverse pairs. * Since the answer can be huge, return...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/KInversePairsArrayKt.class", "javap": "Compiled from \"KInversePairsArray.kt\"\npublic final class KInversePairsArrayKt {\n public static final int kInversePairs(int, int);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: iload_0\n 3: icon...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/MinimumWindowSubstring.kt
/** * Given two strings s and t of lengths m and n respectively, return the minimum window * substring * of s such that every character in t (including duplicates) is included in the window. * If there is no such substring, return the empty string "". * * The testcases will be generated such that the answer is un...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/MinimumWindowSubstringKt.class", "javap": "Compiled from \"MinimumWindowSubstring.kt\"\npublic final class MinimumWindowSubstringKt {\n public static final java.lang.String minWindow(java.lang.String, java.lang.String);\n Code:\n 0: aload_0\n ...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/DivideArrayIntoArraysWithMaxDifference.kt
/** * You are given an integer array nums of size n and a positive integer k. * * Divide the array into one or more arrays of size 3 satisfying the following conditions: * * Each element of nums should be in exactly one array. * The difference between any two elements in one array is less than or equal to k. * R...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/DivideArrayIntoArraysWithMaxDifferenceKt.class", "javap": "Compiled from \"DivideArrayIntoArraysWithMaxDifference.kt\"\npublic final class DivideArrayIntoArraysWithMaxDifferenceKt {\n public static final int[][] divideArray(int[], int);\n Code:\n 0:...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/GroupAnagrams.kt
/** * Given an array of strings strs, group the anagrams together. You can return the answer in any order. * * An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, * typically using all the original letters exactly once. * * * * Example 1: * * Input: strs = ["eat","t...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/GroupAnagramsKt.class", "javap": "Compiled from \"GroupAnagrams.kt\"\npublic final class GroupAnagramsKt {\n public static final java.util.List<java.util.List<java.lang.String>> groupAnagrams(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc ...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/SubarraySumEqualsK.kt
/** * Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k. * * A subarray is a contiguous non-empty sequence of elements within an array. * * * * Example 1: * * Input: nums = [1,1,1], k = 2 * Output: 2 * Example 2: * * Input: nums = [1,2,3], k = 3 *...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/SubarraySumEqualsKKt.class", "javap": "Compiled from \"SubarraySumEqualsK.kt\"\npublic final class SubarraySumEqualsKKt {\n public static final int subarraySum(int[], int);\n Code:\n 0: aload_0\n 1: ldc #9 // String ...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/PerfectSquares.kt
/** * Given an integer n, return the least number of perfect square numbers that sum to n. * * A perfect square is an integer that is the square of an integer; * in other words, it is the product of some integer with itself. * For example, 1, 4, 9, and 16 are perfect squares while 3 and 11 are not. * * * * Exa...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/PerfectSquaresKt.class", "javap": "Compiled from \"PerfectSquares.kt\"\npublic final class PerfectSquaresKt {\n public static final int numSquares(int);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: iload_0\n 3: iconst_1\n 4: iadd...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/LongestCommonSubsequence.kt
/** * Given two strings text1 and text2, return the length of their longest common subsequence. * If there is no common subsequence, return 0. * * A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative order of the remain...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/LongestCommonSubsequenceKt.class", "javap": "Compiled from \"LongestCommonSubsequence.kt\"\npublic final class LongestCommonSubsequenceKt {\n public static final int longestCommonSubsequence(java.lang.String, java.lang.String);\n Code:\n 0: aload_0\...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/PalindromicSubstrings.kt
/** * Given a string s, return the number of palindromic substrings in it. * * A string is a palindrome when it reads the same backward as forward. * * A substring is a contiguous sequence of characters within the string. * * * * Example 1: * * Input: s = "abc" * Output: 3 * Explanation: Three palindromic ...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/PalindromicSubstringsKt.class", "javap": "Compiled from \"PalindromicSubstrings.kt\"\npublic final class PalindromicSubstringsKt {\n public static final int countSubstrings(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #9 ...
Codextor__kotlin-codes__68b75a7/src/main/kotlin/QuickSort.kt
/** * Swap two elements in an array. */ private fun swap(arr: Array<Int>, i: Int, j: Int) { val temp = arr[i] arr[i] = arr[j] arr[j] = temp } /** * Partition the array around a randomly selected pivot. * Return the index of the pivot. */ private fun partition(arr: Array<Int>, left: Int, right: Int): I...
[ { "class_path": "Codextor__kotlin-codes__68b75a7/QuickSortKt.class", "javap": "Compiled from \"QuickSort.kt\"\npublic final class QuickSortKt {\n private static final void swap(java.lang.Integer[], int, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: aaload\n 3: invokevirtual #12 ...
Uberts94__kotlin__ce54675/exercises/practice/minesweeper/src/main/kotlin/Minesweeper.kt
data class MinesweeperBoard(val inputBoard: List<String>) { fun withNumbers(): List<String> = inputBoard.mapIndexed { row, str -> str.mapIndexed { col, cell -> when (cell) { '.' -> adjacentMines(row, col) else -> cell } }.joinToString("") ...
[ { "class_path": "Uberts94__kotlin__ce54675/MinesweeperKt.class", "javap": "Compiled from \"Minesweeper.kt\"\npublic final class MinesweeperKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String args\n 3: invokesta...
bertptrs__adventofcode__1f41f4b/2017/day-10/solution.kt
fun valArray(): IntArray { val arr = IntArray(256) for (i in arr.indices) { arr[i] = i } return arr } fun hash(input: IntArray, values: IntArray, index: Int, skip: Int): Pair<Int, Int> { var curIndex = index var curSkip = skip for (range in input) { val halfRange = range / ...
[ { "class_path": "bertptrs__adventofcode__1f41f4b/SolutionKt.class", "javap": "Compiled from \"solution.kt\"\npublic final class SolutionKt {\n public static final int[] valArray();\n Code:\n 0: sipush 256\n 3: newarray int\n 5: astore_0\n 6: iconst_0\n 7: istor...
nmicra__kotlin_practice__4bf80f0/src/main/kotlin/LangDecoder.kt
/** * Given map is how to encode any character in alphabet. * Write a decode function, that will return all possible variant that can be encoded for a given string * Example: for a given string "12", possible values [ab,l] * for "1213" --> [abac, abm, auc, lac, lm] */ val map = mapOf( "a" to "1", "b" to "2", ...
[ { "class_path": "nmicra__kotlin_practice__4bf80f0/LangDecoderKt.class", "javap": "Compiled from \"LangDecoder.kt\"\npublic final class LangDecoderKt {\n private static final java.util.Map<java.lang.String, java.lang.String> map;\n\n private static final java.util.Map<java.lang.String, java.lang.String> re...
nmicra__kotlin_practice__4bf80f0/src/main/kotlin/AvailableMeetingSlotsInCalendar.kt
import java.time.LocalTime val person1_meetings = listOf("09:00-09:30", "13:00-14:00", "17:20-18:00") // Scheduled meetings for Person1 val person2_meetings = listOf( "13:30-14:30", "17:00-17:30") // Scheduled meetings for Person2 val restrictions_person1 = "08:00,19:00" // Person1 cannot accept meetings before 8:00 &...
[ { "class_path": "nmicra__kotlin_practice__4bf80f0/AvailableMeetingSlotsInCalendarKt.class", "javap": "Compiled from \"AvailableMeetingSlotsInCalendar.kt\"\npublic final class AvailableMeetingSlotsInCalendarKt {\n private static final java.util.List<java.lang.String> person1_meetings;\n\n private static fi...
carolhmj__aoc2019__a101068/day12/day12.kt
import kotlin.math.* import java.io.File data class Moon(val position : IntArray, val velocity : IntArray = intArrayOf(0,0,0)) data class IndexAndValue<T>(val index : Int, val value : T) fun <T, U> cartesianProductIndexed(c1: Collection<T>, c2: Collection<U>): List<Pair<IndexAndValue<T>, IndexAndValue<U>>> { retu...
[ { "class_path": "carolhmj__aoc2019__a101068/Day12Kt.class", "javap": "Compiled from \"day12.kt\"\npublic final class Day12Kt {\n public static final <T, U> java.util.List<kotlin.Pair<IndexAndValue<T>, IndexAndValue<U>>> cartesianProductIndexed(java.util.Collection<? extends T>, java.util.Collection<? exten...
JiangKlijna__leetcode-learning__65a1348/kt/001 Two Sum/TwoSum.kt
/** * Given an array of integers, return indices of the two numbers such that they add up to a specific target. * You may assume that each input would have exactly one solution. * 给出一个int数组和目标值,从数组中找到两个值使得其和为目标值.返回两个下标位置. * */ class TwoSum { fun twoSum(numbers: IntArray, target: Int): IntArray { val re = IntA...
[ { "class_path": "JiangKlijna__leetcode-learning__65a1348/TwoSum.class", "javap": "Compiled from \"TwoSum.kt\"\npublic final class TwoSum {\n public TwoSum();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public fi...
bsautner__Advent-of-Code-2022__5f53cb1/AOC2022/src/main/kotlin/AOC7.kt
import java.io.File class AOC7 { private val input = File("/home/ben/aoc/input-7.txt") private val list = mutableListOf<String>() private var PWD = Node("root", null) //Present Working Directory var spaceNeeded = 0L var winner = 70000000L fun process() { input.forEachLine { list.add...
[ { "class_path": "bsautner__Advent-of-Code-2022__5f53cb1/AOC7.class", "javap": "Compiled from \"AOC7.kt\"\npublic final class AOC7 {\n public static final AOC7$Companion Companion;\n\n private final java.io.File input;\n\n private final java.util.List<java.lang.String> list;\n\n private Node PWD;\n\n pr...
bsautner__Advent-of-Code-2022__5f53cb1/AOC2022/src/main/kotlin/AOC8.kt
import java.io.File class AOC8 { var maxScore = 0 fun process() { val input = File("/home/ben/aoc/input-8.txt") val sample = input.useLines { it.toList() } val matrix = sample.map { it.toCharArray() }.toTypedArray() var count = 0 matrix.mapIndexed { y, row -> ...
[ { "class_path": "bsautner__Advent-of-Code-2022__5f53cb1/AOC8.class", "javap": "Compiled from \"AOC8.kt\"\npublic final class AOC8 {\n private int maxScore;\n\n public AOC8();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: ret...
XinyueZ__lambda-world__3ec03f2/foreach/src/main0.kt
import java.util.stream.Collectors import java.util.stream.IntStream import java.util.stream.Stream fun main(args: Array<String>) { println("Examples foreach, list, array, collection ....") println() val list1 = listOf("one", "two", "three") foreachList(list1) val list2 = list1 + listOf("four", "f...
[ { "class_path": "XinyueZ__lambda-world__3ec03f2/Main0Kt.class", "javap": "Compiled from \"main0.kt\"\npublic final class Main0Kt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String args\n 3: invokestatic #15 ...
SebastianAigner__aoc-2022-kotlin__2b50330/src/Day01.kt
import java.io.File import java.util.PriorityQueue fun main() { fun parseInput(input: String) = input.split("\n\n").map { elf -> elf.lines().map { it.toInt() } } // O(size * log size) -> O(size * log n) -> O(size) fun List<List<Int>>.topNElves(n: Int): Int { fun findTopN(n: Int, elemen...
[ { "class_path": "SebastianAigner__aoc-2022-kotlin__2b50330/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 ...
hannotify__advent-of-code__ccde130/src/main/kotlin/codes/hanno/adventofcode/day3/Day3Runner.kt
import java.io.File import java.nio.file.Path fun main(args: Array<String>) { Day3Runner().run(Path.of("src/main/resources/day3/input.txt")) } class Day3Runner { fun run(input: Path) { File(input.toString()).useLines { lines -> val groups = mutableListOf<Group>() val rucksacks...
[ { "class_path": "hannotify__advent-of-code__ccde130/Day3Runner$Group.class", "javap": "Compiled from \"Day3Runner.kt\"\npublic final class Day3Runner$Group {\n private final java.util.List<Day3Runner$Rucksack> rucksacks;\n\n public Day3Runner$Group(java.util.List<Day3Runner$Rucksack>);\n Code:\n ...
hannotify__advent-of-code__ccde130/src/main/kotlin/codes/hanno/adventofcode/day2/Day2.kt
import Day2.Choice.ChoiceCategory.* import Day2.Outcome.WDL.* import java.nio.file.Files import java.nio.file.Path fun main(args: Array<String>) { Day2().run(Path.of("src/main/resources/day2/input.txt")) } class Day2 { fun run(input: Path) { val scores = Files.lines(input).map { val split...
[ { "class_path": "hannotify__advent-of-code__ccde130/Day2$Choice$WhenMappings.class", "javap": "Compiled from \"Day2.kt\"\npublic final class Day2$Choice$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n public static final int[] $EnumSwitchMapping$1;\n\n static {};\n Code:\n 0...
gouthamhusky__leetcode-journey__a0e158c/neetcode/src/main/java/org/twopointers/TwoPointers.kt
import kotlin.math.max import kotlin.math.min fun main() { trap(intArrayOf(0,1,0,2,1,0,1,3,2,1,2,1)) } fun isPalindrome(s: String): Boolean { val stringBuilder = StringBuilder() for (c in s){ if (!c.isLetterOrDigit()) continue else if (c.isUpperCase()) stringBuilder...
[ { "class_path": "gouthamhusky__leetcode-journey__a0e158c/TwoPointersKt.class", "javap": "Compiled from \"TwoPointers.kt\"\npublic final class TwoPointersKt {\n public static final void main();\n Code:\n 0: bipush 12\n 2: newarray int\n 4: astore_0\n 5: aload_0\n ...
codermrhasan__ctci-problems-and-solutions__3f40e94/chapter_1_arrays_and_strings/1_is_unique/solution.kt
/* PROBLEM Implement an algorithm to determine if a string has all unique characters. What if you can not use additional data structures? */ /* ALGORITHM 1 - areCharsUnique Keep and array of 256 elements, corresponding to each ASCII character, initially set to false. For each letter in the original string ...
[ { "class_path": "codermrhasan__ctci-problems-and-solutions__3f40e94/SolutionKt.class", "javap": "Compiled from \"solution.kt\"\npublic final class SolutionKt {\n private static final java.lang.Boolean[] letters;\n\n public static final java.lang.Boolean[] getLetters();\n Code:\n 0: getstatic ...
magrathealabs__university__c6f2844/dojos/music-theory/kotlin/Main.kt
data class Note(val name: String) { fun flatten() = Note(name[0].toString() + 'b') } val Notes by lazy { listOf("C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B") .map { Note(it) } } enum class Interval(val value: Int) { Half(1), Whole(2), WholeAndHalf(3); ...
[ { "class_path": "magrathealabs__university__c6f2844/MainKt.class", "javap": "Compiled from \"Main.kt\"\npublic final class MainKt {\n private static final kotlin.Lazy Notes$delegate;\n\n public static final java.util.List<Note> getNotes();\n Code:\n 0: getstatic #12 // Field N...
Edsonctm__LeetCodeKotlin__5e9ae01/_14_Longest_Common_Prefix/src/main/kotlin/LongestCommonPrefix.kt
fun main() { val strs = arrayOf("flower","flow","flight") val strs2 = arrayOf("dog","racecar","car") val strs3 = arrayOf("a") val strs4 = arrayOf("reflower","flow","flight") val strs5 = arrayOf("aaa","aa","aaa") longestCommonPrefix(strs) longestCommonPrefix(strs2) longestCommonPrefix(st...
[ { "class_path": "Edsonctm__LeetCodeKotlin__5e9ae01/LongestCommonPrefixKt.class", "javap": "Compiled from \"LongestCommonPrefix.kt\"\npublic final class LongestCommonPrefixKt {\n public static final void main();\n Code:\n 0: iconst_3\n 1: anewarray #8 // class java/lang/S...
kevinrobayna__adventofcode_2020__8b1a84d/src/main/kotlin/day1.kt
import java.util.stream.Collectors // https://adventofcode.com/2020/day/1 class Day1( private val values: List<Int> ) { fun solve(): Pair<Int, Int> { val pairs: MutableList<Pair<Int, Int>> = mutableListOf() for (outLoop in values.indices) { for (innerLoop in values.indices) { ...
[ { "class_path": "kevinrobayna__adventofcode_2020__8b1a84d/Day1.class", "javap": "Compiled from \"day1.kt\"\npublic final class Day1 {\n private final java.util.List<java.lang.Integer> values;\n\n public Day1(java.util.List<java.lang.Integer>);\n Code:\n 0: aload_1\n 1: ldc #10 ...
Walop__AdventOfCode2022__7a13f65/src/main/kotlin/Day15.kt
import java.io.InputStream import kotlin.math.absoluteValue data class Sensor(val pos: Vec2, val range: Int) class Day15 { companion object { private fun readSensors(input: InputStream?): Pair<List<Sensor>, Set<Vec2>> { if (input == null) { throw Exception("Input missing") ...
[ { "class_path": "Walop__AdventOfCode2022__7a13f65/Day15.class", "javap": "Compiled from \"Day15.kt\"\npublic final class Day15 {\n public static final Day15$Companion Companion;\n\n public Day15();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<ini...
Walop__AdventOfCode2022__7a13f65/src/main/kotlin/Day12.kt
import java.io.InputStream data class HeightMap(val start: List<Int>, val end: Int, val width: Int, val graph: List<List<Boolean>>) class Day12 { companion object { private fun readMap(input: InputStream?, startTile: Char, endTile: Char): HeightMap { if (input == null) { throw ...
[ { "class_path": "Walop__AdventOfCode2022__7a13f65/Day12$Companion.class", "javap": "Compiled from \"Day12.kt\"\npublic final class Day12$Companion {\n private Day12$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: r...
Walop__AdventOfCode2022__7a13f65/src/main/kotlin/Day11.kt
import java.io.InputStream data class Monkey( val items: MutableList<Long>, val operation: (Long) -> Long, val test: Long, val trueReceiver: Int, val falseReceiver: Int, var inspectionCount: Long = 0 ) class Day11 { companion object { private fun createOperation(operator: String, o...
[ { "class_path": "Walop__AdventOfCode2022__7a13f65/Day11$Companion$privateProcess$$inlined$sortedByDescending$1.class", "javap": "Compiled from \"Comparisons.kt\"\npublic final class Day11$Companion$privateProcess$$inlined$sortedByDescending$1<T> implements java.util.Comparator {\n public Day11$Companion$pr...
Walop__AdventOfCode2022__7a13f65/src/main/kotlin/Day9.kt
import java.io.InputStream import kotlin.math.abs import kotlin.math.pow import kotlin.math.sqrt data class Vec2( var x: Int, var y: Int ) { operator fun plus(other: Vec2): Vec2 { return Vec2(x + other.x, y + other.y) } operator fun minus(other: Vec2): Vec2 { return Vec2(x - other....
[ { "class_path": "Walop__AdventOfCode2022__7a13f65/Day9$Companion.class", "javap": "Compiled from \"Day9.kt\"\npublic final class Day9$Companion {\n private Day9$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: retur...
Walop__AdventOfCode2022__7a13f65/src/main/kotlin/Day7.kt
import java.io.InputStream interface IFile { val name: String val size: Int } data class File(override val name: String, override val size: Int) : IFile data class Directory( override val name: String, override var size: Int, val children: MutableList<IFile>, val parent: Directory?, ) : I...
[ { "class_path": "Walop__AdventOfCode2022__7a13f65/Day7.class", "javap": "Compiled from \"Day7.kt\"\npublic final class Day7 {\n public static final Day7$Companion Companion;\n\n public Day7();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":...
Walop__AdventOfCode2022__7a13f65/src/main/kotlin/Day8.kt
import java.io.InputStream import kotlin.math.sqrt class Day8 { companion object { private fun readTreeMap(input: InputStream?): String { if (input == null) { throw Exception("Input missing") } return input.reader().readLines().joinToString("") }...
[ { "class_path": "Walop__AdventOfCode2022__7a13f65/Day8$Companion.class", "javap": "Compiled from \"Day8.kt\"\npublic final class Day8$Companion {\n private Day8$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: retur...
nikitabobko__stalin-sort__6098af3/kotlin/StalinSort.kt
fun main(args: Array<String>) { val intComrades = listOf(0, 2, 1, 4, 3, 6, 5).sortComrades() val charComrades = listOf('A', 'C', 'B', 'E', 'D').sortComrades() val redArmyRanks = listOf( RedArmyRank.SOLDIER, RedArmyRank.ASSISTANT_PLATOON_LEADER, RedArmyRank.SQUAD_LEADER).sortC...
[ { "class_path": "nikitabobko__stalin-sort__6098af3/StalinSortKt.class", "javap": "Compiled from \"StalinSort.kt\"\npublic final class StalinSortKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String args\n 3: invo...
somei-san__atcoder-kotline__43ea45f/src/main/Main.kt
import java.util.* fun main(args: Array<String>) { abc000X() } fun abc000X() { System.err.println("!!!!!!!!!!!テスト!!!!!!!!!") val N = readLine()!! val As = readLine()!!.split(" ").map { it.toInt() }.sorted() System.err.println(As) val sets = mutableListOf<kakeru>() for (k in 0 until As.c...
[ { "class_path": "somei-san__atcoder-kotline__43ea45f/MainKt.class", "javap": "Compiled from \"Main.kt\"\npublic final class MainKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String args\n 3: invokestatic #15 ...
piazentin__programming-challenges__db490b1/hacker-rank/sorting/MergeSortCountingInversions.kt
import java.lang.StringBuilder private fun IntArray.toNiceString(): String { val sb = StringBuilder().append("[") this.forEach { sb.append(it).append(",") } if (sb.length > 1) sb.deleteCharAt(sb.lastIndex).append("]") return sb.toString() } private val IntRange.size: Int get() = this.last - this....
[ { "class_path": "piazentin__programming-challenges__db490b1/MergeSortCountingInversionsKt.class", "javap": "Compiled from \"MergeSortCountingInversions.kt\"\npublic final class MergeSortCountingInversionsKt {\n private static final java.lang.String toNiceString(int[]);\n Code:\n 0: new #...
piazentin__programming-challenges__db490b1/hacker-rank/strings/SpecialPalindromeAgain.kt
fun main() { readLine() // ignore first input val str = readLine().orEmpty() var count = 0L val freqTable = buildFreqTable(str) // all singles for (freq in freqTable) count += triangleNumber(freq.second) // all "middle" cases for (i in 0 until freqTable.size - 2) { if (freq...
[ { "class_path": "piazentin__programming-challenges__db490b1/SpecialPalindromeAgainKt.class", "javap": "Compiled from \"SpecialPalindromeAgain.kt\"\npublic final class SpecialPalindromeAgainKt {\n public static final void main();\n Code:\n 0: invokestatic #12 // Method kotlin/io/Co...
piazentin__programming-challenges__db490b1/hacker-rank/sorting/FraudulentActivityNotifications.kt
// https://www.hackerrank.com/challenges/fraudulent-activity-notifications/problem fun main() { val (_, days) = readLine().orEmpty().trim().split(" ").map(String::toInt) val expenditures = readLine().orEmpty().trim().split(" ").map(String::toInt).toTypedArray() fraudulentActivityNotifications(days, expend...
[ { "class_path": "piazentin__programming-challenges__db490b1/FraudulentActivityNotificationsKt.class", "javap": "Compiled from \"FraudulentActivityNotifications.kt\"\npublic final class FraudulentActivityNotificationsKt {\n public static final void main();\n Code:\n 0: nop\n 1: invokestatic ...
piazentin__programming-challenges__db490b1/hacker-rank/strings/SherlockAndTheValidString.kt
// https://www.hackerrank.com/challenges/sherlock-and-valid-string/problem fun main() { val string = readLine().orEmpty() println(if (isValid(string)) "YES" else "NO") } fun isValid(string: String): Boolean { if (string.length <= 3) return true val charFreq = IntArray('z' - 'a' + 1) for (char i...
[ { "class_path": "piazentin__programming-challenges__db490b1/SherlockAndTheValidStringKt.class", "javap": "Compiled from \"SherlockAndTheValidString.kt\"\npublic final class SherlockAndTheValidStringKt {\n public static final void main();\n Code:\n 0: invokestatic #12 // Method kot...
linisme__LeetCodeInKotlin__4382afc/LongestPalindrome.kt
class LongestPalindromeSolution { fun longestPalindrome(s: String): String { var chars = s.toCharArray() val sourceLength = s.length var maxLength = 0 var maxLeft = 0 var maxRight = 0 for (l in 0 until sourceLength) { if (maxLength > sourceLength - l) { break ...
[ { "class_path": "linisme__LeetCodeInKotlin__4382afc/LongestPalindromeKt.class", "javap": "Compiled from \"LongestPalindrome.kt\"\npublic final class LongestPalindromeKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // Strin...
linisme__LeetCodeInKotlin__4382afc/LengthOfLongestSubstring.kt
class LengthOfLongestSubstringSolution { fun lengthOfLongestSubstring(s: String): Int { var set = hashSetOf<Char>() var maxLength = 0 val size = s.length s.forEachIndexed { index, c -> set.clear() var pos = index + 1 set.add(c) var next : Char? = if (pos < si...
[ { "class_path": "linisme__LeetCodeInKotlin__4382afc/LengthOfLongestSubstringKt.class", "javap": "Compiled from \"LengthOfLongestSubstring.kt\"\npublic final class LengthOfLongestSubstringKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 ...
linisme__LeetCodeInKotlin__4382afc/FineMedianSortedArrays.kt
class FindMedianSortedArraysSolution { fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray): Double { var i1 = 0 var i2 = 0 var length1 = nums1.size var length2 = nums2.size var sortedSize = length1 + length2 var sortedArray = IntArray(sortedSize) var k = 0 wh...
[ { "class_path": "linisme__LeetCodeInKotlin__4382afc/FineMedianSortedArraysKt.class", "javap": "Compiled from \"FineMedianSortedArrays.kt\"\npublic final class FineMedianSortedArraysKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 ...
SelenaChen123__AdventOfCode2022__551af4f/src/Day04/Day04.kt
import java.io.File fun main() { fun part1(input: List<String>): Int { var duplicates = 0 for (line in input) { val first = line.split(",")[0].split("-") val second = line.split(",")[1].split("-") if ((second[0].toInt() in first[0].toInt()..first[1].toInt() && ...
[ { "class_path": "SelenaChen123__AdventOfCode2022__551af4f/Day04Kt.class", "javap": "Compiled from \"Day04.kt\"\npublic final class Day04Kt {\n public static final void main();\n Code:\n 0: new #8 // class java/io/File\n 3: dup\n 4: ldc #10 ...
SelenaChen123__AdventOfCode2022__551af4f/src/Day03/Day03.kt
import java.io.File fun main() { fun part1(input: List<String>): Int { var priorities = 0 for (line in input) { val firstHalf = line.substring(0..line.length / 2 - 1).toSet() val secondHalf = line.substring(line.length / 2).toSet() val intersect = (firstHalf int...
[ { "class_path": "SelenaChen123__AdventOfCode2022__551af4f/Day03Kt.class", "javap": "Compiled from \"Day03.kt\"\npublic final class Day03Kt {\n public static final void main();\n Code:\n 0: new #8 // class java/io/File\n 3: dup\n 4: ldc #10 ...
SelenaChen123__AdventOfCode2022__551af4f/src/Day02/Day02.kt
import java.io.File fun main() { fun part1(input: List<String>): Int { var points = 0 for (line in input) { val them = line.split(" ")[0] val you = line.split(" ")[1] val theirValue = when (them) { "A" -> 1 ...
[ { "class_path": "SelenaChen123__AdventOfCode2022__551af4f/Day02Kt.class", "javap": "Compiled from \"Day02.kt\"\npublic final class Day02Kt {\n public static final void main();\n Code:\n 0: new #8 // class java/io/File\n 3: dup\n 4: ldc #10 ...
SelenaChen123__AdventOfCode2022__551af4f/src/Day01/Day01.kt
import java.io.File fun main() { fun part1(input: List<String>): Int { var globalMax = 0 var localMax = 0 for (line in input) { if (line != "") { localMax = localMax + line.toInt() } else { if (localMax.compareTo(globalMax) > 0) { ...
[ { "class_path": "SelenaChen123__AdventOfCode2022__551af4f/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 ...
ryanclanigan__AdventOfCode2021__766fa81/src/main/kotlin/Day2.kt
import java.io.File enum class Direction { UP, DOWN, FORWARD } class SubmarineCommand(val direction: Direction, val magnitude: Int) fun parseSubmarineCommand(command: String): SubmarineCommand { val pieces = command.split(" ") if (pieces.size != 2) throw Exception("Ruh roh") return SubmarineC...
[ { "class_path": "ryanclanigan__AdventOfCode2021__766fa81/Day2Kt$day2Puzzle2$Grid$WhenMappings.class", "javap": "Compiled from \"Day2.kt\"\npublic final class Day2Kt$day2Puzzle2$Grid$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 ...
Javran__leetcode__f3899fe/bulb-switcher/Solution.kt
import java.lang.Math /* math problem in disguise. First we figure out what determines the end state of i-th bulb (1-based): take n = 5 as an example. 1st bulb is on because 1 has the only factor 1 2nd is off because 2 has two factors: 1,2 3rd is off because 3 has two factors: 1,3 4th: on, factors: 1,2,4 5th: off, f...
[ { "class_path": "Javran__leetcode__f3899fe/Solution.class", "javap": "Compiled from \"Solution.kt\"\npublic final class Solution {\n public static final Solution$Companion Companion;\n\n public Solution();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Objec...
colintheshots__ExercismKotlin__f284aec/kotlin/pig-latin/src/main/kotlin/PigLatin.kt
import java.util.* object PigLatin { private val vowels = setOf('a','e','i','o','u') fun translate(input: String) : String { require(input.all { it.isLowerCase() || it.isWhitespace() }) return input.replace("\\b\\w+\\b".toRegex()) { result : MatchResult -> val word = result.value ...
[ { "class_path": "colintheshots__ExercismKotlin__f284aec/PigLatin.class", "javap": "Compiled from \"PigLatin.kt\"\npublic final class PigLatin {\n public static final PigLatin INSTANCE;\n\n private static final java.util.Set<java.lang.Character> vowels;\n\n private PigLatin();\n Code:\n 0: aload_...
colintheshots__ExercismKotlin__f284aec/kotlin/change/src/main/kotlin/ChangeCalculator.kt
class ChangeCalculator (list: List<Int>) { private val sortedList = list.sortedDescending() fun computeMostEfficientChange(total : Int) : List<Int> { require(total >= 0) {"Negative totals are not allowed."} if (total == 0) return emptyList() // no coins make zero change val trimmed = ...
[ { "class_path": "colintheshots__ExercismKotlin__f284aec/ChangeCalculator.class", "javap": "Compiled from \"ChangeCalculator.kt\"\npublic final class ChangeCalculator {\n private final java.util.List<java.lang.Integer> sortedList;\n\n public ChangeCalculator(java.util.List<java.lang.Integer>);\n Code:\n...
indy256__codelibrary__4055526/kotlin/SuffixArray.kt
fun suffixArray(S: CharSequence): IntArray { val n = S.length // Stable sort of characters. // Same characters are sorted by their position in descending order. // E.g. last character which represents suffix of length 1 should be ordered first among same characters. val sa = S.indices.reversed().so...
[ { "class_path": "indy256__codelibrary__4055526/SuffixArrayKt.class", "javap": "Compiled from \"SuffixArray.kt\"\npublic final class SuffixArrayKt {\n public static final int[] suffixArray(java.lang.CharSequence);\n Code:\n 0: aload_0\n 1: ldc #9 // String S\n ...
indy256__codelibrary__4055526/kotlin/MaxBipartiteMatchingEV.kt
// https://en.wikipedia.org/wiki/Matching_(graph_theory)#In_unweighted_bipartite_graphs in O(V * E) fun maxMatching(graph: Array<out List<Int>>, n2: Int): Int { val n1 = graph.size val vis = BooleanArray(n1) val matching = IntArray(n2) { -1 } val findPath = DeepRecursiveFunction { u1 -> vis[u1]...
[ { "class_path": "indy256__codelibrary__4055526/MaxBipartiteMatchingEVKt$maxMatching$findPath$1.class", "javap": "Compiled from \"MaxBipartiteMatchingEV.kt\"\nfinal class MaxBipartiteMatchingEVKt$maxMatching$findPath$1 extends kotlin.coroutines.jvm.internal.RestrictedSuspendLambda implements kotlin.jvm.funct...
indy256__codelibrary__4055526/kotlin/Dijkstra.kt
object Dijkstra { data class Edge(val target: Int, val cost: Int) data class ShortestPaths(val dist: IntArray, val pred: IntArray) fun shortestPaths(graph: Array<out List<Edge>>, s: Int): ShortestPaths { val n = graph.size val dist = IntArray(n) { Int.MAX_VALUE } dist[s] = 0 ...
[ { "class_path": "indy256__codelibrary__4055526/Dijkstra.class", "javap": "Compiled from \"Dijkstra.kt\"\npublic final class Dijkstra {\n public static final Dijkstra INSTANCE;\n\n private Dijkstra();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<i...
indy256__codelibrary__4055526/kotlin/MaxFlowDinic.kt
// https://en.wikipedia.org/wiki/Dinic%27s_algorithm in O(V^2 * E) class MaxFlowDinic(nodes: Int) { data class Edge(val t: Int, val rev: Int, val cap: Int, var f: Int = 0) val graph = (1..nodes).map { arrayListOf<Edge>() }.toTypedArray() val dist = IntArray(nodes) fun addBidiEdge(s: Int, t: Int, cap:...
[ { "class_path": "indy256__codelibrary__4055526/MaxFlowDinicKt.class", "javap": "Compiled from \"MaxFlowDinic.kt\"\npublic final class MaxFlowDinicKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String args\n 3: in...
indy256__codelibrary__4055526/kotlin/Determinant.kt
import kotlin.math.abs // https://en.wikipedia.org/wiki/Determinant fun det(matrix: Array<DoubleArray>): Double { val EPS = 1e-10 val a = matrix.map { it.copyOf() }.toTypedArray() val n = a.size var res = 1.0 for (i in 0 until n) { val p = (i until n).maxByOrNull { abs(a[it][i]) }!! ...
[ { "class_path": "indy256__codelibrary__4055526/DeterminantKt.class", "javap": "Compiled from \"Determinant.kt\"\npublic final class DeterminantKt {\n public static final double det(double[][]);\n Code:\n 0: aload_0\n 1: ldc #9 // String matrix\n 3: invokestat...
indy256__codelibrary__4055526/kotlin/Rational.kt
import java.math.BigInteger class Rational(n: BigInteger, d: BigInteger = BigInteger.ONE) : Comparable<Rational> { val num: BigInteger val den: BigInteger init { val gcd = n.gcd(d) val g = if (d.signum() > 0) gcd else if (d.signum() < 0) gcd.negate() else BigInteger.ONE num = n.div...
[ { "class_path": "indy256__codelibrary__4055526/RationalKt.class", "javap": "Compiled from \"Rational.kt\"\npublic final class RationalKt {\n public static final void main();\n Code:\n 0: new #8 // class Rational\n 3: dup\n 4: lconst_1\n 5: ldc2_w ...
indy256__codelibrary__4055526/kotlin/ConvexHull.kt
data class Point(val x: Int, val y: Int) // Convex hull in O(n*log(n)) fun convexHull(points: Array<Point>): Array<Point> { fun isNotRightTurn(p3: List<Point>): Boolean { val (a, b, c) = p3 val cross = (a.x - b.x).toLong() * (c.y - b.y) - (a.y - b.y).toLong() * (c.x - b.x) val dot = (a.x -...
[ { "class_path": "indy256__codelibrary__4055526/ConvexHullKt.class", "javap": "Compiled from \"ConvexHull.kt\"\npublic final class ConvexHullKt {\n public static final Point[] convexHull(Point[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String points\n 3: invokest...
indy256__codelibrary__4055526/kotlin/PersistentTree.kt
// https://en.wikipedia.org/wiki/Persistent_data_structure object PersistentTree { data class Node( val left: Node? = null, val right: Node? = null, val sum: Int = (left?.sum ?: 0) + (right?.sum ?: 0) ) fun build(left: Int, right: Int): Node { if (left == right)...
[ { "class_path": "indy256__codelibrary__4055526/PersistentTree.class", "javap": "Compiled from \"PersistentTree.kt\"\npublic final class PersistentTree {\n public static final PersistentTree INSTANCE;\n\n private PersistentTree();\n Code:\n 0: aload_0\n 1: invokespecial #8 /...
indy256__codelibrary__4055526/kotlin/Gauss.kt
import kotlin.math.abs import java.util.Random // https://en.wikipedia.org/wiki/Gauss–Jordan_elimination // returns x such that A * x = b. requires |A| > 0 fun gauss(A: Array<DoubleArray>, b: DoubleArray): DoubleArray { val a = A.mapIndexed { i, Ai -> Ai + b[i] }.toTypedArray() val n = a.size for (i in 0 u...
[ { "class_path": "indy256__codelibrary__4055526/GaussKt.class", "javap": "Compiled from \"Gauss.kt\"\npublic final class GaussKt {\n public static final double[] gauss(double[][], double[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String A\n 3: invokestatic #15 ...
JC6__LeetCode__493dbe8/004.median-of-two-sorted-arrays/solution.kt
import kotlin.math.max import kotlin.math.min fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray): Double { val size = nums1.size + nums2.size return if (size % 2 == 0) { (findK(nums1, nums2, size / 2) + findK(nums1, nums2, size / 2 + 1)) / 2.0 } else { findK(nums1, nums2, size / 2...
[ { "class_path": "JC6__LeetCode__493dbe8/SolutionKt.class", "javap": "Compiled from \"solution.kt\"\npublic final class SolutionKt {\n public static final double findMedianSortedArrays(int[], int[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String nums1\n 3: invoke...
shencang__note__f321a2e/语言知识(Language knowledge)/Kotlin/Practice/src/Main.kt
//顶层变量: val Pi = 3.14159265358979 var temp = 0 fun main(){ //定义只读局部变量使⽤关键字 val 定义。只能为其赋值⼀次 val a: Int = 1 // ⽴即赋值 val b = 2 // ⾃动推断出 `Int` 类型 val c: Int // 如果没有初始值类型不能省略 c = 3 // 明确赋值 var edge = a*b*c println("S-P-D-B") println(sum(a,b)) edge*=2 println(sum1(b,c)) println(sum...
[ { "class_path": "shencang__note__f321a2e/MainKt.class", "javap": "Compiled from \"Main.kt\"\npublic final class MainKt {\n private static final double Pi;\n\n private static int temp;\n\n public static final double getPi();\n Code:\n 0: getstatic #10 // Field Pi:D\n 3: ...
SimonMarquis__advent-of-code-2020__560e322/src/main/kotlin/Day03.kt
class Day03(raw: List<String>) { private val forest: Forest = Forest.parse(raw) fun part1(): Long = forest.trees(Slope(right = 3, down = 1)) fun part2(): Long = listOf( Slope(right = 1, down = 1), Slope(right = 3, down = 1), Slope(right = 5, down = 1), Slope(right = 7, dow...
[ { "class_path": "SimonMarquis__advent-of-code-2020__560e322/Day03$Forest$positions$1.class", "javap": "Compiled from \"Day03.kt\"\nfinal class Day03$Forest$positions$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<java.lang.Integer, java.lang.Integer, Day03$Posi...
reitzig__advent-of-code-2020__f17184f/src/main/kotlin/shared.kt
import kotlin.math.absoluteValue data class Either<T, U>(val t: T? = null, val u: U? = null) { init { assert((t == null) != (u == null)) { "Exactly one parameter must be null" } } override fun toString(): String = "${t ?: ""}${u ?: ""}" } fun <T> List<T>.split(splitEntry: T): List<List<T>> = ...
[ { "class_path": "reitzig__advent-of-code-2020__f17184f/SharedKt.class", "javap": "Compiled from \"shared.kt\"\npublic final class SharedKt {\n public static final <T> java.util.List<java.util.List<T>> split(java.util.List<? extends T>, T);\n Code:\n 0: aload_0\n 1: ldc #10 ...
BrightOS__os_2__84f5b71/src/main/kotlin/Main.kt
import java.io.File const val QUANTUM_TIME = 2 private var numberOfPriorityTicks = 0 fun parseInputFile(file: File): Pair<ArrayList<Process>, Int> { var resultNumberOfTicks = 0 val list = arrayListOf<Process>().apply { file.forEachLine { it.split(" ").let { add( ...
[ { "class_path": "BrightOS__os_2__84f5b71/MainKt$main$lambda$6$$inlined$sortBy$1.class", "javap": "Compiled from \"Comparisons.kt\"\npublic final class MainKt$main$lambda$6$$inlined$sortBy$1<T> implements java.util.Comparator {\n public MainKt$main$lambda$6$$inlined$sortBy$1();\n Code:\n 0: aload_0...
chynerdu__JAV1001-Lab2__7492690/ArrayTools.kt
fun main() { println("Hello World") println(averageArray(arrayOf(1, 2, 2, 4, 4))) println(averageArray(arrayOf(1, -2, -2, 4, 4))) println(checkValueExistence(arrayOf(1, 2, 2, 4, 4), 8)) println(reverseArray(arrayOf(1, 2, 3, 4, 5, 6, 7, 34, 28))) val ciphertext = caesarCipherFunc() println(...
[ { "class_path": "chynerdu__JAV1001-Lab2__7492690/ArrayToolsKt.class", "javap": "Compiled from \"ArrayTools.kt\"\npublic final class ArrayToolsKt {\n public static final void main();\n Code:\n 0: ldc #8 // String Hello World\n 2: getstatic #14 //...
jcornaz__aoc-kotlin-2022__979c00c/src/main/kotlin/Day15.kt
import kotlin.math.abs object Day15 { fun part1(input: String): Long = numberOfNonBeacon(input, 2000000).toLong() fun part2(input: String, searchScope: Int): Long { val scan = Scan.parse(input) val beacon = (0..searchScope) .asSequence() .map { y -> y to scan.uncovered...
[ { "class_path": "jcornaz__aoc-kotlin-2022__979c00c/Day15.class", "javap": "Compiled from \"Day15.kt\"\npublic final class Day15 {\n public static final Day15 INSTANCE;\n\n private static final kotlin.text.Regex LINE_REGEX;\n\n private Day15();\n Code:\n 0: aload_0\n 1: invokespecial #8 ...
jcornaz__aoc-kotlin-2022__979c00c/src/main/kotlin/Day02.kt
object Day02 { private val plays = Play.values().asSequence() private val results = Result.values().asSequence() enum class Play(val symbol: String, val score: Int) { Rock("A", 1), Paper("B", 2), Scissors("C", 3), } enum class Result(val symbol: String, val score: Int) { ...
[ { "class_path": "jcornaz__aoc-kotlin-2022__979c00c/Day02$Play.class", "javap": "Compiled from \"Day02.kt\"\npublic final class Day02$Play extends java.lang.Enum<Day02$Play> {\n private final java.lang.String symbol;\n\n private final int score;\n\n public static final Day02$Play Rock;\n\n public static ...
jcornaz__aoc-kotlin-2022__979c00c/src/main/kotlin/Day16.kt
import java.util.* private typealias ValveId = String object Day16 { private val LINE_REGEX = Regex("Valve ([A-Z]+) has flow rate=(\\d+); tunnels? leads? to valves? (.+)") fun part1(input: String, time: Int = 30): Int { val valves = input.lineSequence() .map(::parseValve) .to...
[ { "class_path": "jcornaz__aoc-kotlin-2022__979c00c/Day16$Solver$solve$seq$1.class", "javap": "Compiled from \"Day16.kt\"\nfinal class Day16$Solver$solve$seq$1 extends kotlin.coroutines.jvm.internal.RestrictedSuspendLambda implements kotlin.jvm.functions.Function2<kotlin.sequences.SequenceScope<? super Day16...
jcornaz__aoc-kotlin-2022__979c00c/src/main/kotlin/Day12.kt
object Day12 { @Suppress("UNUSED_PARAMETER") fun part1(input: String): Long = TODO() @Suppress("UNUSED_PARAMETER") fun part2(input: String): Long = TODO() private const val START_CHARACTER = 'S' private const val GOAL_CHARACTER = 'E' fun findPath(input: String): String { val map ...
[ { "class_path": "jcornaz__aoc-kotlin-2022__979c00c/Day12$Direction$DOWN.class", "javap": "Compiled from \"Day12.kt\"\nfinal class Day12$Direction$DOWN extends Day12$Direction {\n Day12$Direction$DOWN();\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: bipush 118\n ...
jcornaz__aoc-kotlin-2022__979c00c/src/main/kotlin/Day13.kt
import java.lang.StringBuilder object Day13 { fun part1(input: String): Int = input.split("\n\n").withIndex() .filter { (_, both) -> isInCorrectOrder(both.lines().first(), both.lines().last())!! } .sumOf { it.index + 1 } @Suppress("UNUSED_PARAMETER"...
[ { "class_path": "jcornaz__aoc-kotlin-2022__979c00c/Day13.class", "javap": "Compiled from \"Day13.kt\"\npublic final class Day13 {\n public static final Day13 INSTANCE;\n\n private Day13();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\...
jcornaz__aoc-kotlin-2022__979c00c/src/main/kotlin/Day05.kt
import java.util.* object Day05 { fun part1(input: String): String { val stacks = input.initialState() input.instructions().forEach { instruction -> repeat(instruction.count) { stacks[instruction.to].push(stacks[instruction.from].pop()) } } r...
[ { "class_path": "jcornaz__aoc-kotlin-2022__979c00c/Day05.class", "javap": "Compiled from \"Day05.kt\"\npublic final class Day05 {\n public static final Day05 INSTANCE;\n\n private Day05();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\...
pkleczek__Kotlin_Koans__48e2cc5/Generics/Generic functions/src/Task.kt
fun <T, C : MutableCollection<T>> Iterable<T>.partitionTo( first: C, second: C, predicate: (T) -> Boolean ): Pair<C, C> = this.partition(predicate) .let { first.addAll(it.first) second.addAll(it.second) first to second } fun partitionWordsAndLines() {...
[ { "class_path": "pkleczek__Kotlin_Koans__48e2cc5/TaskKt.class", "javap": "Compiled from \"Task.kt\"\npublic final class TaskKt {\n public static final <T, C extends java.util.Collection<T>> kotlin.Pair<C, C> partitionTo(java.lang.Iterable<? extends T>, C, C, kotlin.jvm.functions.Function1<? super T, java.l...