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 ...
ILIYANGERMANOV__algorithms__4abe4b5/Algorithms/src/main/kotlin/PermutationInString.kt
/** * # 567. Permutation in String * Problem: * https://leetcode.com/problems/permutation-in-string/ * * WARNING: This solution is not optimal! */ class PermutationInString { fun checkInclusion(target: String, source: String): Boolean { if (target.length > source.length) return false return pe...
[ { "class_path": "ILIYANGERMANOV__algorithms__4abe4b5/PermutationInString.class", "javap": "Compiled from \"PermutationInString.kt\"\npublic final class PermutationInString {\n public PermutationInString();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object...
ILIYANGERMANOV__algorithms__4abe4b5/Algorithms/src/main/kotlin/MaxSubArray.kt
/** * # Maximum Subarray * Problem: * https://leetcode.com/problems/maximum-subarray/ */ class MaxSubArray { fun maxSubArray(nums: IntArray): Int { val size = nums.size if (size == 1) return nums[0] var sum = nums.first() var localMax = sum for (i in 1 until size) { ...
[ { "class_path": "ILIYANGERMANOV__algorithms__4abe4b5/MaxSubArray.class", "javap": "Compiled from \"MaxSubArray.kt\"\npublic final class MaxSubArray {\n public MaxSubArray();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: retur...
ILIYANGERMANOV__algorithms__4abe4b5/Algorithms/src/main/kotlin/Search2DMatrix.kt
/** * # Search a 2D Matrix * Problem: * https://leetcode.com/problems/search-a-2d-matrix/ */ class Search2DMatrix { fun searchMatrix(matrix: Array<IntArray>, target: Int): Boolean { val rowsCount = matrix.size if (rowsCount == 1) return binarySearchRow(matrix[0], target) return binarySea...
[ { "class_path": "ILIYANGERMANOV__algorithms__4abe4b5/Search2DMatrix.class", "javap": "Compiled from \"Search2DMatrix.kt\"\npublic final class Search2DMatrix {\n public Search2DMatrix();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n ...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Droplets.kt
fun main() = Droplets.solve() private object Droplets { fun solve() { val input = readInput() val droplet = Droplet(input) println("total surface area ${droplet.surfaceArea1()}") println("outside surface area ${droplet.surfaceArea2()}") } private fun readInput(): List<Pos> ...
[ { "class_path": "alebedev__aoc2022__d6ba46b/DropletsKt.class", "javap": "Compiled from \"Droplets.kt\"\npublic final class DropletsKt {\n public static final void main();\n Code:\n 0: getstatic #12 // Field Droplets.INSTANCE:LDroplets;\n 3: invokevirtual #15 ...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Sand.kt
fun main() = Sand.solve() private object Sand { fun solve() { val input = readInput() val (grid, start) = inputToGrid(input) drawGrid(grid) println("Start: $start") drawGrid(addSand(grid, start)) } private fun addSand(grid: List<MutableList<Cell>>, start: Pos): List...
[ { "class_path": "alebedev__aoc2022__d6ba46b/Sand$Pos.class", "javap": "Compiled from \"Sand.kt\"\npublic final class Sand$Pos implements java.lang.Comparable<Sand$Pos> {\n private final int x;\n\n private final int y;\n\n public Sand$Pos(int, int);\n Code:\n 0: aload_0\n 1: invokespecial #...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Path.kt
fun main() = Path.solve() private typealias Matrix = List<List<Int>> private object Path { const val START = 0 const val TARGET = ('z'.code - 'a'.code) + 1 fun solve() { val input = readInput() val starts = findAll(input, START) val target = findAll(input, TARGET).first() ...
[ { "class_path": "alebedev__aoc2022__d6ba46b/Path$Pos.class", "javap": "Compiled from \"Path.kt\"\npublic final class Path$Pos {\n private final int x;\n\n private final int y;\n\n public Path$Pos(int, int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Obj...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Calculator.kt
fun main() = Calculator.solve() private object Calculator { fun solve() { val expressions = readInput() println("Part 1: root value ${calcValue(expressions, "root")}") println("Part 2, humn requires value ${matchValuesAt(expressions, "root")}") } private fun readInput(): Map<String...
[ { "class_path": "alebedev__aoc2022__d6ba46b/Calculator.class", "javap": "Compiled from \"Calculator.kt\"\nfinal class Calculator {\n public static final Calculator INSTANCE;\n\n private Calculator();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<i...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Crane.kt
fun main() { Crane.solve() } object Crane { fun solve() { val input = readInput() val result = runMoves(input.state, input.moves) println("Top of stacks: ${result.map { it.first() }.joinToString("")}") } private fun readInput(): Input { val stacks = mutableListOf<Pair<I...
[ { "class_path": "alebedev__aoc2022__d6ba46b/Crane$Move.class", "javap": "Compiled from \"Crane.kt\"\npublic final class Crane$Move {\n private final int from;\n\n private final int to;\n\n private final int count;\n\n public Crane$Move(int, int, int);\n Code:\n 0: aload_0\n 1: invokespeci...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Beacons.kt
import kotlin.math.abs fun main() = Beacons.solve(0..4_000_000) private object Beacons { fun solve(possibleCoordinates: IntRange) { val sensors = readInput() val distress = findDistressBeacon(sensors, possibleCoordinates) println("Distress breacon at $distress, freq: ${distress.x.toBigInte...
[ { "class_path": "alebedev__aoc2022__d6ba46b/Beacons$Sensor.class", "javap": "Compiled from \"Beacons.kt\"\npublic final class Beacons$Sensor {\n private final Beacons$Pos pos;\n\n private final Beacons$Pos nearestBeacon;\n\n public Beacons$Sensor(Beacons$Pos, Beacons$Pos);\n Code:\n 0: aload_1\n...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Robots.kt
fun main() = Robots.solve() private object Robots { const val MAX_TURNS = 32 fun solve() { val blueprints = readInput().take(3) // println("1st: ${maxGeodes(blueprints.first())}") val score = blueprints.map { maxGeodes(it) }.reduce { x, y -> x * y } println("Total score: ${score...
[ { "class_path": "alebedev__aoc2022__d6ba46b/Robots.class", "javap": "Compiled from \"Robots.kt\"\nfinal class Robots {\n public static final Robots INSTANCE;\n\n public static final int MAX_TURNS;\n\n private Robots();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method j...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Packets.kt
fun main() = Packets.solve() private object Packets { fun solve() { val input = readInput().toMutableList() val dividers = setOf( Lst(listOf(Lst(listOf(Num(2))))), Lst(listOf(Lst(listOf(Num(6))))) ) input.addAll(dividers) val sorted = input.sorted() ...
[ { "class_path": "alebedev__aoc2022__d6ba46b/Packets.class", "javap": "Compiled from \"Packets.kt\"\nfinal class Packets {\n public static final Packets INSTANCE;\n\n private Packets();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n ...
alebedev__aoc2022__d6ba46b/src/main/kotlin/DirWalk.kt
fun main() { DirWalk.solve() } private object DirWalk { fun solve() { val tree = buildTree(readInput()) val sizes = getDirSizes(tree) // for (size in sizes) { // println("${size.key.name} ${size.value}") // } val smallDirsTotal = sizes.filter { it.value <= 100_0...
[ { "class_path": "alebedev__aoc2022__d6ba46b/DirWalk$CommandLs.class", "javap": "Compiled from \"DirWalk.kt\"\npublic final class DirWalk$CommandLs implements DirWalk$Input {\n private final java.lang.String path;\n\n public DirWalk$CommandLs(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc ...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Blizzards.kt
import java.util.* import kotlin.math.abs fun main() = Blizzards.solve() private object Blizzards { fun solve() { var board = readInput() val start = Pos(1, 0) val target = Pos(board.cells.last().indexOfFirst { it is Space }, board.cells.size - 1) val initialPath = Path( ...
[ { "class_path": "alebedev__aoc2022__d6ba46b/Blizzards$readInput$cells$1.class", "javap": "Compiled from \"Blizzards.kt\"\nfinal class Blizzards$readInput$cells$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function0<java.lang.String> {\n public static final Blizzards$r...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Tetris.kt
import kotlin.streams.toList fun main() = Tetris.solve() private object Tetris { private const val width = 7 private val winds = mutableListOf<Int>() private var fallingRock: FallingRock? = null private val cells = mutableListOf( // Floor MutableList(width) { i -> Cell.StableRock } ...
[ { "class_path": "alebedev__aoc2022__d6ba46b/Tetris$Pos.class", "javap": "Compiled from \"Tetris.kt\"\nfinal class Tetris$Pos {\n private final int x;\n\n private final int y;\n\n public Tetris$Pos(int, int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Ob...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Rucksack.kt
import java.lang.RuntimeException fun main() { var result = 0 for (group in readRucksack()) { result += charScore(findGroupBadge(group)) } println("Total score: $result") } private typealias Group = MutableList<String> private fun readRucksack(): Iterable<Group> { val result = mutableList...
[ { "class_path": "alebedev__aoc2022__d6ba46b/RucksackKt.class", "javap": "Compiled from \"Rucksack.kt\"\npublic final class RucksackKt {\n public static final void main();\n Code:\n 0: iconst_0\n 1: istore_0\n 2: invokestatic #10 // Method readRucksack:()Ljava/lang/Iter...
alebedev__aoc2022__d6ba46b/src/main/kotlin/RPS.kt
import java.lang.RuntimeException fun main() { RPS.solve() } private object RPS { // Day 2 fun solve() { val input = readInput() var result = 0 for (pair in input) { val myMove = when(pair.second) { Result.Draw -> pair.first Result.Win ->...
[ { "class_path": "alebedev__aoc2022__d6ba46b/RPS.class", "javap": "Compiled from \"RPS.kt\"\nfinal class RPS {\n public static final RPS INSTANCE;\n\n private RPS();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n p...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Monkeys.kt
import java.math.BigInteger fun main() = Monkeys.solve() object Monkeys { private var inspectedBy = mutableListOf<Int>() fun solve() { val input = readInput() for (monkey in input) { inspectedBy.add(monkey.id, 0) } for (turn in 1..10000) { runTurn(input...
[ { "class_path": "alebedev__aoc2022__d6ba46b/Monkeys$readInput$1.class", "javap": "Compiled from \"Monkeys.kt\"\nfinal class Monkeys$readInput$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function0<java.lang.String> {\n public static final Monkeys$readInput$1 INSTANCE;...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Fuel.kt
fun main() = Fuel.solve() private object Fuel { fun solve() { println("${fromSnafu("1=11-2")}") println("-> ${toSnafu(12345)}") val nums = readInput() println("$nums") val sum = nums.sum() println("Sum: $sum, SNAFU: ${toSnafu(sum)}") } private fun readInput(...
[ { "class_path": "alebedev__aoc2022__d6ba46b/Fuel$readInput$1.class", "javap": "Compiled from \"Fuel.kt\"\nfinal class Fuel$readInput$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function0<java.lang.String> {\n public static final Fuel$readInput$1 INSTANCE;\n\n Fuel$r...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Valves.kt
fun main() = Valves.solve() private object Valves { fun solve() { val nodes = readInput() val maxPressure = findMaxPressureRelease(nodes, "AA", 26) println("Max releasable pressure: ${maxPressure}") } private fun readInput(): Map<String, Node> = buildMap<String, Node> { gen...
[ { "class_path": "alebedev__aoc2022__d6ba46b/Valves$readInput$1$1.class", "javap": "Compiled from \"Valves.kt\"\nfinal class Valves$readInput$1$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function0<java.lang.String> {\n public static final Valves$readInput$1$1 INSTANC...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Seeding.kt
import kotlin.math.abs fun main() = Seeding.solve() private object Seeding { fun solve() { var board = Board(readInput()) println("Initial") board.visualize() var i = 0 while (true) { println("$i") val direction = Direction.values()[i % 4] ...
[ { "class_path": "alebedev__aoc2022__d6ba46b/SeedingKt.class", "javap": "Compiled from \"Seeding.kt\"\npublic final class SeedingKt {\n public static final void main();\n Code:\n 0: getstatic #12 // Field Seeding.INSTANCE:LSeeding;\n 3: invokevirtual #15 //...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Forest.kt
fun main() { Forest.solve() } private object Forest { fun solve() { val grid = readInput() println("Visible trees: ${countVisible(grid)}") println("Max scenic score: ${maxScenicScore(grid)}") } private fun readInput(): Grid { return generateSequence(::readLine).map { ...
[ { "class_path": "alebedev__aoc2022__d6ba46b/Forest.class", "javap": "Compiled from \"Forest.kt\"\nfinal class Forest {\n public static final Forest INSTANCE;\n\n private Forest();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Rope.kt
import kotlin.math.abs import kotlin.math.sign fun main() { Rope.solve() } private object Rope { fun solve() { val moves = readInput() println("tail visited ${getTailPath(moves, 10).toSet().size}") } private fun readInput(): Sequence<Move> { return generateSequence(::readLine)...
[ { "class_path": "alebedev__aoc2022__d6ba46b/Rope.class", "javap": "Compiled from \"Rope.kt\"\nfinal class Rope {\n public static final Rope INSTANCE;\n\n private Rope();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Map.kt
import kotlin.math.abs fun main() = AocMap.solve() private object AocMap { fun solve() { val (board, moves) = readInput() println("$moves") // board.print() // val pos = applyMoves(board, moves) println("Board size ${board.cells.size}x${board.cells.first().size}") pri...
[ { "class_path": "alebedev__aoc2022__d6ba46b/MapKt.class", "javap": "Compiled from \"Map.kt\"\npublic final class MapKt {\n public static final void main();\n Code:\n 0: getstatic #12 // Field AocMap.INSTANCE:LAocMap;\n 3: invokevirtual #15 // Method AocMap...
alebedev__aoc2022__d6ba46b/src/main/kotlin/Cleanup.kt
// Day4 fun main() { val sections = readInput() val fullyContained = sections.count { fullyContains(it.first, it.second) || fullyContains(it.second, it.first) } val overlapping = sections.count { overlaps(it.first, it.second) } println("# of fully contained ${fullyContained}") println("# of overlapp...
[ { "class_path": "alebedev__aoc2022__d6ba46b/CleanupKt.class", "javap": "Compiled from \"Cleanup.kt\"\npublic final class CleanupKt {\n public static final void main();\n Code:\n 0: invokestatic #10 // Method readInput:()Ljava/lang/Iterable;\n 3: astore_0\n 4: aload_0\n...
shengmin__coding-problem__08e6554/hackerrank/journey-to-the-moon/Solution.kt
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...
[ { "class_path": "shengmin__coding-problem__08e6554/SolutionKt.class", "javap": "Compiled from \"Solution.kt\"\npublic final class SolutionKt {\n public static final long journeyToMoon(int, java.lang.Integer[][]);\n Code:\n 0: aload_1\n 1: ldc #9 // String pairs\n ...
Davio__rosalind__f5350b0/src/nl/davefranken/rosalind/P4FIB.kt
import java.io.File import java.math.BigInteger import java.util.stream.Stream /** * Problem A sequence is an ordered collection of objects (usually numbers), which are allowed to repeat. Sequences can be finite or infinite. Two examples are the finite sequence (π,−2–√,0,π)(π,−2,0,π) and the infinite sequence of od...
[ { "class_path": "Davio__rosalind__f5350b0/P4FIBKt.class", "javap": "Compiled from \"P4FIB.kt\"\npublic final class P4FIBKt {\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 ...
laitingsheng__2020S1-COMP-SCI-7007__2fc3e7a/pracexam1problem3/TwoStringMasks.kt
class TwoStringMasks { private val IMPOSSIBLE: String = "impossible" private fun String.trim(b: Int): String { var i = b while (this[i] != '*') ++i return removeRange(i, i + 1) } private fun String.combine(b1: Int, e1: Int, other: String, b2: Int, e2: Int): String {...
[ { "class_path": "laitingsheng__2020S1-COMP-SCI-7007__2fc3e7a/TwoStringMasks.class", "javap": "Compiled from \"TwoStringMasks.kt\"\npublic final class TwoStringMasks {\n private final java.lang.String IMPOSSIBLE;\n\n public TwoStringMasks();\n Code:\n 0: aload_0\n 1: invokespecial #8 ...
laitingsheng__2020S1-COMP-SCI-7007__2fc3e7a/week11familytravel/FamilyTravel.kt
import java.util.PriorityQueue class FamilyTravel { data class Stop(@JvmField val dist: Int, @JvmField val prevDist: Int, @JvmField val src: Int) : Comparable<Stop> { override fun compareTo(other: Stop): Int = dist - other.dist } fun shortest(edges: Array<String>): Int { val m = edges.firs...
[ { "class_path": "laitingsheng__2020S1-COMP-SCI-7007__2fc3e7a/FamilyTravel.class", "javap": "Compiled from \"FamilyTravel.kt\"\npublic final class FamilyTravel {\n public FamilyTravel();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n ...
laitingsheng__2020S1-COMP-SCI-7007__2fc3e7a/week7fewestfactors/FewestFactors.kt
class FewestFactors { private fun IntArray.swap(l: Int, r: Int) { val tmp = this[l] this[l] = this[r] this[r] = tmp } private val IntArray.number: Int get() = fold(0) { acc, it -> 10 * acc + it } private val Int.factors: Int get() { var nf = 0 ...
[ { "class_path": "laitingsheng__2020S1-COMP-SCI-7007__2fc3e7a/FewestFactors.class", "javap": "Compiled from \"FewestFactors.kt\"\npublic final class FewestFactors {\n public FewestFactors();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\...
laitingsheng__2020S1-COMP-SCI-7007__2fc3e7a/week7matchnumberseasy/MatchNumbersEasy.kt
class MatchNumbersEasy { private fun compare(sb1: StringBuilder, sb2: StringBuilder): Int { if (sb1.isEmpty() || sb2.isEmpty()) return sb1.length - sb2.length var nz1 = sb1.indexOfFirst { c -> c != '0' } if (nz1 == -1) nz1 = sb1.length - 1 var nz2 = sb2.index...
[ { "class_path": "laitingsheng__2020S1-COMP-SCI-7007__2fc3e7a/MatchNumbersEasy.class", "javap": "Compiled from \"MatchNumbersEasy.kt\"\npublic final class MatchNumbersEasy {\n public MatchNumbersEasy();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<...
bejohi__UiB_INF237__7e34663/src/8ExponentialTimeAlgorithms/MapColouring.kt
import java.util.* val resultList = mutableListOf<String>() var done = false // Solution for https://open.kattis.com/problems/mapcolouring // With help from https://github.com/amartop fun main(args: Array<String>){ val input = Scanner(System.`in`) val numberOfTestCases = input.nextInt() for(testCase in...
[ { "class_path": "bejohi__UiB_INF237__7e34663/MapColouringKt.class", "javap": "Compiled from \"MapColouring.kt\"\npublic final class MapColouringKt {\n private static final java.util.List<java.lang.String> resultList;\n\n private static boolean done;\n\n public static final java.util.List<java.lang.String...
bejohi__UiB_INF237__7e34663/src/9DynamicProgramming2/TheCitrusIntern.kt
import java.util.* // Solution for https://open.kattis.com/problems/citrusintern // With help from https://github.com/amartop var numberOfEmployees = 0 var input = Scanner(System.`in`) var costs = mutableListOf<Int>() var inL = arrayOf<Long>() var outUpL = arrayOf<Long>() var outDownL = arrayOf<Long>() var root = -1 ...
[ { "class_path": "bejohi__UiB_INF237__7e34663/TheCitrusInternKt.class", "javap": "Compiled from \"TheCitrusIntern.kt\"\npublic final class TheCitrusInternKt {\n private static int numberOfEmployees;\n\n private static java.util.Scanner input;\n\n private static java.util.List<java.lang.Integer> costs;\n\n...
bejohi__UiB_INF237__7e34663/src/8ExponentialTimeAlgorithms/ColoringGraphs.kt
import java.util.* import kotlin.system.exitProcess // Solution for https://open.kattis.com/problems/coloring // With help from https://github.com/amartop fun main(args: Array<String>){ val input = Scanner(System.`in`) val vertices = input.nextLine().toInt() val adjMatrix = Array(vertices,{IntArray(verti...
[ { "class_path": "bejohi__UiB_INF237__7e34663/ColoringGraphsKt.class", "javap": "Compiled from \"ColoringGraphs.kt\"\npublic final class ColoringGraphsKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String args\n 3...
frango9000__advent-of-code-22__62e91dd/src/Day04.kt
fun main() { val input = readInput("Day04") println(Day04.part1(input)) println(Day04.part2(input)) } class Day04 { companion object { fun part1(input: List<String>): Int { return input.filter { it: String -> val (a1, a2, b1, b2) = it.split(",") ....
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/Day04$Companion.class", "javap": "Compiled from \"Day04.kt\"\npublic final class Day04$Companion {\n private Day04$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n ...
frango9000__advent-of-code-22__62e91dd/src/Day15.kt
import kotlin.math.absoluteValue fun main() { val input = readInput("Day15") printTime { print(Day15.part1(input, 2_000_000)) } printTime { print(Day15.part2(input, 4_000_000)) } } class Day15 { companion object { fun part1(input: List<String>, targetY: Int): Int { val sensorsAndBe...
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/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....
frango9000__advent-of-code-22__62e91dd/src/Utils.kt
import java.io.File import java.math.BigInteger import java.security.MessageDigest import java.util.function.Predicate import kotlin.math.absoluteValue import kotlin.system.measureNanoTime /** * Reads lines from the given input txt file. */ fun readInput(name: String) = File("src", "$name.txt").readLines() /** * R...
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/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...
frango9000__advent-of-code-22__62e91dd/src/Day14.kt
fun main() { val input = readInput("Day14") printTime { println(Day14.part1(input)) } printTime { println(Day14.part2(input)) } } class Day14 { companion object { fun part1(input: List<String>): Int { val pointMatrix = input.map { it.split(" -> ").map(::Point) } val poin...
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/Day14Kt.class", "javap": "Compiled from \"Day14.kt\"\npublic final class Day14Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day14\n 2: invokestatic #14 // Method UtilsK...
frango9000__advent-of-code-22__62e91dd/src/Day12.kt
fun main() { val input = readInput("Day12") printTime { println(Day12.part1(input)) } printTime { println(Day12.part2(input)) } } class Day12 { companion object { fun part1(input: List<String>): Int { val (end, start) = input.toHeightGraph() return end.getShortestPathBfs...
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/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 ...
frango9000__advent-of-code-22__62e91dd/src/Day13.kt
import kotlin.math.max fun main() { val input = readInput("Day13") printTime { println(Day13.part1(input)) } printTime { println(Day13.part2(input)) } } class Day13 { companion object { fun part1(input: List<String>): Int { val packetPairs = input.partitionOnElement("").map { it.ma...
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/Day13.class", "javap": "Compiled from \"Day13.kt\"\npublic final class Day13 {\n public static final Day13$Companion Companion;\n\n public Day13();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object....
frango9000__advent-of-code-22__62e91dd/src/Day16.kt
import kotlin.math.max fun main() { val input = readInput("Day16") printTime { print(Day16.part1(input)) } printTime { print(Day16.part2(input)) } } class Day16 { companion object { fun part1(input: List<String>): Int { val valves = input.map { it.split( ...
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/Day16$Valve.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16$Valve {\n private final java.lang.String name;\n\n private final int rate;\n\n private final java.util.Set<java.lang.String> tunnelsTo;\n\n private final java.util.S...
frango9000__advent-of-code-22__62e91dd/src/Day08.kt
fun main() { val input = readInput("Day08") println(Day08.part1(input)) println(Day08.part2(input)) } class Day08 { companion object { fun part1(input: List<String>): Int { val forest = input.map { it.split("").filter { c -> c.isNotEmpty() }.map { character -> char...
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/Day08.class", "javap": "Compiled from \"Day08.kt\"\npublic final class Day08 {\n public static final Day08$Companion Companion;\n\n public Day08();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object....
frango9000__advent-of-code-22__62e91dd/src/Day05.kt
fun main() { val input = readInput("Day05") println(Day05.part1(input)) println(Day05.part2(input)) } data class Move(val size: Int, val from: Int, val to: Int) class Day05 { companion object { fun part1(input: List<String>): String { val (initial, rawActions) = input.partitionOn...
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/Day05Kt.class", "javap": "Compiled from \"Day05.kt\"\npublic final class Day05Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day05\n 2: invokestatic #14 // Method UtilsK...
frango9000__advent-of-code-22__62e91dd/src/Day03.kt
fun main() { val input = readInput("Day03") println(Day03.part1(input)) println(Day03.part2(input)) } class Day03 { companion object { fun part1(input: List<String>): Int { return input.map { it.chunked(it.length / 2) } .map { it[0].filter { x -> it[1].contains(x) }....
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/Day03$Companion.class", "javap": "Compiled from \"Day03.kt\"\npublic final class Day03$Companion {\n private Day03$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n ...
frango9000__advent-of-code-22__62e91dd/src/Day11.kt
fun main() { val input = readInput("Day11") printTime { println(Day11.part1(input)) } printTime { println(Day11.part2(input)) } } class Day11 { companion object { fun part1(input: List<String>): Long { val monkeys = input.toMonkeys() monkeys.playKeepAway { it.floorDiv(3)...
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/Day11.class", "javap": "Compiled from \"Day11.kt\"\npublic final class Day11 {\n public static final Day11$Companion Companion;\n\n public Day11();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object....
frango9000__advent-of-code-22__62e91dd/src/Day02.kt
fun main() { val input = readInput("Day02") println(Day02.part1(input)) println(Day02.part2(input)) } class Day02 { companion object { private fun checkGuessRound(it: String): Int { val (a, b) = it.split(" ").map { it.toCharArray().first() } val selectionPoints = b.code ...
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/Day02$Companion.class", "javap": "Compiled from \"Day02.kt\"\npublic final class Day02$Companion {\n private Day02$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n ...
frango9000__advent-of-code-22__62e91dd/src/Day07.kt
fun main() { val input = readInput("Day07") println(Day07.part1(input)) println(Day07.part2(input)) } class Day07 { companion object { fun getFolderSizes(input: List<String>): MutableMap<String, Int> { val folders: MutableMap<String, Int> = mutableMapOf() val stack: Ar...
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/Day07Kt.class", "javap": "Compiled from \"Day07.kt\"\npublic final class Day07Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day07\n 2: invokestatic #14 // Method UtilsK...
frango9000__advent-of-code-22__62e91dd/src/Day09.kt
fun main() { val input = readInput("Day09") println(Day09.part1(input)) println(Day09.part2(input)) } data class HeadMovement(val direction: Direction, val steps: Int) enum class Direction { U, R, D, L, } class Day09 { companion object { fun part1(input: List<String>): Int { retur...
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/Day09.class", "javap": "Compiled from \"Day09.kt\"\npublic final class Day09 {\n public static final Day09$Companion Companion;\n\n public Day09();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object....
frango9000__advent-of-code-22__62e91dd/src/Day10.kt
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 ...
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/Day10.class", "javap": "Compiled from \"Day10.kt\"\npublic final class Day10 {\n public static final Day10$Companion Companion;\n\n public Day10();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object....
frango9000__advent-of-code-22__62e91dd/src/Day18.kt
import javax.swing.JOptionPane fun main() { val input = readInput("Day18") printTime { print(Day18.part1(input)) } printTime { print(Day18.part1Bitwise(input)) } printTime { print(Day18.part2(input)) } } class Day18 { companion object { fun part1(input: List<String>): Int { v...
[ { "class_path": "frango9000__advent-of-code-22__62e91dd/Day18.class", "javap": "Compiled from \"Day18.kt\"\npublic final class Day18 {\n public static final Day18$Companion Companion;\n\n public Day18();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object....
davidwhitney__Aoc2023__7989c1b/day2-kotlin/src/main/kotlin/GameRequirements.kt
import java.util.stream.Stream class GameRequirements(val gameId: Int, private val requirements: HashMap<String, Int>) { val power: Int get() { return requirements["red"]!! * requirements["green"]!! * requirements["blue"]!!; } fun isViable(red: Int, green: Int, blue: Int): Boolean ...
[ { "class_path": "davidwhitney__Aoc2023__7989c1b/GameRequirements$Companion.class", "javap": "Compiled from \"GameRequirements.kt\"\npublic final class GameRequirements$Companion {\n private GameRequirements$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method ja...
Abijeet123__KotlinAlgorithmsImplementations__902adc3/Graph.kt
import java.util.* private fun readLn() = readLine()!! // string line private fun readInt() = readLn().toInt() // single int private fun readLong() = readLn().toLong() // single long private fun readDouble() = readLn().toDouble() // single double private fun readStrings() = readLn().split(" ") // list of strings priva...
[ { "class_path": "Abijeet123__KotlinAlgorithmsImplementations__902adc3/GraphKt$dikstra$$inlined$compareBy$1.class", "javap": "Compiled from \"Comparisons.kt\"\npublic final class GraphKt$dikstra$$inlined$compareBy$1<T> implements java.util.Comparator {\n public GraphKt$dikstra$$inlined$compareBy$1();\n C...
drochecsp2017__special_pots_shop__20727dd/special_shop.kt
import kotlin.math.round; class Parabola(potCount: Long, xMult: Long, yMult: Long) { private val coeffA = xMult + yMult; private val coeffB = -2 * yMult * potCount; private val coeffC = potCount * potCount * yMult; fun minXCoord(): Long { val numerator = -1.0 * coeffB; val denominator...
[ { "class_path": "drochecsp2017__special_pots_shop__20727dd/Special_shopKt.class", "javap": "Compiled from \"special_shop.kt\"\npublic final class Special_shopKt {\n public static final long solveCase(long, long, long);\n Code:\n 0: new #8 // class Parabola\n 3: dup...
jorander__advent-of-code-2022__1681218/src/Utils.kt
import java.io.File import java.math.BigInteger import java.security.MessageDigest /** * Reads lines from the given input txt file. */ fun readInput(name: String) = File("src", "$name.txt").readLines() /** * Converts string to md5 hash. */ fun String.md5(): String = BigInteger(1, MessageDigest.getInstance("MD5")....
[ { "class_path": "jorander__advent-of-code-2022__1681218/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...
jorander__advent-of-code-2022__1681218/src/Day04.kt
fun main() { val day = "Day04" fun assignmentsAsIntRanges(assignments: String) = assignments.split(",") .map { it.split("-") } .map { (firstSection, lastSection) -> firstSection.toInt()..lastSection.toInt() } fun part1(input: List<String>): Int { return input.map(::assignmentsAsIn...
[ { "class_path": "jorander__advent-of-code-2022__1681218/Day04Kt.class", "javap": "Compiled from \"Day04.kt\"\npublic final class Day04Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day04\n 2: astore_0\n 3: new #10 ...
jorander__advent-of-code-2022__1681218/src/Day05.kt
import java.util.Stack fun main() { val day = "Day05" // Some utility functions for Pair fun <A, B, R> Pair<A, B>.mapFirst(operation: (A) -> R) = operation(first) to second fun <A, B, R> Pair<A, B>.mapSecond(operation: (B) -> R) = first to operation(second) fun <A, B, R> Pair<Iterable<A>, B>.fol...
[ { "class_path": "jorander__advent-of-code-2022__1681218/Day05Kt$main$parse$startingStacksAndRearrangementInstructions$1.class", "javap": "Compiled from \"Day05.kt\"\nfinal class Day05Kt$main$parse$startingStacksAndRearrangementInstructions$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotli...
jorander__advent-of-code-2022__1681218/src/Day11.kt
private data class Item(val worryLevel: Long) { fun relieved(): Item { return Item(worryLevel / 3L) } } private data class TestedItem(val item: Item, val action: (Item, Array<Monkey>) -> Unit) private data class Monkey( val items: List<Item>, val operation: (Item) -> Item, val testValue: L...
[ { "class_path": "jorander__advent-of-code-2022__1681218/Day11Kt$main$part1$1.class", "javap": "Compiled from \"Day11.kt\"\nfinal class Day11Kt$main$part1$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Item, Item> {\n public static final Day11Kt$main$part1$1 IN...
jorander__advent-of-code-2022__1681218/src/Day07.kt
import java.util.* import kotlin.collections.ArrayList fun main() { val day = "Day07" data class Directory(val name: String, var size: Int = 0) fun parseDirectorySizes(input: List<String>): List<Directory> { fun String.toFileSize() = split(" ")[0].toInt() data class State(val path: Sta...
[ { "class_path": "jorander__advent-of-code-2022__1681218/Day07Kt.class", "javap": "Compiled from \"Day07.kt\"\npublic final class Day07Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day07\n 2: astore_0\n 3: new #10 ...
jorander__advent-of-code-2022__1681218/src/Day06.kt
fun main() { val day = "Day06" fun String.toNumberOfCharsBeforeUniqeSetOfSize(size: Int) = windowed(size) .mapIndexed { index, s -> index + size to s } .first { (_, s) -> s.toSet().size == size }.first fun part1(input: String): Int { return input.toNumberOfCharsBeforeUniqeSetOfSiz...
[ { "class_path": "jorander__advent-of-code-2022__1681218/Day06Kt.class", "javap": "Compiled from \"Day06.kt\"\npublic final class Day06Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day06\n 2: astore_0\n 3: aload_0\n 4: invokestati...
jorander__advent-of-code-2022__1681218/src/Day03.kt
fun main() { val day = "Day03" fun List<String>.findCommonChar() = this.drop(1).fold(this.first().toSet()) { acc, s -> s.toSet().intersect(acc) }.first() fun calculatePriority(badge: Char) = if (badge.isLowerCase()) { badge - 'a' + 1 } else { badge - 'A' + ...
[ { "class_path": "jorander__advent-of-code-2022__1681218/Day03Kt.class", "javap": "Compiled from \"Day03.kt\"\npublic final class Day03Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day03\n 2: astore_0\n 3: new #10 ...
jorander__advent-of-code-2022__1681218/src/Day02.kt
import Outcome.* import Outcome.Companion.outcome import Shape.Companion.myShape import Shape.Companion.opponentShape enum class Shape(val opponentCode: String, val myCode: String, val score: Int, val winsOver: Int) { ROCK("A", "X", 1, 2), PAPER("B", "Y", 2, 0), SCISSORS("C", "Z", 3, 1); companion obj...
[ { "class_path": "jorander__advent-of-code-2022__1681218/Day02Kt.class", "javap": "Compiled from \"Day02.kt\"\npublic final class Day02Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day02\n 2: astore_0\n 3: new #10 ...
jorander__advent-of-code-2022__1681218/src/Day09.kt
import kotlin.math.abs typealias Knot = Position2D private fun Knot.isCloseTo(other: Knot) = (this - other).run { abs(dx) <= 1 && abs(dy) <= 1 } fun main() { val day = "Day09" data class Simulation( val numberOfExtraKnots: Int = 0, val head: Knot = Knot(0, 0), val knots: List<Knot> ...
[ { "class_path": "jorander__advent-of-code-2022__1681218/Day09Kt.class", "javap": "Compiled from \"Day09.kt\"\npublic final class Day09Kt {\n private static final boolean isCloseTo(Position2D, Position2D);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokevirtual #12 // Metho...
jorander__advent-of-code-2022__1681218/src/Day08.kt
typealias Trees = Grid2D<Char> typealias TreePosition = Position2D typealias Direction = (TreePosition, Trees) -> List<TreePosition> fun main() { val day = "Day08" val up: Direction = { tp: TreePosition, _: Trees -> (0 until tp.y).map { TreePosition(tp.x, it) }.reversed() } val down: Direction = ...
[ { "class_path": "jorander__advent-of-code-2022__1681218/Day08Kt.class", "javap": "Compiled from \"Day08.kt\"\npublic final class Day08Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day08\n 2: astore_0\n 3: invokedynamic #27, 0 ...
d1snin__aoc-2023__8b5b34c/src/main/kotlin/Day1.kt
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in wr...
[ { "class_path": "d1snin__aoc-2023__8b5b34c/Day1Kt.class", "javap": "Compiled from \"Day1.kt\"\npublic final class Day1Kt {\n private static final java.lang.String INPUT;\n\n private static final java.util.Map<java.lang.String, java.lang.String> digitMap;\n\n private static final java.util.List<java.lang....
d1snin__aoc-2023__8b5b34c/src/main/kotlin/Day3.kt
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in wr...
[ { "class_path": "d1snin__aoc-2023__8b5b34c/Day3Kt.class", "javap": "Compiled from \"Day3.kt\"\npublic final class Day3Kt {\n private static final java.lang.String INPUT;\n\n private static final java.util.List<java.lang.String> lines;\n\n private static final java.util.List<Gear> gears;\n\n public stati...
d1snin__aoc-2023__8b5b34c/src/main/kotlin/Day2.kt
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in wr...
[ { "class_path": "d1snin__aoc-2023__8b5b34c/Day2Kt.class", "javap": "Compiled from \"Day2.kt\"\npublic final class Day2Kt {\n private static final java.lang.String INPUT;\n\n private static final int RED_LIMIT;\n\n private static final int GREEN_LIMIT;\n\n private static final int BLUE_LIMIT;\n\n privat...
d1snin__aoc-2023__8b5b34c/src/main/kotlin/Day4.kt
/* * Copyright 2023 <NAME> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in wr...
[ { "class_path": "d1snin__aoc-2023__8b5b34c/Day4Kt.class", "javap": "Compiled from \"Day4.kt\"\npublic final class Day4Kt {\n private static final java.lang.String INPUT;\n\n private static final java.util.List<java.lang.String> lines;\n\n public static final void day4();\n Code:\n 0: ldc ...
rolf-rosenbaum__aoc-2022__59cd426/src/main/Utils.kt
import java.io.File import kotlin.math.abs /** * Reads lines from the given input txt file. */ fun readInput(name: String) = File("src", "$name.txt") .readLines() fun <T> List<T>.second() = this[1] fun <T, R> Pair<T, R>.reverse() = second to first data class Point(val x: Int, val y: Int) { fun neighbours(i...
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/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...
Hotkeyyy__advent-of-code-2022__dfb20f1/src/Day04.kt
import java.io.File fun main() { fun part1(input: String) { val pairs = input.split("\n").map { val parts = it.split(",") Pair(parts[0].split("-").map { it.toInt() }, parts[1].split("-").map { it.toInt() }) } val count = pairs.count { val (a, b) = it ...
[ { "class_path": "Hotkeyyy__advent-of-code-2022__dfb20f1/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 ...
Hotkeyyy__advent-of-code-2022__dfb20f1/src/Day03.kt
import java.io.File fun main() { val lowerCase = ('a'..'z').toList() val upperCase = ('A'..'Z').toList() fun part1(input: String) { var result = 0 input.split("\r").map { it.trim() }.forEach { val firstCompartment = it.substring(0, it.length / 2) val secondCompartm...
[ { "class_path": "Hotkeyyy__advent-of-code-2022__dfb20f1/Day03Kt.class", "javap": "Compiled from \"Day03.kt\"\npublic final class Day03Kt {\n public static final void main();\n Code:\n 0: new #8 // class kotlin/ranges/CharRange\n 3: dup\n 4: bipush 97\n...
Hotkeyyy__advent-of-code-2022__dfb20f1/src/Day02.kt
import java.io.File val meL = "XYZ".toList() val opponentL = "ABC".toList() fun main() { fun part1(input: String) { val rounds = input.split("\r") var result = 0 rounds.forEach { val me = it.split(" ").last() val opponent = it.split(" ").first() val p = g...
[ { "class_path": "Hotkeyyy__advent-of-code-2022__dfb20f1/Day02Kt.class", "javap": "Compiled from \"Day02.kt\"\npublic final class Day02Kt {\n private static final java.util.List<java.lang.Character> meL;\n\n private static final java.util.List<java.lang.Character> opponentL;\n\n public static final java.u...
netguru__CarLens-Android__321fa52/app/src/main/kotlin/co/netguru/android/carrecognition/common/MultimapExt.kt
typealias Multimap<K, V> = Map<K, List<V>> fun <K, V> Multimap<K, V>.partition( predicate: (V) -> Boolean ): Pair<Multimap<K, V>, Multimap<K, V>> { val first = mutableMapOf<K, List<V>>() val second = mutableMapOf<K, List<V>>() for (k in this.keys) { val (firstValuePartition, secondValuePartitio...
[ { "class_path": "netguru__CarLens-Android__321fa52/MultimapExtKt.class", "javap": "Compiled from \"MultimapExt.kt\"\npublic final class MultimapExtKt {\n public static final <K, V> kotlin.Pair<java.util.Map<K, java.util.List<V>>, java.util.Map<K, java.util.List<V>>> partition(java.util.Map<K, ? extends jav...
funfunStudy__algorithm__a207e4d/kotlin/src/main/kotlin/LongestSubstringFromChanHo.kt
import kotlin.math.max fun main(args: Array<String>) { val problems = listOf("abcabcbb", "bbbbb", "pwwkew", "", "dvdf", "asjrgapa") val expected = listOf(3, 1, 3, 0, 3, 6) problems.mapIndexed { index, s -> Pair(solution(s), expected.get(index)) } .forEach { (result, expected) -> ...
[ { "class_path": "funfunStudy__algorithm__a207e4d/LongestSubstringFromChanHoKt.class", "javap": "Compiled from \"LongestSubstringFromChanHo.kt\"\npublic final class LongestSubstringFromChanHoKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 ...
funfunStudy__algorithm__a207e4d/kotlin/src/main/kotlin/StreetRgb.kt
fun main(args: Array<String>) { val list: List<List<Int>> = listOf(listOf(26, 40, 83), listOf(49, 60, 57), listOf(13, 89, 99)) val list2: List<List<Int>> = listOf(listOf(1, 20, 30), listOf(50, 5, 6), listOf(9, 3, 7)) println(solve(list)) println(solve(list2)) } fun solve(list: List<List<Int>>, index:...
[ { "class_path": "funfunStudy__algorithm__a207e4d/StreetRgbKt.class", "javap": "Compiled from \"StreetRgb.kt\"\npublic final class StreetRgbKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String args\n 3: invokesta...
funfunStudy__algorithm__a207e4d/kotlin/src/main/kotlin/Saddlepoint.kt
fun main(args: Array<String>) { val test1 = listOf( listOf(9, 8, 7), listOf(5, 3, 2), listOf(6, 6, 7)) val test2 = listOf( listOf(1, 2, 3), listOf(3, 1, 2), listOf(2, 3, 1)) val test3 = listOf( listOf(4, 5, 4), ...
[ { "class_path": "funfunStudy__algorithm__a207e4d/SaddlepointKt.class", "javap": "Compiled from \"Saddlepoint.kt\"\npublic final class SaddlepointKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String args\n 3: inv...
funfunStudy__algorithm__a207e4d/kotlin/src/main/kotlin/RefreshRecord.kt
fun main(args: Array<String>) { solve(listOf(10, 5, 20, 20, 4, 5, 2, 25, 1), 9) solve2(listOf(10, 5, 20, 20, 4, 5, 2, 25, 1)) solve3(listOf(10, 5, 20, 20, 4, 5, 2, 25, 1)) solve3(listOf(3, 4, 21, 36, 10, 28, 35, 5, 24, 42)) } data class RecordedScore(val minScore: Int = 0, val maxScore: Int = 0, val mi...
[ { "class_path": "funfunStudy__algorithm__a207e4d/RefreshRecordKt.class", "javap": "Compiled from \"RefreshRecord.kt\"\npublic final class RefreshRecordKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String args\n ...
mr-kaffee__aoc-2023__5cbd13d/day11/kotlin/RJPlog/day2311_1_2.kt
import java.io.File import kotlin.math.* fun day11(in1: Int): Long { var expansionValue = 1 if (in1 == 2) { expansionValue = 1000000 - 1 } var universe: String = "" var xDim = 0 var yDim = 0 var galaxyMap = mutableMapOf<Int, Pair<Int, Int>>() var galaxyCount = 1 File("day2311_puzzle_input.txt").forEachLin...
[ { "class_path": "mr-kaffee__aoc-2023__5cbd13d/Day2311_1_2Kt.class", "javap": "Compiled from \"day2311_1_2.kt\"\npublic final class Day2311_1_2Kt {\n public static final long day11(int);\n Code:\n 0: new #8 // class kotlin/jvm/internal/Ref$IntRef\n 3: dup\n 4:...
mr-kaffee__aoc-2023__5cbd13d/day04/kotlin/RJPlog/day2304_1_2.kt
import java.io.File import kotlin.math.* fun scratchCard(): Int { var result = 0 val pattern = """(\d)+""".toRegex() File("day2304_puzzle_input.txt").forEachLine { var winningNumbers = pattern.findAll(it.substringAfter(": ").split(" | ")[0]).map { it.value }.toList() var numbersYouHave = pattern.findAll(it.subs...
[ { "class_path": "mr-kaffee__aoc-2023__5cbd13d/Day2304_1_2Kt.class", "javap": "Compiled from \"day2304_1_2.kt\"\npublic final class Day2304_1_2Kt {\n public static final int scratchCard();\n Code:\n 0: new #8 // class kotlin/jvm/internal/Ref$IntRef\n 3: dup\n ...
mr-kaffee__aoc-2023__5cbd13d/day01/kotlin/RJPlog/day2301_1_2.kt
import java.io.File fun trebuchet(in1: Int): Int { var conMap = mutableMapOf("0" to 1, "1" to 1, "2" to 2, "3" to 3, "4" to 4, "5" to 5, "6" to 6, "7" to 7, "8" to 8, "9" to 9) var pattern = """\d""".toRegex() if (in1 == 2) { var conMap2 =...
[ { "class_path": "mr-kaffee__aoc-2023__5cbd13d/Day2301_1_2Kt.class", "javap": "Compiled from \"day2301_1_2.kt\"\npublic final class Day2301_1_2Kt {\n public static final int trebuchet(int);\n Code:\n 0: new #8 // class kotlin/jvm/internal/Ref$ObjectRef\n 3: dup\n ...
mr-kaffee__aoc-2023__5cbd13d/day08/kotlin/RJPlog/day2308_1_2.kt
import java.io.File import kotlin.math.* fun wasteland(in1: Int): Int { var lines = File("day2308_puzzle_input.txt").readLines() var network = mutableMapOf<String, Pair<String, String>>() var instructions = lines[0] for (i in 2..lines.size - 1) { network.put( lines[i].substringBefore(" ="), Pair(lines[i].s...
[ { "class_path": "mr-kaffee__aoc-2023__5cbd13d/Day2308_1_2Kt.class", "javap": "Compiled from \"day2308_1_2.kt\"\npublic final class Day2308_1_2Kt {\n public static final int wasteland(int);\n Code:\n 0: new #8 // class java/io/File\n 3: dup\n 4: ldc ...
mr-kaffee__aoc-2023__5cbd13d/day09/kotlin/RJPlog/day2309_1_2.kt
import java.io.File import kotlin.math.* fun day09(in1: Int): Long { var result = 0L var lines = File("day2309_puzzle_input.txt").readLines() lines.forEach { var line = it.split(" ").map { it.toLong() }.toList() var interpolationValues = mutableListOf<Long>() var diffList = mutableListOf<Long>() if (in...
[ { "class_path": "mr-kaffee__aoc-2023__5cbd13d/Day2309_1_2Kt.class", "javap": "Compiled from \"day2309_1_2.kt\"\npublic final class Day2309_1_2Kt {\n public static final long day09(int);\n Code:\n 0: lconst_0\n 1: lstore 21\n 3: new #8 // class java/io/...
mr-kaffee__aoc-2023__5cbd13d/day05/kotlin/RJPlog/day2305_1_2.kt
import java.io.File import kotlin.math.* fun fertilizer(): Long { var locationList = mutableListOf<Long>() var newLocationList = mutableListOf<Long>() File("day2305_puzzle_input.txt").forEachLine { if (it.contains("seeds: ")) { locationList = it.substringAfter("seeds: ").split(" ").map { it.toLong() }.toMutab...
[ { "class_path": "mr-kaffee__aoc-2023__5cbd13d/Day2305_1_2Kt.class", "javap": "Compiled from \"day2305_1_2.kt\"\npublic final class Day2305_1_2Kt {\n public static final long fertilizer();\n Code:\n 0: new #8 // class kotlin/jvm/internal/Ref$ObjectRef\n 3: dup\n ...
mr-kaffee__aoc-2023__5cbd13d/day06/kotlin/RJPlog/day2306_1_2.kt
import java.io.File fun waitForIt(in1: Int): Long { val pattern = """(\d)+""".toRegex() var lines = File("day2306_puzzle_input.txt").readLines() var line0 = pattern.findAll(lines[0]).map { it.value }.toList() var line1 = pattern.findAll(lines[1]).map { it.value }.toList() var time = mutableListOf<Pair<Long, L...
[ { "class_path": "mr-kaffee__aoc-2023__5cbd13d/Day2306_1_2Kt.class", "javap": "Compiled from \"day2306_1_2.kt\"\npublic final class Day2306_1_2Kt {\n public static final long waitForIt(int);\n Code:\n 0: new #8 // class kotlin/text/Regex\n 3: dup\n 4: ldc ...
mr-kaffee__aoc-2023__5cbd13d/day03/kotlin/RJPlog/day2303_1_2.kt
import java.io.File import kotlin.math.* fun gearRatio(): Int { var result = 0 val patternSymbol = """\W""".toRegex() val patternPartNumber = """(\d)+""".toRegex() var y = 0 File("day2303_puzzle_input.txt").forEachLine { var matchSymbol = patternSymbol.findAll(it.replace(".", "a")) matchSymbol.forEach { v...
[ { "class_path": "mr-kaffee__aoc-2023__5cbd13d/Day2303_1_2Kt.class", "javap": "Compiled from \"day2303_1_2.kt\"\npublic final class Day2303_1_2Kt {\n public static final int gearRatio();\n Code:\n 0: new #8 // class kotlin/jvm/internal/Ref$IntRef\n 3: dup\n 4:...
mr-kaffee__aoc-2023__5cbd13d/day02/kotlin/RJPlog/day02_1_2.kt
import java.io.File fun cube(in1: Int): Int { var result = 0 File("day2302_puzzle_input.txt").forEachLine { var gamePossible = true var maxRed = 0 var maxGreen = 0 var maxBlue = 0 var instruction = it.split(": ") var game = instruction[0].substringAfter("Game ").toInt() var results = instruction[1].s...
[ { "class_path": "mr-kaffee__aoc-2023__5cbd13d/Day02_1_2Kt.class", "javap": "Compiled from \"day02_1_2.kt\"\npublic final class Day02_1_2Kt {\n public static final int cube(int);\n Code:\n 0: new #8 // class kotlin/jvm/internal/Ref$IntRef\n 3: dup\n 4: invokes...
Rxfa__kotlin-basics__5ba1a7e/DiagonalDifference.kt
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...
[ { "class_path": "Rxfa__kotlin-basics__5ba1a7e/DiagonalDifferenceKt.class", "javap": "Compiled from \"DiagonalDifference.kt\"\npublic final class DiagonalDifferenceKt {\n public static final int diagonalDifference(java.lang.Integer[][]);\n Code:\n 0: aload_0\n 1: ldc #9 ...
mike10004__adventofcode2017__977c5c1/advent08/src/Registers.kt
import java.io.File import java.io.FileReader import java.util.stream.Stream fun main(args: Array<String>) { FileReader(File("./input.txt")).buffered().use { main(it.lines()) } } fun doExample() { val lines = listOf( "b inc 5 if a > 1", "a inc 1 if b < 5", "c de...
[ { "class_path": "mike10004__adventofcode2017__977c5c1/RegistersKt.class", "javap": "Compiled from \"Registers.kt\"\npublic final class RegistersKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #11 // String args\n 3: invo...
codinasion__program__d8880e3/program/add-two-matrices/AddTwoMatrices.kt
fun main() { print("Enter the two matrices line separated: \n") val size = 3 val a = readMatrix(size) readln() val b = readMatrix(size) val c = addMatrices(a, b) println("Result of adding the matrices: \n") printMatrix(c) } // Takes number of rows and columns and reads the matrix from...
[ { "class_path": "codinasion__program__d8880e3/AddTwoMatricesKt.class", "javap": "Compiled from \"AddTwoMatrices.kt\"\npublic final class AddTwoMatricesKt {\n public static final void main();\n Code:\n 0: ldc #8 // String Enter the two matrices line separated: \\n\n ...
mdenburger__aoc-2020__b965f46/src/main/kotlin/day11/Day11.kt
import java.io.File import java.lang.Integer.max import kotlin.math.absoluteValue fun main() { val seatLayout = File("src/main/kotlin/day11/day11-input.txt").readLines().map { it.toCharArray() } var current = seatLayout var currentHashCode = current.contentHashCode() val found = mutableSetOf<Int>() ...
[ { "class_path": "mdenburger__aoc-2020__b965f46/Day11Kt.class", "javap": "Compiled from \"Day11.kt\"\npublic final class Day11Kt {\n public static final void main();\n Code:\n 0: new #8 // class java/io/File\n 3: dup\n 4: ldc #10 // S...