kt_path
stringlengths
35
167
kt_source
stringlengths
626
28.9k
classes
listlengths
1
17
rolf-rosenbaum__aoc-2022__59cd426/src/main/day09/day09.kt
package day09 import Point import kotlin.math.sign import readInput typealias Segment = Point enum class Direction { R, U, D, L } val regex = """([RUDL]) (\d+)""".toRegex() val start = Segment(0, 0) fun main() { val input = readInput("main/day09/Day09") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int { return input.toSteps().tailPositions(2).size } fun part2(input: List<String>): Int { return input.toSteps().tailPositions(10).size } private fun List<Direction>.tailPositions(length: Int) = tailPositions(Rope(Array(length) { Point(0, 0) }.toList())) private fun List<Direction>.tailPositions(rope: Rope) = iterator().let { directions -> generateSequence(rope) { if (directions.hasNext()) it.step(directions.next()) else null }.takeWhile { it != null }.map { it.tail() }.distinct().toList() } fun List<String>.toSteps(): List<Direction> { val directions = mutableListOf<Direction>() forEach { regex.matchEntire(it)?.destructured?.let { (direction, steps) -> repeat(steps.toInt()) { directions.add(Direction.valueOf(direction)) } } ?: error("invalid input") } return directions } data class Rope(val segments: List<Segment> = emptyList()) { fun step(direction: Direction): Rope { var newRope = Rope().add(head().move(direction)) segments.drop(1).forEach { segment -> val head = newRope.tail() newRope = if (segment.isAdjacentTo(head)) newRope.add(segment) else newRope.add(Segment((head.x - segment.x).sign + segment.x, (head.y - segment.y).sign + segment.y)) } return newRope } private fun head() = segments.first() fun tail(): Segment = segments.last() private fun add(segment: Segment) = copy(segments = segments + segment) } fun Segment.isAdjacentTo(other: Segment): Boolean { return other.x in (x - 1..x + 1) && other.y in (y - 1..y + 1) } fun Segment.move(direction: Direction) = when (direction) { Direction.R -> copy(x = x + 1) Direction.U -> copy(y = y + 1) Direction.D -> copy(y = y - 1) Direction.L -> copy(x = x - 1) }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day09/Day09Kt$WhenMappings.class", "javap": "Compiled from \"day09.kt\"\npublic final class day09.Day09Kt$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method day09/Direction.values:()[Lday09/Direction;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field day09/Direction.R:Lday09/Direction;\n 12: invokevirtual #22 // Method day09/Direction.ordinal:()I\n 15: iconst_1\n 16: iastore\n 17: goto 21\n 20: astore_1\n 21: nop\n 22: aload_0\n 23: getstatic #25 // Field day09/Direction.U:Lday09/Direction;\n 26: invokevirtual #22 // Method day09/Direction.ordinal:()I\n 29: iconst_2\n 30: iastore\n 31: goto 35\n 34: astore_1\n 35: nop\n 36: aload_0\n 37: getstatic #28 // Field day09/Direction.D:Lday09/Direction;\n 40: invokevirtual #22 // Method day09/Direction.ordinal:()I\n 43: iconst_3\n 44: iastore\n 45: goto 49\n 48: astore_1\n 49: nop\n 50: aload_0\n 51: getstatic #31 // Field day09/Direction.L:Lday09/Direction;\n 54: invokevirtual #22 // Method day09/Direction.ordinal:()I\n 57: iconst_4\n 58: iastore\n 59: goto 63\n 62: astore_1\n 63: aload_0\n 64: putstatic #35 // Field $EnumSwitchMapping$0:[I\n 67: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n 21 31 34 Class java/lang/NoSuchFieldError\n 35 45 48 Class java/lang/NoSuchFieldError\n 49 59 62 Class java/lang/NoSuchFieldError\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day09/Day09Kt.class", "javap": "Compiled from \"day09.kt\"\npublic final class day09.Day09Kt {\n private static final kotlin.text.Regex regex;\n\n private static final Point start;\n\n public static final kotlin.text.Regex getRegex();\n Code:\n 0: getstatic #11 // Field regex:Lkotlin/text/Regex;\n 3: areturn\n\n public static final Point getStart();\n Code:\n 0: getstatic #17 // Field start:LPoint;\n 3: areturn\n\n public static final void main();\n Code:\n 0: ldc #21 // String main/day09/Day09\n 2: invokestatic #27 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #31 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #46 // Method part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #50 // String input\n 3: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #60 // Method toSteps:(Ljava/util/List;)Ljava/util/List;\n 10: iconst_2\n 11: invokestatic #64 // Method tailPositions:(Ljava/util/List;I)Ljava/util/List;\n 14: invokeinterface #70, 1 // InterfaceMethod java/util/List.size:()I\n 19: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #50 // String input\n 3: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #60 // Method toSteps:(Ljava/util/List;)Ljava/util/List;\n 10: bipush 10\n 12: invokestatic #64 // Method tailPositions:(Ljava/util/List;I)Ljava/util/List;\n 15: invokeinterface #70, 1 // InterfaceMethod java/util/List.size:()I\n 20: ireturn\n\n private static final java.util.List<Point> tailPositions(java.util.List<? extends day09.Direction>, int);\n Code:\n 0: aload_0\n 1: iconst_0\n 2: istore_2\n 3: iload_1\n 4: anewarray #73 // class Point\n 7: astore_3\n 8: astore 5\n 10: iload_2\n 11: iload_1\n 12: if_icmpge 37\n 15: iload_2\n 16: istore 4\n 18: aload_3\n 19: iload 4\n 21: new #73 // class Point\n 24: dup\n 25: iconst_0\n 26: iconst_0\n 27: invokespecial #77 // Method Point.\"<init>\":(II)V\n 30: aastore\n 31: iinc 2, 1\n 34: goto 10\n 37: aload 5\n 39: aload_3\n 40: invokestatic #83 // Method kotlin/collections/ArraysKt.toList:([Ljava/lang/Object;)Ljava/util/List;\n 43: astore 6\n 45: new #85 // class day09/Rope\n 48: dup\n 49: aload 6\n 51: invokespecial #88 // Method day09/Rope.\"<init>\":(Ljava/util/List;)V\n 54: invokestatic #91 // Method tailPositions:(Ljava/util/List;Lday09/Rope;)Ljava/util/List;\n 57: areturn\n\n private static final java.util.List<Point> tailPositions(java.util.List<? extends day09.Direction>, day09.Rope);\n Code:\n 0: aload_0\n 1: invokeinterface #101, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 6: astore_2\n 7: iconst_0\n 8: istore_3\n 9: aload_1\n 10: aload_2\n 11: invokedynamic #121, 0 // InvokeDynamic #0:invoke:(Ljava/util/Iterator;)Lkotlin/jvm/functions/Function1;\n 16: invokestatic #127 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 19: invokedynamic #137, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 24: invokestatic #141 // Method kotlin/sequences/SequencesKt.takeWhile:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 27: invokedynamic #148, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;\n 32: invokestatic #151 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 35: invokestatic #155 // Method kotlin/sequences/SequencesKt.distinct:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 38: invokestatic #158 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 41: nop\n 42: areturn\n\n public static final java.util.List<day09.Direction> toSteps(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #166 // String <this>\n 3: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #168 // class java/util/ArrayList\n 9: dup\n 10: invokespecial #170 // Method java/util/ArrayList.\"<init>\":()V\n 13: checkcast #66 // class java/util/List\n 16: astore_1\n 17: aload_0\n 18: checkcast #172 // class java/lang/Iterable\n 21: astore_2\n 22: iconst_0\n 23: istore_3\n 24: aload_2\n 25: invokeinterface #173, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 30: astore 4\n 32: aload 4\n 34: invokeinterface #179, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 39: ifeq 199\n 42: aload 4\n 44: invokeinterface #183, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 49: astore 5\n 51: aload 5\n 53: checkcast #185 // class java/lang/String\n 56: astore 6\n 58: iconst_0\n 59: istore 7\n 61: getstatic #11 // Field regex:Lkotlin/text/Regex;\n 64: aload 6\n 66: checkcast #187 // class java/lang/CharSequence\n 69: invokevirtual #193 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 72: dup\n 73: ifnull 180\n 76: invokeinterface #199, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 81: dup\n 82: ifnull 180\n 85: astore 8\n 87: iconst_0\n 88: istore 9\n 90: aload 8\n 92: invokevirtual #205 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 95: invokeinterface #209, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 100: iconst_1\n 101: invokeinterface #213, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 106: checkcast #185 // class java/lang/String\n 109: astore 10\n 111: aload 8\n 113: invokevirtual #205 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 116: invokeinterface #209, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 121: iconst_2\n 122: invokeinterface #213, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 127: checkcast #185 // class java/lang/String\n 130: astore 11\n 132: aload 11\n 134: invokestatic #219 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 137: istore 12\n 139: iconst_0\n 140: istore 13\n 142: iload 13\n 144: iload 12\n 146: if_icmpge 175\n 149: iload 13\n 151: istore 14\n 153: iconst_0\n 154: istore 15\n 156: aload_1\n 157: aload 10\n 159: invokestatic #225 // Method day09/Direction.valueOf:(Ljava/lang/String;)Lday09/Direction;\n 162: invokeinterface #229, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 167: pop\n 168: nop\n 169: iinc 13, 1\n 172: goto 142\n 175: nop\n 176: nop\n 177: goto 194\n 180: pop\n 181: new #231 // class java/lang/IllegalStateException\n 184: dup\n 185: ldc #233 // String invalid input\n 187: invokevirtual #237 // Method java/lang/Object.toString:()Ljava/lang/String;\n 190: invokespecial #240 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 193: athrow\n 194: nop\n 195: nop\n 196: goto 32\n 199: nop\n 200: aload_1\n 201: areturn\n\n public static final boolean isAdjacentTo(Point, Point);\n Code:\n 0: aload_0\n 1: ldc #166 // String <this>\n 3: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc_w #257 // String other\n 10: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: aload_0\n 14: invokevirtual #260 // Method Point.getX:()I\n 17: iconst_1\n 18: isub\n 19: istore_2\n 20: aload_0\n 21: invokevirtual #260 // Method Point.getX:()I\n 24: iconst_1\n 25: iadd\n 26: istore_3\n 27: aload_1\n 28: invokevirtual #260 // Method Point.getX:()I\n 31: istore 4\n 33: iload_2\n 34: iload 4\n 36: if_icmpgt 53\n 39: iload 4\n 41: iload_3\n 42: if_icmpgt 49\n 45: iconst_1\n 46: goto 54\n 49: iconst_0\n 50: goto 54\n 53: iconst_0\n 54: ifeq 105\n 57: aload_0\n 58: invokevirtual #263 // Method Point.getY:()I\n 61: iconst_1\n 62: isub\n 63: istore_2\n 64: aload_0\n 65: invokevirtual #263 // Method Point.getY:()I\n 68: iconst_1\n 69: iadd\n 70: istore_3\n 71: aload_1\n 72: invokevirtual #263 // Method Point.getY:()I\n 75: istore 4\n 77: iload_2\n 78: iload 4\n 80: if_icmpgt 97\n 83: iload 4\n 85: iload_3\n 86: if_icmpgt 93\n 89: iconst_1\n 90: goto 98\n 93: iconst_0\n 94: goto 98\n 97: iconst_0\n 98: ifeq 105\n 101: iconst_1\n 102: goto 106\n 105: iconst_0\n 106: ireturn\n\n public static final Point move(Point, day09.Direction);\n Code:\n 0: aload_0\n 1: ldc #166 // String <this>\n 3: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc_w #267 // String direction\n 10: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: aload_1\n 14: getstatic #273 // Field day09/Day09Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 17: swap\n 18: invokevirtual #276 // Method day09/Direction.ordinal:()I\n 21: iaload\n 22: tableswitch { // 1 to 4\n 1: 52\n 2: 68\n 3: 84\n 4: 100\n default: 116\n }\n 52: aload_0\n 53: aload_0\n 54: invokevirtual #260 // Method Point.getX:()I\n 57: iconst_1\n 58: iadd\n 59: iconst_0\n 60: iconst_2\n 61: aconst_null\n 62: invokestatic #280 // Method Point.copy$default:(LPoint;IIILjava/lang/Object;)LPoint;\n 65: goto 124\n 68: aload_0\n 69: iconst_0\n 70: aload_0\n 71: invokevirtual #263 // Method Point.getY:()I\n 74: iconst_1\n 75: iadd\n 76: iconst_1\n 77: aconst_null\n 78: invokestatic #280 // Method Point.copy$default:(LPoint;IIILjava/lang/Object;)LPoint;\n 81: goto 124\n 84: aload_0\n 85: iconst_0\n 86: aload_0\n 87: invokevirtual #263 // Method Point.getY:()I\n 90: iconst_1\n 91: isub\n 92: iconst_1\n 93: aconst_null\n 94: invokestatic #280 // Method Point.copy$default:(LPoint;IIILjava/lang/Object;)LPoint;\n 97: goto 124\n 100: aload_0\n 101: aload_0\n 102: invokevirtual #260 // Method Point.getX:()I\n 105: iconst_1\n 106: isub\n 107: iconst_0\n 108: iconst_2\n 109: aconst_null\n 110: invokestatic #280 // Method Point.copy$default:(LPoint;IIILjava/lang/Object;)LPoint;\n 113: goto 124\n 116: new #282 // class kotlin/NoWhenBranchMatchedException\n 119: dup\n 120: invokespecial #283 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 123: athrow\n 124: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #288 // Method main:()V\n 3: return\n\n private static final day09.Rope tailPositions$lambda$3$lambda$0(java.util.Iterator, day09.Rope);\n Code:\n 0: aload_1\n 1: ldc_w #291 // String it\n 4: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokeinterface #179, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 13: ifeq 32\n 16: aload_1\n 17: aload_0\n 18: invokeinterface #183, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 23: checkcast #221 // class day09/Direction\n 26: invokevirtual #295 // Method day09/Rope.step:(Lday09/Direction;)Lday09/Rope;\n 29: goto 33\n 32: aconst_null\n 33: areturn\n\n private static final boolean tailPositions$lambda$3$lambda$1(day09.Rope);\n Code:\n 0: aload_0\n 1: ldc_w #291 // String it\n 4: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: iconst_1\n 8: ireturn\n\n private static final Point tailPositions$lambda$3$lambda$2(day09.Rope);\n Code:\n 0: aload_0\n 1: ldc_w #291 // String it\n 4: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokevirtual #299 // Method day09/Rope.tail:()LPoint;\n 11: areturn\n\n static {};\n Code:\n 0: new #189 // class kotlin/text/Regex\n 3: dup\n 4: ldc_w #302 // String ([RUDL]) (\\\\d+)\n 7: invokespecial #303 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 10: putstatic #11 // Field regex:Lkotlin/text/Regex;\n 13: new #73 // class Point\n 16: dup\n 17: iconst_0\n 18: iconst_0\n 19: invokespecial #77 // Method Point.\"<init>\":(II)V\n 22: putstatic #17 // Field start:LPoint;\n 25: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day08/day08.kt
package day08 import Point import readInput typealias Forest = List<Tree> fun main() { val input = readInput("main/day08/Day08") val forest = input.flatMapIndexed { y, line -> line.mapIndexed { x, height -> Tree(x, y, height.digitToInt()) } } println(part1(forest)) println(part2(forest)) } fun part1(forest: Forest): Int { return forest.count { it.isVisibleFromLeft(forest) || it.isVisibleFromRight(forest) || it.isVisibleFromTop(forest) || it.isVisibleFromBottom(forest) } } fun part2(forest: Forest): Int { return forest.maxOf { it.scenicScore(forest.associateBy { tree -> Point(tree.x, tree.y) }) } } data class Tree(val x: Int, val y: Int, val height: Int) { operator fun compareTo(other: Tree) = this.height.compareTo(other.height) override fun equals(other: Any?): Boolean { return if (other is Tree) x == other.x && y == other.y else false } override fun hashCode(): Int { return x.hashCode() * 31 + y.hashCode() } fun isVisibleFromLeft(otherTrees: Forest): Boolean = otherTrees.none { it.y == y && it >= this && it.x < this.x } fun isVisibleFromRight(otherTrees: Forest): Boolean = otherTrees.none { it.y == y && it >= this && it.x > this.x } fun isVisibleFromTop(otherTrees: Forest): Boolean = otherTrees.none { it.x == x && it >= this && it.y < this.y } fun isVisibleFromBottom(otherTrees: Forest): Boolean = otherTrees.none { it.x == x && it >= this && it.y > this.y } fun scenicScore(treeMap: Map<Point, Tree>): Int { return countVisibleTreesLeft(treeMap) * countVisibleTreesDown(treeMap) * countVisibleTreesRight(treeMap) * countVisibleTreesUp(treeMap) } private fun countVisibleTreesLeft(treeMap: Map<Point, Tree>): Int { var result = 0 var xpos = x - 1 while (xpos >= 0 && this > treeMap[Point(xpos, y)]!!) { result++ xpos-- } return result + if (xpos < 0) 0 else 1 } private fun countVisibleTreesRight(treeMap: Map<Point, Tree>): Int { val maxX = treeMap.maxOf { it.key.x } var result = 0 var xpos = x + 1 while (xpos <= maxX && this > treeMap[Point(xpos, y)]!!) { result++ xpos++ } return result + if (xpos > maxX) 0 else 1 } private fun countVisibleTreesUp(treeMap: Map<Point, Tree>): Int { var result = 0 var ypos = y - 1 while (ypos >= 0 && this > treeMap[Point(x, ypos)]!!) { result++ ypos-- } return result + if (ypos < 0) 0 else 1 } private fun countVisibleTreesDown(treeMap: Map<Point, Tree>): Int { val maxY = treeMap.maxOf { it.key.y } var result = 0 var ypos = y + 1 while (ypos <= maxY && this > treeMap[Point(x, ypos)]!!) { result++ ypos++ } return result + if (ypos > maxY) 0 else 1 } }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day08/Day08Kt.class", "javap": "Compiled from \"day08.kt\"\npublic final class day08.Day08Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String main/day08/Day08\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: checkcast #16 // class java/lang/Iterable\n 10: astore_3\n 11: new #18 // class java/util/ArrayList\n 14: dup\n 15: invokespecial #21 // Method java/util/ArrayList.\"<init>\":()V\n 18: checkcast #23 // class java/util/Collection\n 21: astore 4\n 23: iconst_0\n 24: istore 5\n 26: aload_3\n 27: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 6\n 34: aload 6\n 36: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 216\n 44: aload 6\n 46: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: astore 7\n 53: iload 5\n 55: iinc 5, 1\n 58: istore 8\n 60: iload 8\n 62: ifge 68\n 65: invokestatic #42 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 68: iload 8\n 70: aload 7\n 72: checkcast #44 // class java/lang/String\n 75: astore 9\n 77: istore 10\n 79: iconst_0\n 80: istore 11\n 82: aload 9\n 84: checkcast #46 // class java/lang/CharSequence\n 87: astore 12\n 89: iconst_0\n 90: istore 13\n 92: aload 12\n 94: astore 14\n 96: new #18 // class java/util/ArrayList\n 99: dup\n 100: aload 12\n 102: invokeinterface #50, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 107: invokespecial #53 // Method java/util/ArrayList.\"<init>\":(I)V\n 110: checkcast #23 // class java/util/Collection\n 113: astore 15\n 115: iconst_0\n 116: istore 16\n 118: iconst_0\n 119: istore 17\n 121: iconst_0\n 122: istore 18\n 124: iload 18\n 126: aload 14\n 128: invokeinterface #50, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 133: if_icmpge 196\n 136: aload 14\n 138: iload 18\n 140: invokeinterface #57, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 145: istore 19\n 147: aload 15\n 149: iload 17\n 151: iinc 17, 1\n 154: iload 19\n 156: istore 20\n 158: istore 21\n 160: astore 22\n 162: iconst_0\n 163: istore 23\n 165: new #59 // class day08/Tree\n 168: dup\n 169: iload 21\n 171: iload 10\n 173: iload 20\n 175: invokestatic #65 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 178: invokespecial #68 // Method day08/Tree.\"<init>\":(III)V\n 181: aload 22\n 183: swap\n 184: invokeinterface #72, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 189: pop\n 190: iinc 18, 1\n 193: goto 124\n 196: aload 15\n 198: checkcast #74 // class java/util/List\n 201: nop\n 202: checkcast #16 // class java/lang/Iterable\n 205: nop\n 206: aload 4\n 208: swap\n 209: invokestatic #78 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 212: pop\n 213: goto 34\n 216: aload 4\n 218: checkcast #74 // class java/util/List\n 221: astore_1\n 222: aload_1\n 223: invokestatic #82 // Method part1:(Ljava/util/List;)I\n 226: istore_2\n 227: getstatic #88 // Field java/lang/System.out:Ljava/io/PrintStream;\n 230: iload_2\n 231: invokevirtual #93 // Method java/io/PrintStream.println:(I)V\n 234: aload_1\n 235: invokestatic #96 // Method part2:(Ljava/util/List;)I\n 238: istore_2\n 239: getstatic #88 // Field java/lang/System.out:Ljava/io/PrintStream;\n 242: iload_2\n 243: invokevirtual #93 // Method java/io/PrintStream.println:(I)V\n 246: return\n\n public static final int part1(java.util.List<day08.Tree>);\n Code:\n 0: aload_0\n 1: ldc #120 // String forest\n 3: invokestatic #126 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #16 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: instanceof #23 // class java/util/Collection\n 17: ifeq 36\n 20: aload_1\n 21: checkcast #23 // class java/util/Collection\n 24: invokeinterface #129, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 29: ifeq 36\n 32: iconst_0\n 33: goto 133\n 36: iconst_0\n 37: istore_3\n 38: aload_1\n 39: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 4\n 46: aload 4\n 48: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 132\n 56: aload 4\n 58: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 5\n 65: aload 5\n 67: checkcast #59 // class day08/Tree\n 70: astore 6\n 72: iconst_0\n 73: istore 7\n 75: aload 6\n 77: aload_0\n 78: invokevirtual #133 // Method day08/Tree.isVisibleFromLeft:(Ljava/util/List;)Z\n 81: ifne 111\n 84: aload 6\n 86: aload_0\n 87: invokevirtual #136 // Method day08/Tree.isVisibleFromRight:(Ljava/util/List;)Z\n 90: ifne 111\n 93: aload 6\n 95: aload_0\n 96: invokevirtual #139 // Method day08/Tree.isVisibleFromTop:(Ljava/util/List;)Z\n 99: ifne 111\n 102: aload 6\n 104: aload_0\n 105: invokevirtual #142 // Method day08/Tree.isVisibleFromBottom:(Ljava/util/List;)Z\n 108: ifeq 115\n 111: iconst_1\n 112: goto 116\n 115: iconst_0\n 116: ifeq 46\n 119: iinc 3, 1\n 122: iload_3\n 123: ifge 46\n 126: invokestatic #145 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 129: goto 46\n 132: iload_3\n 133: ireturn\n\n public static final int part2(java.util.List<day08.Tree>);\n Code:\n 0: aload_0\n 1: ldc #120 // String forest\n 3: invokestatic #126 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #16 // class java/lang/Iterable\n 10: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 15: astore_1\n 16: aload_1\n 17: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 22: ifne 33\n 25: new #156 // class java/util/NoSuchElementException\n 28: dup\n 29: invokespecial #157 // Method java/util/NoSuchElementException.\"<init>\":()V\n 32: athrow\n 33: aload_1\n 34: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 39: checkcast #59 // class day08/Tree\n 42: astore_2\n 43: iconst_0\n 44: istore_3\n 45: aload_2\n 46: aload_0\n 47: checkcast #16 // class java/lang/Iterable\n 50: astore 4\n 52: astore 5\n 54: iconst_0\n 55: istore 6\n 57: aload 4\n 59: bipush 10\n 61: invokestatic #161 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 64: invokestatic #167 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 67: bipush 16\n 69: invokestatic #173 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 72: istore 7\n 74: aload 4\n 76: astore 8\n 78: new #175 // class java/util/LinkedHashMap\n 81: dup\n 82: iload 7\n 84: invokespecial #176 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 87: checkcast #178 // class java/util/Map\n 90: astore 9\n 92: iconst_0\n 93: istore 10\n 95: aload 8\n 97: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 102: astore 11\n 104: aload 11\n 106: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 111: ifeq 168\n 114: aload 11\n 116: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 121: astore 12\n 123: aload 9\n 125: aload 12\n 127: checkcast #59 // class day08/Tree\n 130: astore 13\n 132: astore 14\n 134: iconst_0\n 135: istore 15\n 137: new #180 // class Point\n 140: dup\n 141: aload 13\n 143: invokevirtual #183 // Method day08/Tree.getX:()I\n 146: aload 13\n 148: invokevirtual #186 // Method day08/Tree.getY:()I\n 151: invokespecial #189 // Method Point.\"<init>\":(II)V\n 154: aload 14\n 156: swap\n 157: aload 12\n 159: invokeinterface #193, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 164: pop\n 165: goto 104\n 168: aload 9\n 170: nop\n 171: aload 5\n 173: swap\n 174: invokevirtual #197 // Method day08/Tree.scenicScore:(Ljava/util/Map;)I\n 177: istore_2\n 178: aload_1\n 179: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 184: ifeq 343\n 187: aload_1\n 188: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 193: checkcast #59 // class day08/Tree\n 196: astore_3\n 197: iconst_0\n 198: istore 4\n 200: aload_3\n 201: aload_0\n 202: checkcast #16 // class java/lang/Iterable\n 205: astore 5\n 207: astore 6\n 209: iconst_0\n 210: istore 7\n 212: aload 5\n 214: bipush 10\n 216: invokestatic #161 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 219: invokestatic #167 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 222: bipush 16\n 224: invokestatic #173 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 227: istore 8\n 229: aload 5\n 231: astore 9\n 233: new #175 // class java/util/LinkedHashMap\n 236: dup\n 237: iload 8\n 239: invokespecial #176 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 242: checkcast #178 // class java/util/Map\n 245: astore 10\n 247: iconst_0\n 248: istore 11\n 250: aload 9\n 252: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 257: astore 12\n 259: aload 12\n 261: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 266: ifeq 323\n 269: aload 12\n 271: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 276: astore 13\n 278: aload 10\n 280: aload 13\n 282: checkcast #59 // class day08/Tree\n 285: astore 14\n 287: astore 15\n 289: iconst_0\n 290: istore 16\n 292: new #180 // class Point\n 295: dup\n 296: aload 14\n 298: invokevirtual #183 // Method day08/Tree.getX:()I\n 301: aload 14\n 303: invokevirtual #186 // Method day08/Tree.getY:()I\n 306: invokespecial #189 // Method Point.\"<init>\":(II)V\n 309: aload 15\n 311: swap\n 312: aload 13\n 314: invokeinterface #193, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 319: pop\n 320: goto 259\n 323: aload 10\n 325: nop\n 326: aload 6\n 328: swap\n 329: invokevirtual #197 // Method day08/Tree.scenicScore:(Ljava/util/Map;)I\n 332: istore_3\n 333: iload_2\n 334: iload_3\n 335: if_icmpge 178\n 338: iload_3\n 339: istore_2\n 340: goto 178\n 343: iload_2\n 344: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #210 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day23/day23.kt
package day23 import Point import readInput private typealias Grove = Set<Point> var directionsToCheck = mutableListOf( Point::northernNeighbours, Point::southernNeighbours, Point::westernNeighbours, Point::easternNeighbours ) fun main() { val input = readInput("main/day23/Day23") println(year_2017.day23.part1(input)) println(year_2017.day23.part2(input)) } fun part1(input: List<String>): Int { return generateSequence(input.toGrove()) { step(it).second }.drop(10).first().let { tenth -> (1 + tenth.maxOf { it.x } - tenth.minOf { it.x }) * (1 + tenth.maxOf { it.y } - tenth.minOf { it.y }) - tenth.size } } fun part2(input: List<String>): Int { directionsToCheck = mutableListOf( Point::northernNeighbours, Point::southernNeighbours, Point::westernNeighbours, Point::easternNeighbours ) return generateSequence(emptySet<Point>() to input.toGrove()) { result -> step(result.second) }.takeWhile { it.first != it.second }.count() } private fun step(grove: Set<Point>): Pair<Grove, Grove> { val proposedSteps = grove.proposedSteps() directionsToCheck.add(directionsToCheck.removeFirst()) val stepsByElf = proposedSteps.associateBy { it.first } val possiblePositions = proposedSteps.associateTo(mutableMapOf()) { (_, next) -> next to proposedSteps.count { it.second == next } }.filter { it.value == 1 }.keys return grove to grove.map { elf -> if (possiblePositions.contains(stepsByElf[elf]?.second)) stepsByElf[elf]!!.second else elf }.toSet() } fun Grove.proposedSteps(): List<Pair<Point, Point>> { val proposedSteps = mutableListOf<Pair<Point, Point>>() forEach { elf -> if (elf.allNeighbours().any { this.contains(it) }) { val direction = directionsToCheck.firstOrNull { findNeighbours -> findNeighbours.invoke(elf).dropLast(1).none { this.contains(it) } } if (direction != null) { proposedSteps.add(elf to (elf + direction.invoke(elf).last())) } } } return proposedSteps } fun List<String>.toGrove() = flatMapIndexed { y, line -> line.mapIndexedNotNull { x, s -> if (s == '#') Point(x, y) else null } }.toSet() fun Point.northernNeighbours(): List<Point> { return listOf( Point(x - 1, y - 1), Point(x, y - 1), Point(x + 1, y - 1), Point(0, -1), ) } fun Point.southernNeighbours(): List<Point> { return listOf( Point(x - 1, y + 1), Point(x, y + 1), Point(x + 1, y + 1), Point(0, 1), ) } fun Point.easternNeighbours(): List<Point> { return listOf( Point(x + 1, y - 1), Point(x + 1, y), Point(x + 1, y + 1), Point(1, 0), ) } fun Point.westernNeighbours(): List<Point> { return listOf( Point(x - 1, y - 1), Point(x - 1, y), Point(x - 1, y + 1), Point(-1, 0), ) }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day23/Day23Kt$directionsToCheck$3.class", "javap": "Compiled from \"day23.kt\"\nfinal class day23.Day23Kt$directionsToCheck$3 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {\n public static final day23.Day23Kt$directionsToCheck$3 INSTANCE;\n\n day23.Day23Kt$directionsToCheck$3();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class day23/Day23Kt\n 4: ldc #13 // String westernNeighbours\n 6: ldc #15 // String westernNeighbours(LPoint;)Ljava/util/List;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final java.util.List<Point> invoke(Point);\n Code:\n 0: aload_1\n 1: ldc #25 // String p0\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method day23/Day23Kt.westernNeighbours:(LPoint;)Ljava/util/List;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class Point\n 5: invokevirtual #39 // Method invoke:(LPoint;)Ljava/util/List;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class day23/Day23Kt$directionsToCheck$3\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:Lday23/Day23Kt$directionsToCheck$3;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day23/Day23Kt$directionsToCheck$1.class", "javap": "Compiled from \"day23.kt\"\nfinal class day23.Day23Kt$directionsToCheck$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {\n public static final day23.Day23Kt$directionsToCheck$1 INSTANCE;\n\n day23.Day23Kt$directionsToCheck$1();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class day23/Day23Kt\n 4: ldc #13 // String northernNeighbours\n 6: ldc #15 // String northernNeighbours(LPoint;)Ljava/util/List;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final java.util.List<Point> invoke(Point);\n Code:\n 0: aload_1\n 1: ldc #25 // String p0\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method day23/Day23Kt.northernNeighbours:(LPoint;)Ljava/util/List;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class Point\n 5: invokevirtual #39 // Method invoke:(LPoint;)Ljava/util/List;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class day23/Day23Kt$directionsToCheck$1\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:Lday23/Day23Kt$directionsToCheck$1;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day23/Day23Kt$part2$4.class", "javap": "Compiled from \"day23.kt\"\nfinal class day23.Day23Kt$part2$4 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {\n public static final day23.Day23Kt$part2$4 INSTANCE;\n\n day23.Day23Kt$part2$4();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class day23/Day23Kt\n 4: ldc #13 // String easternNeighbours\n 6: ldc #15 // String easternNeighbours(LPoint;)Ljava/util/List;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final java.util.List<Point> invoke(Point);\n Code:\n 0: aload_1\n 1: ldc #25 // String p0\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method day23/Day23Kt.easternNeighbours:(LPoint;)Ljava/util/List;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class Point\n 5: invokevirtual #39 // Method invoke:(LPoint;)Ljava/util/List;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class day23/Day23Kt$part2$4\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:Lday23/Day23Kt$part2$4;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day23/Day23Kt.class", "javap": "Compiled from \"day23.kt\"\npublic final class day23.Day23Kt {\n private static java.util.List<kotlin.reflect.KFunction<java.util.List<Point>>> directionsToCheck;\n\n public static final java.util.List<kotlin.reflect.KFunction<java.util.List<Point>>> getDirectionsToCheck();\n Code:\n 0: getstatic #12 // Field directionsToCheck:Ljava/util/List;\n 3: areturn\n\n public static final void setDirectionsToCheck(java.util.List<kotlin.reflect.KFunction<java.util.List<Point>>>);\n Code:\n 0: aload_0\n 1: ldc #17 // String <set-?>\n 3: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: putstatic #12 // Field directionsToCheck:Ljava/util/List;\n 10: return\n\n public static final void main();\n Code:\n 0: ldc #27 // String main/day23/Day23\n 2: invokestatic #33 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #39 // Method year_2017/day23/Day23Kt.part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #51 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #54 // Method year_2017/day23/Day23Kt.part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #51 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #57 // String input\n 3: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #61 // Method toGrove:(Ljava/util/List;)Ljava/util/Set;\n 10: invokedynamic #80, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 15: invokestatic #86 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 18: bipush 10\n 20: invokestatic #90 // Method kotlin/sequences/SequencesKt.drop:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;\n 23: invokestatic #94 // Method kotlin/sequences/SequencesKt.first:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;\n 26: checkcast #96 // class java/util/Set\n 29: astore_1\n 30: iconst_0\n 31: istore_2\n 32: iconst_1\n 33: aload_1\n 34: checkcast #98 // class java/lang/Iterable\n 37: astore_3\n 38: istore 4\n 40: aload_3\n 41: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 46: astore 5\n 48: aload 5\n 50: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 55: ifne 66\n 58: new #110 // class java/util/NoSuchElementException\n 61: dup\n 62: invokespecial #113 // Method java/util/NoSuchElementException.\"<init>\":()V\n 65: athrow\n 66: aload 5\n 68: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 73: checkcast #119 // class Point\n 76: astore 6\n 78: iconst_0\n 79: istore 7\n 81: aload 6\n 83: invokevirtual #123 // Method Point.getX:()I\n 86: istore 6\n 88: aload 5\n 90: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 95: ifeq 134\n 98: aload 5\n 100: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 105: checkcast #119 // class Point\n 108: astore 7\n 110: iconst_0\n 111: istore 8\n 113: aload 7\n 115: invokevirtual #123 // Method Point.getX:()I\n 118: istore 7\n 120: iload 6\n 122: iload 7\n 124: if_icmpge 88\n 127: iload 7\n 129: istore 6\n 131: goto 88\n 134: iload 6\n 136: istore 9\n 138: iload 4\n 140: iload 9\n 142: iadd\n 143: aload_1\n 144: checkcast #98 // class java/lang/Iterable\n 147: astore_3\n 148: istore 4\n 150: aload_3\n 151: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 156: astore 5\n 158: aload 5\n 160: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 165: ifne 176\n 168: new #110 // class java/util/NoSuchElementException\n 171: dup\n 172: invokespecial #113 // Method java/util/NoSuchElementException.\"<init>\":()V\n 175: athrow\n 176: aload 5\n 178: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 183: checkcast #119 // class Point\n 186: astore 6\n 188: iconst_0\n 189: istore 7\n 191: aload 6\n 193: invokevirtual #123 // Method Point.getX:()I\n 196: istore 6\n 198: aload 5\n 200: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 205: ifeq 244\n 208: aload 5\n 210: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 215: checkcast #119 // class Point\n 218: astore 7\n 220: iconst_0\n 221: istore 8\n 223: aload 7\n 225: invokevirtual #123 // Method Point.getX:()I\n 228: istore 7\n 230: iload 6\n 232: iload 7\n 234: if_icmple 198\n 237: iload 7\n 239: istore 6\n 241: goto 198\n 244: iload 6\n 246: istore 9\n 248: iload 4\n 250: iload 9\n 252: isub\n 253: iconst_1\n 254: aload_1\n 255: checkcast #98 // class java/lang/Iterable\n 258: astore_3\n 259: istore 9\n 261: istore 4\n 263: aload_3\n 264: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 269: astore 5\n 271: aload 5\n 273: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 278: ifne 289\n 281: new #110 // class java/util/NoSuchElementException\n 284: dup\n 285: invokespecial #113 // Method java/util/NoSuchElementException.\"<init>\":()V\n 288: athrow\n 289: aload 5\n 291: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 296: checkcast #119 // class Point\n 299: astore 6\n 301: iconst_0\n 302: istore 7\n 304: aload 6\n 306: invokevirtual #126 // Method Point.getY:()I\n 309: istore 6\n 311: aload 5\n 313: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 318: ifeq 357\n 321: aload 5\n 323: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 328: checkcast #119 // class Point\n 331: astore 7\n 333: iconst_0\n 334: istore 8\n 336: aload 7\n 338: invokevirtual #126 // Method Point.getY:()I\n 341: istore 7\n 343: iload 6\n 345: iload 7\n 347: if_icmpge 311\n 350: iload 7\n 352: istore 6\n 354: goto 311\n 357: iload 6\n 359: istore 10\n 361: iload 4\n 363: iload 9\n 365: iload 10\n 367: iadd\n 368: aload_1\n 369: checkcast #98 // class java/lang/Iterable\n 372: astore_3\n 373: istore 9\n 375: istore 4\n 377: aload_3\n 378: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 383: astore 5\n 385: aload 5\n 387: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 392: ifne 403\n 395: new #110 // class java/util/NoSuchElementException\n 398: dup\n 399: invokespecial #113 // Method java/util/NoSuchElementException.\"<init>\":()V\n 402: athrow\n 403: aload 5\n 405: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 410: checkcast #119 // class Point\n 413: astore 6\n 415: iconst_0\n 416: istore 7\n 418: aload 6\n 420: invokevirtual #126 // Method Point.getY:()I\n 423: istore 6\n 425: aload 5\n 427: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 432: ifeq 471\n 435: aload 5\n 437: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 442: checkcast #119 // class Point\n 445: astore 7\n 447: iconst_0\n 448: istore 8\n 450: aload 7\n 452: invokevirtual #126 // Method Point.getY:()I\n 455: istore 7\n 457: iload 6\n 459: iload 7\n 461: if_icmple 425\n 464: iload 7\n 466: istore 6\n 468: goto 425\n 471: iload 6\n 473: istore 10\n 475: iload 4\n 477: iload 9\n 479: iload 10\n 481: isub\n 482: imul\n 483: aload_1\n 484: invokeinterface #129, 1 // InterfaceMethod java/util/Set.size:()I\n 489: isub\n 490: nop\n 491: nop\n 492: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #57 // String input\n 3: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_4\n 7: anewarray #143 // class kotlin/reflect/KFunction\n 10: astore_1\n 11: aload_1\n 12: iconst_0\n 13: getstatic #149 // Field day23/Day23Kt$part2$1.INSTANCE:Lday23/Day23Kt$part2$1;\n 16: aastore\n 17: aload_1\n 18: iconst_1\n 19: getstatic #154 // Field day23/Day23Kt$part2$2.INSTANCE:Lday23/Day23Kt$part2$2;\n 22: aastore\n 23: aload_1\n 24: iconst_2\n 25: getstatic #159 // Field day23/Day23Kt$part2$3.INSTANCE:Lday23/Day23Kt$part2$3;\n 28: aastore\n 29: aload_1\n 30: iconst_3\n 31: getstatic #164 // Field day23/Day23Kt$part2$4.INSTANCE:Lday23/Day23Kt$part2$4;\n 34: aastore\n 35: aload_1\n 36: invokestatic #170 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 39: putstatic #12 // Field directionsToCheck:Ljava/util/List;\n 42: invokestatic #176 // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;\n 45: aload_0\n 46: invokestatic #61 // Method toGrove:(Ljava/util/List;)Ljava/util/Set;\n 49: invokestatic #182 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 52: invokedynamic #189, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 57: invokestatic #86 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 60: invokedynamic #197, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;\n 65: invokestatic #201 // Method kotlin/sequences/SequencesKt.takeWhile:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 68: invokestatic #205 // Method kotlin/sequences/SequencesKt.count:(Lkotlin/sequences/Sequence;)I\n 71: ireturn\n\n private static final kotlin.Pair<java.util.Set<Point>, java.util.Set<Point>> step(java.util.Set<Point>);\n Code:\n 0: aload_0\n 1: invokestatic #212 // Method proposedSteps:(Ljava/util/Set;)Ljava/util/List;\n 4: astore_1\n 5: getstatic #12 // Field directionsToCheck:Ljava/util/List;\n 8: getstatic #12 // Field directionsToCheck:Ljava/util/List;\n 11: invokeinterface #215, 1 // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;\n 16: dup\n 17: ldc #217 // String removeFirst(...)\n 19: invokestatic #220 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 22: invokeinterface #224, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 27: pop\n 28: aload_1\n 29: checkcast #98 // class java/lang/Iterable\n 32: astore_3\n 33: iconst_0\n 34: istore 4\n 36: aload_3\n 37: bipush 10\n 39: invokestatic #228 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 42: invokestatic #234 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 45: bipush 16\n 47: invokestatic #240 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 50: istore 5\n 52: aload_3\n 53: astore 6\n 55: new #242 // class java/util/LinkedHashMap\n 58: dup\n 59: iload 5\n 61: invokespecial #244 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 64: checkcast #246 // class java/util/Map\n 67: astore 7\n 69: iconst_0\n 70: istore 8\n 72: aload 6\n 74: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 79: astore 9\n 81: aload 9\n 83: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 88: ifeq 136\n 91: aload 9\n 93: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 98: astore 10\n 100: aload 7\n 102: aload 10\n 104: checkcast #248 // class kotlin/Pair\n 107: astore 11\n 109: astore 22\n 111: iconst_0\n 112: istore 12\n 114: aload 11\n 116: invokevirtual #251 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 119: checkcast #119 // class Point\n 122: aload 22\n 124: swap\n 125: aload 10\n 127: invokeinterface #255, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 132: pop\n 133: goto 81\n 136: aload 7\n 138: nop\n 139: astore_2\n 140: aload_1\n 141: checkcast #98 // class java/lang/Iterable\n 144: astore 4\n 146: new #242 // class java/util/LinkedHashMap\n 149: dup\n 150: invokespecial #256 // Method java/util/LinkedHashMap.\"<init>\":()V\n 153: checkcast #246 // class java/util/Map\n 156: astore 5\n 158: nop\n 159: iconst_0\n 160: istore 6\n 162: aload 4\n 164: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 169: astore 7\n 171: aload 7\n 173: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 178: ifeq 357\n 181: aload 7\n 183: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 188: astore 8\n 190: aload 5\n 192: astore 9\n 194: aload 8\n 196: checkcast #248 // class kotlin/Pair\n 199: astore 10\n 201: iconst_0\n 202: istore 11\n 204: aload 10\n 206: invokevirtual #259 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 209: checkcast #119 // class Point\n 212: astore 12\n 214: aload 12\n 216: aload_1\n 217: checkcast #98 // class java/lang/Iterable\n 220: astore 13\n 222: astore 14\n 224: iconst_0\n 225: istore 15\n 227: aload 13\n 229: instanceof #261 // class java/util/Collection\n 232: ifeq 252\n 235: aload 13\n 237: checkcast #261 // class java/util/Collection\n 240: invokeinterface #264, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 245: ifeq 252\n 248: iconst_0\n 249: goto 322\n 252: iconst_0\n 253: istore 16\n 255: aload 13\n 257: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 262: astore 17\n 264: aload 17\n 266: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 271: ifeq 320\n 274: aload 17\n 276: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 281: astore 18\n 283: aload 18\n 285: checkcast #248 // class kotlin/Pair\n 288: astore 19\n 290: iconst_0\n 291: istore 20\n 293: aload 19\n 295: invokevirtual #267 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 298: aload 12\n 300: invokestatic #271 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 303: ifeq 264\n 306: iinc 16, 1\n 309: iload 16\n 311: ifge 264\n 314: invokestatic #274 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 317: goto 264\n 320: iload 16\n 322: istore 21\n 324: aload 14\n 326: iload 21\n 328: invokestatic #280 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 331: invokestatic #182 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 334: astore 10\n 336: aload 9\n 338: aload 10\n 340: invokevirtual #251 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 343: aload 10\n 345: invokevirtual #267 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 348: invokeinterface #255, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 353: pop\n 354: goto 171\n 357: aload 5\n 359: astore 4\n 361: nop\n 362: iconst_0\n 363: istore 5\n 365: aload 4\n 367: astore 6\n 369: new #242 // class java/util/LinkedHashMap\n 372: dup\n 373: invokespecial #256 // Method java/util/LinkedHashMap.\"<init>\":()V\n 376: checkcast #246 // class java/util/Map\n 379: astore 7\n 381: iconst_0\n 382: istore 8\n 384: aload 6\n 386: invokeinterface #283, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 391: invokeinterface #284, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 396: astore 9\n 398: aload 9\n 400: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 405: ifeq 477\n 408: aload 9\n 410: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 415: checkcast #286 // class java/util/Map$Entry\n 418: astore 10\n 420: aload 10\n 422: astore 11\n 424: iconst_0\n 425: istore 12\n 427: aload 11\n 429: invokeinterface #289, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 434: checkcast #291 // class java/lang/Number\n 437: invokevirtual #294 // Method java/lang/Number.intValue:()I\n 440: iconst_1\n 441: if_icmpne 448\n 444: iconst_1\n 445: goto 449\n 448: iconst_0\n 449: ifeq 398\n 452: aload 7\n 454: aload 10\n 456: invokeinterface #297, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 461: aload 10\n 463: invokeinterface #289, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 468: invokeinterface #255, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 473: pop\n 474: goto 398\n 477: aload 7\n 479: nop\n 480: invokeinterface #300, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 485: astore_3\n 486: aload_0\n 487: aload_0\n 488: checkcast #98 // class java/lang/Iterable\n 491: astore 4\n 493: astore 22\n 495: iconst_0\n 496: istore 5\n 498: aload 4\n 500: astore 6\n 502: new #302 // class java/util/ArrayList\n 505: dup\n 506: aload 4\n 508: bipush 10\n 510: invokestatic #228 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 513: invokespecial #303 // Method java/util/ArrayList.\"<init>\":(I)V\n 516: checkcast #261 // class java/util/Collection\n 519: astore 7\n 521: iconst_0\n 522: istore 8\n 524: aload 6\n 526: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 531: astore 9\n 533: aload 9\n 535: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 540: ifeq 640\n 543: aload 9\n 545: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 550: astore 10\n 552: aload 7\n 554: aload 10\n 556: checkcast #119 // class Point\n 559: astore 11\n 561: astore 23\n 563: iconst_0\n 564: istore 12\n 566: aload_3\n 567: checkcast #98 // class java/lang/Iterable\n 570: aload_2\n 571: aload 11\n 573: invokeinterface #306, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 578: checkcast #248 // class kotlin/Pair\n 581: dup\n 582: ifnull 594\n 585: invokevirtual #267 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 588: checkcast #119 // class Point\n 591: goto 596\n 594: pop\n 595: aconst_null\n 596: invokestatic #310 // Method kotlin/collections/CollectionsKt.contains:(Ljava/lang/Iterable;Ljava/lang/Object;)Z\n 599: ifeq 626\n 602: aload_2\n 603: aload 11\n 605: invokeinterface #306, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 610: dup\n 611: invokestatic #314 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 614: checkcast #248 // class kotlin/Pair\n 617: invokevirtual #267 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 620: checkcast #119 // class Point\n 623: goto 628\n 626: aload 11\n 628: aload 23\n 630: swap\n 631: invokeinterface #315, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 636: pop\n 637: goto 533\n 640: aload 7\n 642: checkcast #141 // class java/util/List\n 645: nop\n 646: aload 22\n 648: swap\n 649: checkcast #98 // class java/lang/Iterable\n 652: invokestatic #319 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 655: invokestatic #182 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 658: areturn\n\n public static final java.util.List<kotlin.Pair<Point, Point>> proposedSteps(java.util.Set<Point>);\n Code:\n 0: aload_0\n 1: ldc_w #360 // String <this>\n 4: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: new #302 // class java/util/ArrayList\n 10: dup\n 11: invokespecial #361 // Method java/util/ArrayList.\"<init>\":()V\n 14: checkcast #141 // class java/util/List\n 17: astore_1\n 18: aload_0\n 19: checkcast #98 // class java/lang/Iterable\n 22: astore_2\n 23: iconst_0\n 24: istore_3\n 25: aload_2\n 26: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 31: astore 4\n 33: aload 4\n 35: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 40: ifeq 375\n 43: aload 4\n 45: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 50: astore 5\n 52: aload 5\n 54: checkcast #119 // class Point\n 57: astore 6\n 59: iconst_0\n 60: istore 7\n 62: aload 6\n 64: invokevirtual #364 // Method Point.allNeighbours:()Ljava/util/Set;\n 67: checkcast #98 // class java/lang/Iterable\n 70: astore 8\n 72: iconst_0\n 73: istore 9\n 75: aload 8\n 77: instanceof #261 // class java/util/Collection\n 80: ifeq 100\n 83: aload 8\n 85: checkcast #261 // class java/util/Collection\n 88: invokeinterface #264, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 93: ifeq 100\n 96: iconst_0\n 97: goto 154\n 100: aload 8\n 102: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 107: astore 10\n 109: aload 10\n 111: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 116: ifeq 153\n 119: aload 10\n 121: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 126: astore 11\n 128: aload 11\n 130: checkcast #119 // class Point\n 133: astore 12\n 135: iconst_0\n 136: istore 13\n 138: aload_0\n 139: aload 12\n 141: invokeinterface #366, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 146: ifeq 109\n 149: iconst_1\n 150: goto 154\n 153: iconst_0\n 154: ifeq 370\n 157: getstatic #12 // Field directionsToCheck:Ljava/util/List;\n 160: checkcast #98 // class java/lang/Iterable\n 163: astore 9\n 165: iconst_0\n 166: istore 10\n 168: aload 9\n 170: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 175: astore 11\n 177: aload 11\n 179: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 184: ifeq 321\n 187: aload 11\n 189: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 194: astore 12\n 196: aload 12\n 198: checkcast #143 // class kotlin/reflect/KFunction\n 201: astore 13\n 203: iconst_0\n 204: istore 14\n 206: aload 13\n 208: checkcast #368 // class kotlin/jvm/functions/Function1\n 211: aload 6\n 213: invokeinterface #370, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 218: checkcast #141 // class java/util/List\n 221: iconst_1\n 222: invokestatic #374 // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;\n 225: checkcast #98 // class java/lang/Iterable\n 228: astore 15\n 230: iconst_0\n 231: istore 16\n 233: aload 15\n 235: instanceof #261 // class java/util/Collection\n 238: ifeq 258\n 241: aload 15\n 243: checkcast #261 // class java/util/Collection\n 246: invokeinterface #264, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 251: ifeq 258\n 254: iconst_1\n 255: goto 312\n 258: aload 15\n 260: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 265: astore 17\n 267: aload 17\n 269: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 274: ifeq 311\n 277: aload 17\n 279: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 284: astore 18\n 286: aload 18\n 288: checkcast #119 // class Point\n 291: astore 19\n 293: iconst_0\n 294: istore 20\n 296: aload_0\n 297: aload 19\n 299: invokeinterface #366, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 304: ifeq 267\n 307: iconst_0\n 308: goto 312\n 311: iconst_1\n 312: nop\n 313: ifeq 177\n 316: aload 12\n 318: goto 322\n 321: aconst_null\n 322: checkcast #143 // class kotlin/reflect/KFunction\n 325: astore 8\n 327: aload 8\n 329: ifnull 370\n 332: aload_1\n 333: aload 6\n 335: aload 6\n 337: aload 8\n 339: checkcast #368 // class kotlin/jvm/functions/Function1\n 342: aload 6\n 344: invokeinterface #370, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 349: checkcast #141 // class java/util/List\n 352: invokestatic #378 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 355: checkcast #119 // class Point\n 358: invokevirtual #382 // Method Point.plus:(LPoint;)LPoint;\n 361: invokestatic #182 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 364: invokeinterface #224, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 369: pop\n 370: nop\n 371: nop\n 372: goto 33\n 375: nop\n 376: aload_1\n 377: areturn\n\n public static final java.util.Set<Point> toGrove(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc_w #360 // String <this>\n 4: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: checkcast #98 // class java/lang/Iterable\n 11: astore_1\n 12: new #302 // class java/util/ArrayList\n 15: dup\n 16: invokespecial #361 // Method java/util/ArrayList.\"<init>\":()V\n 19: checkcast #261 // class java/util/Collection\n 22: astore_2\n 23: iconst_0\n 24: istore_3\n 25: aload_1\n 26: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 31: astore 4\n 33: aload 4\n 35: invokeinterface #108, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 40: ifeq 242\n 43: aload 4\n 45: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 50: astore 5\n 52: iload_3\n 53: iinc 3, 1\n 56: istore 6\n 58: iload 6\n 60: ifge 66\n 63: invokestatic #402 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 66: iload 6\n 68: aload 5\n 70: checkcast #404 // class java/lang/String\n 73: astore 7\n 75: istore 8\n 77: iconst_0\n 78: istore 9\n 80: aload 7\n 82: checkcast #406 // class java/lang/CharSequence\n 85: astore 10\n 87: iconst_0\n 88: istore 11\n 90: aload 10\n 92: astore 12\n 94: new #302 // class java/util/ArrayList\n 97: dup\n 98: invokespecial #361 // Method java/util/ArrayList.\"<init>\":()V\n 101: checkcast #261 // class java/util/Collection\n 104: astore 13\n 106: iconst_0\n 107: istore 14\n 109: aload 12\n 111: astore 15\n 113: iconst_0\n 114: istore 16\n 116: iconst_0\n 117: istore 17\n 119: iconst_0\n 120: istore 18\n 122: iload 18\n 124: aload 15\n 126: invokeinterface #409, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 131: if_icmpge 222\n 134: aload 15\n 136: iload 18\n 138: invokeinterface #413, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 143: istore 19\n 145: iload 17\n 147: iinc 17, 1\n 150: iload 19\n 152: istore 20\n 154: istore 21\n 156: iconst_0\n 157: istore 22\n 159: iload 21\n 161: iload 20\n 163: istore 23\n 165: istore 24\n 167: iconst_0\n 168: istore 25\n 170: iload 23\n 172: bipush 35\n 174: if_icmpne 191\n 177: new #119 // class Point\n 180: dup\n 181: iload 24\n 183: iload 8\n 185: invokespecial #416 // Method Point.\"<init>\":(II)V\n 188: goto 192\n 191: aconst_null\n 192: dup\n 193: ifnull 214\n 196: astore 26\n 198: iconst_0\n 199: istore 27\n 201: aload 13\n 203: aload 26\n 205: invokeinterface #315, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 210: pop\n 211: goto 215\n 214: pop\n 215: nop\n 216: iinc 18, 1\n 219: goto 122\n 222: nop\n 223: aload 13\n 225: checkcast #141 // class java/util/List\n 228: nop\n 229: checkcast #98 // class java/lang/Iterable\n 232: nop\n 233: aload_2\n 234: swap\n 235: invokestatic #420 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 238: pop\n 239: goto 33\n 242: aload_2\n 243: checkcast #141 // class java/util/List\n 246: checkcast #98 // class java/lang/Iterable\n 249: invokestatic #319 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 252: areturn\n\n public static final java.util.List<Point> northernNeighbours(Point);\n Code:\n 0: aload_0\n 1: ldc_w #360 // String <this>\n 4: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: iconst_4\n 8: anewarray #119 // class Point\n 11: astore_1\n 12: aload_1\n 13: iconst_0\n 14: new #119 // class Point\n 17: dup\n 18: aload_0\n 19: invokevirtual #123 // Method Point.getX:()I\n 22: iconst_1\n 23: isub\n 24: aload_0\n 25: invokevirtual #126 // Method Point.getY:()I\n 28: iconst_1\n 29: isub\n 30: invokespecial #416 // Method Point.\"<init>\":(II)V\n 33: aastore\n 34: aload_1\n 35: iconst_1\n 36: new #119 // class Point\n 39: dup\n 40: aload_0\n 41: invokevirtual #123 // Method Point.getX:()I\n 44: aload_0\n 45: invokevirtual #126 // Method Point.getY:()I\n 48: iconst_1\n 49: isub\n 50: invokespecial #416 // Method Point.\"<init>\":(II)V\n 53: aastore\n 54: aload_1\n 55: iconst_2\n 56: new #119 // class Point\n 59: dup\n 60: aload_0\n 61: invokevirtual #123 // Method Point.getX:()I\n 64: iconst_1\n 65: iadd\n 66: aload_0\n 67: invokevirtual #126 // Method Point.getY:()I\n 70: iconst_1\n 71: isub\n 72: invokespecial #416 // Method Point.\"<init>\":(II)V\n 75: aastore\n 76: aload_1\n 77: iconst_3\n 78: new #119 // class Point\n 81: dup\n 82: iconst_0\n 83: iconst_m1\n 84: invokespecial #416 // Method Point.\"<init>\":(II)V\n 87: aastore\n 88: aload_1\n 89: invokestatic #448 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 92: areturn\n\n public static final java.util.List<Point> southernNeighbours(Point);\n Code:\n 0: aload_0\n 1: ldc_w #360 // String <this>\n 4: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: iconst_4\n 8: anewarray #119 // class Point\n 11: astore_1\n 12: aload_1\n 13: iconst_0\n 14: new #119 // class Point\n 17: dup\n 18: aload_0\n 19: invokevirtual #123 // Method Point.getX:()I\n 22: iconst_1\n 23: isub\n 24: aload_0\n 25: invokevirtual #126 // Method Point.getY:()I\n 28: iconst_1\n 29: iadd\n 30: invokespecial #416 // Method Point.\"<init>\":(II)V\n 33: aastore\n 34: aload_1\n 35: iconst_1\n 36: new #119 // class Point\n 39: dup\n 40: aload_0\n 41: invokevirtual #123 // Method Point.getX:()I\n 44: aload_0\n 45: invokevirtual #126 // Method Point.getY:()I\n 48: iconst_1\n 49: iadd\n 50: invokespecial #416 // Method Point.\"<init>\":(II)V\n 53: aastore\n 54: aload_1\n 55: iconst_2\n 56: new #119 // class Point\n 59: dup\n 60: aload_0\n 61: invokevirtual #123 // Method Point.getX:()I\n 64: iconst_1\n 65: iadd\n 66: aload_0\n 67: invokevirtual #126 // Method Point.getY:()I\n 70: iconst_1\n 71: iadd\n 72: invokespecial #416 // Method Point.\"<init>\":(II)V\n 75: aastore\n 76: aload_1\n 77: iconst_3\n 78: new #119 // class Point\n 81: dup\n 82: iconst_0\n 83: iconst_1\n 84: invokespecial #416 // Method Point.\"<init>\":(II)V\n 87: aastore\n 88: aload_1\n 89: invokestatic #448 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 92: areturn\n\n public static final java.util.List<Point> easternNeighbours(Point);\n Code:\n 0: aload_0\n 1: ldc_w #360 // String <this>\n 4: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: iconst_4\n 8: anewarray #119 // class Point\n 11: astore_1\n 12: aload_1\n 13: iconst_0\n 14: new #119 // class Point\n 17: dup\n 18: aload_0\n 19: invokevirtual #123 // Method Point.getX:()I\n 22: iconst_1\n 23: iadd\n 24: aload_0\n 25: invokevirtual #126 // Method Point.getY:()I\n 28: iconst_1\n 29: isub\n 30: invokespecial #416 // Method Point.\"<init>\":(II)V\n 33: aastore\n 34: aload_1\n 35: iconst_1\n 36: new #119 // class Point\n 39: dup\n 40: aload_0\n 41: invokevirtual #123 // Method Point.getX:()I\n 44: iconst_1\n 45: iadd\n 46: aload_0\n 47: invokevirtual #126 // Method Point.getY:()I\n 50: invokespecial #416 // Method Point.\"<init>\":(II)V\n 53: aastore\n 54: aload_1\n 55: iconst_2\n 56: new #119 // class Point\n 59: dup\n 60: aload_0\n 61: invokevirtual #123 // Method Point.getX:()I\n 64: iconst_1\n 65: iadd\n 66: aload_0\n 67: invokevirtual #126 // Method Point.getY:()I\n 70: iconst_1\n 71: iadd\n 72: invokespecial #416 // Method Point.\"<init>\":(II)V\n 75: aastore\n 76: aload_1\n 77: iconst_3\n 78: new #119 // class Point\n 81: dup\n 82: iconst_1\n 83: iconst_0\n 84: invokespecial #416 // Method Point.\"<init>\":(II)V\n 87: aastore\n 88: aload_1\n 89: invokestatic #448 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 92: areturn\n\n public static final java.util.List<Point> westernNeighbours(Point);\n Code:\n 0: aload_0\n 1: ldc_w #360 // String <this>\n 4: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: iconst_4\n 8: anewarray #119 // class Point\n 11: astore_1\n 12: aload_1\n 13: iconst_0\n 14: new #119 // class Point\n 17: dup\n 18: aload_0\n 19: invokevirtual #123 // Method Point.getX:()I\n 22: iconst_1\n 23: isub\n 24: aload_0\n 25: invokevirtual #126 // Method Point.getY:()I\n 28: iconst_1\n 29: isub\n 30: invokespecial #416 // Method Point.\"<init>\":(II)V\n 33: aastore\n 34: aload_1\n 35: iconst_1\n 36: new #119 // class Point\n 39: dup\n 40: aload_0\n 41: invokevirtual #123 // Method Point.getX:()I\n 44: iconst_1\n 45: isub\n 46: aload_0\n 47: invokevirtual #126 // Method Point.getY:()I\n 50: invokespecial #416 // Method Point.\"<init>\":(II)V\n 53: aastore\n 54: aload_1\n 55: iconst_2\n 56: new #119 // class Point\n 59: dup\n 60: aload_0\n 61: invokevirtual #123 // Method Point.getX:()I\n 64: iconst_1\n 65: isub\n 66: aload_0\n 67: invokevirtual #126 // Method Point.getY:()I\n 70: iconst_1\n 71: iadd\n 72: invokespecial #416 // Method Point.\"<init>\":(II)V\n 75: aastore\n 76: aload_1\n 77: iconst_3\n 78: new #119 // class Point\n 81: dup\n 82: iconst_m1\n 83: iconst_0\n 84: invokespecial #416 // Method Point.\"<init>\":(II)V\n 87: aastore\n 88: aload_1\n 89: invokestatic #448 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 92: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #458 // Method main:()V\n 3: return\n\n private static final java.util.Set part1$lambda$0(java.util.Set);\n Code:\n 0: aload_0\n 1: ldc_w #461 // String it\n 4: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokestatic #463 // Method step:(Ljava/util/Set;)Lkotlin/Pair;\n 11: invokevirtual #267 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 14: checkcast #96 // class java/util/Set\n 17: areturn\n\n private static final kotlin.Pair part2$lambda$6(kotlin.Pair);\n Code:\n 0: aload_0\n 1: ldc_w #465 // String result\n 4: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokevirtual #267 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 11: checkcast #96 // class java/util/Set\n 14: invokestatic #463 // Method step:(Ljava/util/Set;)Lkotlin/Pair;\n 17: areturn\n\n private static final boolean part2$lambda$7(kotlin.Pair);\n Code:\n 0: aload_0\n 1: ldc_w #461 // String it\n 4: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokevirtual #251 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 11: aload_0\n 12: invokevirtual #267 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 15: invokestatic #271 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 18: ifne 25\n 21: iconst_1\n 22: goto 26\n 25: iconst_0\n 26: ireturn\n\n static {};\n Code:\n 0: iconst_4\n 1: anewarray #143 // class kotlin/reflect/KFunction\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: getstatic #471 // Field day23/Day23Kt$directionsToCheck$1.INSTANCE:Lday23/Day23Kt$directionsToCheck$1;\n 10: aastore\n 11: aload_0\n 12: iconst_1\n 13: getstatic #476 // Field day23/Day23Kt$directionsToCheck$2.INSTANCE:Lday23/Day23Kt$directionsToCheck$2;\n 16: aastore\n 17: aload_0\n 18: iconst_2\n 19: getstatic #481 // Field day23/Day23Kt$directionsToCheck$3.INSTANCE:Lday23/Day23Kt$directionsToCheck$3;\n 22: aastore\n 23: aload_0\n 24: iconst_3\n 25: getstatic #486 // Field day23/Day23Kt$directionsToCheck$4.INSTANCE:Lday23/Day23Kt$directionsToCheck$4;\n 28: aastore\n 29: aload_0\n 30: invokestatic #170 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 33: putstatic #12 // Field directionsToCheck:Ljava/util/List;\n 36: return\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day23/Day23Kt$part2$2.class", "javap": "Compiled from \"day23.kt\"\nfinal class day23.Day23Kt$part2$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {\n public static final day23.Day23Kt$part2$2 INSTANCE;\n\n day23.Day23Kt$part2$2();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class day23/Day23Kt\n 4: ldc #13 // String southernNeighbours\n 6: ldc #15 // String southernNeighbours(LPoint;)Ljava/util/List;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final java.util.List<Point> invoke(Point);\n Code:\n 0: aload_1\n 1: ldc #25 // String p0\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method day23/Day23Kt.southernNeighbours:(LPoint;)Ljava/util/List;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class Point\n 5: invokevirtual #39 // Method invoke:(LPoint;)Ljava/util/List;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class day23/Day23Kt$part2$2\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:Lday23/Day23Kt$part2$2;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day23/Day23Kt$directionsToCheck$2.class", "javap": "Compiled from \"day23.kt\"\nfinal class day23.Day23Kt$directionsToCheck$2 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {\n public static final day23.Day23Kt$directionsToCheck$2 INSTANCE;\n\n day23.Day23Kt$directionsToCheck$2();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class day23/Day23Kt\n 4: ldc #13 // String southernNeighbours\n 6: ldc #15 // String southernNeighbours(LPoint;)Ljava/util/List;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final java.util.List<Point> invoke(Point);\n Code:\n 0: aload_1\n 1: ldc #25 // String p0\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method day23/Day23Kt.southernNeighbours:(LPoint;)Ljava/util/List;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class Point\n 5: invokevirtual #39 // Method invoke:(LPoint;)Ljava/util/List;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class day23/Day23Kt$directionsToCheck$2\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:Lday23/Day23Kt$directionsToCheck$2;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day23/Day23Kt$part2$3.class", "javap": "Compiled from \"day23.kt\"\nfinal class day23.Day23Kt$part2$3 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {\n public static final day23.Day23Kt$part2$3 INSTANCE;\n\n day23.Day23Kt$part2$3();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class day23/Day23Kt\n 4: ldc #13 // String westernNeighbours\n 6: ldc #15 // String westernNeighbours(LPoint;)Ljava/util/List;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final java.util.List<Point> invoke(Point);\n Code:\n 0: aload_1\n 1: ldc #25 // String p0\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method day23/Day23Kt.westernNeighbours:(LPoint;)Ljava/util/List;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class Point\n 5: invokevirtual #39 // Method invoke:(LPoint;)Ljava/util/List;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class day23/Day23Kt$part2$3\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:Lday23/Day23Kt$part2$3;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day23/Day23Kt$part2$1.class", "javap": "Compiled from \"day23.kt\"\nfinal class day23.Day23Kt$part2$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {\n public static final day23.Day23Kt$part2$1 INSTANCE;\n\n day23.Day23Kt$part2$1();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class day23/Day23Kt\n 4: ldc #13 // String northernNeighbours\n 6: ldc #15 // String northernNeighbours(LPoint;)Ljava/util/List;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final java.util.List<Point> invoke(Point);\n Code:\n 0: aload_1\n 1: ldc #25 // String p0\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method day23/Day23Kt.northernNeighbours:(LPoint;)Ljava/util/List;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class Point\n 5: invokevirtual #39 // Method invoke:(LPoint;)Ljava/util/List;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class day23/Day23Kt$part2$1\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:Lday23/Day23Kt$part2$1;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day23/Day23Kt$directionsToCheck$4.class", "javap": "Compiled from \"day23.kt\"\nfinal class day23.Day23Kt$directionsToCheck$4 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<Point, java.util.List<? extends Point>> {\n public static final day23.Day23Kt$directionsToCheck$4 INSTANCE;\n\n day23.Day23Kt$directionsToCheck$4();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class day23/Day23Kt\n 4: ldc #13 // String easternNeighbours\n 6: ldc #15 // String easternNeighbours(LPoint;)Ljava/util/List;\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final java.util.List<Point> invoke(Point);\n Code:\n 0: aload_1\n 1: ldc #25 // String p0\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #33 // Method day23/Day23Kt.easternNeighbours:(LPoint;)Ljava/util/List;\n 10: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #37 // class Point\n 5: invokevirtual #39 // Method invoke:(LPoint;)Ljava/util/List;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class day23/Day23Kt$directionsToCheck$4\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:Lday23/Day23Kt$directionsToCheck$4;\n 10: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day24/day24.kt
package day24 import Point import day24.Blizzard.DOWN import day24.Blizzard.LEFT import day24.Blizzard.RIGHT import day24.Blizzard.UP import day24.Blizzard.WALL import readInput typealias Valley = Map<Point, List<Blizzard>> private val initialValley = readInput("main/day24/Day24").toValley() private val maxX = initialValley.keys.maxOf { it.x } private val minX = initialValley.keys.minOf { it.x } private val maxY = initialValley.keys.maxOf { it.y } private val minY = initialValley.keys.minOf { it.y } private val start = initialValley.filter { it.key.y == minY }.keys.first { initialValley[it]!!.isEmpty() } private val exit = initialValley.filter { it.key.y == maxY }.keys.first { initialValley[it]!!.isEmpty() } private val walls = initialValley.filter { it.value.firstOrNull() == WALL } private val valleySequence = generateSequence(initialValley) { it.step() }.take(1000).toList() fun main() { println(part1()) println(part2()) } fun part1(): Int { return findPath() } fun part2(): Int { val toGoal = findPath() val backToStart = findPath(entry = exit, currentStep = toGoal, goal = start) return findPath(currentStep = backToStart) } fun findPath(entry: Point = start, currentStep: Int = 0, goal: Point = exit): Int { val pathsToCheck = mutableListOf(State(entry, currentStep)) val checked = mutableSetOf<State>() while (pathsToCheck.isNotEmpty()) { val current = pathsToCheck.removeFirst() if (current !in checked) { val nextValley = valleySequence[current.step + 1] val neighbours = validNeighboursFor(current.point).filter { nextValley.isOpenAt(it) } if (goal in neighbours) return current.step + 1 checked += current neighbours.forEach { pathsToCheck.add(State(it, current.step + 1)) } } } error("lost in the vally of blizzards") } fun List<String>.toValley(): Valley { val valley = mutableMapOf<Point, List<Blizzard>>() mapIndexed { y, line -> line.mapIndexed { x, c -> val p = Point(x, y) when (c) { '^' -> valley[p] = listOf(UP) 'v' -> valley[p] = listOf(DOWN) '<' -> valley[p] = listOf(LEFT) '>' -> valley[p] = listOf(RIGHT) '#' -> valley[p] = listOf(WALL) else -> valley[p] = emptyList() } } } return valley } fun validNeighboursFor(p: Point) = p.neighbours(true) .filterNot { it in walls } .filter { it.x in (minX..maxX) } .filter { it.y in (minY..maxY) } fun Valley.isOpenAt(p: Point): Boolean = this[p].isNullOrEmpty() fun Valley.step(): Valley = mutableMapOf<Point, MutableList<Blizzard>>( // start and goal must always be in the map start to mutableListOf(), exit to mutableListOf() ).let { result -> (minX..maxX).forEach { x -> (minY..maxY).forEach { y -> val here = Point(x, y) val blizzards = this[here] if (!blizzards.isNullOrEmpty()) { blizzards.forEach { blizzard -> var newLocation = here + blizzard.offset if (newLocation in walls) { newLocation = when (blizzard) { LEFT -> Point(maxX - 1, y) RIGHT -> Point(minX + 1, y) UP -> Point(x, maxY - 1) DOWN -> Point(x, minY + 1) WALL -> Point(x, y) // walls do not move } } if (result[newLocation] == null) result[newLocation] = mutableListOf(blizzard) else result[newLocation]!!.add(blizzard) } } } } result } enum class Blizzard(val offset: Point) { LEFT(Point(-1, 0)), RIGHT(Point(1, 0)), UP(Point(0, -1)), DOWN(Point(0, 1)), WALL(Point(0, 0)), } data class State(val point: Point, val step: Int)
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day24/Day24Kt$WhenMappings.class", "javap": "Compiled from \"day24.kt\"\npublic final class day24.Day24Kt$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method day24/Blizzard.values:()[Lday24/Blizzard;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field day24/Blizzard.LEFT:Lday24/Blizzard;\n 12: invokevirtual #22 // Method day24/Blizzard.ordinal:()I\n 15: iconst_1\n 16: iastore\n 17: goto 21\n 20: astore_1\n 21: nop\n 22: aload_0\n 23: getstatic #25 // Field day24/Blizzard.RIGHT:Lday24/Blizzard;\n 26: invokevirtual #22 // Method day24/Blizzard.ordinal:()I\n 29: iconst_2\n 30: iastore\n 31: goto 35\n 34: astore_1\n 35: nop\n 36: aload_0\n 37: getstatic #28 // Field day24/Blizzard.UP:Lday24/Blizzard;\n 40: invokevirtual #22 // Method day24/Blizzard.ordinal:()I\n 43: iconst_3\n 44: iastore\n 45: goto 49\n 48: astore_1\n 49: nop\n 50: aload_0\n 51: getstatic #31 // Field day24/Blizzard.DOWN:Lday24/Blizzard;\n 54: invokevirtual #22 // Method day24/Blizzard.ordinal:()I\n 57: iconst_4\n 58: iastore\n 59: goto 63\n 62: astore_1\n 63: nop\n 64: aload_0\n 65: getstatic #34 // Field day24/Blizzard.WALL:Lday24/Blizzard;\n 68: invokevirtual #22 // Method day24/Blizzard.ordinal:()I\n 71: iconst_5\n 72: iastore\n 73: goto 77\n 76: astore_1\n 77: aload_0\n 78: putstatic #38 // Field $EnumSwitchMapping$0:[I\n 81: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n 21 31 34 Class java/lang/NoSuchFieldError\n 35 45 48 Class java/lang/NoSuchFieldError\n 49 59 62 Class java/lang/NoSuchFieldError\n 63 73 76 Class java/lang/NoSuchFieldError\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day24/Day24Kt.class", "javap": "Compiled from \"day24.kt\"\npublic final class day24.Day24Kt {\n private static final java.util.Map<Point, java.util.List<day24.Blizzard>> initialValley;\n\n private static final int maxX;\n\n private static final int minX;\n\n private static final int maxY;\n\n private static final int minY;\n\n private static final Point start;\n\n private static final Point exit;\n\n private static final java.util.Map<Point, java.util.List<day24.Blizzard>> walls;\n\n private static final java.util.List<java.util.Map<Point, java.util.List<day24.Blizzard>>> valleySequence;\n\n public static final void main();\n Code:\n 0: invokestatic #10 // Method part1:()I\n 3: istore_0\n 4: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 7: iload_0\n 8: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 11: invokestatic #25 // Method part2:()I\n 14: istore_0\n 15: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 18: iload_0\n 19: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 22: return\n\n public static final int part1();\n Code:\n 0: aconst_null\n 1: iconst_0\n 2: aconst_null\n 3: bipush 7\n 5: aconst_null\n 6: invokestatic #29 // Method findPath$default:(LPoint;ILPoint;ILjava/lang/Object;)I\n 9: ireturn\n\n public static final int part2();\n Code:\n 0: aconst_null\n 1: iconst_0\n 2: aconst_null\n 3: bipush 7\n 5: aconst_null\n 6: invokestatic #29 // Method findPath$default:(LPoint;ILPoint;ILjava/lang/Object;)I\n 9: istore_0\n 10: getstatic #33 // Field exit:LPoint;\n 13: iload_0\n 14: getstatic #36 // Field start:LPoint;\n 17: invokestatic #40 // Method findPath:(LPoint;ILPoint;)I\n 20: istore_1\n 21: aconst_null\n 22: iload_1\n 23: aconst_null\n 24: iconst_5\n 25: aconst_null\n 26: invokestatic #29 // Method findPath$default:(LPoint;ILPoint;ILjava/lang/Object;)I\n 29: ireturn\n\n public static final int findPath(Point, int, Point);\n Code:\n 0: aload_0\n 1: ldc #46 // String entry\n 3: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #54 // String goal\n 9: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: iconst_1\n 13: anewarray #56 // class day24/State\n 16: astore 4\n 18: aload 4\n 20: iconst_0\n 21: new #56 // class day24/State\n 24: dup\n 25: aload_0\n 26: iload_1\n 27: invokespecial #60 // Method day24/State.\"<init>\":(LPoint;I)V\n 30: aastore\n 31: aload 4\n 33: invokestatic #66 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 36: astore_3\n 37: new #68 // class java/util/LinkedHashSet\n 40: dup\n 41: invokespecial #70 // Method java/util/LinkedHashSet.\"<init>\":()V\n 44: checkcast #72 // class java/util/Set\n 47: astore 4\n 49: aload_3\n 50: checkcast #74 // class java/util/Collection\n 53: invokeinterface #78, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 58: ifne 65\n 61: iconst_1\n 62: goto 66\n 65: iconst_0\n 66: ifeq 334\n 69: aload_3\n 70: invokeinterface #84, 1 // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;\n 75: dup\n 76: ldc #86 // String removeFirst(...)\n 78: invokestatic #89 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 81: checkcast #56 // class day24/State\n 84: astore 5\n 86: aload 4\n 88: aload 5\n 90: invokeinterface #93, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 95: ifne 49\n 98: getstatic #97 // Field valleySequence:Ljava/util/List;\n 101: aload 5\n 103: invokevirtual #100 // Method day24/State.getStep:()I\n 106: iconst_1\n 107: iadd\n 108: invokeinterface #104, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 113: checkcast #106 // class java/util/Map\n 116: astore 6\n 118: aload 5\n 120: invokevirtual #110 // Method day24/State.getPoint:()LPoint;\n 123: invokestatic #114 // Method validNeighboursFor:(LPoint;)Ljava/util/List;\n 126: checkcast #116 // class java/lang/Iterable\n 129: astore 8\n 131: iconst_0\n 132: istore 9\n 134: aload 8\n 136: astore 10\n 138: new #118 // class java/util/ArrayList\n 141: dup\n 142: invokespecial #119 // Method java/util/ArrayList.\"<init>\":()V\n 145: checkcast #74 // class java/util/Collection\n 148: astore 11\n 150: iconst_0\n 151: istore 12\n 153: aload 10\n 155: invokeinterface #123, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 160: astore 13\n 162: aload 13\n 164: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 169: ifeq 214\n 172: aload 13\n 174: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 179: astore 14\n 181: aload 14\n 183: checkcast #133 // class Point\n 186: astore 15\n 188: iconst_0\n 189: istore 16\n 191: aload 6\n 193: aload 15\n 195: invokestatic #137 // Method isOpenAt:(Ljava/util/Map;LPoint;)Z\n 198: ifeq 162\n 201: aload 11\n 203: aload 14\n 205: invokeinterface #140, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 210: pop\n 211: goto 162\n 214: aload 11\n 216: checkcast #80 // class java/util/List\n 219: nop\n 220: astore 7\n 222: aload 7\n 224: aload_2\n 225: invokeinterface #141, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 230: ifeq 241\n 233: aload 5\n 235: invokevirtual #100 // Method day24/State.getStep:()I\n 238: iconst_1\n 239: iadd\n 240: ireturn\n 241: aload 4\n 243: checkcast #74 // class java/util/Collection\n 246: aload 5\n 248: invokeinterface #140, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 253: pop\n 254: aload 7\n 256: checkcast #116 // class java/lang/Iterable\n 259: astore 8\n 261: iconst_0\n 262: istore 9\n 264: aload 8\n 266: invokeinterface #123, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 271: astore 10\n 273: aload 10\n 275: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 280: ifeq 330\n 283: aload 10\n 285: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 290: astore 11\n 292: aload 11\n 294: checkcast #133 // class Point\n 297: astore 12\n 299: iconst_0\n 300: istore 13\n 302: aload_3\n 303: new #56 // class day24/State\n 306: dup\n 307: aload 12\n 309: aload 5\n 311: invokevirtual #100 // Method day24/State.getStep:()I\n 314: iconst_1\n 315: iadd\n 316: invokespecial #60 // Method day24/State.\"<init>\":(LPoint;I)V\n 319: invokeinterface #142, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 324: pop\n 325: nop\n 326: nop\n 327: goto 273\n 330: nop\n 331: goto 49\n 334: new #144 // class java/lang/IllegalStateException\n 337: dup\n 338: ldc #146 // String lost in the vally of blizzards\n 340: invokevirtual #150 // Method java/lang/Object.toString:()Ljava/lang/String;\n 343: invokespecial #153 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 346: athrow\n\n public static int findPath$default(Point, int, Point, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 10\n 6: getstatic #36 // Field start:LPoint;\n 9: astore_0\n 10: iload_3\n 11: iconst_2\n 12: iand\n 13: ifeq 18\n 16: iconst_0\n 17: istore_1\n 18: iload_3\n 19: iconst_4\n 20: iand\n 21: ifeq 28\n 24: getstatic #33 // Field exit:LPoint;\n 27: astore_2\n 28: aload_0\n 29: iload_1\n 30: aload_2\n 31: invokestatic #40 // Method findPath:(LPoint;ILPoint;)I\n 34: ireturn\n\n public static final java.util.Map<Point, java.util.List<day24.Blizzard>> toValley(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #182 // String <this>\n 3: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #184 // class java/util/LinkedHashMap\n 9: dup\n 10: invokespecial #185 // Method java/util/LinkedHashMap.\"<init>\":()V\n 13: checkcast #106 // class java/util/Map\n 16: astore_1\n 17: aload_0\n 18: checkcast #116 // class java/lang/Iterable\n 21: astore_2\n 22: iconst_0\n 23: istore_3\n 24: aload_2\n 25: astore 4\n 27: new #118 // class java/util/ArrayList\n 30: dup\n 31: aload_2\n 32: bipush 10\n 34: invokestatic #189 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 37: invokespecial #191 // Method java/util/ArrayList.\"<init>\":(I)V\n 40: checkcast #74 // class java/util/Collection\n 43: astore 5\n 45: iconst_0\n 46: istore 6\n 48: iconst_0\n 49: istore 7\n 51: aload 4\n 53: invokeinterface #123, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 58: astore 8\n 60: aload 8\n 62: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 67: ifeq 399\n 70: aload 8\n 72: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 77: astore 9\n 79: aload 5\n 81: iload 7\n 83: iinc 7, 1\n 86: istore 10\n 88: iload 10\n 90: ifge 96\n 93: invokestatic #194 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 96: iload 10\n 98: aload 9\n 100: checkcast #196 // class java/lang/String\n 103: astore 11\n 105: istore 12\n 107: astore 27\n 109: iconst_0\n 110: istore 13\n 112: aload 11\n 114: checkcast #198 // class java/lang/CharSequence\n 117: astore 14\n 119: iconst_0\n 120: istore 15\n 122: aload 14\n 124: astore 16\n 126: new #118 // class java/util/ArrayList\n 129: dup\n 130: aload 14\n 132: invokeinterface #201, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 137: invokespecial #191 // Method java/util/ArrayList.\"<init>\":(I)V\n 140: checkcast #74 // class java/util/Collection\n 143: astore 17\n 145: iconst_0\n 146: istore 18\n 148: iconst_0\n 149: istore 19\n 151: iconst_0\n 152: istore 20\n 154: iload 20\n 156: aload 16\n 158: invokeinterface #201, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 163: if_icmpge 380\n 166: aload 16\n 168: iload 20\n 170: invokeinterface #205, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 175: istore 21\n 177: aload 17\n 179: iload 19\n 181: iinc 19, 1\n 184: iload 21\n 186: istore 22\n 188: istore 23\n 190: astore 24\n 192: iconst_0\n 193: istore 25\n 195: new #133 // class Point\n 198: dup\n 199: iload 23\n 201: iload 12\n 203: invokespecial #208 // Method Point.\"<init>\":(II)V\n 206: astore 26\n 208: iload 22\n 210: lookupswitch { // 5\n 35: 332\n 60: 296\n 62: 314\n 94: 260\n 118: 278\n default: 350\n }\n 260: aload_1\n 261: aload 26\n 263: getstatic #214 // Field day24/Blizzard.UP:Lday24/Blizzard;\n 266: invokestatic #218 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 269: invokeinterface #222, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 274: pop\n 275: goto 362\n 278: aload_1\n 279: aload 26\n 281: getstatic #225 // Field day24/Blizzard.DOWN:Lday24/Blizzard;\n 284: invokestatic #218 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 287: invokeinterface #222, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 292: pop\n 293: goto 362\n 296: aload_1\n 297: aload 26\n 299: getstatic #228 // Field day24/Blizzard.LEFT:Lday24/Blizzard;\n 302: invokestatic #218 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 305: invokeinterface #222, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 310: pop\n 311: goto 362\n 314: aload_1\n 315: aload 26\n 317: getstatic #231 // Field day24/Blizzard.RIGHT:Lday24/Blizzard;\n 320: invokestatic #218 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 323: invokeinterface #222, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 328: pop\n 329: goto 362\n 332: aload_1\n 333: aload 26\n 335: getstatic #234 // Field day24/Blizzard.WALL:Lday24/Blizzard;\n 338: invokestatic #218 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 341: invokeinterface #222, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 346: pop\n 347: goto 362\n 350: aload_1\n 351: aload 26\n 353: invokestatic #238 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 356: invokeinterface #222, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 361: pop\n 362: nop\n 363: aload 24\n 365: getstatic #244 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 368: invokeinterface #140, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 373: pop\n 374: iinc 20, 1\n 377: goto 154\n 380: aload 17\n 382: checkcast #80 // class java/util/List\n 385: nop\n 386: nop\n 387: aload 27\n 389: swap\n 390: invokeinterface #140, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 395: pop\n 396: goto 60\n 399: aload 5\n 401: checkcast #80 // class java/util/List\n 404: nop\n 405: pop\n 406: aload_1\n 407: areturn\n\n public static final java.util.List<Point> validNeighboursFor(Point);\n Code:\n 0: aload_0\n 1: ldc_w #264 // String p\n 4: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: iconst_1\n 9: invokevirtual #267 // Method Point.neighbours:(Z)Ljava/util/List;\n 12: checkcast #116 // class java/lang/Iterable\n 15: astore_1\n 16: nop\n 17: iconst_0\n 18: istore_2\n 19: aload_1\n 20: astore_3\n 21: new #118 // class java/util/ArrayList\n 24: dup\n 25: invokespecial #119 // Method java/util/ArrayList.\"<init>\":()V\n 28: checkcast #74 // class java/util/Collection\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: aload_3\n 37: invokeinterface #123, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 6\n 44: aload 6\n 46: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 100\n 54: aload 6\n 56: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 7\n 63: aload 7\n 65: checkcast #133 // class Point\n 68: astore 8\n 70: iconst_0\n 71: istore 9\n 73: getstatic #270 // Field walls:Ljava/util/Map;\n 76: aload 8\n 78: invokeinterface #273, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 83: nop\n 84: ifne 44\n 87: aload 4\n 89: aload 7\n 91: invokeinterface #140, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 96: pop\n 97: goto 44\n 100: aload 4\n 102: checkcast #80 // class java/util/List\n 105: nop\n 106: checkcast #116 // class java/lang/Iterable\n 109: astore_1\n 110: nop\n 111: iconst_0\n 112: istore_2\n 113: aload_1\n 114: astore_3\n 115: new #118 // class java/util/ArrayList\n 118: dup\n 119: invokespecial #119 // Method java/util/ArrayList.\"<init>\":()V\n 122: checkcast #74 // class java/util/Collection\n 125: astore 4\n 127: iconst_0\n 128: istore 5\n 130: aload_3\n 131: invokeinterface #123, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 136: astore 6\n 138: aload 6\n 140: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 145: ifeq 223\n 148: aload 6\n 150: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 155: astore 7\n 157: aload 7\n 159: checkcast #133 // class Point\n 162: astore 8\n 164: iconst_0\n 165: istore 9\n 167: getstatic #276 // Field minX:I\n 170: istore 10\n 172: getstatic #279 // Field maxX:I\n 175: istore 11\n 177: aload 8\n 179: invokevirtual #282 // Method Point.getX:()I\n 182: istore 12\n 184: iload 10\n 186: iload 12\n 188: if_icmpgt 206\n 191: iload 12\n 193: iload 11\n 195: if_icmpgt 202\n 198: iconst_1\n 199: goto 207\n 202: iconst_0\n 203: goto 207\n 206: iconst_0\n 207: ifeq 138\n 210: aload 4\n 212: aload 7\n 214: invokeinterface #140, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 219: pop\n 220: goto 138\n 223: aload 4\n 225: checkcast #80 // class java/util/List\n 228: nop\n 229: checkcast #116 // class java/lang/Iterable\n 232: astore_1\n 233: nop\n 234: iconst_0\n 235: istore_2\n 236: aload_1\n 237: astore_3\n 238: new #118 // class java/util/ArrayList\n 241: dup\n 242: invokespecial #119 // Method java/util/ArrayList.\"<init>\":()V\n 245: checkcast #74 // class java/util/Collection\n 248: astore 4\n 250: iconst_0\n 251: istore 5\n 253: aload_3\n 254: invokeinterface #123, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 259: astore 6\n 261: aload 6\n 263: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 268: ifeq 346\n 271: aload 6\n 273: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 278: astore 7\n 280: aload 7\n 282: checkcast #133 // class Point\n 285: astore 8\n 287: iconst_0\n 288: istore 9\n 290: getstatic #285 // Field minY:I\n 293: istore 10\n 295: getstatic #288 // Field maxY:I\n 298: istore 11\n 300: aload 8\n 302: invokevirtual #291 // Method Point.getY:()I\n 305: istore 12\n 307: iload 10\n 309: iload 12\n 311: if_icmpgt 329\n 314: iload 12\n 316: iload 11\n 318: if_icmpgt 325\n 321: iconst_1\n 322: goto 330\n 325: iconst_0\n 326: goto 330\n 329: iconst_0\n 330: ifeq 261\n 333: aload 4\n 335: aload 7\n 337: invokeinterface #140, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 342: pop\n 343: goto 261\n 346: aload 4\n 348: checkcast #80 // class java/util/List\n 351: nop\n 352: areturn\n\n public static final boolean isOpenAt(java.util.Map<Point, ? extends java.util.List<? extends day24.Blizzard>>, Point);\n Code:\n 0: aload_0\n 1: ldc #182 // String <this>\n 3: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc_w #264 // String p\n 10: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: aload_0\n 14: aload_1\n 15: invokeinterface #302, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 20: checkcast #74 // class java/util/Collection\n 23: astore_2\n 24: aload_2\n 25: ifnull 37\n 28: aload_2\n 29: invokeinterface #78, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 34: ifeq 41\n 37: iconst_1\n 38: goto 42\n 41: iconst_0\n 42: ireturn\n\n public static final java.util.Map<Point, java.util.List<day24.Blizzard>> step(java.util.Map<Point, ? extends java.util.List<? extends day24.Blizzard>>);\n Code:\n 0: aload_0\n 1: ldc #182 // String <this>\n 3: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_2\n 7: anewarray #308 // class kotlin/Pair\n 10: astore_1\n 11: aload_1\n 12: iconst_0\n 13: getstatic #36 // Field start:LPoint;\n 16: new #118 // class java/util/ArrayList\n 19: dup\n 20: invokespecial #119 // Method java/util/ArrayList.\"<init>\":()V\n 23: checkcast #80 // class java/util/List\n 26: invokestatic #314 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 29: aastore\n 30: aload_1\n 31: iconst_1\n 32: getstatic #33 // Field exit:LPoint;\n 35: new #118 // class java/util/ArrayList\n 38: dup\n 39: invokespecial #119 // Method java/util/ArrayList.\"<init>\":()V\n 42: checkcast #80 // class java/util/List\n 45: invokestatic #314 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 48: aastore\n 49: aload_1\n 50: invokestatic #320 // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 53: astore_2\n 54: iconst_0\n 55: istore_3\n 56: new #322 // class kotlin/ranges/IntRange\n 59: dup\n 60: getstatic #276 // Field minX:I\n 63: getstatic #279 // Field maxX:I\n 66: invokespecial #323 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 69: checkcast #116 // class java/lang/Iterable\n 72: astore 4\n 74: iconst_0\n 75: istore 5\n 77: aload 4\n 79: invokeinterface #123, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 84: astore 6\n 86: aload 6\n 88: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 93: ifeq 524\n 96: aload 6\n 98: checkcast #325 // class kotlin/collections/IntIterator\n 101: invokevirtual #328 // Method kotlin/collections/IntIterator.nextInt:()I\n 104: istore 7\n 106: iload 7\n 108: istore 8\n 110: iconst_0\n 111: istore 9\n 113: new #322 // class kotlin/ranges/IntRange\n 116: dup\n 117: getstatic #285 // Field minY:I\n 120: getstatic #288 // Field maxY:I\n 123: invokespecial #323 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 126: checkcast #116 // class java/lang/Iterable\n 129: astore 10\n 131: iconst_0\n 132: istore 11\n 134: aload 10\n 136: invokeinterface #123, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 141: astore 12\n 143: aload 12\n 145: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 150: ifeq 518\n 153: aload 12\n 155: checkcast #325 // class kotlin/collections/IntIterator\n 158: invokevirtual #328 // Method kotlin/collections/IntIterator.nextInt:()I\n 161: istore 13\n 163: iload 13\n 165: istore 14\n 167: iconst_0\n 168: istore 15\n 170: new #133 // class Point\n 173: dup\n 174: iload 8\n 176: iload 14\n 178: invokespecial #208 // Method Point.\"<init>\":(II)V\n 181: astore 16\n 183: aload_0\n 184: aload 16\n 186: invokeinterface #302, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 191: checkcast #80 // class java/util/List\n 194: astore 17\n 196: aload 17\n 198: checkcast #74 // class java/util/Collection\n 201: astore 18\n 203: aload 18\n 205: ifnull 218\n 208: aload 18\n 210: invokeinterface #78, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 215: ifeq 222\n 218: iconst_1\n 219: goto 223\n 222: iconst_0\n 223: ifne 513\n 226: aload 17\n 228: checkcast #116 // class java/lang/Iterable\n 231: astore 18\n 233: iconst_0\n 234: istore 19\n 236: aload 18\n 238: invokeinterface #123, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 243: astore 20\n 245: aload 20\n 247: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 252: ifeq 512\n 255: aload 20\n 257: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 262: astore 21\n 264: aload 21\n 266: checkcast #210 // class day24/Blizzard\n 269: astore 22\n 271: iconst_0\n 272: istore 23\n 274: aload 16\n 276: aload 22\n 278: invokevirtual #331 // Method day24/Blizzard.getOffset:()LPoint;\n 281: invokevirtual #335 // Method Point.plus:(LPoint;)LPoint;\n 284: astore 24\n 286: getstatic #270 // Field walls:Ljava/util/Map;\n 289: aload 24\n 291: invokeinterface #273, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 296: ifeq 436\n 299: aload 22\n 301: getstatic #341 // Field day24/Day24Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 304: swap\n 305: invokevirtual #344 // Method day24/Blizzard.ordinal:()I\n 308: iaload\n 309: tableswitch { // 1 to 5\n 1: 344\n 2: 361\n 3: 378\n 4: 395\n 5: 412\n default: 426\n }\n 344: new #133 // class Point\n 347: dup\n 348: getstatic #279 // Field maxX:I\n 351: iconst_1\n 352: isub\n 353: iload 14\n 355: invokespecial #208 // Method Point.\"<init>\":(II)V\n 358: goto 434\n 361: new #133 // class Point\n 364: dup\n 365: getstatic #276 // Field minX:I\n 368: iconst_1\n 369: iadd\n 370: iload 14\n 372: invokespecial #208 // Method Point.\"<init>\":(II)V\n 375: goto 434\n 378: new #133 // class Point\n 381: dup\n 382: iload 8\n 384: getstatic #288 // Field maxY:I\n 387: iconst_1\n 388: isub\n 389: invokespecial #208 // Method Point.\"<init>\":(II)V\n 392: goto 434\n 395: new #133 // class Point\n 398: dup\n 399: iload 8\n 401: getstatic #285 // Field minY:I\n 404: iconst_1\n 405: iadd\n 406: invokespecial #208 // Method Point.\"<init>\":(II)V\n 409: goto 434\n 412: new #133 // class Point\n 415: dup\n 416: iload 8\n 418: iload 14\n 420: invokespecial #208 // Method Point.\"<init>\":(II)V\n 423: goto 434\n 426: new #346 // class kotlin/NoWhenBranchMatchedException\n 429: dup\n 430: invokespecial #347 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 433: athrow\n 434: astore 24\n 436: aload_2\n 437: aload 24\n 439: invokeinterface #302, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 444: ifnonnull 484\n 447: aload_2\n 448: astore 25\n 450: iconst_1\n 451: anewarray #210 // class day24/Blizzard\n 454: astore 26\n 456: aload 26\n 458: iconst_0\n 459: aload 22\n 461: aastore\n 462: aload 26\n 464: invokestatic #66 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 467: astore 26\n 469: aload 25\n 471: aload 24\n 473: aload 26\n 475: invokeinterface #222, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 480: pop\n 481: goto 507\n 484: aload_2\n 485: aload 24\n 487: invokeinterface #302, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 492: dup\n 493: invokestatic #351 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 496: checkcast #80 // class java/util/List\n 499: aload 22\n 501: invokeinterface #142, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 506: pop\n 507: nop\n 508: nop\n 509: goto 245\n 512: nop\n 513: nop\n 514: nop\n 515: goto 143\n 518: nop\n 519: nop\n 520: nop\n 521: goto 86\n 524: nop\n 525: aload_2\n 526: nop\n 527: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #366 // Method main:()V\n 3: return\n\n private static final java.util.Map valleySequence$lambda$9(java.util.Map);\n Code:\n 0: aload_0\n 1: ldc_w #370 // String it\n 4: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokestatic #372 // Method step:(Ljava/util/Map;)Ljava/util/Map;\n 11: areturn\n\n static {};\n Code:\n 0: ldc_w #375 // String main/day24/Day24\n 3: invokestatic #381 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 6: invokestatic #383 // Method toValley:(Ljava/util/List;)Ljava/util/Map;\n 9: putstatic #386 // Field initialValley:Ljava/util/Map;\n 12: getstatic #386 // Field initialValley:Ljava/util/Map;\n 15: invokeinterface #390, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 20: checkcast #116 // class java/lang/Iterable\n 23: invokeinterface #123, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 28: astore_1\n 29: aload_1\n 30: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 35: ifne 46\n 38: new #392 // class java/util/NoSuchElementException\n 41: dup\n 42: invokespecial #393 // Method java/util/NoSuchElementException.\"<init>\":()V\n 45: athrow\n 46: aload_1\n 47: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 52: checkcast #133 // class Point\n 55: astore_2\n 56: iconst_0\n 57: istore_3\n 58: aload_2\n 59: invokevirtual #282 // Method Point.getX:()I\n 62: istore_2\n 63: aload_1\n 64: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 69: ifeq 100\n 72: aload_1\n 73: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 78: checkcast #133 // class Point\n 81: astore_3\n 82: iconst_0\n 83: istore 4\n 85: aload_3\n 86: invokevirtual #282 // Method Point.getX:()I\n 89: istore_3\n 90: iload_2\n 91: iload_3\n 92: if_icmpge 63\n 95: iload_3\n 96: istore_2\n 97: goto 63\n 100: iload_2\n 101: putstatic #279 // Field maxX:I\n 104: getstatic #386 // Field initialValley:Ljava/util/Map;\n 107: invokeinterface #390, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 112: checkcast #116 // class java/lang/Iterable\n 115: invokeinterface #123, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 120: astore_1\n 121: aload_1\n 122: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 127: ifne 138\n 130: new #392 // class java/util/NoSuchElementException\n 133: dup\n 134: invokespecial #393 // Method java/util/NoSuchElementException.\"<init>\":()V\n 137: athrow\n 138: aload_1\n 139: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 144: checkcast #133 // class Point\n 147: astore_2\n 148: iconst_0\n 149: istore_3\n 150: aload_2\n 151: invokevirtual #282 // Method Point.getX:()I\n 154: istore_2\n 155: aload_1\n 156: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 161: ifeq 192\n 164: aload_1\n 165: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 170: checkcast #133 // class Point\n 173: astore_3\n 174: iconst_0\n 175: istore 4\n 177: aload_3\n 178: invokevirtual #282 // Method Point.getX:()I\n 181: istore_3\n 182: iload_2\n 183: iload_3\n 184: if_icmple 155\n 187: iload_3\n 188: istore_2\n 189: goto 155\n 192: iload_2\n 193: putstatic #276 // Field minX:I\n 196: getstatic #386 // Field initialValley:Ljava/util/Map;\n 199: invokeinterface #390, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 204: checkcast #116 // class java/lang/Iterable\n 207: invokeinterface #123, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 212: astore_1\n 213: aload_1\n 214: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 219: ifne 230\n 222: new #392 // class java/util/NoSuchElementException\n 225: dup\n 226: invokespecial #393 // Method java/util/NoSuchElementException.\"<init>\":()V\n 229: athrow\n 230: aload_1\n 231: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 236: checkcast #133 // class Point\n 239: astore_2\n 240: iconst_0\n 241: istore_3\n 242: aload_2\n 243: invokevirtual #291 // Method Point.getY:()I\n 246: istore_2\n 247: aload_1\n 248: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 253: ifeq 284\n 256: aload_1\n 257: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 262: checkcast #133 // class Point\n 265: astore_3\n 266: iconst_0\n 267: istore 4\n 269: aload_3\n 270: invokevirtual #291 // Method Point.getY:()I\n 273: istore_3\n 274: iload_2\n 275: iload_3\n 276: if_icmpge 247\n 279: iload_3\n 280: istore_2\n 281: goto 247\n 284: iload_2\n 285: putstatic #288 // Field maxY:I\n 288: getstatic #386 // Field initialValley:Ljava/util/Map;\n 291: invokeinterface #390, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 296: checkcast #116 // class java/lang/Iterable\n 299: invokeinterface #123, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 304: astore_1\n 305: aload_1\n 306: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 311: ifne 322\n 314: new #392 // class java/util/NoSuchElementException\n 317: dup\n 318: invokespecial #393 // Method java/util/NoSuchElementException.\"<init>\":()V\n 321: athrow\n 322: aload_1\n 323: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 328: checkcast #133 // class Point\n 331: astore_2\n 332: iconst_0\n 333: istore_3\n 334: aload_2\n 335: invokevirtual #291 // Method Point.getY:()I\n 338: istore_2\n 339: aload_1\n 340: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 345: ifeq 376\n 348: aload_1\n 349: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 354: checkcast #133 // class Point\n 357: astore_3\n 358: iconst_0\n 359: istore 4\n 361: aload_3\n 362: invokevirtual #291 // Method Point.getY:()I\n 365: istore_3\n 366: iload_2\n 367: iload_3\n 368: if_icmple 339\n 371: iload_3\n 372: istore_2\n 373: goto 339\n 376: iload_2\n 377: putstatic #285 // Field minY:I\n 380: getstatic #386 // Field initialValley:Ljava/util/Map;\n 383: astore_0\n 384: iconst_0\n 385: istore_1\n 386: aload_0\n 387: astore_2\n 388: new #184 // class java/util/LinkedHashMap\n 391: dup\n 392: invokespecial #185 // Method java/util/LinkedHashMap.\"<init>\":()V\n 395: checkcast #106 // class java/util/Map\n 398: astore_3\n 399: iconst_0\n 400: istore 4\n 402: aload_2\n 403: invokeinterface #396, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 408: invokeinterface #397, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 413: astore 5\n 415: aload 5\n 417: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 422: ifeq 495\n 425: aload 5\n 427: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 432: checkcast #399 // class java/util/Map$Entry\n 435: astore 6\n 437: aload 6\n 439: astore 7\n 441: iconst_0\n 442: istore 8\n 444: aload 7\n 446: invokeinterface #402, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 451: checkcast #133 // class Point\n 454: invokevirtual #291 // Method Point.getY:()I\n 457: getstatic #285 // Field minY:I\n 460: if_icmpne 467\n 463: iconst_1\n 464: goto 468\n 467: iconst_0\n 468: ifeq 415\n 471: aload_3\n 472: aload 6\n 474: invokeinterface #402, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 479: aload 6\n 481: invokeinterface #405, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 486: invokeinterface #222, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 491: pop\n 492: goto 415\n 495: aload_3\n 496: nop\n 497: invokeinterface #390, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 502: checkcast #116 // class java/lang/Iterable\n 505: astore_0\n 506: iconst_0\n 507: istore_1\n 508: aload_0\n 509: invokeinterface #123, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 514: astore_2\n 515: aload_2\n 516: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 521: ifeq 569\n 524: aload_2\n 525: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 530: astore_3\n 531: aload_3\n 532: checkcast #133 // class Point\n 535: astore 4\n 537: iconst_0\n 538: istore 5\n 540: getstatic #386 // Field initialValley:Ljava/util/Map;\n 543: aload 4\n 545: invokeinterface #302, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 550: dup\n 551: invokestatic #351 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 554: checkcast #80 // class java/util/List\n 557: invokeinterface #406, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 562: ifeq 515\n 565: aload_3\n 566: goto 580\n 569: new #392 // class java/util/NoSuchElementException\n 572: dup\n 573: ldc_w #408 // String Collection contains no element matching the predicate.\n 576: invokespecial #409 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 579: athrow\n 580: checkcast #133 // class Point\n 583: putstatic #36 // Field start:LPoint;\n 586: getstatic #386 // Field initialValley:Ljava/util/Map;\n 589: astore_0\n 590: iconst_0\n 591: istore_1\n 592: aload_0\n 593: astore_2\n 594: new #184 // class java/util/LinkedHashMap\n 597: dup\n 598: invokespecial #185 // Method java/util/LinkedHashMap.\"<init>\":()V\n 601: checkcast #106 // class java/util/Map\n 604: astore_3\n 605: iconst_0\n 606: istore 4\n 608: aload_2\n 609: invokeinterface #396, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 614: invokeinterface #397, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 619: astore 5\n 621: aload 5\n 623: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 628: ifeq 701\n 631: aload 5\n 633: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 638: checkcast #399 // class java/util/Map$Entry\n 641: astore 6\n 643: aload 6\n 645: astore 7\n 647: iconst_0\n 648: istore 8\n 650: aload 7\n 652: invokeinterface #402, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 657: checkcast #133 // class Point\n 660: invokevirtual #291 // Method Point.getY:()I\n 663: getstatic #288 // Field maxY:I\n 666: if_icmpne 673\n 669: iconst_1\n 670: goto 674\n 673: iconst_0\n 674: ifeq 621\n 677: aload_3\n 678: aload 6\n 680: invokeinterface #402, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 685: aload 6\n 687: invokeinterface #405, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 692: invokeinterface #222, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 697: pop\n 698: goto 621\n 701: aload_3\n 702: nop\n 703: invokeinterface #390, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 708: checkcast #116 // class java/lang/Iterable\n 711: astore_0\n 712: iconst_0\n 713: istore_1\n 714: aload_0\n 715: invokeinterface #123, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 720: astore_2\n 721: aload_2\n 722: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 727: ifeq 775\n 730: aload_2\n 731: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 736: astore_3\n 737: aload_3\n 738: checkcast #133 // class Point\n 741: astore 4\n 743: iconst_0\n 744: istore 5\n 746: getstatic #386 // Field initialValley:Ljava/util/Map;\n 749: aload 4\n 751: invokeinterface #302, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 756: dup\n 757: invokestatic #351 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 760: checkcast #80 // class java/util/List\n 763: invokeinterface #406, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 768: ifeq 721\n 771: aload_3\n 772: goto 786\n 775: new #392 // class java/util/NoSuchElementException\n 778: dup\n 779: ldc_w #408 // String Collection contains no element matching the predicate.\n 782: invokespecial #409 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 785: athrow\n 786: checkcast #133 // class Point\n 789: putstatic #33 // Field exit:LPoint;\n 792: getstatic #386 // Field initialValley:Ljava/util/Map;\n 795: astore_0\n 796: iconst_0\n 797: istore_1\n 798: aload_0\n 799: astore_2\n 800: new #184 // class java/util/LinkedHashMap\n 803: dup\n 804: invokespecial #185 // Method java/util/LinkedHashMap.\"<init>\":()V\n 807: checkcast #106 // class java/util/Map\n 810: astore_3\n 811: iconst_0\n 812: istore 4\n 814: aload_2\n 815: invokeinterface #396, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 820: invokeinterface #397, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 825: astore 5\n 827: aload 5\n 829: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 834: ifeq 907\n 837: aload 5\n 839: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 844: checkcast #399 // class java/util/Map$Entry\n 847: astore 6\n 849: aload 6\n 851: astore 7\n 853: iconst_0\n 854: istore 8\n 856: aload 7\n 858: invokeinterface #405, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 863: checkcast #80 // class java/util/List\n 866: invokestatic #413 // Method kotlin/collections/CollectionsKt.firstOrNull:(Ljava/util/List;)Ljava/lang/Object;\n 869: getstatic #234 // Field day24/Blizzard.WALL:Lday24/Blizzard;\n 872: if_acmpne 879\n 875: iconst_1\n 876: goto 880\n 879: iconst_0\n 880: ifeq 827\n 883: aload_3\n 884: aload 6\n 886: invokeinterface #402, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 891: aload 6\n 893: invokeinterface #405, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 898: invokeinterface #222, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 903: pop\n 904: goto 827\n 907: aload_3\n 908: nop\n 909: putstatic #270 // Field walls:Ljava/util/Map;\n 912: getstatic #386 // Field initialValley:Ljava/util/Map;\n 915: invokedynamic #429, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 920: invokestatic #435 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 923: sipush 1000\n 926: invokestatic #439 // Method kotlin/sequences/SequencesKt.take:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;\n 929: invokestatic #443 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 932: putstatic #97 // Field valleySequence:Ljava/util/List;\n 935: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day12/day12.kt
package day12 import Point import readInput typealias Grid = MutableMap<Point, Char> fun main() { val input = readInput("main/day12/Day12") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int = input.solveFor('S') fun part2(input: List<String>): Int = input.solveFor('a') fun List<String>.solveFor(start: Char): Int { val grid = parse() val startPoint = grid.filter { it.value == 'S' }.keys.first() val goal = grid.filterValues { it == 'E' }.keys.first() grid[goal] = 'z' return grid.filter { it.value == start }.mapNotNull { grid[startPoint] = 'a' distance(it.key, goal, grid) }.minOf { it } } private fun distance(start: Point, goal: Point, grid: Grid): Int? { // the metaphor is to "flood" the terrain with water, always going in all 4 directions if the neighbouring point is not too high // and keep track of the distance. // As soon as the goal is "wet", we have our result val lake = mutableMapOf(start to 0) var distance = 0 var currentSize = 0 do { currentSize = lake.size distance = grid.floodValley(lake, distance) } while (!lake.containsKey(goal) && lake.size > currentSize) if (lake.size <= currentSize) { // there is no valid path from start to goal return null } return distance } fun Grid.floodValley(lake: MutableMap<Point, Int>, distance: Int): Int { lake.filterValues { it == distance }.forEach { (point, _) -> point.neighbours().filter { this[it] != null && this[it]!! - this[point]!! <= 1 }.forEach { if (!lake.containsKey(it)) lake[it] = distance + 1 } } return distance + 1 } fun List<String>.parse(): Grid { val result = mutableMapOf<Point, Char>() forEachIndexed { y, line -> line.forEachIndexed { x, c -> result[Point(x, y)] = c } } return result }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day12/Day12Kt.class", "javap": "Compiled from \"day12.kt\"\npublic final class day12.Day12Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String main/day12/Day12\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #33 // Method part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: bipush 83\n 9: invokestatic #48 // Method solveFor:(Ljava/util/List;C)I\n 12: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: bipush 97\n 9: invokestatic #48 // Method solveFor:(Ljava/util/List;C)I\n 12: ireturn\n\n public static final int solveFor(java.util.List<java.lang.String>, char);\n Code:\n 0: aload_0\n 1: ldc #51 // String <this>\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #55 // Method parse:(Ljava/util/List;)Ljava/util/Map;\n 10: astore_2\n 11: aload_2\n 12: astore 4\n 14: iconst_0\n 15: istore 5\n 17: aload 4\n 19: astore 6\n 21: new #57 // class java/util/LinkedHashMap\n 24: dup\n 25: invokespecial #60 // Method java/util/LinkedHashMap.\"<init>\":()V\n 28: checkcast #62 // class java/util/Map\n 31: astore 7\n 33: iconst_0\n 34: istore 8\n 36: aload 6\n 38: invokeinterface #66, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 43: invokeinterface #72, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 48: astore 9\n 50: aload 9\n 52: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 57: ifeq 130\n 60: aload 9\n 62: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 67: checkcast #84 // class java/util/Map$Entry\n 70: astore 10\n 72: aload 10\n 74: astore 11\n 76: iconst_0\n 77: istore 12\n 79: aload 11\n 81: invokeinterface #87, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 86: checkcast #89 // class java/lang/Character\n 89: invokevirtual #93 // Method java/lang/Character.charValue:()C\n 92: bipush 83\n 94: if_icmpne 101\n 97: iconst_1\n 98: goto 102\n 101: iconst_0\n 102: ifeq 50\n 105: aload 7\n 107: aload 10\n 109: invokeinterface #96, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 114: aload 10\n 116: invokeinterface #87, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 121: invokeinterface #100, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 126: pop\n 127: goto 50\n 130: aload 7\n 132: nop\n 133: invokeinterface #103, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 138: checkcast #105 // class java/lang/Iterable\n 141: invokestatic #111 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 144: checkcast #113 // class Point\n 147: astore_3\n 148: aload_2\n 149: astore 5\n 151: iconst_0\n 152: istore 6\n 154: new #57 // class java/util/LinkedHashMap\n 157: dup\n 158: invokespecial #60 // Method java/util/LinkedHashMap.\"<init>\":()V\n 161: astore 7\n 163: aload 5\n 165: invokeinterface #66, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 170: invokeinterface #72, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 175: astore 8\n 177: aload 8\n 179: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 184: ifeq 255\n 187: aload 8\n 189: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 194: checkcast #84 // class java/util/Map$Entry\n 197: astore 9\n 199: aload 9\n 201: invokeinterface #87, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 206: checkcast #89 // class java/lang/Character\n 209: invokevirtual #93 // Method java/lang/Character.charValue:()C\n 212: istore 10\n 214: iconst_0\n 215: istore 11\n 217: iload 10\n 219: bipush 69\n 221: if_icmpne 228\n 224: iconst_1\n 225: goto 229\n 228: iconst_0\n 229: ifeq 177\n 232: aload 7\n 234: aload 9\n 236: invokeinterface #96, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 241: aload 9\n 243: invokeinterface #87, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 248: invokevirtual #114 // Method java/util/LinkedHashMap.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 251: pop\n 252: goto 177\n 255: aload 7\n 257: checkcast #62 // class java/util/Map\n 260: invokeinterface #103, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 265: checkcast #105 // class java/lang/Iterable\n 268: invokestatic #111 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 271: checkcast #113 // class Point\n 274: astore 4\n 276: aload_2\n 277: aload 4\n 279: bipush 122\n 281: invokestatic #118 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 284: invokeinterface #100, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 289: pop\n 290: aload_2\n 291: astore 5\n 293: iconst_0\n 294: istore 6\n 296: aload 5\n 298: astore 7\n 300: new #57 // class java/util/LinkedHashMap\n 303: dup\n 304: invokespecial #60 // Method java/util/LinkedHashMap.\"<init>\":()V\n 307: checkcast #62 // class java/util/Map\n 310: astore 8\n 312: iconst_0\n 313: istore 9\n 315: aload 7\n 317: invokeinterface #66, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 322: invokeinterface #72, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 327: astore 10\n 329: aload 10\n 331: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 336: ifeq 408\n 339: aload 10\n 341: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 346: checkcast #84 // class java/util/Map$Entry\n 349: astore 11\n 351: aload 11\n 353: astore 12\n 355: iconst_0\n 356: istore 13\n 358: aload 12\n 360: invokeinterface #87, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 365: checkcast #89 // class java/lang/Character\n 368: invokevirtual #93 // Method java/lang/Character.charValue:()C\n 371: iload_1\n 372: if_icmpne 379\n 375: iconst_1\n 376: goto 380\n 379: iconst_0\n 380: ifeq 329\n 383: aload 8\n 385: aload 11\n 387: invokeinterface #96, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 392: aload 11\n 394: invokeinterface #87, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 399: invokeinterface #100, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 404: pop\n 405: goto 329\n 408: aload 8\n 410: nop\n 411: astore 5\n 413: nop\n 414: iconst_0\n 415: istore 6\n 417: aload 5\n 419: astore 7\n 421: new #120 // class java/util/ArrayList\n 424: dup\n 425: invokespecial #121 // Method java/util/ArrayList.\"<init>\":()V\n 428: checkcast #123 // class java/util/Collection\n 431: astore 8\n 433: iconst_0\n 434: istore 9\n 436: aload 7\n 438: astore 10\n 440: iconst_0\n 441: istore 11\n 443: aload 10\n 445: invokeinterface #66, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 450: invokeinterface #72, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 455: astore 12\n 457: aload 12\n 459: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 464: ifeq 549\n 467: aload 12\n 469: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 474: checkcast #84 // class java/util/Map$Entry\n 477: astore 13\n 479: aload 13\n 481: astore 14\n 483: iconst_0\n 484: istore 15\n 486: aload 14\n 488: astore 16\n 490: iconst_0\n 491: istore 17\n 493: aload_2\n 494: aload_3\n 495: bipush 97\n 497: invokestatic #118 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 500: invokeinterface #100, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 505: pop\n 506: aload 16\n 508: invokeinterface #96, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 513: checkcast #113 // class Point\n 516: aload 4\n 518: aload_2\n 519: invokestatic #127 // Method distance:(LPoint;LPoint;Ljava/util/Map;)Ljava/lang/Integer;\n 522: dup\n 523: ifnull 544\n 526: astore 18\n 528: iconst_0\n 529: istore 19\n 531: aload 8\n 533: aload 18\n 535: invokeinterface #131, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 540: pop\n 541: goto 545\n 544: pop\n 545: nop\n 546: goto 457\n 549: nop\n 550: aload 8\n 552: checkcast #133 // class java/util/List\n 555: nop\n 556: checkcast #105 // class java/lang/Iterable\n 559: invokeinterface #134, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 564: astore 6\n 566: aload 6\n 568: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 573: ifne 584\n 576: new #136 // class java/util/NoSuchElementException\n 579: dup\n 580: invokespecial #137 // Method java/util/NoSuchElementException.\"<init>\":()V\n 583: athrow\n 584: aload 6\n 586: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 591: checkcast #139 // class java/lang/Number\n 594: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 597: istore 7\n 599: iconst_0\n 600: istore 8\n 602: iload 7\n 604: istore 7\n 606: aload 6\n 608: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 613: ifeq 652\n 616: aload 6\n 618: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 623: checkcast #139 // class java/lang/Number\n 626: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 629: istore 8\n 631: iconst_0\n 632: istore 9\n 634: iload 8\n 636: istore 8\n 638: iload 7\n 640: iload 8\n 642: if_icmple 606\n 645: iload 8\n 647: istore 7\n 649: goto 606\n 652: iload 7\n 654: ireturn\n\n private static final java.lang.Integer distance(Point, Point, java.util.Map<Point, java.lang.Character>);\n Code:\n 0: iconst_1\n 1: anewarray #187 // class kotlin/Pair\n 4: astore 4\n 6: aload 4\n 8: iconst_0\n 9: aload_0\n 10: iconst_0\n 11: invokestatic #190 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 14: invokestatic #196 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 17: aastore\n 18: aload 4\n 20: invokestatic #202 // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 23: astore_3\n 24: iconst_0\n 25: istore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #205, 1 // InterfaceMethod java/util/Map.size:()I\n 36: istore 5\n 38: aload_2\n 39: aload_3\n 40: iload 4\n 42: invokestatic #209 // Method floodValley:(Ljava/util/Map;Ljava/util/Map;I)I\n 45: istore 4\n 47: aload_3\n 48: aload_1\n 49: invokeinterface #212, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 54: ifne 68\n 57: aload_3\n 58: invokeinterface #205, 1 // InterfaceMethod java/util/Map.size:()I\n 63: iload 5\n 65: if_icmpgt 30\n 68: aload_3\n 69: invokeinterface #205, 1 // InterfaceMethod java/util/Map.size:()I\n 74: iload 5\n 76: if_icmpgt 81\n 79: aconst_null\n 80: areturn\n 81: iload 4\n 83: invokestatic #190 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 86: areturn\n\n public static final int floodValley(java.util.Map<Point, java.lang.Character>, java.util.Map<Point, java.lang.Integer>, int);\n Code:\n 0: aload_0\n 1: ldc #51 // String <this>\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #216 // String lake\n 9: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: astore_3\n 14: iconst_0\n 15: istore 4\n 17: new #57 // class java/util/LinkedHashMap\n 20: dup\n 21: invokespecial #60 // Method java/util/LinkedHashMap.\"<init>\":()V\n 24: astore 5\n 26: aload_3\n 27: invokeinterface #66, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 32: invokeinterface #72, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 37: astore 6\n 39: aload 6\n 41: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 116\n 49: aload 6\n 51: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 56: checkcast #84 // class java/util/Map$Entry\n 59: astore 7\n 61: aload 7\n 63: invokeinterface #87, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 68: checkcast #139 // class java/lang/Number\n 71: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 74: istore 8\n 76: iconst_0\n 77: istore 9\n 79: iload 8\n 81: iload_2\n 82: if_icmpne 89\n 85: iconst_1\n 86: goto 90\n 89: iconst_0\n 90: ifeq 39\n 93: aload 5\n 95: aload 7\n 97: invokeinterface #96, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 102: aload 7\n 104: invokeinterface #87, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 109: invokevirtual #114 // Method java/util/LinkedHashMap.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 112: pop\n 113: goto 39\n 116: aload 5\n 118: checkcast #62 // class java/util/Map\n 121: astore_3\n 122: nop\n 123: iconst_0\n 124: istore 4\n 126: aload_3\n 127: invokeinterface #66, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 132: invokeinterface #72, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 137: astore 5\n 139: aload 5\n 141: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 146: ifeq 416\n 149: aload 5\n 151: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 156: checkcast #84 // class java/util/Map$Entry\n 159: astore 6\n 161: aload 6\n 163: astore 7\n 165: iconst_0\n 166: istore 8\n 168: aload 7\n 170: invokeinterface #96, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 175: checkcast #113 // class Point\n 178: astore 9\n 180: aload 9\n 182: iconst_0\n 183: iconst_1\n 184: aconst_null\n 185: invokestatic #220 // Method Point.neighbours$default:(LPoint;ZILjava/lang/Object;)Ljava/util/List;\n 188: checkcast #105 // class java/lang/Iterable\n 191: astore 10\n 193: iconst_0\n 194: istore 11\n 196: aload 10\n 198: astore 12\n 200: new #120 // class java/util/ArrayList\n 203: dup\n 204: invokespecial #121 // Method java/util/ArrayList.\"<init>\":()V\n 207: checkcast #123 // class java/util/Collection\n 210: astore 13\n 212: iconst_0\n 213: istore 14\n 215: aload 12\n 217: invokeinterface #134, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 222: astore 15\n 224: aload 15\n 226: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 231: ifeq 326\n 234: aload 15\n 236: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 241: astore 16\n 243: aload 16\n 245: checkcast #113 // class Point\n 248: astore 17\n 250: iconst_0\n 251: istore 18\n 253: aload_0\n 254: aload 17\n 256: invokeinterface #224, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 261: ifnull 309\n 264: aload_0\n 265: aload 17\n 267: invokeinterface #224, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 272: dup\n 273: invokestatic #228 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 276: checkcast #89 // class java/lang/Character\n 279: invokevirtual #93 // Method java/lang/Character.charValue:()C\n 282: aload_0\n 283: aload 9\n 285: invokeinterface #224, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 290: dup\n 291: invokestatic #228 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 294: checkcast #89 // class java/lang/Character\n 297: invokevirtual #93 // Method java/lang/Character.charValue:()C\n 300: isub\n 301: iconst_1\n 302: if_icmpgt 309\n 305: iconst_1\n 306: goto 310\n 309: iconst_0\n 310: ifeq 224\n 313: aload 13\n 315: aload 16\n 317: invokeinterface #131, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 322: pop\n 323: goto 224\n 326: aload 13\n 328: checkcast #133 // class java/util/List\n 331: nop\n 332: checkcast #105 // class java/lang/Iterable\n 335: astore 10\n 337: nop\n 338: iconst_0\n 339: istore 11\n 341: aload 10\n 343: invokeinterface #134, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 348: astore 12\n 350: aload 12\n 352: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 357: ifeq 410\n 360: aload 12\n 362: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 367: astore 13\n 369: aload 13\n 371: checkcast #113 // class Point\n 374: astore 14\n 376: iconst_0\n 377: istore 15\n 379: aload_1\n 380: aload 14\n 382: invokeinterface #212, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 387: ifne 405\n 390: aload_1\n 391: aload 14\n 393: iload_2\n 394: iconst_1\n 395: iadd\n 396: invokestatic #190 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 399: invokeinterface #100, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 404: pop\n 405: nop\n 406: nop\n 407: goto 350\n 410: nop\n 411: nop\n 412: nop\n 413: goto 139\n 416: nop\n 417: iload_2\n 418: iconst_1\n 419: iadd\n 420: ireturn\n\n public static final java.util.Map<Point, java.lang.Character> parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #51 // String <this>\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #57 // class java/util/LinkedHashMap\n 9: dup\n 10: invokespecial #60 // Method java/util/LinkedHashMap.\"<init>\":()V\n 13: checkcast #62 // class java/util/Map\n 16: astore_1\n 17: aload_0\n 18: checkcast #105 // class java/lang/Iterable\n 21: astore_2\n 22: iconst_0\n 23: istore_3\n 24: iconst_0\n 25: istore 4\n 27: aload_2\n 28: invokeinterface #134, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 33: astore 5\n 35: aload 5\n 37: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 42: ifeq 177\n 45: aload 5\n 47: invokeinterface #82, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 52: astore 6\n 54: iload 4\n 56: iinc 4, 1\n 59: istore 7\n 61: iload 7\n 63: ifge 69\n 66: invokestatic #241 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 69: iload 7\n 71: aload 6\n 73: checkcast #243 // class java/lang/String\n 76: astore 8\n 78: istore 9\n 80: iconst_0\n 81: istore 10\n 83: aload 8\n 85: checkcast #245 // class java/lang/CharSequence\n 88: astore 11\n 90: iconst_0\n 91: istore 12\n 93: iconst_0\n 94: istore 13\n 96: iconst_0\n 97: istore 14\n 99: iload 14\n 101: aload 11\n 103: invokeinterface #248, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 108: if_icmpge 171\n 111: aload 11\n 113: iload 14\n 115: invokeinterface #252, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 120: istore 15\n 122: iload 13\n 124: iinc 13, 1\n 127: iload 15\n 129: istore 16\n 131: istore 17\n 133: iconst_0\n 134: istore 18\n 136: iload 16\n 138: invokestatic #118 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 141: astore 19\n 143: aload_1\n 144: new #113 // class Point\n 147: dup\n 148: iload 17\n 150: iload 9\n 152: invokespecial #255 // Method Point.\"<init>\":(II)V\n 155: aload 19\n 157: invokeinterface #100, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 162: pop\n 163: nop\n 164: nop\n 165: iinc 14, 1\n 168: goto 99\n 171: nop\n 172: nop\n 173: nop\n 174: goto 35\n 177: nop\n 178: aload_1\n 179: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #272 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day15/day15.kt
package day15 import Point import day15.CavePoint.Sensor import kotlin.math.abs import readInput import union val regex = """.+x=(-?\d+).*y=(-?\d+):.*x=(-?\d+).*y=(-?\d+)""".toRegex() const val prd_row = 2_000_000 const val test_row = 10 val prd_range = 0..4000000 val test_range = 0..20 typealias Cave = MutableSet<CavePoint> sealed class CavePoint(open val location: Point) { data class BeaconExcluded(override val location: Point) : CavePoint(location) data class Sensor(override val location: Point, val beacon: Point) : CavePoint(beacon) { val beaconDistance get() = location.distanceTo(beacon) } override fun equals(other: Any?): Boolean { return if (other is CavePoint) location == other.location else false } override fun hashCode(): Int { return location.hashCode() } } fun main() { val input = readInput("main/day15/Day15_test") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int { val cave = input.parse() val row = if (input.size < 20) test_row else prd_row cave.markNoBeaconArea(row) val beaconLocations = cave.filterIsInstance<Sensor>().map { it.beacon }.toSet() return cave.count { it.location.y == row && it.location !in beaconLocations } } fun part2(input: List<String>): Long { val cave = input.parse() val range = if (input.size > 20) prd_range else test_range range.forEach { row -> cave.lineRangesFor(row).reduce { acc, range -> (acc.union(range)) ?: return (acc.last + 1) * 4_000_000L + row } } return -1 } fun Cave.markNoBeaconArea(row: Int) { val sensors = filterIsInstance<Sensor>() sensors.forEach { sensor -> (sensor.location.x - sensor.beaconDistance..sensor.location.x + sensor.beaconDistance).forEach { x -> val candidate = Point(x, row) if (candidate.distanceTo(sensor.location) <= sensor.beaconDistance) add(CavePoint.BeaconExcluded(candidate)) } } } fun Cave.lineRangesFor(row: Int): List<IntRange> { return filterIsInstance<Sensor>().map { sensor -> val distance = sensor.beaconDistance - abs(row - sensor.location.y) sensor.location.x - distance..sensor.location.x + distance }.sortedBy { it.first } } fun List<String>.parse(): Cave = map { regex.matchEntire(it)?.destructured?.let { (sX, sY, bX, bY) -> Sensor(location = Point(x = sX.toInt(), y = sY.toInt()), beacon = Point(bX.toInt(), bY.toInt())) } ?: error("PARSER PROBLEM") }.toMutableSet()
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day15/Day15Kt.class", "javap": "Compiled from \"day15.kt\"\npublic final class day15.Day15Kt {\n private static final kotlin.text.Regex regex;\n\n public static final int prd_row;\n\n public static final int test_row;\n\n private static final kotlin.ranges.IntRange prd_range;\n\n private static final kotlin.ranges.IntRange test_range;\n\n public static final kotlin.text.Regex getRegex();\n Code:\n 0: getstatic #11 // Field regex:Lkotlin/text/Regex;\n 3: areturn\n\n public static final kotlin.ranges.IntRange getPrd_range();\n Code:\n 0: getstatic #17 // Field prd_range:Lkotlin/ranges/IntRange;\n 3: areturn\n\n public static final kotlin.ranges.IntRange getTest_range();\n Code:\n 0: getstatic #21 // Field test_range:Lkotlin/ranges/IntRange;\n 3: areturn\n\n public static final void main();\n Code:\n 0: ldc #25 // String main/day15/Day15_test\n 2: invokestatic #31 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #35 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #41 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #47 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #51 // Method part2:(Ljava/util/List;)J\n 22: lstore_1\n 23: getstatic #41 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: lload_1\n 27: invokevirtual #54 // Method java/io/PrintStream.println:(J)V\n 30: return\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #58 // String input\n 3: invokestatic #64 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #68 // Method parse:(Ljava/util/List;)Ljava/util/Set;\n 10: astore_1\n 11: aload_0\n 12: invokeinterface #74, 1 // InterfaceMethod java/util/List.size:()I\n 17: bipush 20\n 19: if_icmpge 27\n 22: bipush 10\n 24: goto 29\n 27: ldc #75 // int 2000000\n 29: istore_2\n 30: aload_1\n 31: iload_2\n 32: invokestatic #79 // Method markNoBeaconArea:(Ljava/util/Set;I)V\n 35: aload_1\n 36: checkcast #81 // class java/lang/Iterable\n 39: astore 4\n 41: iconst_0\n 42: istore 5\n 44: aload 4\n 46: astore 6\n 48: new #83 // class java/util/ArrayList\n 51: dup\n 52: invokespecial #86 // Method java/util/ArrayList.\"<init>\":()V\n 55: checkcast #88 // class java/util/Collection\n 58: astore 7\n 60: iconst_0\n 61: istore 8\n 63: aload 6\n 65: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 70: astore 9\n 72: aload 9\n 74: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 79: ifeq 112\n 82: aload 9\n 84: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 89: astore 10\n 91: aload 10\n 93: instanceof #104 // class day15/CavePoint$Sensor\n 96: ifeq 72\n 99: aload 7\n 101: aload 10\n 103: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 108: pop\n 109: goto 72\n 112: aload 7\n 114: checkcast #70 // class java/util/List\n 117: nop\n 118: checkcast #81 // class java/lang/Iterable\n 121: astore 4\n 123: nop\n 124: iconst_0\n 125: istore 5\n 127: aload 4\n 129: astore 6\n 131: new #83 // class java/util/ArrayList\n 134: dup\n 135: aload 4\n 137: bipush 10\n 139: invokestatic #114 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 142: invokespecial #116 // Method java/util/ArrayList.\"<init>\":(I)V\n 145: checkcast #88 // class java/util/Collection\n 148: astore 7\n 150: iconst_0\n 151: istore 8\n 153: aload 6\n 155: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 160: astore 9\n 162: aload 9\n 164: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 169: ifeq 212\n 172: aload 9\n 174: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 179: astore 10\n 181: aload 7\n 183: aload 10\n 185: checkcast #104 // class day15/CavePoint$Sensor\n 188: astore 11\n 190: astore 13\n 192: iconst_0\n 193: istore 12\n 195: aload 11\n 197: invokevirtual #120 // Method day15/CavePoint$Sensor.getBeacon:()LPoint;\n 200: aload 13\n 202: swap\n 203: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 208: pop\n 209: goto 162\n 212: aload 7\n 214: checkcast #70 // class java/util/List\n 217: nop\n 218: checkcast #81 // class java/lang/Iterable\n 221: invokestatic #124 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 224: astore_3\n 225: aload_1\n 226: checkcast #81 // class java/lang/Iterable\n 229: astore 4\n 231: iconst_0\n 232: istore 5\n 234: aload 4\n 236: instanceof #88 // class java/util/Collection\n 239: ifeq 259\n 242: aload 4\n 244: checkcast #88 // class java/util/Collection\n 247: invokeinterface #127, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 252: ifeq 259\n 255: iconst_0\n 256: goto 350\n 259: iconst_0\n 260: istore 6\n 262: aload 4\n 264: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 269: astore 7\n 271: aload 7\n 273: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 278: ifeq 348\n 281: aload 7\n 283: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 288: astore 8\n 290: aload 8\n 292: checkcast #129 // class day15/CavePoint\n 295: astore 9\n 297: iconst_0\n 298: istore 10\n 300: aload 9\n 302: invokevirtual #132 // Method day15/CavePoint.getLocation:()LPoint;\n 305: invokevirtual #137 // Method Point.getY:()I\n 308: iload_2\n 309: if_icmpne 330\n 312: aload_3\n 313: aload 9\n 315: invokevirtual #132 // Method day15/CavePoint.getLocation:()LPoint;\n 318: invokeinterface #142, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 323: ifne 330\n 326: iconst_1\n 327: goto 331\n 330: iconst_0\n 331: ifeq 271\n 334: iinc 6, 1\n 337: iload 6\n 339: ifge 271\n 342: invokestatic #145 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 345: goto 271\n 348: iload 6\n 350: ireturn\n\n public static final long part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #58 // String input\n 3: invokestatic #64 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #68 // Method parse:(Ljava/util/List;)Ljava/util/Set;\n 10: astore_1\n 11: aload_0\n 12: invokeinterface #74, 1 // InterfaceMethod java/util/List.size:()I\n 17: bipush 20\n 19: if_icmple 28\n 22: getstatic #17 // Field prd_range:Lkotlin/ranges/IntRange;\n 25: goto 31\n 28: getstatic #21 // Field test_range:Lkotlin/ranges/IntRange;\n 31: astore_2\n 32: aload_2\n 33: checkcast #81 // class java/lang/Iterable\n 36: astore_3\n 37: iconst_0\n 38: istore 4\n 40: aload_3\n 41: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 46: astore 5\n 48: aload 5\n 50: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 55: ifeq 199\n 58: aload 5\n 60: checkcast #176 // class kotlin/collections/IntIterator\n 63: invokevirtual #179 // Method kotlin/collections/IntIterator.nextInt:()I\n 66: istore 6\n 68: iload 6\n 70: istore 7\n 72: iconst_0\n 73: istore 8\n 75: aload_1\n 76: iload 7\n 78: invokestatic #183 // Method lineRangesFor:(Ljava/util/Set;I)Ljava/util/List;\n 81: checkcast #81 // class java/lang/Iterable\n 84: astore 9\n 86: iconst_0\n 87: istore 10\n 89: aload 9\n 91: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 96: astore 11\n 98: aload 11\n 100: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 105: ifne 118\n 108: new #185 // class java/lang/UnsupportedOperationException\n 111: dup\n 112: ldc #187 // String Empty collection can\\'t be reduced.\n 114: invokespecial #190 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 117: athrow\n 118: aload 11\n 120: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 125: astore 12\n 127: aload 11\n 129: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 134: ifeq 193\n 137: aload 12\n 139: aload 11\n 141: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 146: checkcast #192 // class kotlin/ranges/IntRange\n 149: astore 13\n 151: checkcast #192 // class kotlin/ranges/IntRange\n 154: astore 14\n 156: iconst_0\n 157: istore 15\n 159: aload 14\n 161: aload 13\n 163: invokestatic #196 // Method UtilsKt.union:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Lkotlin/ranges/IntRange;\n 166: dup\n 167: ifnonnull 188\n 170: pop\n 171: aload 14\n 173: invokevirtual #199 // Method kotlin/ranges/IntRange.getLast:()I\n 176: iconst_1\n 177: iadd\n 178: i2l\n 179: ldc2_w #200 // long 4000000l\n 182: lmul\n 183: iload 7\n 185: i2l\n 186: ladd\n 187: lreturn\n 188: astore 12\n 190: goto 127\n 193: nop\n 194: nop\n 195: nop\n 196: goto 48\n 199: nop\n 200: ldc2_w #202 // long -1l\n 203: lreturn\n\n public static final void markNoBeaconArea(java.util.Set<day15.CavePoint>, int);\n Code:\n 0: aload_0\n 1: ldc #217 // String <this>\n 3: invokestatic #64 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #81 // class java/lang/Iterable\n 10: astore_3\n 11: iconst_0\n 12: istore 4\n 14: aload_3\n 15: astore 5\n 17: new #83 // class java/util/ArrayList\n 20: dup\n 21: invokespecial #86 // Method java/util/ArrayList.\"<init>\":()V\n 24: checkcast #88 // class java/util/Collection\n 27: astore 6\n 29: iconst_0\n 30: istore 7\n 32: aload 5\n 34: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 8\n 41: aload 8\n 43: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 81\n 51: aload 8\n 53: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 9\n 60: aload 9\n 62: instanceof #104 // class day15/CavePoint$Sensor\n 65: ifeq 41\n 68: aload 6\n 70: aload 9\n 72: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 77: pop\n 78: goto 41\n 81: aload 6\n 83: checkcast #70 // class java/util/List\n 86: nop\n 87: astore_2\n 88: aload_2\n 89: checkcast #81 // class java/lang/Iterable\n 92: astore_3\n 93: iconst_0\n 94: istore 4\n 96: aload_3\n 97: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 102: astore 5\n 104: aload 5\n 106: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 111: ifeq 269\n 114: aload 5\n 116: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 121: astore 6\n 123: aload 6\n 125: checkcast #104 // class day15/CavePoint$Sensor\n 128: astore 7\n 130: iconst_0\n 131: istore 8\n 133: new #192 // class kotlin/ranges/IntRange\n 136: dup\n 137: aload 7\n 139: invokevirtual #218 // Method day15/CavePoint$Sensor.getLocation:()LPoint;\n 142: invokevirtual #221 // Method Point.getX:()I\n 145: aload 7\n 147: invokevirtual #224 // Method day15/CavePoint$Sensor.getBeaconDistance:()I\n 150: isub\n 151: aload 7\n 153: invokevirtual #218 // Method day15/CavePoint$Sensor.getLocation:()LPoint;\n 156: invokevirtual #221 // Method Point.getX:()I\n 159: aload 7\n 161: invokevirtual #224 // Method day15/CavePoint$Sensor.getBeaconDistance:()I\n 164: iadd\n 165: invokespecial #227 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 168: checkcast #81 // class java/lang/Iterable\n 171: astore 9\n 173: iconst_0\n 174: istore 10\n 176: aload 9\n 178: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 183: astore 11\n 185: aload 11\n 187: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 192: ifeq 263\n 195: aload 11\n 197: checkcast #176 // class kotlin/collections/IntIterator\n 200: invokevirtual #179 // Method kotlin/collections/IntIterator.nextInt:()I\n 203: istore 12\n 205: iload 12\n 207: istore 13\n 209: iconst_0\n 210: istore 14\n 212: new #134 // class Point\n 215: dup\n 216: iload 13\n 218: iload_1\n 219: invokespecial #228 // Method Point.\"<init>\":(II)V\n 222: astore 15\n 224: aload 15\n 226: aload 7\n 228: invokevirtual #218 // Method day15/CavePoint$Sensor.getLocation:()LPoint;\n 231: invokevirtual #232 // Method Point.distanceTo:(LPoint;)I\n 234: aload 7\n 236: invokevirtual #224 // Method day15/CavePoint$Sensor.getBeaconDistance:()I\n 239: if_icmpgt 258\n 242: aload_0\n 243: new #234 // class day15/CavePoint$BeaconExcluded\n 246: dup\n 247: aload 15\n 249: invokespecial #237 // Method day15/CavePoint$BeaconExcluded.\"<init>\":(LPoint;)V\n 252: invokeinterface #238, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 257: pop\n 258: nop\n 259: nop\n 260: goto 185\n 263: nop\n 264: nop\n 265: nop\n 266: goto 104\n 269: nop\n 270: return\n\n public static final java.util.List<kotlin.ranges.IntRange> lineRangesFor(java.util.Set<day15.CavePoint>, int);\n Code:\n 0: aload_0\n 1: ldc #217 // String <this>\n 3: invokestatic #64 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #81 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #83 // class java/util/ArrayList\n 19: dup\n 20: invokespecial #86 // Method java/util/ArrayList.\"<init>\":()V\n 23: checkcast #88 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 80\n 50: aload 7\n 52: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 8\n 61: instanceof #104 // class day15/CavePoint$Sensor\n 64: ifeq 40\n 67: aload 5\n 69: aload 8\n 71: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 76: pop\n 77: goto 40\n 80: aload 5\n 82: checkcast #70 // class java/util/List\n 85: nop\n 86: checkcast #81 // class java/lang/Iterable\n 89: astore_2\n 90: nop\n 91: iconst_0\n 92: istore_3\n 93: aload_2\n 94: astore 4\n 96: new #83 // class java/util/ArrayList\n 99: dup\n 100: aload_2\n 101: bipush 10\n 103: invokestatic #114 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 106: invokespecial #116 // Method java/util/ArrayList.\"<init>\":(I)V\n 109: checkcast #88 // class java/util/Collection\n 112: astore 5\n 114: iconst_0\n 115: istore 6\n 117: aload 4\n 119: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 124: astore 7\n 126: aload 7\n 128: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 133: ifeq 221\n 136: aload 7\n 138: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 143: astore 8\n 145: aload 5\n 147: aload 8\n 149: checkcast #104 // class day15/CavePoint$Sensor\n 152: astore 9\n 154: astore 12\n 156: iconst_0\n 157: istore 10\n 159: aload 9\n 161: invokevirtual #224 // Method day15/CavePoint$Sensor.getBeaconDistance:()I\n 164: iload_1\n 165: aload 9\n 167: invokevirtual #218 // Method day15/CavePoint$Sensor.getLocation:()LPoint;\n 170: invokevirtual #137 // Method Point.getY:()I\n 173: isub\n 174: invokestatic #253 // Method java/lang/Math.abs:(I)I\n 177: isub\n 178: istore 11\n 180: new #192 // class kotlin/ranges/IntRange\n 183: dup\n 184: aload 9\n 186: invokevirtual #218 // Method day15/CavePoint$Sensor.getLocation:()LPoint;\n 189: invokevirtual #221 // Method Point.getX:()I\n 192: iload 11\n 194: isub\n 195: aload 9\n 197: invokevirtual #218 // Method day15/CavePoint$Sensor.getLocation:()LPoint;\n 200: invokevirtual #221 // Method Point.getX:()I\n 203: iload 11\n 205: iadd\n 206: invokespecial #227 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 209: aload 12\n 211: swap\n 212: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 217: pop\n 218: goto 126\n 221: aload 5\n 223: checkcast #70 // class java/util/List\n 226: nop\n 227: checkcast #81 // class java/lang/Iterable\n 230: astore_2\n 231: nop\n 232: iconst_0\n 233: istore_3\n 234: aload_2\n 235: new #255 // class day15/Day15Kt$lineRangesFor$$inlined$sortedBy$1\n 238: dup\n 239: invokespecial #256 // Method day15/Day15Kt$lineRangesFor$$inlined$sortedBy$1.\"<init>\":()V\n 242: checkcast #258 // class java/util/Comparator\n 245: invokestatic #262 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 248: areturn\n\n public static final java.util.Set<day15.CavePoint> parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #217 // String <this>\n 3: invokestatic #64 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #81 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: astore_3\n 15: new #83 // class java/util/ArrayList\n 18: dup\n 19: aload_1\n 20: bipush 10\n 22: invokestatic #114 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 25: invokespecial #116 // Method java/util/ArrayList.\"<init>\":(I)V\n 28: checkcast #88 // class java/util/Collection\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: aload_3\n 37: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 6\n 44: aload 6\n 46: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 262\n 54: aload 6\n 56: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 7\n 63: aload 4\n 65: aload 7\n 67: checkcast #270 // class java/lang/String\n 70: astore 8\n 72: astore 16\n 74: iconst_0\n 75: istore 9\n 77: getstatic #11 // Field regex:Lkotlin/text/Regex;\n 80: aload 8\n 82: checkcast #272 // class java/lang/CharSequence\n 85: invokevirtual #278 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 88: dup\n 89: ifnull 235\n 92: invokeinterface #284, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 97: dup\n 98: ifnull 235\n 101: astore 10\n 103: iconst_0\n 104: istore 11\n 106: aload 10\n 108: invokevirtual #290 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 111: invokeinterface #294, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 116: iconst_1\n 117: invokeinterface #298, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 122: checkcast #270 // class java/lang/String\n 125: astore 12\n 127: aload 10\n 129: invokevirtual #290 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 132: invokeinterface #294, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 137: iconst_2\n 138: invokeinterface #298, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 143: checkcast #270 // class java/lang/String\n 146: astore 13\n 148: aload 10\n 150: invokevirtual #290 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 153: invokeinterface #294, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 158: iconst_3\n 159: invokeinterface #298, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 164: checkcast #270 // class java/lang/String\n 167: astore 14\n 169: aload 10\n 171: invokevirtual #290 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 174: invokeinterface #294, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 179: iconst_4\n 180: invokeinterface #298, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 185: checkcast #270 // class java/lang/String\n 188: astore 15\n 190: new #104 // class day15/CavePoint$Sensor\n 193: dup\n 194: new #134 // class Point\n 197: dup\n 198: aload 12\n 200: invokestatic #304 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 203: aload 13\n 205: invokestatic #304 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 208: invokespecial #228 // Method Point.\"<init>\":(II)V\n 211: new #134 // class Point\n 214: dup\n 215: aload 14\n 217: invokestatic #304 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 220: aload 15\n 222: invokestatic #304 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 225: invokespecial #228 // Method Point.\"<init>\":(II)V\n 228: invokespecial #307 // Method day15/CavePoint$Sensor.\"<init>\":(LPoint;LPoint;)V\n 231: nop\n 232: goto 250\n 235: pop\n 236: new #309 // class java/lang/IllegalStateException\n 239: dup\n 240: ldc_w #311 // String PARSER PROBLEM\n 243: invokevirtual #315 // Method java/lang/Object.toString:()Ljava/lang/String;\n 246: invokespecial #316 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 249: athrow\n 250: aload 16\n 252: swap\n 253: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 258: pop\n 259: goto 44\n 262: aload 4\n 264: checkcast #70 // class java/util/List\n 267: nop\n 268: checkcast #81 // class java/lang/Iterable\n 271: invokestatic #319 // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 274: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #330 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: new #274 // class kotlin/text/Regex\n 3: dup\n 4: ldc_w #335 // String .+x=(-?\\\\d+).*y=(-?\\\\d+):.*x=(-?\\\\d+).*y=(-?\\\\d+)\n 7: invokespecial #336 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 10: putstatic #11 // Field regex:Lkotlin/text/Regex;\n 13: new #192 // class kotlin/ranges/IntRange\n 16: dup\n 17: iconst_0\n 18: ldc_w #337 // int 4000000\n 21: invokespecial #227 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 24: putstatic #17 // Field prd_range:Lkotlin/ranges/IntRange;\n 27: new #192 // class kotlin/ranges/IntRange\n 30: dup\n 31: iconst_0\n 32: bipush 20\n 34: invokespecial #227 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 37: putstatic #21 // Field test_range:Lkotlin/ranges/IntRange;\n 40: return\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day15/Day15Kt$lineRangesFor$$inlined$sortedBy$1.class", "javap": "Compiled from \"Comparisons.kt\"\npublic final class day15.Day15Kt$lineRangesFor$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public day15.Day15Kt$lineRangesFor$$inlined$sortedBy$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_1\n 1: checkcast #23 // class kotlin/ranges/IntRange\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method kotlin/ranges/IntRange.getFirst:()I\n 12: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 15: checkcast #35 // class java/lang/Comparable\n 18: aload_2\n 19: checkcast #23 // class kotlin/ranges/IntRange\n 22: astore_3\n 23: astore 5\n 25: iconst_0\n 26: istore 4\n 28: aload_3\n 29: invokevirtual #27 // Method kotlin/ranges/IntRange.getFirst:()I\n 32: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: aload 5\n 37: swap\n 38: checkcast #35 // class java/lang/Comparable\n 41: invokestatic #41 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 44: ireturn\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day14/day14.kt
package day14 import kotlin.math.max import kotlin.math.min import readInput private typealias Cave = MutableSet<Point> private typealias Rock = Point private typealias Grain = Point private data class Point(val x: Int, val y: Int) private val source = Point(500, 0) fun main() { val input = readInput("main/day14/Day14_test") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int { val cave = input.parseTosSolidRock() return cave.pourSand() } fun part2(input: List<String>): Int { val cave = input.parseTosSolidRock() val maxX = cave.maxOf { it.x } //.also { println("max x: $it") } val minX = cave.minOf { it.x } //.also { println("min x: $it") } val floorY = cave.maxOf { it.y } + 2 cave.addRock(Point(minX - 1500, floorY), Point(maxX + 1500, floorY)) return cave.pourSand() } private fun Cave.pourSand(): Int { val startSize = size do { val droppedGrain = source.fall(this) if (droppedGrain != null) add(droppedGrain) if (size % 1000 == 0) println(size) } while (droppedGrain != null) return size - startSize } private fun Grain.fall(cave: Cave): Grain? { if (cave.contains(source)) return null if (down().y > cave.maxOf { it.y }) return null if (!cave.contains(down())) return down().fall(cave) if (!cave.contains(downLeft())) return downLeft().fall(cave) if (!cave.contains(downRight())) return downRight().fall(cave) return this } private fun Cave.addRock(start: Point, end: Point) { val startX = min(start.x, end.x) val startY = min(start.y, end.y) val endX = max(start.x, end.x) val endY = max(start.y, end.y) (startX..endX).forEach { x -> (startY..endY).forEach { y -> add(Rock(x, y)) } } } private fun List<String>.parseTosSolidRock(): Cave { val cave = mutableSetOf<Point>() map { line -> line.split(" -> ") .map { it.split(", ") } .windowed(2) { (start, end) -> cave.addRock( rock(start.first()), rock(end.first()) ) } } return cave } private fun rock(point: String): Rock { return point.split(",").map { it.toInt() }.let { (x, y) -> Point(x, y) } } private fun Grain.down() = copy(y = y + 1) private fun Grain.downLeft() = copy(x = x - 1, y = y + 1) private fun Grain.downRight() = copy(x = x + 1, y = y + 1)
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day14/Day14Kt.class", "javap": "Compiled from \"day14.kt\"\npublic final class day14.Day14Kt {\n private static final day14.Point source;\n\n public static final void main();\n Code:\n 0: ldc #8 // String main/day14/Day14_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #33 // Method part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #48 // Method parseTosSolidRock:(Ljava/util/List;)Ljava/util/Set;\n 10: astore_1\n 11: aload_1\n 12: invokestatic #52 // Method pourSand:(Ljava/util/Set;)I\n 15: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #48 // Method parseTosSolidRock:(Ljava/util/List;)Ljava/util/Set;\n 10: astore_1\n 11: aload_1\n 12: checkcast #56 // class java/lang/Iterable\n 15: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 20: astore 4\n 22: aload 4\n 24: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifne 40\n 32: new #68 // class java/util/NoSuchElementException\n 35: dup\n 36: invokespecial #71 // Method java/util/NoSuchElementException.\"<init>\":()V\n 39: athrow\n 40: aload 4\n 42: invokeinterface #75, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 47: checkcast #77 // class day14/Point\n 50: astore 5\n 52: iconst_0\n 53: istore 6\n 55: aload 5\n 57: invokevirtual #81 // Method day14/Point.getX:()I\n 60: istore 5\n 62: aload 4\n 64: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 69: ifeq 108\n 72: aload 4\n 74: invokeinterface #75, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 79: checkcast #77 // class day14/Point\n 82: astore 6\n 84: iconst_0\n 85: istore 7\n 87: aload 6\n 89: invokevirtual #81 // Method day14/Point.getX:()I\n 92: istore 6\n 94: iload 5\n 96: iload 6\n 98: if_icmpge 62\n 101: iload 6\n 103: istore 5\n 105: goto 62\n 108: iload 5\n 110: istore_2\n 111: aload_1\n 112: checkcast #56 // class java/lang/Iterable\n 115: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 120: astore 5\n 122: aload 5\n 124: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 129: ifne 140\n 132: new #68 // class java/util/NoSuchElementException\n 135: dup\n 136: invokespecial #71 // Method java/util/NoSuchElementException.\"<init>\":()V\n 139: athrow\n 140: aload 5\n 142: invokeinterface #75, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 147: checkcast #77 // class day14/Point\n 150: astore 6\n 152: iconst_0\n 153: istore 7\n 155: aload 6\n 157: invokevirtual #81 // Method day14/Point.getX:()I\n 160: istore 6\n 162: aload 5\n 164: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 169: ifeq 208\n 172: aload 5\n 174: invokeinterface #75, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 179: checkcast #77 // class day14/Point\n 182: astore 7\n 184: iconst_0\n 185: istore 8\n 187: aload 7\n 189: invokevirtual #81 // Method day14/Point.getX:()I\n 192: istore 7\n 194: iload 6\n 196: iload 7\n 198: if_icmple 162\n 201: iload 7\n 203: istore 6\n 205: goto 162\n 208: iload 6\n 210: istore_3\n 211: aload_1\n 212: checkcast #56 // class java/lang/Iterable\n 215: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 220: astore 6\n 222: aload 6\n 224: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 229: ifne 240\n 232: new #68 // class java/util/NoSuchElementException\n 235: dup\n 236: invokespecial #71 // Method java/util/NoSuchElementException.\"<init>\":()V\n 239: athrow\n 240: aload 6\n 242: invokeinterface #75, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 247: checkcast #77 // class day14/Point\n 250: astore 7\n 252: iconst_0\n 253: istore 8\n 255: aload 7\n 257: invokevirtual #84 // Method day14/Point.getY:()I\n 260: istore 7\n 262: aload 6\n 264: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 269: ifeq 308\n 272: aload 6\n 274: invokeinterface #75, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 279: checkcast #77 // class day14/Point\n 282: astore 8\n 284: iconst_0\n 285: istore 9\n 287: aload 8\n 289: invokevirtual #84 // Method day14/Point.getY:()I\n 292: istore 8\n 294: iload 7\n 296: iload 8\n 298: if_icmpge 262\n 301: iload 8\n 303: istore 7\n 305: goto 262\n 308: iload 7\n 310: iconst_2\n 311: iadd\n 312: istore 4\n 314: aload_1\n 315: new #77 // class day14/Point\n 318: dup\n 319: iload_3\n 320: sipush 1500\n 323: isub\n 324: iload 4\n 326: invokespecial #87 // Method day14/Point.\"<init>\":(II)V\n 329: new #77 // class day14/Point\n 332: dup\n 333: iload_2\n 334: sipush 1500\n 337: iadd\n 338: iload 4\n 340: invokespecial #87 // Method day14/Point.\"<init>\":(II)V\n 343: invokestatic #91 // Method addRock:(Ljava/util/Set;Lday14/Point;Lday14/Point;)V\n 346: aload_1\n 347: invokestatic #52 // Method pourSand:(Ljava/util/Set;)I\n 350: ireturn\n\n private static final int pourSand(java.util.Set<day14.Point>);\n Code:\n 0: aload_0\n 1: invokeinterface #108, 1 // InterfaceMethod java/util/Set.size:()I\n 6: istore_1\n 7: getstatic #111 // Field source:Lday14/Point;\n 10: aload_0\n 11: invokestatic #115 // Method fall:(Lday14/Point;Ljava/util/Set;)Lday14/Point;\n 14: astore_2\n 15: aload_2\n 16: ifnull 27\n 19: aload_0\n 20: aload_2\n 21: invokeinterface #119, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 26: pop\n 27: aload_0\n 28: invokeinterface #108, 1 // InterfaceMethod java/util/Set.size:()I\n 33: sipush 1000\n 36: irem\n 37: ifne 54\n 40: aload_0\n 41: invokeinterface #108, 1 // InterfaceMethod java/util/Set.size:()I\n 46: istore_3\n 47: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 50: iload_3\n 51: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 54: aload_2\n 55: ifnonnull 7\n 58: aload_0\n 59: invokeinterface #108, 1 // InterfaceMethod java/util/Set.size:()I\n 64: iload_1\n 65: isub\n 66: ireturn\n\n private static final day14.Point fall(day14.Point, java.util.Set<day14.Point>);\n Code:\n 0: aload_1\n 1: getstatic #111 // Field source:Lday14/Point;\n 4: invokeinterface #126, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 9: ifeq 14\n 12: aconst_null\n 13: areturn\n 14: aload_0\n 15: invokestatic #130 // Method down:(Lday14/Point;)Lday14/Point;\n 18: invokevirtual #84 // Method day14/Point.getY:()I\n 21: aload_1\n 22: checkcast #56 // class java/lang/Iterable\n 25: astore_2\n 26: istore 7\n 28: aload_2\n 29: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 34: astore_3\n 35: aload_3\n 36: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifne 52\n 44: new #68 // class java/util/NoSuchElementException\n 47: dup\n 48: invokespecial #71 // Method java/util/NoSuchElementException.\"<init>\":()V\n 51: athrow\n 52: aload_3\n 53: invokeinterface #75, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: checkcast #77 // class day14/Point\n 61: astore 4\n 63: iconst_0\n 64: istore 5\n 66: aload 4\n 68: invokevirtual #84 // Method day14/Point.getY:()I\n 71: istore 4\n 73: aload_3\n 74: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 79: ifeq 117\n 82: aload_3\n 83: invokeinterface #75, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 88: checkcast #77 // class day14/Point\n 91: astore 5\n 93: iconst_0\n 94: istore 6\n 96: aload 5\n 98: invokevirtual #84 // Method day14/Point.getY:()I\n 101: istore 5\n 103: iload 4\n 105: iload 5\n 107: if_icmpge 73\n 110: iload 5\n 112: istore 4\n 114: goto 73\n 117: iload 4\n 119: istore 8\n 121: iload 7\n 123: iload 8\n 125: if_icmple 130\n 128: aconst_null\n 129: areturn\n 130: aload_1\n 131: aload_0\n 132: invokestatic #130 // Method down:(Lday14/Point;)Lday14/Point;\n 135: invokeinterface #126, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 140: ifne 152\n 143: aload_0\n 144: invokestatic #130 // Method down:(Lday14/Point;)Lday14/Point;\n 147: aload_1\n 148: invokestatic #115 // Method fall:(Lday14/Point;Ljava/util/Set;)Lday14/Point;\n 151: areturn\n 152: aload_1\n 153: aload_0\n 154: invokestatic #133 // Method downLeft:(Lday14/Point;)Lday14/Point;\n 157: invokeinterface #126, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 162: ifne 174\n 165: aload_0\n 166: invokestatic #133 // Method downLeft:(Lday14/Point;)Lday14/Point;\n 169: aload_1\n 170: invokestatic #115 // Method fall:(Lday14/Point;Ljava/util/Set;)Lday14/Point;\n 173: areturn\n 174: aload_1\n 175: aload_0\n 176: invokestatic #136 // Method downRight:(Lday14/Point;)Lday14/Point;\n 179: invokeinterface #126, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 184: ifne 196\n 187: aload_0\n 188: invokestatic #136 // Method downRight:(Lday14/Point;)Lday14/Point;\n 191: aload_1\n 192: invokestatic #115 // Method fall:(Lday14/Point;Ljava/util/Set;)Lday14/Point;\n 195: areturn\n 196: aload_0\n 197: areturn\n\n private static final void addRock(java.util.Set<day14.Point>, day14.Point, day14.Point);\n Code:\n 0: aload_1\n 1: invokevirtual #81 // Method day14/Point.getX:()I\n 4: aload_2\n 5: invokevirtual #81 // Method day14/Point.getX:()I\n 8: invokestatic #145 // Method java/lang/Math.min:(II)I\n 11: istore_3\n 12: aload_1\n 13: invokevirtual #84 // Method day14/Point.getY:()I\n 16: aload_2\n 17: invokevirtual #84 // Method day14/Point.getY:()I\n 20: invokestatic #145 // Method java/lang/Math.min:(II)I\n 23: istore 4\n 25: aload_1\n 26: invokevirtual #81 // Method day14/Point.getX:()I\n 29: aload_2\n 30: invokevirtual #81 // Method day14/Point.getX:()I\n 33: invokestatic #148 // Method java/lang/Math.max:(II)I\n 36: istore 5\n 38: aload_1\n 39: invokevirtual #84 // Method day14/Point.getY:()I\n 42: aload_2\n 43: invokevirtual #84 // Method day14/Point.getY:()I\n 46: invokestatic #148 // Method java/lang/Math.max:(II)I\n 49: istore 6\n 51: new #150 // class kotlin/ranges/IntRange\n 54: dup\n 55: iload_3\n 56: iload 5\n 58: invokespecial #151 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 61: checkcast #56 // class java/lang/Iterable\n 64: astore 7\n 66: iconst_0\n 67: istore 8\n 69: aload 7\n 71: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 76: astore 9\n 78: aload 9\n 80: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 85: ifeq 189\n 88: aload 9\n 90: checkcast #153 // class kotlin/collections/IntIterator\n 93: invokevirtual #156 // Method kotlin/collections/IntIterator.nextInt:()I\n 96: istore 10\n 98: iload 10\n 100: istore 11\n 102: iconst_0\n 103: istore 12\n 105: new #150 // class kotlin/ranges/IntRange\n 108: dup\n 109: iload 4\n 111: iload 6\n 113: invokespecial #151 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 116: checkcast #56 // class java/lang/Iterable\n 119: astore 13\n 121: iconst_0\n 122: istore 14\n 124: aload 13\n 126: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 131: astore 15\n 133: aload 15\n 135: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 140: ifeq 183\n 143: aload 15\n 145: checkcast #153 // class kotlin/collections/IntIterator\n 148: invokevirtual #156 // Method kotlin/collections/IntIterator.nextInt:()I\n 151: istore 16\n 153: iload 16\n 155: istore 17\n 157: iconst_0\n 158: istore 18\n 160: aload_0\n 161: new #77 // class day14/Point\n 164: dup\n 165: iload 11\n 167: iload 17\n 169: invokespecial #87 // Method day14/Point.\"<init>\":(II)V\n 172: invokeinterface #119, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 177: pop\n 178: nop\n 179: nop\n 180: goto 133\n 183: nop\n 184: nop\n 185: nop\n 186: goto 78\n 189: nop\n 190: return\n\n private static final java.util.Set<day14.Point> parseTosSolidRock(java.util.List<java.lang.String>);\n Code:\n 0: new #174 // class java/util/LinkedHashSet\n 3: dup\n 4: invokespecial #175 // Method java/util/LinkedHashSet.\"<init>\":()V\n 7: checkcast #104 // class java/util/Set\n 10: astore_1\n 11: aload_0\n 12: checkcast #56 // class java/lang/Iterable\n 15: astore_2\n 16: iconst_0\n 17: istore_3\n 18: aload_2\n 19: astore 4\n 21: new #177 // class java/util/ArrayList\n 24: dup\n 25: aload_2\n 26: bipush 10\n 28: invokestatic #183 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 31: invokespecial #185 // Method java/util/ArrayList.\"<init>\":(I)V\n 34: checkcast #187 // class java/util/Collection\n 37: astore 5\n 39: iconst_0\n 40: istore 6\n 42: aload 4\n 44: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 49: astore 7\n 51: aload 7\n 53: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 58: ifeq 264\n 61: aload 7\n 63: invokeinterface #75, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 68: astore 8\n 70: aload 5\n 72: aload 8\n 74: checkcast #189 // class java/lang/String\n 77: astore 9\n 79: astore 22\n 81: iconst_0\n 82: istore 10\n 84: aload 9\n 86: checkcast #191 // class java/lang/CharSequence\n 89: iconst_1\n 90: anewarray #189 // class java/lang/String\n 93: astore 11\n 95: aload 11\n 97: iconst_0\n 98: ldc #193 // String ->\n 100: aastore\n 101: aload 11\n 103: iconst_0\n 104: iconst_0\n 105: bipush 6\n 107: aconst_null\n 108: invokestatic #199 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 111: checkcast #56 // class java/lang/Iterable\n 114: astore 11\n 116: nop\n 117: iconst_0\n 118: istore 12\n 120: aload 11\n 122: astore 13\n 124: new #177 // class java/util/ArrayList\n 127: dup\n 128: aload 11\n 130: bipush 10\n 132: invokestatic #183 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 135: invokespecial #185 // Method java/util/ArrayList.\"<init>\":(I)V\n 138: checkcast #187 // class java/util/Collection\n 141: astore 14\n 143: iconst_0\n 144: istore 15\n 146: aload 13\n 148: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 153: astore 16\n 155: aload 16\n 157: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 162: ifeq 227\n 165: aload 16\n 167: invokeinterface #75, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 172: astore 17\n 174: aload 14\n 176: aload 17\n 178: checkcast #189 // class java/lang/String\n 181: astore 18\n 183: astore 19\n 185: iconst_0\n 186: istore 20\n 188: aload 18\n 190: checkcast #191 // class java/lang/CharSequence\n 193: iconst_1\n 194: anewarray #189 // class java/lang/String\n 197: astore 21\n 199: aload 21\n 201: iconst_0\n 202: ldc #201 // String ,\n 204: aastore\n 205: aload 21\n 207: iconst_0\n 208: iconst_0\n 209: bipush 6\n 211: aconst_null\n 212: invokestatic #199 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 215: aload 19\n 217: swap\n 218: invokeinterface #202, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 223: pop\n 224: goto 155\n 227: aload 14\n 229: checkcast #102 // class java/util/List\n 232: nop\n 233: checkcast #56 // class java/lang/Iterable\n 236: iconst_2\n 237: iconst_0\n 238: iconst_0\n 239: aload_1\n 240: invokedynamic #222, 0 // InvokeDynamic #0:invoke:(Ljava/util/Set;)Lkotlin/jvm/functions/Function1;\n 245: bipush 6\n 247: aconst_null\n 248: invokestatic #226 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/util/List;\n 251: nop\n 252: aload 22\n 254: swap\n 255: invokeinterface #202, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 260: pop\n 261: goto 51\n 264: aload 5\n 266: checkcast #102 // class java/util/List\n 269: nop\n 270: pop\n 271: aload_1\n 272: areturn\n\n private static final day14.Point rock(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #191 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #189 // class java/lang/String\n 8: astore_1\n 9: aload_1\n 10: iconst_0\n 11: ldc #243 // String ,\n 13: aastore\n 14: aload_1\n 15: iconst_0\n 16: iconst_0\n 17: bipush 6\n 19: aconst_null\n 20: invokestatic #199 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: checkcast #56 // class java/lang/Iterable\n 26: astore_1\n 27: iconst_0\n 28: istore_2\n 29: aload_1\n 30: astore_3\n 31: new #177 // class java/util/ArrayList\n 34: dup\n 35: aload_1\n 36: bipush 10\n 38: invokestatic #183 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 41: invokespecial #185 // Method java/util/ArrayList.\"<init>\":(I)V\n 44: checkcast #187 // class java/util/Collection\n 47: astore 4\n 49: iconst_0\n 50: istore 5\n 52: aload_3\n 53: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 58: astore 6\n 60: aload 6\n 62: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 67: ifeq 114\n 70: aload 6\n 72: invokeinterface #75, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 77: astore 7\n 79: aload 4\n 81: aload 7\n 83: checkcast #189 // class java/lang/String\n 86: astore 8\n 88: astore 10\n 90: iconst_0\n 91: istore 9\n 93: aload 8\n 95: invokestatic #249 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 98: nop\n 99: invokestatic #253 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 102: aload 10\n 104: swap\n 105: invokeinterface #202, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 110: pop\n 111: goto 60\n 114: aload 4\n 116: checkcast #102 // class java/util/List\n 119: nop\n 120: astore_2\n 121: iconst_0\n 122: istore_3\n 123: aload_2\n 124: iconst_0\n 125: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 130: checkcast #259 // class java/lang/Number\n 133: invokevirtual #262 // Method java/lang/Number.intValue:()I\n 136: istore 4\n 138: aload_2\n 139: iconst_1\n 140: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 145: checkcast #259 // class java/lang/Number\n 148: invokevirtual #262 // Method java/lang/Number.intValue:()I\n 151: istore 5\n 153: new #77 // class day14/Point\n 156: dup\n 157: iload 4\n 159: iload 5\n 161: invokespecial #87 // Method day14/Point.\"<init>\":(II)V\n 164: nop\n 165: areturn\n\n private static final day14.Point down(day14.Point);\n Code:\n 0: aload_0\n 1: iconst_0\n 2: aload_0\n 3: invokevirtual #84 // Method day14/Point.getY:()I\n 6: iconst_1\n 7: iadd\n 8: iconst_1\n 9: aconst_null\n 10: invokestatic #269 // Method day14/Point.copy$default:(Lday14/Point;IIILjava/lang/Object;)Lday14/Point;\n 13: areturn\n\n private static final day14.Point downLeft(day14.Point);\n Code:\n 0: aload_0\n 1: aload_0\n 2: invokevirtual #81 // Method day14/Point.getX:()I\n 5: iconst_1\n 6: isub\n 7: aload_0\n 8: invokevirtual #84 // Method day14/Point.getY:()I\n 11: iconst_1\n 12: iadd\n 13: invokevirtual #274 // Method day14/Point.copy:(II)Lday14/Point;\n 16: areturn\n\n private static final day14.Point downRight(day14.Point);\n Code:\n 0: aload_0\n 1: aload_0\n 2: invokevirtual #81 // Method day14/Point.getX:()I\n 5: iconst_1\n 6: iadd\n 7: aload_0\n 8: invokevirtual #84 // Method day14/Point.getY:()I\n 11: iconst_1\n 12: iadd\n 13: invokevirtual #274 // Method day14/Point.copy:(II)Lday14/Point;\n 16: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #279 // Method main:()V\n 3: return\n\n private static final kotlin.Unit parseTosSolidRock$lambda$8$lambda$7(java.util.Set, java.util.List);\n Code:\n 0: aload_1\n 1: ldc_w #283 // String <destruct>\n 4: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: iconst_0\n 9: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 14: checkcast #102 // class java/util/List\n 17: astore_2\n 18: aload_1\n 19: iconst_1\n 20: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 25: checkcast #102 // class java/util/List\n 28: astore_3\n 29: aload_0\n 30: aload_2\n 31: invokestatic #287 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 34: checkcast #189 // class java/lang/String\n 37: invokestatic #289 // Method rock:(Ljava/lang/String;)Lday14/Point;\n 40: aload_3\n 41: invokestatic #287 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 44: checkcast #189 // class java/lang/String\n 47: invokestatic #289 // Method rock:(Ljava/lang/String;)Lday14/Point;\n 50: invokestatic #91 // Method addRock:(Ljava/util/Set;Lday14/Point;Lday14/Point;)V\n 53: getstatic #295 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 56: areturn\n\n static {};\n Code:\n 0: new #77 // class day14/Point\n 3: dup\n 4: sipush 500\n 7: iconst_0\n 8: invokespecial #87 // Method day14/Point.\"<init>\":(II)V\n 11: putstatic #111 // Field source:Lday14/Point;\n 14: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day13/day13.kt
package day13 import java.util.* import readInput import second sealed interface Packet : Comparable<Packet> { data class ListPacket(val packets: MutableList<Packet> = mutableListOf()) : Packet { override fun compareTo(other: Packet): Int { return when (other) { is IntPacket -> this.compareTo(other.toListPacket()) is ListPacket -> packets.compareTo(other.packets) } } private fun Iterable<Packet>.compareTo(other: Iterable<Packet>): Int { val left = Stack<Packet>() this.reversed().forEach { left.push(it) } val right = Stack<Packet>() other.reversed().forEach { right.push(it) } while (left.isNotEmpty()) { val l = left.pop() val r = if (right.isNotEmpty()) right.pop() else return 1 val comp = l.compareTo(r) if (comp != 0) return comp } // left is empty is right also empty? return if (right.isEmpty()) 0 else -1 } } data class IntPacket(val value: Int) : Packet { override fun compareTo(other: Packet): Int { return when (other) { is ListPacket -> toListPacket().compareTo(other) is IntPacket -> value.compareTo(other.value) } } } fun toListPacket(): Packet = ListPacket(mutableListOf(this)) companion object { fun parse(input: String): Packet = toPacket( input.split("""((?<=[\[\],])|(?=[\[\],]))""".toRegex()) .filter { it.isNotBlank() } .filterNot { it == "," } .iterator() ) private fun toPacket(input: Iterator<String>): Packet { val packets = mutableListOf<Packet>() while (input.hasNext()) { when (val symbol = input.next()) { "]" -> return ListPacket(packets) "[" -> packets.add(toPacket(input)) else -> packets.add(IntPacket(symbol.toInt())) } } return ListPacket(packets) } } } fun main() { val input = readInput("main/day13/Day13") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int { val list = input.filter(String::isNotBlank).map { Packet.parse(it) }.chunked(2) return list.mapIndexed { index, signals -> if (signals.first() < signals.second()) index + 1 else 0 }.sum() } fun part2(input: List<String>): Int { val firstDivider = Packet.parse("[[2]]") val secondDivider = Packet.parse("[[6]]") val list = (input.filter(String::isNotBlank).map { Packet.parse(it) } + listOf(firstDivider, secondDivider)).sorted() return (list.indexOf(firstDivider) + 1) * (list.indexOf(secondDivider) + 1) }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day13/Day13Kt.class", "javap": "Compiled from \"day13.kt\"\npublic final class day13.Day13Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String main/day13/Day13\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #33 // Method part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #46 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #48 // class java/util/ArrayList\n 19: dup\n 20: invokespecial #51 // Method java/util/ArrayList.\"<init>\":()V\n 23: checkcast #53 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 102\n 50: aload 7\n 52: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 8\n 61: checkcast #69 // class java/lang/String\n 64: astore 9\n 66: iconst_0\n 67: istore 10\n 69: aload 9\n 71: checkcast #71 // class java/lang/CharSequence\n 74: invokestatic #77 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 77: ifne 84\n 80: iconst_1\n 81: goto 85\n 84: iconst_0\n 85: nop\n 86: ifeq 40\n 89: aload 5\n 91: aload 8\n 93: invokeinterface #81, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 98: pop\n 99: goto 40\n 102: aload 5\n 104: checkcast #83 // class java/util/List\n 107: nop\n 108: checkcast #46 // class java/lang/Iterable\n 111: astore_2\n 112: nop\n 113: iconst_0\n 114: istore_3\n 115: aload_2\n 116: astore 4\n 118: new #48 // class java/util/ArrayList\n 121: dup\n 122: aload_2\n 123: bipush 10\n 125: invokestatic #89 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 128: invokespecial #91 // Method java/util/ArrayList.\"<init>\":(I)V\n 131: checkcast #53 // class java/util/Collection\n 134: astore 5\n 136: iconst_0\n 137: istore 6\n 139: aload 4\n 141: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 146: astore 7\n 148: aload 7\n 150: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 155: ifeq 201\n 158: aload 7\n 160: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 165: astore 8\n 167: aload 5\n 169: aload 8\n 171: checkcast #69 // class java/lang/String\n 174: astore 9\n 176: astore 14\n 178: iconst_0\n 179: istore 10\n 181: getstatic #97 // Field day13/Packet.Companion:Lday13/Packet$Companion;\n 184: aload 9\n 186: invokevirtual #103 // Method day13/Packet$Companion.parse:(Ljava/lang/String;)Lday13/Packet;\n 189: aload 14\n 191: swap\n 192: invokeinterface #81, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 197: pop\n 198: goto 148\n 201: aload 5\n 203: checkcast #83 // class java/util/List\n 206: nop\n 207: checkcast #46 // class java/lang/Iterable\n 210: iconst_2\n 211: invokestatic #107 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 214: astore_1\n 215: aload_1\n 216: checkcast #46 // class java/lang/Iterable\n 219: astore_2\n 220: iconst_0\n 221: istore_3\n 222: aload_2\n 223: astore 4\n 225: new #48 // class java/util/ArrayList\n 228: dup\n 229: aload_2\n 230: bipush 10\n 232: invokestatic #89 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 235: invokespecial #91 // Method java/util/ArrayList.\"<init>\":(I)V\n 238: checkcast #53 // class java/util/Collection\n 241: astore 5\n 243: iconst_0\n 244: istore 6\n 246: iconst_0\n 247: istore 7\n 249: aload 4\n 251: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 256: astore 8\n 258: aload 8\n 260: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 265: ifeq 354\n 268: aload 8\n 270: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 275: astore 9\n 277: aload 5\n 279: iload 7\n 281: iinc 7, 1\n 284: istore 10\n 286: iload 10\n 288: ifge 294\n 291: invokestatic #110 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 294: iload 10\n 296: aload 9\n 298: checkcast #83 // class java/util/List\n 301: astore 11\n 303: istore 12\n 305: astore 14\n 307: iconst_0\n 308: istore 13\n 310: aload 11\n 312: invokestatic #114 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 315: checkcast #93 // class day13/Packet\n 318: aload 11\n 320: invokestatic #117 // Method UtilsKt.second:(Ljava/util/List;)Ljava/lang/Object;\n 323: invokeinterface #121, 2 // InterfaceMethod day13/Packet.compareTo:(Ljava/lang/Object;)I\n 328: ifge 338\n 331: iload 12\n 333: iconst_1\n 334: iadd\n 335: goto 339\n 338: iconst_0\n 339: invokestatic #127 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 342: aload 14\n 344: swap\n 345: invokeinterface #81, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 350: pop\n 351: goto 258\n 354: aload 5\n 356: checkcast #83 // class java/util/List\n 359: nop\n 360: checkcast #46 // class java/lang/Iterable\n 363: invokestatic #131 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 366: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #97 // Field day13/Packet.Companion:Lday13/Packet$Companion;\n 9: ldc #162 // String [[2]]\n 11: invokevirtual #103 // Method day13/Packet$Companion.parse:(Ljava/lang/String;)Lday13/Packet;\n 14: astore_1\n 15: getstatic #97 // Field day13/Packet.Companion:Lday13/Packet$Companion;\n 18: ldc #164 // String [[6]]\n 20: invokevirtual #103 // Method day13/Packet$Companion.parse:(Ljava/lang/String;)Lday13/Packet;\n 23: astore_2\n 24: aload_0\n 25: checkcast #46 // class java/lang/Iterable\n 28: astore 4\n 30: iconst_0\n 31: istore 5\n 33: aload 4\n 35: astore 6\n 37: new #48 // class java/util/ArrayList\n 40: dup\n 41: invokespecial #51 // Method java/util/ArrayList.\"<init>\":()V\n 44: checkcast #53 // class java/util/Collection\n 47: astore 7\n 49: iconst_0\n 50: istore 8\n 52: aload 6\n 54: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 59: astore 9\n 61: aload 9\n 63: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 68: ifeq 123\n 71: aload 9\n 73: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 78: astore 10\n 80: aload 10\n 82: checkcast #69 // class java/lang/String\n 85: astore 11\n 87: iconst_0\n 88: istore 12\n 90: aload 11\n 92: checkcast #71 // class java/lang/CharSequence\n 95: invokestatic #77 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 98: ifne 105\n 101: iconst_1\n 102: goto 106\n 105: iconst_0\n 106: nop\n 107: ifeq 61\n 110: aload 7\n 112: aload 10\n 114: invokeinterface #81, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 119: pop\n 120: goto 61\n 123: aload 7\n 125: checkcast #83 // class java/util/List\n 128: nop\n 129: checkcast #46 // class java/lang/Iterable\n 132: astore 4\n 134: nop\n 135: iconst_0\n 136: istore 5\n 138: aload 4\n 140: astore 6\n 142: new #48 // class java/util/ArrayList\n 145: dup\n 146: aload 4\n 148: bipush 10\n 150: invokestatic #89 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 153: invokespecial #91 // Method java/util/ArrayList.\"<init>\":(I)V\n 156: checkcast #53 // class java/util/Collection\n 159: astore 7\n 161: iconst_0\n 162: istore 8\n 164: aload 6\n 166: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 171: astore 9\n 173: aload 9\n 175: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 180: ifeq 226\n 183: aload 9\n 185: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 190: astore 10\n 192: aload 7\n 194: aload 10\n 196: checkcast #69 // class java/lang/String\n 199: astore 11\n 201: astore 13\n 203: iconst_0\n 204: istore 12\n 206: getstatic #97 // Field day13/Packet.Companion:Lday13/Packet$Companion;\n 209: aload 11\n 211: invokevirtual #103 // Method day13/Packet$Companion.parse:(Ljava/lang/String;)Lday13/Packet;\n 214: aload 13\n 216: swap\n 217: invokeinterface #81, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 222: pop\n 223: goto 173\n 226: aload 7\n 228: checkcast #83 // class java/util/List\n 231: nop\n 232: checkcast #53 // class java/util/Collection\n 235: iconst_2\n 236: anewarray #93 // class day13/Packet\n 239: astore 4\n 241: aload 4\n 243: iconst_0\n 244: aload_1\n 245: aastore\n 246: aload 4\n 248: iconst_1\n 249: aload_2\n 250: aastore\n 251: aload 4\n 253: invokestatic #168 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 256: checkcast #46 // class java/lang/Iterable\n 259: invokestatic #172 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 262: checkcast #46 // class java/lang/Iterable\n 265: invokestatic #176 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 268: astore_3\n 269: aload_3\n 270: aload_1\n 271: invokeinterface #179, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 276: iconst_1\n 277: iadd\n 278: aload_3\n 279: aload_2\n 280: invokeinterface #179, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 285: iconst_1\n 286: iadd\n 287: imul\n 288: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #187 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day25/day25.kt
package day25 import kotlin.math.pow import kotlin.math.roundToLong import readInput val UNSNAFU = mapOf( "=" to -2.0, "-" to -1.0, "0" to 0.0, "1" to 1.0, "2" to 2.0, ) fun main() { val input = readInput("main/day25/Day25") println(part1(input)) } fun part1(input: List<String>): String { val numbers = input.associateBy { it.unsnafucate() } return numbers.keys.sum().snafucate() } fun Long.snafucate(): String { return generateSequence(this) { (it + 2) / 5 } .takeWhile { it != 0L }.toList() .map { "012=-"[(it % 5).toInt()] } .joinToString("").reversed() } fun String.unsnafucate(): Long { return indices.sumOf { (5.0.pow(it) * UNSNAFU[this[length - it - 1].toString()]!!.toLong()).roundToLong() } }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day25/Day25Kt.class", "javap": "Compiled from \"day25.kt\"\npublic final class day25.Day25Kt {\n private static final java.util.Map<java.lang.String, java.lang.Double> UNSNAFU;\n\n public static final java.util.Map<java.lang.String, java.lang.Double> getUNSNAFU();\n Code:\n 0: getstatic #12 // Field UNSNAFU:Ljava/util/Map;\n 3: areturn\n\n public static final void main();\n Code:\n 0: ldc #16 // String main/day25/Day25\n 2: invokestatic #22 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #26 // Method part1:(Ljava/util/List;)Ljava/lang/String;\n 10: getstatic #32 // Field java/lang/System.out:Ljava/io/PrintStream;\n 13: swap\n 14: invokevirtual #38 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 17: return\n\n public static final java.lang.String part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #42 // String input\n 3: invokestatic #48 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #50 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: bipush 10\n 16: invokestatic #56 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokestatic #62 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 22: bipush 16\n 24: invokestatic #68 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 27: istore 4\n 29: aload_2\n 30: astore 5\n 32: new #70 // class java/util/LinkedHashMap\n 35: dup\n 36: iload 4\n 38: invokespecial #74 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 41: checkcast #76 // class java/util/Map\n 44: astore 6\n 46: iconst_0\n 47: istore 7\n 49: aload 5\n 51: invokeinterface #80, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 56: astore 8\n 58: aload 8\n 60: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 65: ifeq 113\n 68: aload 8\n 70: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 75: astore 9\n 77: aload 6\n 79: aload 9\n 81: checkcast #92 // class java/lang/String\n 84: astore 10\n 86: astore 12\n 88: iconst_0\n 89: istore 11\n 91: aload 10\n 93: invokestatic #96 // Method unsnafucate:(Ljava/lang/String;)J\n 96: invokestatic #102 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 99: aload 12\n 101: swap\n 102: aload 9\n 104: invokeinterface #106, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 109: pop\n 110: goto 58\n 113: aload 6\n 115: nop\n 116: astore_1\n 117: aload_1\n 118: invokeinterface #110, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 123: checkcast #50 // class java/lang/Iterable\n 126: invokestatic #114 // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J\n 129: invokestatic #118 // Method snafucate:(J)Ljava/lang/String;\n 132: areturn\n\n public static final java.lang.String snafucate(long);\n Code:\n 0: lload_0\n 1: invokestatic #102 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 4: invokedynamic #153, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 9: invokestatic #159 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 12: invokedynamic #167, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 17: invokestatic #171 // Method kotlin/sequences/SequencesKt.takeWhile:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 20: invokestatic #175 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 23: checkcast #50 // class java/lang/Iterable\n 26: astore_2\n 27: nop\n 28: iconst_0\n 29: istore_3\n 30: aload_2\n 31: astore 4\n 33: new #177 // class java/util/ArrayList\n 36: dup\n 37: aload_2\n 38: bipush 10\n 40: invokestatic #56 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 43: invokespecial #178 // Method java/util/ArrayList.\"<init>\":(I)V\n 46: checkcast #180 // class java/util/Collection\n 49: astore 5\n 51: iconst_0\n 52: istore 6\n 54: aload 4\n 56: invokeinterface #80, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 61: astore 7\n 63: aload 7\n 65: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 70: ifeq 125\n 73: aload 7\n 75: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 80: astore 8\n 82: aload 5\n 84: aload 8\n 86: checkcast #182 // class java/lang/Number\n 89: invokevirtual #186 // Method java/lang/Number.longValue:()J\n 92: lstore 9\n 94: astore 12\n 96: iconst_0\n 97: istore 11\n 99: ldc #188 // String 012=-\n 101: lload 9\n 103: iconst_5\n 104: i2l\n 105: lrem\n 106: l2i\n 107: invokevirtual #192 // Method java/lang/String.charAt:(I)C\n 110: invokestatic #197 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 113: aload 12\n 115: swap\n 116: invokeinterface #201, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 121: pop\n 122: goto 63\n 125: aload 5\n 127: checkcast #134 // class java/util/List\n 130: nop\n 131: checkcast #50 // class java/lang/Iterable\n 134: ldc #203 // String\n 136: checkcast #205 // class java/lang/CharSequence\n 139: aconst_null\n 140: aconst_null\n 141: iconst_0\n 142: aconst_null\n 143: aconst_null\n 144: bipush 62\n 146: aconst_null\n 147: invokestatic #209 // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;\n 150: checkcast #205 // class java/lang/CharSequence\n 153: invokestatic #215 // Method kotlin/text/StringsKt.reversed:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 156: invokevirtual #219 // Method java/lang/Object.toString:()Ljava/lang/String;\n 159: areturn\n\n public static final long unsnafucate(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #230 // String <this>\n 3: invokestatic #48 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #205 // class java/lang/CharSequence\n 10: invokestatic #234 // Method kotlin/text/StringsKt.getIndices:(Ljava/lang/CharSequence;)Lkotlin/ranges/IntRange;\n 13: checkcast #50 // class java/lang/Iterable\n 16: astore_1\n 17: lconst_0\n 18: lstore_2\n 19: aload_1\n 20: invokeinterface #80, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 25: astore 4\n 27: aload 4\n 29: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 34: ifeq 117\n 37: aload 4\n 39: checkcast #236 // class kotlin/collections/IntIterator\n 42: invokevirtual #240 // Method kotlin/collections/IntIterator.nextInt:()I\n 45: istore 5\n 47: lload_2\n 48: iload 5\n 50: istore 6\n 52: lstore 8\n 54: iconst_0\n 55: istore 7\n 57: ldc2_w #241 // double 5.0d\n 60: iload 6\n 62: i2d\n 63: invokestatic #248 // Method java/lang/Math.pow:(DD)D\n 66: getstatic #12 // Field UNSNAFU:Ljava/util/Map;\n 69: aload_0\n 70: aload_0\n 71: invokevirtual #251 // Method java/lang/String.length:()I\n 74: iload 6\n 76: isub\n 77: iconst_1\n 78: isub\n 79: invokevirtual #192 // Method java/lang/String.charAt:(I)C\n 82: invokestatic #254 // Method java/lang/String.valueOf:(C)Ljava/lang/String;\n 85: invokeinterface #257, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 90: dup\n 91: invokestatic #260 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 94: checkcast #182 // class java/lang/Number\n 97: invokevirtual #264 // Method java/lang/Number.doubleValue:()D\n 100: d2l\n 101: l2d\n 102: dmul\n 103: invokestatic #270 // Method kotlin/math/MathKt.roundToLong:(D)J\n 106: lstore 10\n 108: lload 8\n 110: lload 10\n 112: ladd\n 113: lstore_2\n 114: goto 27\n 117: lload_2\n 118: lreturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #275 // Method main:()V\n 3: return\n\n private static final java.lang.Long snafucate$lambda$1(long);\n Code:\n 0: lload_0\n 1: iconst_2\n 2: i2l\n 3: ladd\n 4: iconst_5\n 5: i2l\n 6: ldiv\n 7: invokestatic #102 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 10: areturn\n\n private static final boolean snafucate$lambda$2(long);\n Code:\n 0: lload_0\n 1: lconst_0\n 2: lcmp\n 3: ifeq 10\n 6: iconst_1\n 7: goto 11\n 10: iconst_0\n 11: ireturn\n\n static {};\n Code:\n 0: iconst_5\n 1: anewarray #280 // class kotlin/Pair\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: ldc_w #282 // String =\n 10: ldc2_w #283 // double -2.0d\n 13: invokestatic #289 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 16: invokestatic #295 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 19: aastore\n 20: aload_0\n 21: iconst_1\n 22: ldc_w #297 // String -\n 25: ldc2_w #298 // double -1.0d\n 28: invokestatic #289 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 31: invokestatic #295 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 34: aastore\n 35: aload_0\n 36: iconst_2\n 37: ldc_w #301 // String 0\n 40: dconst_0\n 41: invokestatic #289 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 44: invokestatic #295 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 47: aastore\n 48: aload_0\n 49: iconst_3\n 50: ldc_w #303 // String 1\n 53: dconst_1\n 54: invokestatic #289 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 57: invokestatic #295 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 60: aastore\n 61: aload_0\n 62: iconst_4\n 63: ldc_w #305 // String 2\n 66: ldc2_w #306 // double 2.0d\n 69: invokestatic #289 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 72: invokestatic #295 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 75: aastore\n 76: aload_0\n 77: invokestatic #311 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 80: putstatic #12 // Field UNSNAFU:Ljava/util/Map;\n 83: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day22/day22.kt
package day22 import Point import day22.Direction.DOWN import day22.Direction.LEFT import day22.Direction.RIGHT import day22.Direction.UP import readInput typealias Board = Map<Point, Char> const val WALL = '#' const val OPEN = '.' fun main() { val input = readInput("main/day22/Day22") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int { val board = input.parseBoard() val directions = input.readDirections() var currentDirection = RIGHT var position = board.filter { it.key.y == 1 }.minBy { it.key.x }.key var index = 0 while (index < directions.length) { var steps = "" while (index < directions.length && directions[index].isDigit()) { steps += directions[index] index++ } val numSteps = steps.toInt() repeat(numSteps) { position = board.nextTileFrom(position, currentDirection) } if (index < directions.length) { currentDirection = if (directions[index] == 'L') currentDirection.left() else currentDirection.right() index++ } } return position.y * 1000 + position.x * 4 + currentDirection.facing } fun part2(input: List<String>): Int { val board = input.parseBoard() val directions = input.readDirections() var currentDirection = RIGHT var position = board.filter { it.key.y == 1 }.minBy { it.key.x }.key var index = 0 while (index < directions.length) { var steps = "" while (index < directions.length && directions[index].isDigit()) { steps += directions[index] index++ } val numSteps = steps.toInt() repeat(numSteps) { val (pos, dir) = board.nextTileOnCubeFrom(position, currentDirection) position = pos currentDirection = dir } if (index < directions.length) { currentDirection = if (directions[index] == 'L') currentDirection.left() else currentDirection.right() index++ } } return position.y * 1000 + position.x * 4 + currentDirection.facing } fun List<String>.parseBoard(): Board { val board = mutableMapOf<Point, Char>() this.takeWhile { it.isNotBlank() }.mapIndexed { y, line -> line.mapIndexed { x, c -> if (c == OPEN || c == WALL) board[Point(x + 1, y + 1)] = c } } return board } fun List<String>.readDirections() = this.dropLastWhile { it.isBlank() }.last() fun Board.nextTileFrom(p: Point, direction: Direction): Point = when (direction) { UP -> { var next = Point(p.x, p.y - 1) if (this[next] == WALL) next = p if (this[next] == null) next = keys.filter { it.x == p.x }.maxBy { it.y } if (this[next] == WALL) next = p next } DOWN -> { var next = Point(p.x, p.y + 1) if (this[next] == WALL) next = p if (this[next] == null) next = keys.filter { it.x == p.x }.minBy { it.y } if (this[next] == WALL) next = p next } RIGHT -> { var next = Point(p.x + 1, p.y) if (this[next] == WALL) next = p if (this[next] == null) next = keys.filter { it.y == p.y }.minBy { it.x } if (this[next] == WALL) next = p next } LEFT -> { var next = Point(p.x - 1, p.y) if (this[next] == WALL) next = p if (this[next] == null) next = keys.filter { it.y == p.y }.maxBy { it.x } if (this[next] == WALL) next = p next } } fun Board.nextTileOnCubeFrom(p: Point, direction: Direction): Pair<Point, Direction> { return when (direction) { UP -> nextPositionAndDirection(Point(p.x, p.y - 1), p, direction) DOWN -> nextPositionAndDirection(Point(p.x, p.y + 1), p, direction) RIGHT -> nextPositionAndDirection(Point(p.x + 1, p.y), p, direction) LEFT -> nextPositionAndDirection(Point(p.x - 1, p.y), p, direction) } } private fun Board.nextPositionAndDirection(next: Point, p: Point, direction: Direction): Pair<Point, Direction> { var next1 = next var newDirection = direction if (this[next1] == WALL) next1 = p if (this[next1] == null) { val (pos, dir) = gotoNextSide(p, direction) next1 = pos newDirection = dir } if (this[next1] == WALL) { next1 = p newDirection = direction } return next1 to newDirection } private fun sideOf(pos: Point): Char { if (pos.x in 51..100 && pos.y in 1..50) return 'A' if (pos.x in 101..150 && pos.y in 1..50) return 'B' if (pos.x in 51..100 && pos.y in 51..100) return 'C' if (pos.x in 51..100 && pos.y in 101..150) return 'D' if (pos.x in 1..50 && pos.y in 101..150) return 'E' if (pos.x in 1..50 && pos.y in 151..200) return 'F' error("Side does not exist for $pos") } fun gotoNextSide(position: Point, direction: Direction): Pair<Point, Direction> { var nextDir = direction val side = sideOf(position) var nextPos = position val sideLength = 50 if (side == 'A' && direction == UP) { nextDir = RIGHT nextPos = Point(1, 3 * sideLength + position.x - sideLength) // nextSide = F } else if (side == 'A' && direction == LEFT) { nextDir = RIGHT nextPos = Point(1, 2 * sideLength + (sideLength - position.y)) // nextSide = E } else if (side == 'B' && direction == UP) { nextDir = UP nextPos = Point(position.x - 2 * sideLength, 201) // nextSide = F } else if (side == 'B' && direction == RIGHT) { nextDir = LEFT nextPos = Point(101, (sideLength - position.y) + 2 * sideLength) // nextSide = D } else if (side == 'B' && direction == DOWN) { nextDir = LEFT nextPos = Point(101, sideLength + (position.x - 2 * sideLength)) // nextSide = C } else if (side == 'C' && direction == RIGHT) { nextDir = UP nextPos = Point((position.y - sideLength) + 2 * sideLength, sideLength) // nextSide = B } else if (side == 'C' && direction == LEFT) { nextDir = DOWN nextPos = Point(position.y - sideLength, 101) // nextSide = E } else if (side == 'E' && direction == LEFT) { nextDir = RIGHT nextPos = Point(51, sideLength - (position.y - 2 * sideLength)) // nextSide = 'A' } else if (side == 'E' && direction == UP) { nextDir = RIGHT nextPos = Point(51, sideLength + position.x) // nextSide = C } else if (side == 'D' && direction == DOWN) { nextDir = LEFT nextPos = Point(101, 3 * sideLength + (position.x - sideLength)) // nextSide = F } else if (side == 'D' && direction == RIGHT) { nextDir = LEFT nextPos = Point(151, sideLength - (position.y - sideLength * 2)) // nextSide = B } else if (side == 'F' && direction == RIGHT) { nextDir = UP nextPos = Point((position.y - 3 * sideLength) + sideLength, 151) // nextSide = D } else if (side == 'F' && direction == LEFT) { nextDir = DOWN nextPos = Point(sideLength + (position.y - 3 * sideLength), 1) // nextSide = 'A' } else if (side == 'F' && direction == DOWN) { nextDir = DOWN nextPos = Point(position.x + 2 * sideLength, 1) // nextSide = B } return nextPos to nextDir } enum class Direction(val facing: Int) { UP(3), DOWN(1), RIGHT(0), LEFT(2); fun right() = when (this) { UP -> RIGHT DOWN -> LEFT RIGHT -> DOWN LEFT -> UP } fun left() = when (this) { UP -> LEFT DOWN -> RIGHT RIGHT -> UP LEFT -> DOWN } }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day22/Day22Kt.class", "javap": "Compiled from \"day22.kt\"\npublic final class day22.Day22Kt {\n public static final char WALL;\n\n public static final char OPEN;\n\n public static final void main();\n Code:\n 0: ldc #8 // String main/day22/Day22\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #33 // Method part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #48 // Method parseBoard:(Ljava/util/List;)Ljava/util/Map;\n 10: astore_1\n 11: aload_0\n 12: invokestatic #52 // Method readDirections:(Ljava/util/List;)Ljava/lang/String;\n 15: astore_2\n 16: aconst_null\n 17: astore_3\n 18: getstatic #58 // Field day22/Direction.RIGHT:Lday22/Direction;\n 21: astore_3\n 22: aconst_null\n 23: astore 4\n 25: aload_1\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 5\n 33: astore 7\n 35: new #60 // class java/util/LinkedHashMap\n 38: dup\n 39: invokespecial #63 // Method java/util/LinkedHashMap.\"<init>\":()V\n 42: checkcast #65 // class java/util/Map\n 45: astore 8\n 47: iconst_0\n 48: istore 9\n 50: aload 7\n 52: invokeinterface #69, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 57: invokeinterface #75, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 62: astore 10\n 64: aload 10\n 66: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 71: ifeq 143\n 74: aload 10\n 76: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 81: checkcast #87 // class java/util/Map$Entry\n 84: astore 11\n 86: aload 11\n 88: astore 12\n 90: iconst_0\n 91: istore 13\n 93: aload 12\n 95: invokeinterface #90, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 100: checkcast #92 // class Point\n 103: invokevirtual #96 // Method Point.getY:()I\n 106: iconst_1\n 107: if_icmpne 114\n 110: iconst_1\n 111: goto 115\n 114: iconst_0\n 115: ifeq 64\n 118: aload 8\n 120: aload 11\n 122: invokeinterface #90, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 127: aload 11\n 129: invokeinterface #99, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 134: invokeinterface #103, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 139: pop\n 140: goto 64\n 143: aload 8\n 145: nop\n 146: invokeinterface #69, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 151: checkcast #105 // class java/lang/Iterable\n 154: astore 6\n 156: aload 6\n 158: invokeinterface #106, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 163: astore 7\n 165: aload 7\n 167: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 172: ifne 183\n 175: new #108 // class java/util/NoSuchElementException\n 178: dup\n 179: invokespecial #109 // Method java/util/NoSuchElementException.\"<init>\":()V\n 182: athrow\n 183: aload 7\n 185: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 190: astore 8\n 192: aload 7\n 194: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 199: ifne 207\n 202: aload 8\n 204: goto 293\n 207: aload 8\n 209: checkcast #87 // class java/util/Map$Entry\n 212: astore 9\n 214: iconst_0\n 215: istore 10\n 217: aload 9\n 219: invokeinterface #90, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 224: checkcast #92 // class Point\n 227: invokevirtual #112 // Method Point.getX:()I\n 230: istore 9\n 232: aload 7\n 234: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 239: astore 10\n 241: aload 10\n 243: checkcast #87 // class java/util/Map$Entry\n 246: astore 11\n 248: iconst_0\n 249: istore 12\n 251: aload 11\n 253: invokeinterface #90, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 258: checkcast #92 // class Point\n 261: invokevirtual #112 // Method Point.getX:()I\n 264: istore 11\n 266: iload 9\n 268: iload 11\n 270: if_icmple 281\n 273: aload 10\n 275: astore 8\n 277: iload 11\n 279: istore 9\n 281: aload 7\n 283: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 288: ifne 232\n 291: aload 8\n 293: checkcast #87 // class java/util/Map$Entry\n 296: invokeinterface #90, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 301: astore 4\n 303: iconst_0\n 304: istore 5\n 306: iload 5\n 308: aload_2\n 309: invokevirtual #117 // Method java/lang/String.length:()I\n 312: if_icmpge 453\n 315: ldc #119 // String\n 317: astore 6\n 319: iload 5\n 321: aload_2\n 322: invokevirtual #117 // Method java/lang/String.length:()I\n 325: if_icmpge 372\n 328: aload_2\n 329: iload 5\n 331: invokevirtual #123 // Method java/lang/String.charAt:(I)C\n 334: invokestatic #129 // Method java/lang/Character.isDigit:(C)Z\n 337: ifeq 372\n 340: new #131 // class java/lang/StringBuilder\n 343: dup\n 344: invokespecial #132 // Method java/lang/StringBuilder.\"<init>\":()V\n 347: aload 6\n 349: invokevirtual #136 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 352: aload_2\n 353: iload 5\n 355: invokevirtual #123 // Method java/lang/String.charAt:(I)C\n 358: invokevirtual #139 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 361: invokevirtual #143 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 364: astore 6\n 366: iinc 5, 1\n 369: goto 319\n 372: aload 6\n 374: invokestatic #149 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 377: istore 7\n 379: iconst_0\n 380: istore 8\n 382: iload 8\n 384: iload 7\n 386: if_icmpge 415\n 389: iload 8\n 391: istore 9\n 393: iconst_0\n 394: istore 10\n 396: aload_1\n 397: aload 4\n 399: checkcast #92 // class Point\n 402: aload_3\n 403: invokestatic #153 // Method nextTileFrom:(Ljava/util/Map;LPoint;Lday22/Direction;)LPoint;\n 406: astore 4\n 408: nop\n 409: iinc 8, 1\n 412: goto 382\n 415: iload 5\n 417: aload_2\n 418: invokevirtual #117 // Method java/lang/String.length:()I\n 421: if_icmpge 306\n 424: aload_2\n 425: iload 5\n 427: invokevirtual #123 // Method java/lang/String.charAt:(I)C\n 430: bipush 76\n 432: if_icmpne 442\n 435: aload_3\n 436: invokevirtual #157 // Method day22/Direction.left:()Lday22/Direction;\n 439: goto 446\n 442: aload_3\n 443: invokevirtual #160 // Method day22/Direction.right:()Lday22/Direction;\n 446: astore_3\n 447: iinc 5, 1\n 450: goto 306\n 453: aload 4\n 455: checkcast #92 // class Point\n 458: invokevirtual #96 // Method Point.getY:()I\n 461: sipush 1000\n 464: imul\n 465: aload 4\n 467: checkcast #92 // class Point\n 470: invokevirtual #112 // Method Point.getX:()I\n 473: iconst_4\n 474: imul\n 475: iadd\n 476: aload_3\n 477: invokevirtual #163 // Method day22/Direction.getFacing:()I\n 480: iadd\n 481: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #48 // Method parseBoard:(Ljava/util/List;)Ljava/util/Map;\n 10: astore_1\n 11: aload_0\n 12: invokestatic #52 // Method readDirections:(Ljava/util/List;)Ljava/lang/String;\n 15: astore_2\n 16: aconst_null\n 17: astore_3\n 18: getstatic #58 // Field day22/Direction.RIGHT:Lday22/Direction;\n 21: astore_3\n 22: aconst_null\n 23: astore 4\n 25: aload_1\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 5\n 33: astore 7\n 35: new #60 // class java/util/LinkedHashMap\n 38: dup\n 39: invokespecial #63 // Method java/util/LinkedHashMap.\"<init>\":()V\n 42: checkcast #65 // class java/util/Map\n 45: astore 8\n 47: iconst_0\n 48: istore 9\n 50: aload 7\n 52: invokeinterface #69, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 57: invokeinterface #75, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 62: astore 10\n 64: aload 10\n 66: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 71: ifeq 143\n 74: aload 10\n 76: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 81: checkcast #87 // class java/util/Map$Entry\n 84: astore 11\n 86: aload 11\n 88: astore 12\n 90: iconst_0\n 91: istore 13\n 93: aload 12\n 95: invokeinterface #90, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 100: checkcast #92 // class Point\n 103: invokevirtual #96 // Method Point.getY:()I\n 106: iconst_1\n 107: if_icmpne 114\n 110: iconst_1\n 111: goto 115\n 114: iconst_0\n 115: ifeq 64\n 118: aload 8\n 120: aload 11\n 122: invokeinterface #90, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 127: aload 11\n 129: invokeinterface #99, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 134: invokeinterface #103, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 139: pop\n 140: goto 64\n 143: aload 8\n 145: nop\n 146: invokeinterface #69, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 151: checkcast #105 // class java/lang/Iterable\n 154: astore 6\n 156: aload 6\n 158: invokeinterface #106, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 163: astore 7\n 165: aload 7\n 167: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 172: ifne 183\n 175: new #108 // class java/util/NoSuchElementException\n 178: dup\n 179: invokespecial #109 // Method java/util/NoSuchElementException.\"<init>\":()V\n 182: athrow\n 183: aload 7\n 185: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 190: astore 8\n 192: aload 7\n 194: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 199: ifne 207\n 202: aload 8\n 204: goto 293\n 207: aload 8\n 209: checkcast #87 // class java/util/Map$Entry\n 212: astore 9\n 214: iconst_0\n 215: istore 10\n 217: aload 9\n 219: invokeinterface #90, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 224: checkcast #92 // class Point\n 227: invokevirtual #112 // Method Point.getX:()I\n 230: istore 9\n 232: aload 7\n 234: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 239: astore 10\n 241: aload 10\n 243: checkcast #87 // class java/util/Map$Entry\n 246: astore 11\n 248: iconst_0\n 249: istore 12\n 251: aload 11\n 253: invokeinterface #90, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 258: checkcast #92 // class Point\n 261: invokevirtual #112 // Method Point.getX:()I\n 264: istore 11\n 266: iload 9\n 268: iload 11\n 270: if_icmple 281\n 273: aload 10\n 275: astore 8\n 277: iload 11\n 279: istore 9\n 281: aload 7\n 283: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 288: ifne 232\n 291: aload 8\n 293: checkcast #87 // class java/util/Map$Entry\n 296: invokeinterface #90, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 301: astore 4\n 303: iconst_0\n 304: istore 5\n 306: iload 5\n 308: aload_2\n 309: invokevirtual #117 // Method java/lang/String.length:()I\n 312: if_icmpge 480\n 315: ldc #119 // String\n 317: astore 6\n 319: iload 5\n 321: aload_2\n 322: invokevirtual #117 // Method java/lang/String.length:()I\n 325: if_icmpge 372\n 328: aload_2\n 329: iload 5\n 331: invokevirtual #123 // Method java/lang/String.charAt:(I)C\n 334: invokestatic #129 // Method java/lang/Character.isDigit:(C)Z\n 337: ifeq 372\n 340: new #131 // class java/lang/StringBuilder\n 343: dup\n 344: invokespecial #132 // Method java/lang/StringBuilder.\"<init>\":()V\n 347: aload 6\n 349: invokevirtual #136 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 352: aload_2\n 353: iload 5\n 355: invokevirtual #123 // Method java/lang/String.charAt:(I)C\n 358: invokevirtual #139 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 361: invokevirtual #143 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 364: astore 6\n 366: iinc 5, 1\n 369: goto 319\n 372: aload 6\n 374: invokestatic #149 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 377: istore 7\n 379: iconst_0\n 380: istore 8\n 382: iload 8\n 384: iload 7\n 386: if_icmpge 442\n 389: iload 8\n 391: istore 9\n 393: iconst_0\n 394: istore 10\n 396: aload_1\n 397: aload 4\n 399: checkcast #92 // class Point\n 402: aload_3\n 403: invokestatic #191 // Method nextTileOnCubeFrom:(Ljava/util/Map;LPoint;Lday22/Direction;)Lkotlin/Pair;\n 406: astore 11\n 408: aload 11\n 410: invokevirtual #196 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 413: checkcast #92 // class Point\n 416: astore 12\n 418: aload 11\n 420: invokevirtual #199 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 423: checkcast #54 // class day22/Direction\n 426: astore 13\n 428: aload 12\n 430: astore 4\n 432: aload 13\n 434: astore_3\n 435: nop\n 436: iinc 8, 1\n 439: goto 382\n 442: iload 5\n 444: aload_2\n 445: invokevirtual #117 // Method java/lang/String.length:()I\n 448: if_icmpge 306\n 451: aload_2\n 452: iload 5\n 454: invokevirtual #123 // Method java/lang/String.charAt:(I)C\n 457: bipush 76\n 459: if_icmpne 469\n 462: aload_3\n 463: invokevirtual #157 // Method day22/Direction.left:()Lday22/Direction;\n 466: goto 473\n 469: aload_3\n 470: invokevirtual #160 // Method day22/Direction.right:()Lday22/Direction;\n 473: astore_3\n 474: iinc 5, 1\n 477: goto 306\n 480: aload 4\n 482: checkcast #92 // class Point\n 485: invokevirtual #96 // Method Point.getY:()I\n 488: sipush 1000\n 491: imul\n 492: aload 4\n 494: checkcast #92 // class Point\n 497: invokevirtual #112 // Method Point.getX:()I\n 500: iconst_4\n 501: imul\n 502: iadd\n 503: aload_3\n 504: invokevirtual #163 // Method day22/Direction.getFacing:()I\n 507: iadd\n 508: ireturn\n\n public static final java.util.Map<Point, java.lang.Character> parseBoard(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #208 // String <this>\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #60 // class java/util/LinkedHashMap\n 9: dup\n 10: invokespecial #63 // Method java/util/LinkedHashMap.\"<init>\":()V\n 13: checkcast #65 // class java/util/Map\n 16: astore_1\n 17: aload_0\n 18: checkcast #105 // class java/lang/Iterable\n 21: astore_2\n 22: iconst_0\n 23: istore_3\n 24: new #210 // class java/util/ArrayList\n 27: dup\n 28: invokespecial #211 // Method java/util/ArrayList.\"<init>\":()V\n 31: astore 4\n 33: aload_2\n 34: invokeinterface #106, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 5\n 41: aload 5\n 43: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 104\n 51: aload 5\n 53: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 6\n 60: aload 6\n 62: checkcast #114 // class java/lang/String\n 65: astore 7\n 67: iconst_0\n 68: istore 8\n 70: aload 7\n 72: checkcast #213 // class java/lang/CharSequence\n 75: invokestatic #219 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 78: ifne 85\n 81: iconst_1\n 82: goto 86\n 85: iconst_0\n 86: nop\n 87: ifne 93\n 90: goto 104\n 93: aload 4\n 95: aload 6\n 97: invokevirtual #223 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 100: pop\n 101: goto 41\n 104: aload 4\n 106: checkcast #187 // class java/util/List\n 109: checkcast #105 // class java/lang/Iterable\n 112: astore_2\n 113: nop\n 114: iconst_0\n 115: istore_3\n 116: aload_2\n 117: astore 4\n 119: new #210 // class java/util/ArrayList\n 122: dup\n 123: aload_2\n 124: bipush 10\n 126: invokestatic #229 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 129: invokespecial #231 // Method java/util/ArrayList.\"<init>\":(I)V\n 132: checkcast #233 // class java/util/Collection\n 135: astore 5\n 137: iconst_0\n 138: istore 6\n 140: iconst_0\n 141: istore 7\n 143: aload 4\n 145: invokeinterface #106, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 150: astore 8\n 152: aload 8\n 154: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 159: ifeq 384\n 162: aload 8\n 164: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 169: astore 9\n 171: aload 5\n 173: iload 7\n 175: iinc 7, 1\n 178: istore 10\n 180: iload 10\n 182: ifge 188\n 185: invokestatic #236 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 188: iload 10\n 190: aload 9\n 192: checkcast #114 // class java/lang/String\n 195: astore 11\n 197: istore 12\n 199: astore 27\n 201: iconst_0\n 202: istore 13\n 204: aload 11\n 206: checkcast #213 // class java/lang/CharSequence\n 209: astore 14\n 211: iconst_0\n 212: istore 15\n 214: aload 14\n 216: astore 16\n 218: new #210 // class java/util/ArrayList\n 221: dup\n 222: aload 14\n 224: invokeinterface #237, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 229: invokespecial #231 // Method java/util/ArrayList.\"<init>\":(I)V\n 232: checkcast #233 // class java/util/Collection\n 235: astore 17\n 237: iconst_0\n 238: istore 18\n 240: iconst_0\n 241: istore 19\n 243: iconst_0\n 244: istore 20\n 246: iload 20\n 248: aload 16\n 250: invokeinterface #237, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 255: if_icmpge 365\n 258: aload 16\n 260: iload 20\n 262: invokeinterface #238, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 267: istore 21\n 269: aload 17\n 271: iload 19\n 273: iinc 19, 1\n 276: iload 21\n 278: istore 22\n 280: istore 23\n 282: astore 24\n 284: iconst_0\n 285: istore 25\n 287: iload 22\n 289: lookupswitch { // 2\n 35: 316\n 46: 316\n default: 347\n }\n 316: iload 22\n 318: invokestatic #242 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 321: astore 26\n 323: aload_1\n 324: new #92 // class Point\n 327: dup\n 328: iload 23\n 330: iconst_1\n 331: iadd\n 332: iload 12\n 334: iconst_1\n 335: iadd\n 336: invokespecial #245 // Method Point.\"<init>\":(II)V\n 339: aload 26\n 341: invokeinterface #103, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 346: pop\n 347: nop\n 348: aload 24\n 350: getstatic #251 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 353: invokeinterface #252, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 358: pop\n 359: iinc 20, 1\n 362: goto 246\n 365: aload 17\n 367: checkcast #187 // class java/util/List\n 370: nop\n 371: nop\n 372: aload 27\n 374: swap\n 375: invokeinterface #252, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 380: pop\n 381: goto 152\n 384: aload 5\n 386: checkcast #187 // class java/util/List\n 389: nop\n 390: pop\n 391: aload_1\n 392: areturn\n\n public static final java.lang.String readDirections(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #208 // String <this>\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: invokeinterface #279, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 16: ifne 84\n 19: aload_1\n 20: aload_1\n 21: invokeinterface #282, 1 // InterfaceMethod java/util/List.size:()I\n 26: invokeinterface #286, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 31: astore_3\n 32: aload_3\n 33: invokeinterface #291, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 38: ifeq 84\n 41: aload_3\n 42: invokeinterface #294, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 47: checkcast #114 // class java/lang/String\n 50: astore 4\n 52: iconst_0\n 53: istore 5\n 55: aload 4\n 57: checkcast #213 // class java/lang/CharSequence\n 60: invokestatic #219 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 63: ifne 32\n 66: aload_1\n 67: checkcast #105 // class java/lang/Iterable\n 70: aload_3\n 71: invokeinterface #297, 1 // InterfaceMethod java/util/ListIterator.nextIndex:()I\n 76: iconst_1\n 77: iadd\n 78: invokestatic #301 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 81: goto 87\n 84: invokestatic #305 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 87: invokestatic #309 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 90: checkcast #114 // class java/lang/String\n 93: areturn\n\n public static final Point nextTileFrom(java.util.Map<Point, java.lang.Character>, Point, day22.Direction);\n Code:\n 0: aload_0\n 1: ldc #208 // String <this>\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc_w #318 // String p\n 10: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: aload_2\n 14: ldc_w #320 // String direction\n 17: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 20: aload_2\n 21: getstatic #326 // Field day22/Day22Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 24: swap\n 25: invokevirtual #329 // Method day22/Direction.ordinal:()I\n 28: iaload\n 29: tableswitch { // 1 to 4\n 1: 60\n 2: 400\n 3: 740\n 4: 1080\n default: 1420\n }\n 60: new #92 // class Point\n 63: dup\n 64: aload_1\n 65: invokevirtual #112 // Method Point.getX:()I\n 68: aload_1\n 69: invokevirtual #96 // Method Point.getY:()I\n 72: iconst_1\n 73: isub\n 74: invokespecial #245 // Method Point.\"<init>\":(II)V\n 77: astore_3\n 78: aload_0\n 79: aload_3\n 80: invokeinterface #333, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 85: checkcast #125 // class java/lang/Character\n 88: bipush 35\n 90: istore 4\n 92: dup\n 93: ifnonnull 100\n 96: pop\n 97: goto 110\n 100: invokevirtual #337 // Method java/lang/Character.charValue:()C\n 103: iload 4\n 105: if_icmpne 110\n 108: aload_1\n 109: astore_3\n 110: aload_0\n 111: aload_3\n 112: invokeinterface #333, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 117: ifnonnull 364\n 120: aload_0\n 121: invokeinterface #340, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 126: checkcast #105 // class java/lang/Iterable\n 129: astore 4\n 131: iconst_0\n 132: istore 5\n 134: aload 4\n 136: astore 6\n 138: new #210 // class java/util/ArrayList\n 141: dup\n 142: invokespecial #211 // Method java/util/ArrayList.\"<init>\":()V\n 145: checkcast #233 // class java/util/Collection\n 148: astore 7\n 150: iconst_0\n 151: istore 8\n 153: aload 6\n 155: invokeinterface #106, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 160: astore 9\n 162: aload 9\n 164: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 169: ifeq 224\n 172: aload 9\n 174: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 179: astore 10\n 181: aload 10\n 183: checkcast #92 // class Point\n 186: astore 11\n 188: iconst_0\n 189: istore 12\n 191: aload 11\n 193: invokevirtual #112 // Method Point.getX:()I\n 196: aload_1\n 197: invokevirtual #112 // Method Point.getX:()I\n 200: if_icmpne 207\n 203: iconst_1\n 204: goto 208\n 207: iconst_0\n 208: ifeq 162\n 211: aload 7\n 213: aload 10\n 215: invokeinterface #252, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 220: pop\n 221: goto 162\n 224: aload 7\n 226: checkcast #187 // class java/util/List\n 229: nop\n 230: checkcast #105 // class java/lang/Iterable\n 233: astore 4\n 235: nop\n 236: iconst_0\n 237: istore 5\n 239: aload 4\n 241: invokeinterface #106, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 246: astore 6\n 248: aload 6\n 250: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 255: ifne 266\n 258: new #108 // class java/util/NoSuchElementException\n 261: dup\n 262: invokespecial #109 // Method java/util/NoSuchElementException.\"<init>\":()V\n 265: athrow\n 266: aload 6\n 268: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 273: astore 7\n 275: aload 6\n 277: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 282: ifne 290\n 285: aload 7\n 287: goto 360\n 290: aload 7\n 292: checkcast #92 // class Point\n 295: astore 8\n 297: iconst_0\n 298: istore 9\n 300: aload 8\n 302: invokevirtual #96 // Method Point.getY:()I\n 305: istore 8\n 307: aload 6\n 309: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 314: astore 9\n 316: aload 9\n 318: checkcast #92 // class Point\n 321: astore 10\n 323: iconst_0\n 324: istore 11\n 326: aload 10\n 328: invokevirtual #96 // Method Point.getY:()I\n 331: istore 10\n 333: iload 8\n 335: iload 10\n 337: if_icmpge 348\n 340: aload 9\n 342: astore 7\n 344: iload 10\n 346: istore 8\n 348: aload 6\n 350: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 355: ifne 307\n 358: aload 7\n 360: checkcast #92 // class Point\n 363: astore_3\n 364: aload_0\n 365: aload_3\n 366: invokeinterface #333, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 371: checkcast #125 // class java/lang/Character\n 374: bipush 35\n 376: istore 4\n 378: dup\n 379: ifnonnull 386\n 382: pop\n 383: goto 396\n 386: invokevirtual #337 // Method java/lang/Character.charValue:()C\n 389: iload 4\n 391: if_icmpne 396\n 394: aload_1\n 395: astore_3\n 396: aload_3\n 397: goto 1428\n 400: new #92 // class Point\n 403: dup\n 404: aload_1\n 405: invokevirtual #112 // Method Point.getX:()I\n 408: aload_1\n 409: invokevirtual #96 // Method Point.getY:()I\n 412: iconst_1\n 413: iadd\n 414: invokespecial #245 // Method Point.\"<init>\":(II)V\n 417: astore_3\n 418: aload_0\n 419: aload_3\n 420: invokeinterface #333, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 425: checkcast #125 // class java/lang/Character\n 428: bipush 35\n 430: istore 4\n 432: dup\n 433: ifnonnull 440\n 436: pop\n 437: goto 450\n 440: invokevirtual #337 // Method java/lang/Character.charValue:()C\n 443: iload 4\n 445: if_icmpne 450\n 448: aload_1\n 449: astore_3\n 450: aload_0\n 451: aload_3\n 452: invokeinterface #333, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 457: ifnonnull 704\n 460: aload_0\n 461: invokeinterface #340, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 466: checkcast #105 // class java/lang/Iterable\n 469: astore 4\n 471: iconst_0\n 472: istore 5\n 474: aload 4\n 476: astore 6\n 478: new #210 // class java/util/ArrayList\n 481: dup\n 482: invokespecial #211 // Method java/util/ArrayList.\"<init>\":()V\n 485: checkcast #233 // class java/util/Collection\n 488: astore 7\n 490: iconst_0\n 491: istore 8\n 493: aload 6\n 495: invokeinterface #106, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 500: astore 9\n 502: aload 9\n 504: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 509: ifeq 564\n 512: aload 9\n 514: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 519: astore 10\n 521: aload 10\n 523: checkcast #92 // class Point\n 526: astore 11\n 528: iconst_0\n 529: istore 12\n 531: aload 11\n 533: invokevirtual #112 // Method Point.getX:()I\n 536: aload_1\n 537: invokevirtual #112 // Method Point.getX:()I\n 540: if_icmpne 547\n 543: iconst_1\n 544: goto 548\n 547: iconst_0\n 548: ifeq 502\n 551: aload 7\n 553: aload 10\n 555: invokeinterface #252, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 560: pop\n 561: goto 502\n 564: aload 7\n 566: checkcast #187 // class java/util/List\n 569: nop\n 570: checkcast #105 // class java/lang/Iterable\n 573: astore 4\n 575: nop\n 576: iconst_0\n 577: istore 5\n 579: aload 4\n 581: invokeinterface #106, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 586: astore 6\n 588: aload 6\n 590: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 595: ifne 606\n 598: new #108 // class java/util/NoSuchElementException\n 601: dup\n 602: invokespecial #109 // Method java/util/NoSuchElementException.\"<init>\":()V\n 605: athrow\n 606: aload 6\n 608: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 613: astore 7\n 615: aload 6\n 617: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 622: ifne 630\n 625: aload 7\n 627: goto 700\n 630: aload 7\n 632: checkcast #92 // class Point\n 635: astore 8\n 637: iconst_0\n 638: istore 9\n 640: aload 8\n 642: invokevirtual #96 // Method Point.getY:()I\n 645: istore 8\n 647: aload 6\n 649: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 654: astore 9\n 656: aload 9\n 658: checkcast #92 // class Point\n 661: astore 10\n 663: iconst_0\n 664: istore 11\n 666: aload 10\n 668: invokevirtual #96 // Method Point.getY:()I\n 671: istore 10\n 673: iload 8\n 675: iload 10\n 677: if_icmple 688\n 680: aload 9\n 682: astore 7\n 684: iload 10\n 686: istore 8\n 688: aload 6\n 690: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 695: ifne 647\n 698: aload 7\n 700: checkcast #92 // class Point\n 703: astore_3\n 704: aload_0\n 705: aload_3\n 706: invokeinterface #333, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 711: checkcast #125 // class java/lang/Character\n 714: bipush 35\n 716: istore 4\n 718: dup\n 719: ifnonnull 726\n 722: pop\n 723: goto 736\n 726: invokevirtual #337 // Method java/lang/Character.charValue:()C\n 729: iload 4\n 731: if_icmpne 736\n 734: aload_1\n 735: astore_3\n 736: aload_3\n 737: goto 1428\n 740: new #92 // class Point\n 743: dup\n 744: aload_1\n 745: invokevirtual #112 // Method Point.getX:()I\n 748: iconst_1\n 749: iadd\n 750: aload_1\n 751: invokevirtual #96 // Method Point.getY:()I\n 754: invokespecial #245 // Method Point.\"<init>\":(II)V\n 757: astore_3\n 758: aload_0\n 759: aload_3\n 760: invokeinterface #333, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 765: checkcast #125 // class java/lang/Character\n 768: bipush 35\n 770: istore 4\n 772: dup\n 773: ifnonnull 780\n 776: pop\n 777: goto 790\n 780: invokevirtual #337 // Method java/lang/Character.charValue:()C\n 783: iload 4\n 785: if_icmpne 790\n 788: aload_1\n 789: astore_3\n 790: aload_0\n 791: aload_3\n 792: invokeinterface #333, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 797: ifnonnull 1044\n 800: aload_0\n 801: invokeinterface #340, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 806: checkcast #105 // class java/lang/Iterable\n 809: astore 4\n 811: iconst_0\n 812: istore 5\n 814: aload 4\n 816: astore 6\n 818: new #210 // class java/util/ArrayList\n 821: dup\n 822: invokespecial #211 // Method java/util/ArrayList.\"<init>\":()V\n 825: checkcast #233 // class java/util/Collection\n 828: astore 7\n 830: iconst_0\n 831: istore 8\n 833: aload 6\n 835: invokeinterface #106, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 840: astore 9\n 842: aload 9\n 844: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 849: ifeq 904\n 852: aload 9\n 854: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 859: astore 10\n 861: aload 10\n 863: checkcast #92 // class Point\n 866: astore 11\n 868: iconst_0\n 869: istore 12\n 871: aload 11\n 873: invokevirtual #96 // Method Point.getY:()I\n 876: aload_1\n 877: invokevirtual #96 // Method Point.getY:()I\n 880: if_icmpne 887\n 883: iconst_1\n 884: goto 888\n 887: iconst_0\n 888: ifeq 842\n 891: aload 7\n 893: aload 10\n 895: invokeinterface #252, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 900: pop\n 901: goto 842\n 904: aload 7\n 906: checkcast #187 // class java/util/List\n 909: nop\n 910: checkcast #105 // class java/lang/Iterable\n 913: astore 4\n 915: nop\n 916: iconst_0\n 917: istore 5\n 919: aload 4\n 921: invokeinterface #106, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 926: astore 6\n 928: aload 6\n 930: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 935: ifne 946\n 938: new #108 // class java/util/NoSuchElementException\n 941: dup\n 942: invokespecial #109 // Method java/util/NoSuchElementException.\"<init>\":()V\n 945: athrow\n 946: aload 6\n 948: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 953: astore 7\n 955: aload 6\n 957: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 962: ifne 970\n 965: aload 7\n 967: goto 1040\n 970: aload 7\n 972: checkcast #92 // class Point\n 975: astore 8\n 977: iconst_0\n 978: istore 9\n 980: aload 8\n 982: invokevirtual #112 // Method Point.getX:()I\n 985: istore 8\n 987: aload 6\n 989: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 994: astore 9\n 996: aload 9\n 998: checkcast #92 // class Point\n 1001: astore 10\n 1003: iconst_0\n 1004: istore 11\n 1006: aload 10\n 1008: invokevirtual #112 // Method Point.getX:()I\n 1011: istore 10\n 1013: iload 8\n 1015: iload 10\n 1017: if_icmple 1028\n 1020: aload 9\n 1022: astore 7\n 1024: iload 10\n 1026: istore 8\n 1028: aload 6\n 1030: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1035: ifne 987\n 1038: aload 7\n 1040: checkcast #92 // class Point\n 1043: astore_3\n 1044: aload_0\n 1045: aload_3\n 1046: invokeinterface #333, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 1051: checkcast #125 // class java/lang/Character\n 1054: bipush 35\n 1056: istore 4\n 1058: dup\n 1059: ifnonnull 1066\n 1062: pop\n 1063: goto 1076\n 1066: invokevirtual #337 // Method java/lang/Character.charValue:()C\n 1069: iload 4\n 1071: if_icmpne 1076\n 1074: aload_1\n 1075: astore_3\n 1076: aload_3\n 1077: goto 1428\n 1080: new #92 // class Point\n 1083: dup\n 1084: aload_1\n 1085: invokevirtual #112 // Method Point.getX:()I\n 1088: iconst_1\n 1089: isub\n 1090: aload_1\n 1091: invokevirtual #96 // Method Point.getY:()I\n 1094: invokespecial #245 // Method Point.\"<init>\":(II)V\n 1097: astore_3\n 1098: aload_0\n 1099: aload_3\n 1100: invokeinterface #333, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 1105: checkcast #125 // class java/lang/Character\n 1108: bipush 35\n 1110: istore 4\n 1112: dup\n 1113: ifnonnull 1120\n 1116: pop\n 1117: goto 1130\n 1120: invokevirtual #337 // Method java/lang/Character.charValue:()C\n 1123: iload 4\n 1125: if_icmpne 1130\n 1128: aload_1\n 1129: astore_3\n 1130: aload_0\n 1131: aload_3\n 1132: invokeinterface #333, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 1137: ifnonnull 1384\n 1140: aload_0\n 1141: invokeinterface #340, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 1146: checkcast #105 // class java/lang/Iterable\n 1149: astore 4\n 1151: iconst_0\n 1152: istore 5\n 1154: aload 4\n 1156: astore 6\n 1158: new #210 // class java/util/ArrayList\n 1161: dup\n 1162: invokespecial #211 // Method java/util/ArrayList.\"<init>\":()V\n 1165: checkcast #233 // class java/util/Collection\n 1168: astore 7\n 1170: iconst_0\n 1171: istore 8\n 1173: aload 6\n 1175: invokeinterface #106, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1180: astore 9\n 1182: aload 9\n 1184: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1189: ifeq 1244\n 1192: aload 9\n 1194: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1199: astore 10\n 1201: aload 10\n 1203: checkcast #92 // class Point\n 1206: astore 11\n 1208: iconst_0\n 1209: istore 12\n 1211: aload 11\n 1213: invokevirtual #96 // Method Point.getY:()I\n 1216: aload_1\n 1217: invokevirtual #96 // Method Point.getY:()I\n 1220: if_icmpne 1227\n 1223: iconst_1\n 1224: goto 1228\n 1227: iconst_0\n 1228: ifeq 1182\n 1231: aload 7\n 1233: aload 10\n 1235: invokeinterface #252, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 1240: pop\n 1241: goto 1182\n 1244: aload 7\n 1246: checkcast #187 // class java/util/List\n 1249: nop\n 1250: checkcast #105 // class java/lang/Iterable\n 1253: astore 4\n 1255: nop\n 1256: iconst_0\n 1257: istore 5\n 1259: aload 4\n 1261: invokeinterface #106, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1266: astore 6\n 1268: aload 6\n 1270: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1275: ifne 1286\n 1278: new #108 // class java/util/NoSuchElementException\n 1281: dup\n 1282: invokespecial #109 // Method java/util/NoSuchElementException.\"<init>\":()V\n 1285: athrow\n 1286: aload 6\n 1288: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1293: astore 7\n 1295: aload 6\n 1297: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1302: ifne 1310\n 1305: aload 7\n 1307: goto 1380\n 1310: aload 7\n 1312: checkcast #92 // class Point\n 1315: astore 8\n 1317: iconst_0\n 1318: istore 9\n 1320: aload 8\n 1322: invokevirtual #112 // Method Point.getX:()I\n 1325: istore 8\n 1327: aload 6\n 1329: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1334: astore 9\n 1336: aload 9\n 1338: checkcast #92 // class Point\n 1341: astore 10\n 1343: iconst_0\n 1344: istore 11\n 1346: aload 10\n 1348: invokevirtual #112 // Method Point.getX:()I\n 1351: istore 10\n 1353: iload 8\n 1355: iload 10\n 1357: if_icmpge 1368\n 1360: aload 9\n 1362: astore 7\n 1364: iload 10\n 1366: istore 8\n 1368: aload 6\n 1370: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1375: ifne 1327\n 1378: aload 7\n 1380: checkcast #92 // class Point\n 1383: astore_3\n 1384: aload_0\n 1385: aload_3\n 1386: invokeinterface #333, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 1391: checkcast #125 // class java/lang/Character\n 1394: bipush 35\n 1396: istore 4\n 1398: dup\n 1399: ifnonnull 1406\n 1402: pop\n 1403: goto 1416\n 1406: invokevirtual #337 // Method java/lang/Character.charValue:()C\n 1409: iload 4\n 1411: if_icmpne 1416\n 1414: aload_1\n 1415: astore_3\n 1416: aload_3\n 1417: goto 1428\n 1420: new #342 // class kotlin/NoWhenBranchMatchedException\n 1423: dup\n 1424: invokespecial #343 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 1427: athrow\n 1428: areturn\n\n public static final kotlin.Pair<Point, day22.Direction> nextTileOnCubeFrom(java.util.Map<Point, java.lang.Character>, Point, day22.Direction);\n Code:\n 0: aload_0\n 1: ldc #208 // String <this>\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc_w #318 // String p\n 10: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: aload_2\n 14: ldc_w #320 // String direction\n 17: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 20: aload_2\n 21: getstatic #326 // Field day22/Day22Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 24: swap\n 25: invokevirtual #329 // Method day22/Direction.ordinal:()I\n 28: iaload\n 29: tableswitch { // 1 to 4\n 1: 60\n 2: 86\n 3: 112\n 4: 138\n default: 164\n }\n 60: aload_0\n 61: new #92 // class Point\n 64: dup\n 65: aload_1\n 66: invokevirtual #112 // Method Point.getX:()I\n 69: aload_1\n 70: invokevirtual #96 // Method Point.getY:()I\n 73: iconst_1\n 74: isub\n 75: invokespecial #245 // Method Point.\"<init>\":(II)V\n 78: aload_1\n 79: aload_2\n 80: invokestatic #368 // Method nextPositionAndDirection:(Ljava/util/Map;LPoint;LPoint;Lday22/Direction;)Lkotlin/Pair;\n 83: goto 172\n 86: aload_0\n 87: new #92 // class Point\n 90: dup\n 91: aload_1\n 92: invokevirtual #112 // Method Point.getX:()I\n 95: aload_1\n 96: invokevirtual #96 // Method Point.getY:()I\n 99: iconst_1\n 100: iadd\n 101: invokespecial #245 // Method Point.\"<init>\":(II)V\n 104: aload_1\n 105: aload_2\n 106: invokestatic #368 // Method nextPositionAndDirection:(Ljava/util/Map;LPoint;LPoint;Lday22/Direction;)Lkotlin/Pair;\n 109: goto 172\n 112: aload_0\n 113: new #92 // class Point\n 116: dup\n 117: aload_1\n 118: invokevirtual #112 // Method Point.getX:()I\n 121: iconst_1\n 122: iadd\n 123: aload_1\n 124: invokevirtual #96 // Method Point.getY:()I\n 127: invokespecial #245 // Method Point.\"<init>\":(II)V\n 130: aload_1\n 131: aload_2\n 132: invokestatic #368 // Method nextPositionAndDirection:(Ljava/util/Map;LPoint;LPoint;Lday22/Direction;)Lkotlin/Pair;\n 135: goto 172\n 138: aload_0\n 139: new #92 // class Point\n 142: dup\n 143: aload_1\n 144: invokevirtual #112 // Method Point.getX:()I\n 147: iconst_1\n 148: isub\n 149: aload_1\n 150: invokevirtual #96 // Method Point.getY:()I\n 153: invokespecial #245 // Method Point.\"<init>\":(II)V\n 156: aload_1\n 157: aload_2\n 158: invokestatic #368 // Method nextPositionAndDirection:(Ljava/util/Map;LPoint;LPoint;Lday22/Direction;)Lkotlin/Pair;\n 161: goto 172\n 164: new #342 // class kotlin/NoWhenBranchMatchedException\n 167: dup\n 168: invokespecial #343 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 171: athrow\n 172: areturn\n\n private static final kotlin.Pair<Point, day22.Direction> nextPositionAndDirection(java.util.Map<Point, java.lang.Character>, Point, Point, day22.Direction);\n Code:\n 0: aload_1\n 1: astore 4\n 3: aload_3\n 4: astore 5\n 6: aload_0\n 7: aload 4\n 9: invokeinterface #333, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 14: checkcast #125 // class java/lang/Character\n 17: bipush 35\n 19: istore 6\n 21: dup\n 22: ifnonnull 29\n 25: pop\n 26: goto 40\n 29: invokevirtual #337 // Method java/lang/Character.charValue:()C\n 32: iload 6\n 34: if_icmpne 40\n 37: aload_2\n 38: astore 4\n 40: aload_0\n 41: aload 4\n 43: invokeinterface #333, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 48: ifnonnull 86\n 51: aload_2\n 52: aload_3\n 53: invokestatic #374 // Method gotoNextSide:(LPoint;Lday22/Direction;)Lkotlin/Pair;\n 56: astore 6\n 58: aload 6\n 60: invokevirtual #196 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 63: checkcast #92 // class Point\n 66: astore 7\n 68: aload 6\n 70: invokevirtual #199 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 73: checkcast #54 // class day22/Direction\n 76: astore 8\n 78: aload 7\n 80: astore 4\n 82: aload 8\n 84: astore 5\n 86: aload_0\n 87: aload 4\n 89: invokeinterface #333, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 94: checkcast #125 // class java/lang/Character\n 97: bipush 35\n 99: istore 6\n 101: dup\n 102: ifnonnull 109\n 105: pop\n 106: goto 123\n 109: invokevirtual #337 // Method java/lang/Character.charValue:()C\n 112: iload 6\n 114: if_icmpne 123\n 117: aload_2\n 118: astore 4\n 120: aload_3\n 121: astore 5\n 123: aload 4\n 125: aload 5\n 127: invokestatic #380 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 130: areturn\n\n private static final char sideOf(Point);\n Code:\n 0: aload_0\n 1: invokevirtual #112 // Method Point.getX:()I\n 4: istore_1\n 5: bipush 51\n 7: iload_1\n 8: if_icmpgt 25\n 11: iload_1\n 12: bipush 101\n 14: if_icmpge 21\n 17: iconst_1\n 18: goto 26\n 21: iconst_0\n 22: goto 26\n 25: iconst_0\n 26: ifeq 60\n 29: aload_0\n 30: invokevirtual #96 // Method Point.getY:()I\n 33: istore_1\n 34: iconst_1\n 35: iload_1\n 36: if_icmpgt 53\n 39: iload_1\n 40: bipush 51\n 42: if_icmpge 49\n 45: iconst_1\n 46: goto 54\n 49: iconst_0\n 50: goto 54\n 53: iconst_0\n 54: ifeq 60\n 57: bipush 65\n 59: ireturn\n 60: aload_0\n 61: invokevirtual #112 // Method Point.getX:()I\n 64: istore_1\n 65: bipush 101\n 67: iload_1\n 68: if_icmpgt 86\n 71: iload_1\n 72: sipush 151\n 75: if_icmpge 82\n 78: iconst_1\n 79: goto 87\n 82: iconst_0\n 83: goto 87\n 86: iconst_0\n 87: ifeq 121\n 90: aload_0\n 91: invokevirtual #96 // Method Point.getY:()I\n 94: istore_1\n 95: iconst_1\n 96: iload_1\n 97: if_icmpgt 114\n 100: iload_1\n 101: bipush 51\n 103: if_icmpge 110\n 106: iconst_1\n 107: goto 115\n 110: iconst_0\n 111: goto 115\n 114: iconst_0\n 115: ifeq 121\n 118: bipush 66\n 120: ireturn\n 121: aload_0\n 122: invokevirtual #112 // Method Point.getX:()I\n 125: istore_1\n 126: bipush 51\n 128: iload_1\n 129: if_icmpgt 146\n 132: iload_1\n 133: bipush 101\n 135: if_icmpge 142\n 138: iconst_1\n 139: goto 147\n 142: iconst_0\n 143: goto 147\n 146: iconst_0\n 147: ifeq 182\n 150: aload_0\n 151: invokevirtual #96 // Method Point.getY:()I\n 154: istore_1\n 155: bipush 51\n 157: iload_1\n 158: if_icmpgt 175\n 161: iload_1\n 162: bipush 101\n 164: if_icmpge 171\n 167: iconst_1\n 168: goto 176\n 171: iconst_0\n 172: goto 176\n 175: iconst_0\n 176: ifeq 182\n 179: bipush 67\n 181: ireturn\n 182: aload_0\n 183: invokevirtual #112 // Method Point.getX:()I\n 186: istore_1\n 187: bipush 51\n 189: iload_1\n 190: if_icmpgt 207\n 193: iload_1\n 194: bipush 101\n 196: if_icmpge 203\n 199: iconst_1\n 200: goto 208\n 203: iconst_0\n 204: goto 208\n 207: iconst_0\n 208: ifeq 244\n 211: aload_0\n 212: invokevirtual #96 // Method Point.getY:()I\n 215: istore_1\n 216: bipush 101\n 218: iload_1\n 219: if_icmpgt 237\n 222: iload_1\n 223: sipush 151\n 226: if_icmpge 233\n 229: iconst_1\n 230: goto 238\n 233: iconst_0\n 234: goto 238\n 237: iconst_0\n 238: ifeq 244\n 241: bipush 68\n 243: ireturn\n 244: aload_0\n 245: invokevirtual #112 // Method Point.getX:()I\n 248: istore_1\n 249: iconst_1\n 250: iload_1\n 251: if_icmpgt 268\n 254: iload_1\n 255: bipush 51\n 257: if_icmpge 264\n 260: iconst_1\n 261: goto 269\n 264: iconst_0\n 265: goto 269\n 268: iconst_0\n 269: ifeq 305\n 272: aload_0\n 273: invokevirtual #96 // Method Point.getY:()I\n 276: istore_1\n 277: bipush 101\n 279: iload_1\n 280: if_icmpgt 298\n 283: iload_1\n 284: sipush 151\n 287: if_icmpge 294\n 290: iconst_1\n 291: goto 299\n 294: iconst_0\n 295: goto 299\n 298: iconst_0\n 299: ifeq 305\n 302: bipush 69\n 304: ireturn\n 305: aload_0\n 306: invokevirtual #112 // Method Point.getX:()I\n 309: istore_1\n 310: iconst_1\n 311: iload_1\n 312: if_icmpgt 329\n 315: iload_1\n 316: bipush 51\n 318: if_icmpge 325\n 321: iconst_1\n 322: goto 330\n 325: iconst_0\n 326: goto 330\n 329: iconst_0\n 330: ifeq 367\n 333: aload_0\n 334: invokevirtual #96 // Method Point.getY:()I\n 337: istore_1\n 338: sipush 151\n 341: iload_1\n 342: if_icmpgt 360\n 345: iload_1\n 346: sipush 201\n 349: if_icmpge 356\n 352: iconst_1\n 353: goto 361\n 356: iconst_0\n 357: goto 361\n 360: iconst_0\n 361: ifeq 367\n 364: bipush 70\n 366: ireturn\n 367: new #387 // class java/lang/IllegalStateException\n 370: dup\n 371: new #131 // class java/lang/StringBuilder\n 374: dup\n 375: invokespecial #132 // Method java/lang/StringBuilder.\"<init>\":()V\n 378: ldc_w #389 // String Side does not exist for\n 381: invokevirtual #136 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 384: aload_0\n 385: invokevirtual #392 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 388: invokevirtual #143 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 391: invokevirtual #393 // Method java/lang/Object.toString:()Ljava/lang/String;\n 394: invokespecial #396 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 397: athrow\n\n public static final kotlin.Pair<Point, day22.Direction> gotoNextSide(Point, day22.Direction);\n Code:\n 0: aload_0\n 1: ldc_w #398 // String position\n 4: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: ldc_w #320 // String direction\n 11: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: aload_1\n 15: astore_2\n 16: aload_0\n 17: invokestatic #400 // Method sideOf:(LPoint;)C\n 20: istore_3\n 21: aload_0\n 22: astore 4\n 24: bipush 50\n 26: istore 5\n 28: iload_3\n 29: bipush 65\n 31: if_icmpne 70\n 34: aload_1\n 35: getstatic #403 // Field day22/Direction.UP:Lday22/Direction;\n 38: if_acmpne 70\n 41: getstatic #58 // Field day22/Direction.RIGHT:Lday22/Direction;\n 44: astore_2\n 45: new #92 // class Point\n 48: dup\n 49: iconst_1\n 50: iconst_3\n 51: iload 5\n 53: imul\n 54: aload_0\n 55: invokevirtual #112 // Method Point.getX:()I\n 58: iadd\n 59: iload 5\n 61: isub\n 62: invokespecial #245 // Method Point.\"<init>\":(II)V\n 65: astore 4\n 67: goto 610\n 70: iload_3\n 71: bipush 65\n 73: if_icmpne 112\n 76: aload_1\n 77: getstatic #406 // Field day22/Direction.LEFT:Lday22/Direction;\n 80: if_acmpne 112\n 83: getstatic #58 // Field day22/Direction.RIGHT:Lday22/Direction;\n 86: astore_2\n 87: new #92 // class Point\n 90: dup\n 91: iconst_1\n 92: iconst_2\n 93: iload 5\n 95: imul\n 96: iload 5\n 98: aload_0\n 99: invokevirtual #96 // Method Point.getY:()I\n 102: isub\n 103: iadd\n 104: invokespecial #245 // Method Point.\"<init>\":(II)V\n 107: astore 4\n 109: goto 610\n 112: iload_3\n 113: bipush 66\n 115: if_icmpne 153\n 118: aload_1\n 119: getstatic #403 // Field day22/Direction.UP:Lday22/Direction;\n 122: if_acmpne 153\n 125: getstatic #403 // Field day22/Direction.UP:Lday22/Direction;\n 128: astore_2\n 129: new #92 // class Point\n 132: dup\n 133: aload_0\n 134: invokevirtual #112 // Method Point.getX:()I\n 137: iconst_2\n 138: iload 5\n 140: imul\n 141: isub\n 142: sipush 201\n 145: invokespecial #245 // Method Point.\"<init>\":(II)V\n 148: astore 4\n 150: goto 610\n 153: iload_3\n 154: bipush 66\n 156: if_icmpne 196\n 159: aload_1\n 160: getstatic #58 // Field day22/Direction.RIGHT:Lday22/Direction;\n 163: if_acmpne 196\n 166: getstatic #406 // Field day22/Direction.LEFT:Lday22/Direction;\n 169: astore_2\n 170: new #92 // class Point\n 173: dup\n 174: bipush 101\n 176: iload 5\n 178: aload_0\n 179: invokevirtual #96 // Method Point.getY:()I\n 182: isub\n 183: iconst_2\n 184: iload 5\n 186: imul\n 187: iadd\n 188: invokespecial #245 // Method Point.\"<init>\":(II)V\n 191: astore 4\n 193: goto 610\n 196: iload_3\n 197: bipush 66\n 199: if_icmpne 239\n 202: aload_1\n 203: getstatic #409 // Field day22/Direction.DOWN:Lday22/Direction;\n 206: if_acmpne 239\n 209: getstatic #406 // Field day22/Direction.LEFT:Lday22/Direction;\n 212: astore_2\n 213: new #92 // class Point\n 216: dup\n 217: bipush 101\n 219: iload 5\n 221: aload_0\n 222: invokevirtual #112 // Method Point.getX:()I\n 225: iconst_2\n 226: iload 5\n 228: imul\n 229: isub\n 230: iadd\n 231: invokespecial #245 // Method Point.\"<init>\":(II)V\n 234: astore 4\n 236: goto 610\n 239: iload_3\n 240: bipush 67\n 242: if_icmpne 282\n 245: aload_1\n 246: getstatic #58 // Field day22/Direction.RIGHT:Lday22/Direction;\n 249: if_acmpne 282\n 252: getstatic #403 // Field day22/Direction.UP:Lday22/Direction;\n 255: astore_2\n 256: new #92 // class Point\n 259: dup\n 260: aload_0\n 261: invokevirtual #96 // Method Point.getY:()I\n 264: iload 5\n 266: isub\n 267: iconst_2\n 268: iload 5\n 270: imul\n 271: iadd\n 272: iload 5\n 274: invokespecial #245 // Method Point.\"<init>\":(II)V\n 277: astore 4\n 279: goto 610\n 282: iload_3\n 283: bipush 67\n 285: if_icmpne 320\n 288: aload_1\n 289: getstatic #406 // Field day22/Direction.LEFT:Lday22/Direction;\n 292: if_acmpne 320\n 295: getstatic #409 // Field day22/Direction.DOWN:Lday22/Direction;\n 298: astore_2\n 299: new #92 // class Point\n 302: dup\n 303: aload_0\n 304: invokevirtual #96 // Method Point.getY:()I\n 307: iload 5\n 309: isub\n 310: bipush 101\n 312: invokespecial #245 // Method Point.\"<init>\":(II)V\n 315: astore 4\n 317: goto 610\n 320: iload_3\n 321: bipush 69\n 323: if_icmpne 363\n 326: aload_1\n 327: getstatic #406 // Field day22/Direction.LEFT:Lday22/Direction;\n 330: if_acmpne 363\n 333: getstatic #58 // Field day22/Direction.RIGHT:Lday22/Direction;\n 336: astore_2\n 337: new #92 // class Point\n 340: dup\n 341: bipush 51\n 343: iload 5\n 345: aload_0\n 346: invokevirtual #96 // Method Point.getY:()I\n 349: iconst_2\n 350: iload 5\n 352: imul\n 353: isub\n 354: isub\n 355: invokespecial #245 // Method Point.\"<init>\":(II)V\n 358: astore 4\n 360: goto 610\n 363: iload_3\n 364: bipush 69\n 366: if_icmpne 401\n 369: aload_1\n 370: getstatic #403 // Field day22/Direction.UP:Lday22/Direction;\n 373: if_acmpne 401\n 376: getstatic #58 // Field day22/Direction.RIGHT:Lday22/Direction;\n 379: astore_2\n 380: new #92 // class Point\n 383: dup\n 384: bipush 51\n 386: iload 5\n 388: aload_0\n 389: invokevirtual #112 // Method Point.getX:()I\n 392: iadd\n 393: invokespecial #245 // Method Point.\"<init>\":(II)V\n 396: astore 4\n 398: goto 610\n 401: iload_3\n 402: bipush 68\n 404: if_icmpne 444\n 407: aload_1\n 408: getstatic #409 // Field day22/Direction.DOWN:Lday22/Direction;\n 411: if_acmpne 444\n 414: getstatic #406 // Field day22/Direction.LEFT:Lday22/Direction;\n 417: astore_2\n 418: new #92 // class Point\n 421: dup\n 422: bipush 101\n 424: iconst_3\n 425: iload 5\n 427: imul\n 428: aload_0\n 429: invokevirtual #112 // Method Point.getX:()I\n 432: iload 5\n 434: isub\n 435: iadd\n 436: invokespecial #245 // Method Point.\"<init>\":(II)V\n 439: astore 4\n 441: goto 610\n 444: iload_3\n 445: bipush 68\n 447: if_icmpne 488\n 450: aload_1\n 451: getstatic #58 // Field day22/Direction.RIGHT:Lday22/Direction;\n 454: if_acmpne 488\n 457: getstatic #406 // Field day22/Direction.LEFT:Lday22/Direction;\n 460: astore_2\n 461: new #92 // class Point\n 464: dup\n 465: sipush 151\n 468: iload 5\n 470: aload_0\n 471: invokevirtual #96 // Method Point.getY:()I\n 474: iload 5\n 476: iconst_2\n 477: imul\n 478: isub\n 479: isub\n 480: invokespecial #245 // Method Point.\"<init>\":(II)V\n 483: astore 4\n 485: goto 610\n 488: iload_3\n 489: bipush 70\n 491: if_icmpne 532\n 494: aload_1\n 495: getstatic #58 // Field day22/Direction.RIGHT:Lday22/Direction;\n 498: if_acmpne 532\n 501: getstatic #403 // Field day22/Direction.UP:Lday22/Direction;\n 504: astore_2\n 505: new #92 // class Point\n 508: dup\n 509: aload_0\n 510: invokevirtual #96 // Method Point.getY:()I\n 513: iconst_3\n 514: iload 5\n 516: imul\n 517: isub\n 518: iload 5\n 520: iadd\n 521: sipush 151\n 524: invokespecial #245 // Method Point.\"<init>\":(II)V\n 527: astore 4\n 529: goto 610\n 532: iload_3\n 533: bipush 70\n 535: if_icmpne 574\n 538: aload_1\n 539: getstatic #406 // Field day22/Direction.LEFT:Lday22/Direction;\n 542: if_acmpne 574\n 545: getstatic #409 // Field day22/Direction.DOWN:Lday22/Direction;\n 548: astore_2\n 549: new #92 // class Point\n 552: dup\n 553: iload 5\n 555: aload_0\n 556: invokevirtual #96 // Method Point.getY:()I\n 559: iconst_3\n 560: iload 5\n 562: imul\n 563: isub\n 564: iadd\n 565: iconst_1\n 566: invokespecial #245 // Method Point.\"<init>\":(II)V\n 569: astore 4\n 571: goto 610\n 574: iload_3\n 575: bipush 70\n 577: if_icmpne 610\n 580: aload_1\n 581: getstatic #409 // Field day22/Direction.DOWN:Lday22/Direction;\n 584: if_acmpne 610\n 587: getstatic #409 // Field day22/Direction.DOWN:Lday22/Direction;\n 590: astore_2\n 591: new #92 // class Point\n 594: dup\n 595: aload_0\n 596: invokevirtual #112 // Method Point.getX:()I\n 599: iconst_2\n 600: iload 5\n 602: imul\n 603: iadd\n 604: iconst_1\n 605: invokespecial #245 // Method Point.\"<init>\":(II)V\n 608: astore 4\n 610: aload 4\n 612: aload_2\n 613: invokestatic #380 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 616: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #416 // Method main:()V\n 3: return\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day22/Day22Kt$WhenMappings.class", "javap": "Compiled from \"day22.kt\"\npublic final class day22.Day22Kt$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method day22/Direction.values:()[Lday22/Direction;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field day22/Direction.UP:Lday22/Direction;\n 12: invokevirtual #22 // Method day22/Direction.ordinal:()I\n 15: iconst_1\n 16: iastore\n 17: goto 21\n 20: astore_1\n 21: nop\n 22: aload_0\n 23: getstatic #25 // Field day22/Direction.DOWN:Lday22/Direction;\n 26: invokevirtual #22 // Method day22/Direction.ordinal:()I\n 29: iconst_2\n 30: iastore\n 31: goto 35\n 34: astore_1\n 35: nop\n 36: aload_0\n 37: getstatic #28 // Field day22/Direction.RIGHT:Lday22/Direction;\n 40: invokevirtual #22 // Method day22/Direction.ordinal:()I\n 43: iconst_3\n 44: iastore\n 45: goto 49\n 48: astore_1\n 49: nop\n 50: aload_0\n 51: getstatic #31 // Field day22/Direction.LEFT:Lday22/Direction;\n 54: invokevirtual #22 // Method day22/Direction.ordinal:()I\n 57: iconst_4\n 58: iastore\n 59: goto 63\n 62: astore_1\n 63: aload_0\n 64: putstatic #35 // Field $EnumSwitchMapping$0:[I\n 67: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n 21 31 34 Class java/lang/NoSuchFieldError\n 35 45 48 Class java/lang/NoSuchFieldError\n 49 59 62 Class java/lang/NoSuchFieldError\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day04/day04.kt
package day04 import fullyContains import overlapsWith import readInput fun part1(input: List<String>): Int = input.solve(IntRange::fullyContains) fun part2(input: List<String>): Int = input.solve(IntRange::overlapsWith) val regex by lazy { """(\d+)-(\d+),(\d+)-(\d+)""".toRegex() } fun main() { val input = readInput("main/day04/Day04") println(part1(input)) println(part2(input)) } private fun List<String>.solve(check: IntRange.(IntRange) -> Boolean) = map { it.toRangesPairs() }.count { it.first.check(it.second) } fun String.toRangesPairs(): Pair<IntRange, IntRange> { return regex.matchEntire(this)?.destructured?.let { (a, b, c, d) -> a.toInt()..b.toInt() to c.toInt()..d.toInt() } ?: error("invalid line") }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day04/Day04Kt.class", "javap": "Compiled from \"day04.kt\"\npublic final class day04.Day04Kt {\n private static final kotlin.Lazy regex$delegate;\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getstatic #22 // Field day04/Day04Kt$part1$1.INSTANCE:Lday04/Day04Kt$part1$1;\n 10: checkcast #24 // class kotlin/jvm/functions/Function2\n 13: invokestatic #28 // Method solve:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)I\n 16: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getstatic #35 // Field day04/Day04Kt$part2$1.INSTANCE:Lday04/Day04Kt$part2$1;\n 10: checkcast #24 // class kotlin/jvm/functions/Function2\n 13: invokestatic #28 // Method solve:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)I\n 16: ireturn\n\n public static final kotlin.text.Regex getRegex();\n Code:\n 0: getstatic #41 // Field regex$delegate:Lkotlin/Lazy;\n 3: astore_0\n 4: aload_0\n 5: invokeinterface #47, 1 // InterfaceMethod kotlin/Lazy.getValue:()Ljava/lang/Object;\n 10: checkcast #49 // class kotlin/text/Regex\n 13: areturn\n\n public static final void main();\n Code:\n 0: ldc #53 // String main/day04/Day04\n 2: invokestatic #59 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #61 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #73 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #75 // Method part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #73 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n private static final int solve(java.util.List<java.lang.String>, kotlin.jvm.functions.Function2<? super kotlin.ranges.IntRange, ? super kotlin.ranges.IntRange, java.lang.Boolean>);\n Code:\n 0: aload_0\n 1: checkcast #78 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: astore 4\n 10: new #80 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #86 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #89 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #91 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 90\n 50: aload 7\n 52: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #106 // class java/lang/String\n 66: astore 9\n 68: astore 11\n 70: iconst_0\n 71: istore 10\n 73: aload 9\n 75: invokestatic #110 // Method toRangesPairs:(Ljava/lang/String;)Lkotlin/Pair;\n 78: aload 11\n 80: swap\n 81: invokeinterface #114, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 86: pop\n 87: goto 40\n 90: aload 5\n 92: checkcast #116 // class java/util/List\n 95: nop\n 96: checkcast #78 // class java/lang/Iterable\n 99: astore_2\n 100: nop\n 101: iconst_0\n 102: istore_3\n 103: aload_2\n 104: instanceof #91 // class java/util/Collection\n 107: ifeq 126\n 110: aload_2\n 111: checkcast #91 // class java/util/Collection\n 114: invokeinterface #119, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 119: ifeq 126\n 122: iconst_0\n 123: goto 207\n 126: iconst_0\n 127: istore 4\n 129: aload_2\n 130: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 135: astore 5\n 137: aload 5\n 139: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 144: ifeq 205\n 147: aload 5\n 149: invokeinterface #104, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 154: astore 6\n 156: aload 6\n 158: checkcast #121 // class kotlin/Pair\n 161: astore 7\n 163: iconst_0\n 164: istore 8\n 166: aload_1\n 167: aload 7\n 169: invokevirtual #124 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 172: aload 7\n 174: invokevirtual #127 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 177: invokeinterface #131, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 182: checkcast #133 // class java/lang/Boolean\n 185: invokevirtual #136 // Method java/lang/Boolean.booleanValue:()Z\n 188: ifeq 137\n 191: iinc 4, 1\n 194: iload 4\n 196: ifge 137\n 199: invokestatic #139 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 202: goto 137\n 205: iload 4\n 207: ireturn\n\n public static final kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange> toRangesPairs(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #164 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: invokestatic #166 // Method getRegex:()Lkotlin/text/Regex;\n 9: aload_0\n 10: checkcast #168 // class java/lang/CharSequence\n 13: invokevirtual #172 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 16: dup\n 17: ifnull 152\n 20: invokeinterface #178, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 25: dup\n 26: ifnull 152\n 29: astore_1\n 30: iconst_0\n 31: istore_2\n 32: aload_1\n 33: invokevirtual #184 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 36: invokeinterface #188, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 41: iconst_1\n 42: invokeinterface #192, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 47: checkcast #106 // class java/lang/String\n 50: astore_3\n 51: aload_1\n 52: invokevirtual #184 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 55: invokeinterface #188, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 60: iconst_2\n 61: invokeinterface #192, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 66: checkcast #106 // class java/lang/String\n 69: astore 4\n 71: aload_1\n 72: invokevirtual #184 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 75: invokeinterface #188, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 80: iconst_3\n 81: invokeinterface #192, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 86: checkcast #106 // class java/lang/String\n 89: astore 5\n 91: aload_1\n 92: invokevirtual #184 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 95: invokeinterface #188, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 100: iconst_4\n 101: invokeinterface #192, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 106: checkcast #106 // class java/lang/String\n 109: astore 6\n 111: new #194 // class kotlin/ranges/IntRange\n 114: dup\n 115: aload_3\n 116: invokestatic #200 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 119: aload 4\n 121: invokestatic #200 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 124: invokespecial #203 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 127: new #194 // class kotlin/ranges/IntRange\n 130: dup\n 131: aload 5\n 133: invokestatic #200 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 136: aload 6\n 138: invokestatic #200 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 141: invokespecial #203 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 144: invokestatic #209 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 147: nop\n 148: dup\n 149: ifnonnull 166\n 152: pop\n 153: new #211 // class java/lang/IllegalStateException\n 156: dup\n 157: ldc #213 // String invalid line\n 159: invokevirtual #217 // Method java/lang/Object.toString:()Ljava/lang/String;\n 162: invokespecial #220 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 165: athrow\n 166: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #229 // Method main:()V\n 3: return\n\n private static final kotlin.text.Regex regex_delegate$lambda$0();\n Code:\n 0: new #49 // class kotlin/text/Regex\n 3: dup\n 4: ldc #234 // String (\\\\d+)-(\\\\d+),(\\\\d+)-(\\\\d+)\n 6: invokespecial #235 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: areturn\n\n static {};\n Code:\n 0: invokedynamic #251, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function0;\n 5: invokestatic #257 // Method kotlin/LazyKt.lazy:(Lkotlin/jvm/functions/Function0;)Lkotlin/Lazy;\n 8: putstatic #41 // Field regex$delegate:Lkotlin/Lazy;\n 11: return\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day04/Day04Kt$part1$1.class", "javap": "Compiled from \"day04.kt\"\nfinal class day04.Day04Kt$part1$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<kotlin.ranges.IntRange, kotlin.ranges.IntRange, java.lang.Boolean> {\n public static final day04.Day04Kt$part1$1 INSTANCE;\n\n day04.Day04Kt$part1$1();\n Code:\n 0: aload_0\n 1: iconst_2\n 2: ldc #11 // class UtilsKt\n 4: ldc #13 // String fullyContains\n 6: ldc #15 // String fullyContains(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final java.lang.Boolean invoke(kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_1\n 1: ldc #24 // String p0\n 3: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #32 // String p1\n 9: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #35 // Method UtilsKt.fullyContains:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z\n 17: invokestatic #41 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 20: areturn\n\n public java.lang.Object invoke(java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #45 // class kotlin/ranges/IntRange\n 5: aload_2\n 6: checkcast #45 // class kotlin/ranges/IntRange\n 9: invokevirtual #47 // Method invoke:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Ljava/lang/Boolean;\n 12: areturn\n\n static {};\n Code:\n 0: new #2 // class day04/Day04Kt$part1$1\n 3: dup\n 4: invokespecial #52 // Method \"<init>\":()V\n 7: putstatic #55 // Field INSTANCE:Lday04/Day04Kt$part1$1;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day04/Day04Kt$part2$1.class", "javap": "Compiled from \"day04.kt\"\nfinal class day04.Day04Kt$part2$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<kotlin.ranges.IntRange, kotlin.ranges.IntRange, java.lang.Boolean> {\n public static final day04.Day04Kt$part2$1 INSTANCE;\n\n day04.Day04Kt$part2$1();\n Code:\n 0: aload_0\n 1: iconst_2\n 2: ldc #11 // class UtilsKt\n 4: ldc #13 // String overlapsWith\n 6: ldc #15 // String overlapsWith(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final java.lang.Boolean invoke(kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_1\n 1: ldc #24 // String p0\n 3: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #32 // String p1\n 9: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #35 // Method UtilsKt.overlapsWith:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z\n 17: invokestatic #41 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 20: areturn\n\n public java.lang.Object invoke(java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #45 // class kotlin/ranges/IntRange\n 5: aload_2\n 6: checkcast #45 // class kotlin/ranges/IntRange\n 9: invokevirtual #47 // Method invoke:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Ljava/lang/Boolean;\n 12: areturn\n\n static {};\n Code:\n 0: new #2 // class day04/Day04Kt$part2$1\n 3: dup\n 4: invokespecial #52 // Method \"<init>\":()V\n 7: putstatic #55 // Field INSTANCE:Lday04/Day04Kt$part2$1;\n 10: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day02/day02.kt
package day02 import readInput import reverse import second const val ROCK = "A" const val PAPER = "B" const val SCISSORS = "C" const val ROCK_ = "X" const val PAPER_ = "Y" const val SCISSORS_ = "Z" const val LOSE = "X" const val DRAW = "Y" const val WIN = "Z" fun part1(input: List<String>): Int { return input.toPairs().sumOf { when (it) { ROCK to ROCK_ -> 1 + 3 ROCK to PAPER_ -> 2 + 6 ROCK to SCISSORS_ -> 3 + 0 PAPER to ROCK_ -> 1 + 0 PAPER to PAPER_ -> 2 + 3 PAPER to SCISSORS_ -> 3 + 6 SCISSORS to ROCK_ -> 1 + 6 SCISSORS to PAPER_ -> 2 + 0 SCISSORS to SCISSORS_ -> 3 + 3 else -> error("invalid pair") }.toInt() } } fun part2(input: List<String>): Int { return input.toPairs().sumOf { when (it.reverse()) { LOSE to ROCK -> 0 + 3 DRAW to ROCK -> 3 + 1 WIN to ROCK -> 6 + 2 LOSE to PAPER -> 0 + 1 DRAW to PAPER -> 3 + 2 WIN to PAPER -> 6 + 3 LOSE to SCISSORS -> 0 + 2 DRAW to SCISSORS -> 3 + 3 WIN to SCISSORS -> 6 + 1 else -> error("invalid pair") }.toInt() } } fun main() { val input = readInput("main/day02/Day02") println(part1(input)) println(part2(input)) } fun List<String>.toPairs() = map { it.split(" ").let { pair -> pair.first() to pair.second() } }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day02/Day02Kt.class", "javap": "Compiled from \"day02.kt\"\npublic final class day02.Day02Kt {\n public static final java.lang.String ROCK;\n\n public static final java.lang.String PAPER;\n\n public static final java.lang.String SCISSORS;\n\n public static final java.lang.String ROCK_;\n\n public static final java.lang.String PAPER_;\n\n public static final java.lang.String SCISSORS_;\n\n public static final java.lang.String LOSE;\n\n public static final java.lang.String DRAW;\n\n public static final java.lang.String WIN;\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #20 // Method toPairs:(Ljava/util/List;)Ljava/util/List;\n 10: checkcast #22 // class java/lang/Iterable\n 13: astore_1\n 14: iconst_0\n 15: istore_2\n 16: aload_1\n 17: invokeinterface #26, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 22: astore_3\n 23: aload_3\n 24: invokeinterface #32, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifeq 257\n 32: aload_3\n 33: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 38: astore 4\n 40: iload_2\n 41: aload 4\n 43: checkcast #38 // class kotlin/Pair\n 46: astore 5\n 48: istore 8\n 50: iconst_0\n 51: istore 6\n 53: aload 5\n 55: astore 7\n 57: aload 7\n 59: ldc #40 // String A\n 61: ldc #42 // String X\n 63: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 66: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 69: ifeq 76\n 72: iconst_4\n 73: goto 245\n 76: aload 7\n 78: ldc #40 // String A\n 80: ldc #54 // String Y\n 82: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 85: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 88: ifeq 96\n 91: bipush 8\n 93: goto 245\n 96: aload 7\n 98: ldc #40 // String A\n 100: ldc #56 // String Z\n 102: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 105: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 108: ifeq 115\n 111: iconst_3\n 112: goto 245\n 115: aload 7\n 117: ldc #58 // String B\n 119: ldc #42 // String X\n 121: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 124: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 127: ifeq 134\n 130: iconst_1\n 131: goto 245\n 134: aload 7\n 136: ldc #58 // String B\n 138: ldc #54 // String Y\n 140: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 143: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 146: ifeq 153\n 149: iconst_5\n 150: goto 245\n 153: aload 7\n 155: ldc #58 // String B\n 157: ldc #56 // String Z\n 159: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 162: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 165: ifeq 173\n 168: bipush 9\n 170: goto 245\n 173: aload 7\n 175: ldc #60 // String C\n 177: ldc #42 // String X\n 179: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 182: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 185: ifeq 193\n 188: bipush 7\n 190: goto 245\n 193: aload 7\n 195: ldc #60 // String C\n 197: ldc #54 // String Y\n 199: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 202: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 205: ifeq 212\n 208: iconst_2\n 209: goto 245\n 212: aload 7\n 214: ldc #60 // String C\n 216: ldc #56 // String Z\n 218: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 221: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 224: ifeq 232\n 227: bipush 6\n 229: goto 245\n 232: new #62 // class java/lang/IllegalStateException\n 235: dup\n 236: ldc #64 // String invalid pair\n 238: invokevirtual #68 // Method java/lang/Object.toString:()Ljava/lang/String;\n 241: invokespecial #72 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 244: athrow\n 245: nop\n 246: istore 9\n 248: iload 8\n 250: iload 9\n 252: iadd\n 253: istore_2\n 254: goto 23\n 257: iload_2\n 258: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #20 // Method toPairs:(Ljava/util/List;)Ljava/util/List;\n 10: checkcast #22 // class java/lang/Iterable\n 13: astore_1\n 14: iconst_0\n 15: istore_2\n 16: aload_1\n 17: invokeinterface #26, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 22: astore_3\n 23: aload_3\n 24: invokeinterface #32, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifeq 260\n 32: aload_3\n 33: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 38: astore 4\n 40: iload_2\n 41: aload 4\n 43: checkcast #38 // class kotlin/Pair\n 46: astore 5\n 48: istore 8\n 50: iconst_0\n 51: istore 6\n 53: aload 5\n 55: invokestatic #86 // Method UtilsKt.reverse:(Lkotlin/Pair;)Lkotlin/Pair;\n 58: astore 7\n 60: aload 7\n 62: ldc #42 // String X\n 64: ldc #40 // String A\n 66: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 69: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 72: ifeq 79\n 75: iconst_3\n 76: goto 248\n 79: aload 7\n 81: ldc #54 // String Y\n 83: ldc #40 // String A\n 85: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 88: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 91: ifeq 98\n 94: iconst_4\n 95: goto 248\n 98: aload 7\n 100: ldc #56 // String Z\n 102: ldc #40 // String A\n 104: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 107: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 110: ifeq 118\n 113: bipush 8\n 115: goto 248\n 118: aload 7\n 120: ldc #42 // String X\n 122: ldc #58 // String B\n 124: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 127: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 130: ifeq 137\n 133: iconst_1\n 134: goto 248\n 137: aload 7\n 139: ldc #54 // String Y\n 141: ldc #58 // String B\n 143: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 146: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 149: ifeq 156\n 152: iconst_5\n 153: goto 248\n 156: aload 7\n 158: ldc #56 // String Z\n 160: ldc #58 // String B\n 162: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 165: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 168: ifeq 176\n 171: bipush 9\n 173: goto 248\n 176: aload 7\n 178: ldc #42 // String X\n 180: ldc #60 // String C\n 182: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 185: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 188: ifeq 195\n 191: iconst_2\n 192: goto 248\n 195: aload 7\n 197: ldc #54 // String Y\n 199: ldc #60 // String C\n 201: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 204: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 207: ifeq 215\n 210: bipush 6\n 212: goto 248\n 215: aload 7\n 217: ldc #56 // String Z\n 219: ldc #60 // String C\n 221: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 224: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 227: ifeq 235\n 230: bipush 7\n 232: goto 248\n 235: new #62 // class java/lang/IllegalStateException\n 238: dup\n 239: ldc #64 // String invalid pair\n 241: invokevirtual #68 // Method java/lang/Object.toString:()Ljava/lang/String;\n 244: invokespecial #72 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 247: athrow\n 248: nop\n 249: istore 9\n 251: iload 8\n 253: iload 9\n 255: iadd\n 256: istore_2\n 257: goto 23\n 260: iload_2\n 261: ireturn\n\n public static final void main();\n Code:\n 0: ldc #91 // String main/day02/Day02\n 2: invokestatic #95 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #97 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #103 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #109 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #111 // Method part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #103 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #109 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static final java.util.List<kotlin.Pair<java.lang.String, java.lang.String>> toPairs(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #114 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #22 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: astore_3\n 15: new #116 // class java/util/ArrayList\n 18: dup\n 19: aload_1\n 20: bipush 10\n 22: invokestatic #122 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 25: invokespecial #124 // Method java/util/ArrayList.\"<init>\":(I)V\n 28: checkcast #126 // class java/util/Collection\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: aload_3\n 37: invokeinterface #26, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 6\n 44: aload 6\n 46: invokeinterface #32, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 136\n 54: aload 6\n 56: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 7\n 63: aload 4\n 65: aload 7\n 67: checkcast #128 // class java/lang/String\n 70: astore 8\n 72: astore 13\n 74: iconst_0\n 75: istore 9\n 77: aload 8\n 79: checkcast #130 // class java/lang/CharSequence\n 82: iconst_1\n 83: anewarray #128 // class java/lang/String\n 86: astore 10\n 88: aload 10\n 90: iconst_0\n 91: ldc #132 // String\n 93: aastore\n 94: aload 10\n 96: iconst_0\n 97: iconst_0\n 98: bipush 6\n 100: aconst_null\n 101: invokestatic #138 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 104: astore 11\n 106: iconst_0\n 107: istore 12\n 109: aload 11\n 111: invokestatic #142 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 114: aload 11\n 116: invokestatic #145 // Method UtilsKt.second:(Ljava/util/List;)Ljava/lang/Object;\n 119: invokestatic #48 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 122: nop\n 123: nop\n 124: aload 13\n 126: swap\n 127: invokeinterface #149, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 132: pop\n 133: goto 44\n 136: aload 4\n 138: checkcast #79 // class java/util/List\n 141: nop\n 142: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #166 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day05/day05.kt
package day05 import java.util.* import readInput val stackIndices = listOf(1, 5, 9, 13, 17, 21, 25, 29, 33) var stacks: List<Stack<Char>> = emptyList() var moves: List<Move> = emptyList() val regex by lazy { """move (\d+) from (\d) to (\d)""".toRegex() } fun main() { val input = readInput("main/day05/Day05") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): String { input.parse() rearrange(::movingSingleCrate) return message() } fun part2(input: List<String>): String { input.parse() rearrange(::movingPartialStack) return message() } private fun List<String>.parse(numOfRows: Int = 8, numOfStacks: Int = 9) { stacks = take(numOfRows).parseToStacks(numOfStacks) moves = drop(numOfRows + 2).parseMoves() } private fun rearrange(move: (Move, List<Stack<Char>>) -> Unit) { moves.forEach { move(it, stacks) } } private fun movingSingleCrate(move: Move, stacks: List<Stack<Char>>) { repeat(move.numberOfCrates) { _ -> stacks[move.to - 1].push(stacks[move.from - 1].pop()) } } private fun movingPartialStack(move: Move, stacks: List<Stack<Char>>) { val tmp = mutableListOf<Char>() repeat(move.numberOfCrates) { _ -> tmp.add(stacks[move.from - 1].pop()) } tmp.reversed().forEach { c -> stacks[move.to - 1].push(c) } } private fun message() = stacks.map { it.pop() }.joinToString("") fun List<String>.parseMoves(): List<Move> { return this.map { regex.matchEntire(it)?.destructured?.let { (count, from, to) -> Move(from.toInt(), to.toInt(), count.toInt()) } ?: error("") } } fun List<String>.parseToStacks(numOfStacks: Int): List<Stack<Char>> { val result = mutableListOf<Stack<Char>>() repeat(numOfStacks) { result.add(Stack()) } this.reversed().forEach { s -> s.forEachIndexed { index, c -> if (index in stackIndices) { if (c != ' ') result[(index / 4)].push(c) } } } return result } data class Move(val from: Int, val to: Int, val numberOfCrates: Int)
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day05/Day05Kt.class", "javap": "Compiled from \"day05.kt\"\npublic final class day05.Day05Kt {\n private static final java.util.List<java.lang.Integer> stackIndices;\n\n private static java.util.List<? extends java.util.Stack<java.lang.Character>> stacks;\n\n private static java.util.List<day05.Move> moves;\n\n private static final kotlin.Lazy regex$delegate;\n\n public static final java.util.List<java.lang.Integer> getStackIndices();\n Code:\n 0: getstatic #12 // Field stackIndices:Ljava/util/List;\n 3: areturn\n\n public static final java.util.List<java.util.Stack<java.lang.Character>> getStacks();\n Code:\n 0: getstatic #17 // Field stacks:Ljava/util/List;\n 3: areturn\n\n public static final void setStacks(java.util.List<? extends java.util.Stack<java.lang.Character>>);\n Code:\n 0: aload_0\n 1: ldc #22 // String <set-?>\n 3: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: putstatic #17 // Field stacks:Ljava/util/List;\n 10: return\n\n public static final java.util.List<day05.Move> getMoves();\n Code:\n 0: getstatic #33 // Field moves:Ljava/util/List;\n 3: areturn\n\n public static final void setMoves(java.util.List<day05.Move>);\n Code:\n 0: aload_0\n 1: ldc #22 // String <set-?>\n 3: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: putstatic #33 // Field moves:Ljava/util/List;\n 10: return\n\n public static final kotlin.text.Regex getRegex();\n Code:\n 0: getstatic #41 // Field regex$delegate:Lkotlin/Lazy;\n 3: astore_0\n 4: aload_0\n 5: invokeinterface #47, 1 // InterfaceMethod kotlin/Lazy.getValue:()Ljava/lang/Object;\n 10: checkcast #49 // class kotlin/text/Regex\n 13: areturn\n\n public static final void main();\n Code:\n 0: ldc #53 // String main/day05/Day05\n 2: invokestatic #59 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #63 // Method part1:(Ljava/util/List;)Ljava/lang/String;\n 10: getstatic #69 // Field java/lang/System.out:Ljava/io/PrintStream;\n 13: swap\n 14: invokevirtual #75 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 17: aload_0\n 18: invokestatic #78 // Method part2:(Ljava/util/List;)Ljava/lang/String;\n 21: getstatic #69 // Field java/lang/System.out:Ljava/io/PrintStream;\n 24: swap\n 25: invokevirtual #75 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 28: return\n\n public static final java.lang.String part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #81 // String input\n 3: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iconst_0\n 8: iconst_0\n 9: iconst_3\n 10: aconst_null\n 11: invokestatic #85 // Method parse$default:(Ljava/util/List;IIILjava/lang/Object;)V\n 14: getstatic #91 // Field day05/Day05Kt$part1$1.INSTANCE:Lday05/Day05Kt$part1$1;\n 17: checkcast #93 // class kotlin/jvm/functions/Function2\n 20: invokestatic #97 // Method rearrange:(Lkotlin/jvm/functions/Function2;)V\n 23: invokestatic #101 // Method message:()Ljava/lang/String;\n 26: areturn\n\n public static final java.lang.String part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #81 // String input\n 3: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iconst_0\n 8: iconst_0\n 9: iconst_3\n 10: aconst_null\n 11: invokestatic #85 // Method parse$default:(Ljava/util/List;IIILjava/lang/Object;)V\n 14: getstatic #106 // Field day05/Day05Kt$part2$1.INSTANCE:Lday05/Day05Kt$part2$1;\n 17: checkcast #93 // class kotlin/jvm/functions/Function2\n 20: invokestatic #97 // Method rearrange:(Lkotlin/jvm/functions/Function2;)V\n 23: invokestatic #101 // Method message:()Ljava/lang/String;\n 26: areturn\n\n private static final void parse(java.util.List<java.lang.String>, int, int);\n Code:\n 0: aload_0\n 1: checkcast #111 // class java/lang/Iterable\n 4: iload_1\n 5: invokestatic #117 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 8: iload_2\n 9: invokestatic #121 // Method parseToStacks:(Ljava/util/List;I)Ljava/util/List;\n 12: putstatic #17 // Field stacks:Ljava/util/List;\n 15: aload_0\n 16: checkcast #111 // class java/lang/Iterable\n 19: iload_1\n 20: iconst_2\n 21: iadd\n 22: invokestatic #124 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 25: invokestatic #128 // Method parseMoves:(Ljava/util/List;)Ljava/util/List;\n 28: putstatic #33 // Field moves:Ljava/util/List;\n 31: return\n\n static void parse$default(java.util.List, int, int, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 9\n 6: bipush 8\n 8: istore_1\n 9: iload_3\n 10: iconst_2\n 11: iand\n 12: ifeq 18\n 15: bipush 9\n 17: istore_2\n 18: aload_0\n 19: iload_1\n 20: iload_2\n 21: invokestatic #134 // Method parse:(Ljava/util/List;II)V\n 24: return\n\n private static final void rearrange(kotlin.jvm.functions.Function2<? super day05.Move, ? super java.util.List<? extends java.util.Stack<java.lang.Character>>, kotlin.Unit>);\n Code:\n 0: getstatic #33 // Field moves:Ljava/util/List;\n 3: checkcast #111 // class java/lang/Iterable\n 6: astore_1\n 7: iconst_0\n 8: istore_2\n 9: aload_1\n 10: invokeinterface #139, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 15: astore_3\n 16: aload_3\n 17: invokeinterface #145, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 22: ifeq 60\n 25: aload_3\n 26: invokeinterface #148, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 31: astore 4\n 33: aload 4\n 35: checkcast #150 // class day05/Move\n 38: astore 5\n 40: iconst_0\n 41: istore 6\n 43: aload_0\n 44: aload 5\n 46: getstatic #17 // Field stacks:Ljava/util/List;\n 49: invokeinterface #154, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 54: pop\n 55: nop\n 56: nop\n 57: goto 16\n 60: nop\n 61: return\n\n private static final void movingSingleCrate(day05.Move, java.util.List<? extends java.util.Stack<java.lang.Character>>);\n Code:\n 0: aload_0\n 1: invokevirtual #171 // Method day05/Move.getNumberOfCrates:()I\n 4: istore_2\n 5: iconst_0\n 6: istore_3\n 7: iload_3\n 8: iload_2\n 9: if_icmpge 59\n 12: iconst_0\n 13: istore 4\n 15: aload_1\n 16: aload_0\n 17: invokevirtual #174 // Method day05/Move.getTo:()I\n 20: iconst_1\n 21: isub\n 22: invokeinterface #180, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 27: checkcast #182 // class java/util/Stack\n 30: aload_1\n 31: aload_0\n 32: invokevirtual #185 // Method day05/Move.getFrom:()I\n 35: iconst_1\n 36: isub\n 37: invokeinterface #180, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 42: checkcast #182 // class java/util/Stack\n 45: invokevirtual #188 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 48: invokevirtual #192 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 51: pop\n 52: nop\n 53: iinc 3, 1\n 56: goto 7\n 59: return\n\n private static final void movingPartialStack(day05.Move, java.util.List<? extends java.util.Stack<java.lang.Character>>);\n Code:\n 0: new #196 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #199 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #176 // class java/util/List\n 10: astore_2\n 11: aload_0\n 12: invokevirtual #171 // Method day05/Move.getNumberOfCrates:()I\n 15: istore_3\n 16: iconst_0\n 17: istore 4\n 19: iload 4\n 21: iload_3\n 22: if_icmpge 66\n 25: iconst_0\n 26: istore 6\n 28: aload_2\n 29: aload_1\n 30: aload_0\n 31: invokevirtual #185 // Method day05/Move.getFrom:()I\n 34: iconst_1\n 35: isub\n 36: invokeinterface #180, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 41: checkcast #182 // class java/util/Stack\n 44: invokevirtual #188 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 47: dup\n 48: ldc #201 // String pop(...)\n 50: invokestatic #204 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 53: invokeinterface #208, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 58: pop\n 59: nop\n 60: iinc 4, 1\n 63: goto 19\n 66: aload_2\n 67: checkcast #111 // class java/lang/Iterable\n 70: invokestatic #212 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 73: checkcast #111 // class java/lang/Iterable\n 76: astore_3\n 77: iconst_0\n 78: istore 4\n 80: aload_3\n 81: invokeinterface #139, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 86: astore 5\n 88: aload 5\n 90: invokeinterface #145, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 95: ifeq 149\n 98: aload 5\n 100: invokeinterface #148, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 105: astore 6\n 107: aload 6\n 109: checkcast #214 // class java/lang/Character\n 112: invokevirtual #218 // Method java/lang/Character.charValue:()C\n 115: istore 7\n 117: iconst_0\n 118: istore 8\n 120: aload_1\n 121: aload_0\n 122: invokevirtual #174 // Method day05/Move.getTo:()I\n 125: iconst_1\n 126: isub\n 127: invokeinterface #180, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 132: checkcast #182 // class java/util/Stack\n 135: iload 7\n 137: invokestatic #222 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 140: invokevirtual #192 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 143: pop\n 144: nop\n 145: nop\n 146: goto 88\n 149: nop\n 150: return\n\n private static final java.lang.String message();\n Code:\n 0: getstatic #17 // Field stacks:Ljava/util/List;\n 3: checkcast #111 // class java/lang/Iterable\n 6: astore_0\n 7: iconst_0\n 8: istore_1\n 9: aload_0\n 10: astore_2\n 11: new #196 // class java/util/ArrayList\n 14: dup\n 15: aload_0\n 16: bipush 10\n 18: invokestatic #231 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 21: invokespecial #234 // Method java/util/ArrayList.\"<init>\":(I)V\n 24: checkcast #236 // class java/util/Collection\n 27: astore_3\n 28: iconst_0\n 29: istore 4\n 31: aload_2\n 32: invokeinterface #139, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore 5\n 39: aload 5\n 41: invokeinterface #145, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 91\n 49: aload 5\n 51: invokeinterface #148, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 56: astore 6\n 58: aload_3\n 59: aload 6\n 61: checkcast #182 // class java/util/Stack\n 64: astore 7\n 66: astore 9\n 68: iconst_0\n 69: istore 8\n 71: aload 7\n 73: invokevirtual #188 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 76: checkcast #214 // class java/lang/Character\n 79: aload 9\n 81: swap\n 82: invokeinterface #237, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 87: pop\n 88: goto 39\n 91: aload_3\n 92: checkcast #176 // class java/util/List\n 95: nop\n 96: checkcast #111 // class java/lang/Iterable\n 99: ldc #239 // String\n 101: checkcast #241 // class java/lang/CharSequence\n 104: aconst_null\n 105: aconst_null\n 106: iconst_0\n 107: aconst_null\n 108: aconst_null\n 109: bipush 62\n 111: aconst_null\n 112: invokestatic #245 // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;\n 115: areturn\n\n public static final java.util.List<day05.Move> parseMoves(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc_w #257 // String <this>\n 4: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: checkcast #111 // class java/lang/Iterable\n 11: astore_1\n 12: iconst_0\n 13: istore_2\n 14: aload_1\n 15: astore_3\n 16: new #196 // class java/util/ArrayList\n 19: dup\n 20: aload_1\n 21: bipush 10\n 23: invokestatic #231 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #234 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #236 // class java/util/Collection\n 32: astore 4\n 34: iconst_0\n 35: istore 5\n 37: aload_3\n 38: invokeinterface #139, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 43: astore 6\n 45: aload 6\n 47: invokeinterface #145, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 52: ifeq 222\n 55: aload 6\n 57: invokeinterface #148, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 62: astore 7\n 64: aload 4\n 66: aload 7\n 68: checkcast #259 // class java/lang/String\n 71: astore 8\n 73: astore 15\n 75: iconst_0\n 76: istore 9\n 78: invokestatic #261 // Method getRegex:()Lkotlin/text/Regex;\n 81: aload 8\n 83: checkcast #241 // class java/lang/CharSequence\n 86: invokevirtual #265 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 89: dup\n 90: ifnull 196\n 93: invokeinterface #271, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 98: dup\n 99: ifnull 196\n 102: astore 10\n 104: iconst_0\n 105: istore 11\n 107: aload 10\n 109: invokevirtual #277 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 112: invokeinterface #280, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 117: iconst_1\n 118: invokeinterface #180, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 123: checkcast #259 // class java/lang/String\n 126: astore 12\n 128: aload 10\n 130: invokevirtual #277 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 133: invokeinterface #280, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 138: iconst_2\n 139: invokeinterface #180, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 144: checkcast #259 // class java/lang/String\n 147: astore 13\n 149: aload 10\n 151: invokevirtual #277 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 154: invokeinterface #280, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 159: iconst_3\n 160: invokeinterface #180, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 165: checkcast #259 // class java/lang/String\n 168: astore 14\n 170: new #150 // class day05/Move\n 173: dup\n 174: aload 13\n 176: invokestatic #286 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 179: aload 14\n 181: invokestatic #286 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 184: aload 12\n 186: invokestatic #286 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 189: invokespecial #289 // Method day05/Move.\"<init>\":(III)V\n 192: nop\n 193: goto 210\n 196: pop\n 197: new #291 // class java/lang/IllegalStateException\n 200: dup\n 201: ldc #239 // String\n 203: invokevirtual #294 // Method java/lang/Object.toString:()Ljava/lang/String;\n 206: invokespecial #297 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 209: athrow\n 210: aload 15\n 212: swap\n 213: invokeinterface #237, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 218: pop\n 219: goto 45\n 222: aload 4\n 224: checkcast #176 // class java/util/List\n 227: nop\n 228: areturn\n\n public static final java.util.List<java.util.Stack<java.lang.Character>> parseToStacks(java.util.List<java.lang.String>, int);\n Code:\n 0: aload_0\n 1: ldc_w #257 // String <this>\n 4: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: new #196 // class java/util/ArrayList\n 10: dup\n 11: invokespecial #199 // Method java/util/ArrayList.\"<init>\":()V\n 14: checkcast #176 // class java/util/List\n 17: astore_2\n 18: iconst_0\n 19: istore_3\n 20: iload_3\n 21: iload_1\n 22: if_icmpge 51\n 25: iload_3\n 26: istore 4\n 28: iconst_0\n 29: istore 5\n 31: aload_2\n 32: new #182 // class java/util/Stack\n 35: dup\n 36: invokespecial #306 // Method java/util/Stack.\"<init>\":()V\n 39: invokeinterface #208, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 44: pop\n 45: iinc 3, 1\n 48: goto 20\n 51: aload_0\n 52: checkcast #111 // class java/lang/Iterable\n 55: invokestatic #212 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 58: checkcast #111 // class java/lang/Iterable\n 61: astore_3\n 62: iconst_0\n 63: istore 4\n 65: aload_3\n 66: invokeinterface #139, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 71: astore 5\n 73: aload 5\n 75: invokeinterface #145, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 80: ifeq 214\n 83: aload 5\n 85: invokeinterface #148, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 90: astore 6\n 92: aload 6\n 94: checkcast #259 // class java/lang/String\n 97: astore 7\n 99: iconst_0\n 100: istore 8\n 102: aload 7\n 104: checkcast #241 // class java/lang/CharSequence\n 107: astore 9\n 109: iconst_0\n 110: istore 10\n 112: iconst_0\n 113: istore 11\n 115: iconst_0\n 116: istore 12\n 118: iload 12\n 120: aload 9\n 122: invokeinterface #309, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 127: if_icmpge 208\n 130: aload 9\n 132: iload 12\n 134: invokeinterface #313, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 139: istore 13\n 141: iload 11\n 143: iinc 11, 1\n 146: iload 13\n 148: istore 14\n 150: istore 15\n 152: iconst_0\n 153: istore 16\n 155: getstatic #12 // Field stackIndices:Ljava/util/List;\n 158: iload 15\n 160: invokestatic #316 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 163: invokeinterface #319, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 168: ifeq 200\n 171: iload 14\n 173: bipush 32\n 175: if_icmpeq 200\n 178: aload_2\n 179: iload 15\n 181: iconst_4\n 182: idiv\n 183: invokeinterface #180, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 188: checkcast #182 // class java/util/Stack\n 191: iload 14\n 193: invokestatic #222 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 196: invokevirtual #192 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 199: pop\n 200: nop\n 201: nop\n 202: iinc 12, 1\n 205: goto 118\n 208: nop\n 209: nop\n 210: nop\n 211: goto 73\n 214: nop\n 215: aload_2\n 216: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #334 // Method main:()V\n 3: return\n\n private static final kotlin.text.Regex regex_delegate$lambda$0();\n Code:\n 0: new #49 // class kotlin/text/Regex\n 3: dup\n 4: ldc_w #339 // String move (\\\\d+) from (\\\\d) to (\\\\d)\n 7: invokespecial #340 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 10: areturn\n\n public static final void access$movingSingleCrate(day05.Move, java.util.List);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #343 // Method movingSingleCrate:(Lday05/Move;Ljava/util/List;)V\n 5: return\n\n public static final void access$movingPartialStack(day05.Move, java.util.List);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #346 // Method movingPartialStack:(Lday05/Move;Ljava/util/List;)V\n 5: return\n\n static {};\n Code:\n 0: bipush 9\n 2: anewarray #282 // class java/lang/Integer\n 5: astore_0\n 6: aload_0\n 7: iconst_0\n 8: iconst_1\n 9: invokestatic #316 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 12: aastore\n 13: aload_0\n 14: iconst_1\n 15: iconst_5\n 16: invokestatic #316 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 19: aastore\n 20: aload_0\n 21: iconst_2\n 22: bipush 9\n 24: invokestatic #316 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 27: aastore\n 28: aload_0\n 29: iconst_3\n 30: bipush 13\n 32: invokestatic #316 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: aastore\n 36: aload_0\n 37: iconst_4\n 38: bipush 17\n 40: invokestatic #316 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 43: aastore\n 44: aload_0\n 45: iconst_5\n 46: bipush 21\n 48: invokestatic #316 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 51: aastore\n 52: aload_0\n 53: bipush 6\n 55: bipush 25\n 57: invokestatic #316 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 60: aastore\n 61: aload_0\n 62: bipush 7\n 64: bipush 29\n 66: invokestatic #316 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 69: aastore\n 70: aload_0\n 71: bipush 8\n 73: bipush 33\n 75: invokestatic #316 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 78: aastore\n 79: aload_0\n 80: invokestatic #351 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 83: putstatic #12 // Field stackIndices:Ljava/util/List;\n 86: invokestatic #354 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 89: putstatic #17 // Field stacks:Ljava/util/List;\n 92: invokestatic #354 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 95: putstatic #33 // Field moves:Ljava/util/List;\n 98: invokedynamic #369, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function0;\n 103: invokestatic #375 // Method kotlin/LazyKt.lazy:(Lkotlin/jvm/functions/Function0;)Lkotlin/Lazy;\n 106: putstatic #41 // Field regex$delegate:Lkotlin/Lazy;\n 109: return\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day05/Day05Kt$part2$1.class", "javap": "Compiled from \"day05.kt\"\nfinal class day05.Day05Kt$part2$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<day05.Move, java.util.List<? extends java.util.Stack<java.lang.Character>>, kotlin.Unit> {\n public static final day05.Day05Kt$part2$1 INSTANCE;\n\n day05.Day05Kt$part2$1();\n Code:\n 0: aload_0\n 1: iconst_2\n 2: ldc #11 // class day05/Day05Kt\n 4: ldc #13 // String movingPartialStack\n 6: ldc #15 // String movingPartialStack(Lday05/Move;Ljava/util/List;)V\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final void invoke(day05.Move, java.util.List<? extends java.util.Stack<java.lang.Character>>);\n Code:\n 0: aload_1\n 1: ldc #25 // String p0\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #33 // String p1\n 9: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #36 // Method day05/Day05Kt.access$movingPartialStack:(Lday05/Move;Ljava/util/List;)V\n 17: return\n\n public java.lang.Object invoke(java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #41 // class day05/Move\n 5: aload_2\n 6: checkcast #43 // class java/util/List\n 9: invokevirtual #45 // Method invoke:(Lday05/Move;Ljava/util/List;)V\n 12: getstatic #51 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 15: areturn\n\n static {};\n Code:\n 0: new #2 // class day05/Day05Kt$part2$1\n 3: dup\n 4: invokespecial #56 // Method \"<init>\":()V\n 7: putstatic #58 // Field INSTANCE:Lday05/Day05Kt$part2$1;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day05/Day05Kt$part1$1.class", "javap": "Compiled from \"day05.kt\"\nfinal class day05.Day05Kt$part1$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function2<day05.Move, java.util.List<? extends java.util.Stack<java.lang.Character>>, kotlin.Unit> {\n public static final day05.Day05Kt$part1$1 INSTANCE;\n\n day05.Day05Kt$part1$1();\n Code:\n 0: aload_0\n 1: iconst_2\n 2: ldc #11 // class day05/Day05Kt\n 4: ldc #13 // String movingSingleCrate\n 6: ldc #15 // String movingSingleCrate(Lday05/Move;Ljava/util/List;)V\n 8: iconst_1\n 9: invokespecial #18 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final void invoke(day05.Move, java.util.List<? extends java.util.Stack<java.lang.Character>>);\n Code:\n 0: aload_1\n 1: ldc #25 // String p0\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #33 // String p1\n 9: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #36 // Method day05/Day05Kt.access$movingSingleCrate:(Lday05/Move;Ljava/util/List;)V\n 17: return\n\n public java.lang.Object invoke(java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #41 // class day05/Move\n 5: aload_2\n 6: checkcast #43 // class java/util/List\n 9: invokevirtual #45 // Method invoke:(Lday05/Move;Ljava/util/List;)V\n 12: getstatic #51 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 15: areturn\n\n static {};\n Code:\n 0: new #2 // class day05/Day05Kt$part1$1\n 3: dup\n 4: invokespecial #56 // Method \"<init>\":()V\n 7: putstatic #58 // Field INSTANCE:Lday05/Day05Kt$part1$1;\n 10: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day18/day18.kt
package day18 import readInput fun main() { val input = readInput("main/day18/Day18") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int = input.toCubes().surfaceArea() fun part2(input: List<String>): Int = exteriorSurfaceArea(input.toCubes()) private fun List<String>.toCubes() = map { line -> val (x, y, z) = line.split(",") Cube(x.toInt(), y.toInt(), z.toInt()) } private fun List<Cube>.surfaceArea(): Int = sumOf { it.neighbours().filter { c -> c !in this }.size } private fun exteriorSurfaceArea(cubes: List<Cube>): Int { val minX = cubes.minOf { it.x } - 1 val maxX = cubes.maxOf { it.x } + 1 val minY = cubes.minOf { it.y } - 1 val maxY = cubes.maxOf { it.y } + 1 val minZ = cubes.minOf { it.z } - 1 val maxZ = cubes.maxOf { it.z } + 1 val surface = mutableSetOf<Cube>() val queue = mutableListOf(Cube(minX, minY, minZ)) while (queue.isNotEmpty()) { val current = queue.removeLast() if (current in cubes) continue val (x, y, z) = current if (x !in minX..maxX || y !in minY..maxY || z !in minZ..maxZ) continue if (surface.add(current)) queue.addAll(current.neighbours()) } return cubes.sumOf { it.neighbours().filter { c -> c in surface }.size } } data class Cube(val x: Int, val y: Int, val z: Int) { fun neighbours() = listOf( Cube(x + 1, y, z), Cube(x - 1, y, z), Cube(x, y + 1, z), Cube(x, y - 1, z), Cube(x, y, z + 1), Cube(x, y, z - 1) ) }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day18/Day18Kt.class", "javap": "Compiled from \"day18.kt\"\npublic final class day18.Day18Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String main/day18/Day18\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #33 // Method part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #48 // Method toCubes:(Ljava/util/List;)Ljava/util/List;\n 10: invokestatic #51 // Method surfaceArea:(Ljava/util/List;)I\n 13: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #48 // Method toCubes:(Ljava/util/List;)Ljava/util/List;\n 10: invokestatic #54 // Method exteriorSurfaceArea:(Ljava/util/List;)I\n 13: ireturn\n\n private static final java.util.List<day18.Cube> toCubes(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #57 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: astore_3\n 9: new #59 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #65 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #68 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #70 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 173\n 48: aload 6\n 50: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #86 // class java/lang/String\n 64: astore 8\n 66: astore 14\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: checkcast #88 // class java/lang/CharSequence\n 76: iconst_1\n 77: anewarray #86 // class java/lang/String\n 80: astore 10\n 82: aload 10\n 84: iconst_0\n 85: ldc #90 // String ,\n 87: aastore\n 88: aload 10\n 90: iconst_0\n 91: iconst_0\n 92: bipush 6\n 94: aconst_null\n 95: invokestatic #96 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 98: astore 11\n 100: aload 11\n 102: iconst_0\n 103: invokeinterface #102, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 108: checkcast #86 // class java/lang/String\n 111: astore 10\n 113: aload 11\n 115: iconst_1\n 116: invokeinterface #102, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 121: checkcast #86 // class java/lang/String\n 124: astore 12\n 126: aload 11\n 128: iconst_2\n 129: invokeinterface #102, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 134: checkcast #86 // class java/lang/String\n 137: astore 13\n 139: new #104 // class day18/Cube\n 142: dup\n 143: aload 10\n 145: invokestatic #110 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 148: aload 12\n 150: invokestatic #110 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 153: aload 13\n 155: invokestatic #110 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 158: invokespecial #113 // Method day18/Cube.\"<init>\":(III)V\n 161: aload 14\n 163: swap\n 164: invokeinterface #117, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 169: pop\n 170: goto 38\n 173: aload 4\n 175: checkcast #98 // class java/util/List\n 178: nop\n 179: areturn\n\n private static final int surfaceArea(java.util.List<day18.Cube>);\n Code:\n 0: aload_0\n 1: checkcast #57 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 168\n 23: aload_3\n 24: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 29: astore 4\n 31: iload_2\n 32: aload 4\n 34: checkcast #104 // class day18/Cube\n 37: astore 5\n 39: istore 16\n 41: iconst_0\n 42: istore 6\n 44: aload 5\n 46: invokevirtual #139 // Method day18/Cube.neighbours:()Ljava/util/List;\n 49: checkcast #57 // class java/lang/Iterable\n 52: astore 7\n 54: iconst_0\n 55: istore 8\n 57: aload 7\n 59: astore 9\n 61: new #59 // class java/util/ArrayList\n 64: dup\n 65: invokespecial #141 // Method java/util/ArrayList.\"<init>\":()V\n 68: checkcast #70 // class java/util/Collection\n 71: astore 10\n 73: iconst_0\n 74: istore 11\n 76: aload 9\n 78: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 83: astore 12\n 85: aload 12\n 87: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 92: ifeq 146\n 95: aload 12\n 97: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 102: astore 13\n 104: aload 13\n 106: checkcast #104 // class day18/Cube\n 109: astore 14\n 111: iconst_0\n 112: istore 15\n 114: aload_0\n 115: aload 14\n 117: invokeinterface #144, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 122: ifne 129\n 125: iconst_1\n 126: goto 130\n 129: iconst_0\n 130: ifeq 85\n 133: aload 10\n 135: aload 13\n 137: invokeinterface #117, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 142: pop\n 143: goto 85\n 146: aload 10\n 148: checkcast #98 // class java/util/List\n 151: nop\n 152: invokeinterface #148, 1 // InterfaceMethod java/util/List.size:()I\n 157: istore 17\n 159: iload 16\n 161: iload 17\n 163: iadd\n 164: istore_2\n 165: goto 14\n 168: iload_2\n 169: ireturn\n\n private static final int exteriorSurfaceArea(java.util.List<day18.Cube>);\n Code:\n 0: aload_0\n 1: checkcast #57 // class java/lang/Iterable\n 4: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 9: astore_3\n 10: aload_3\n 11: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 16: ifne 27\n 19: new #161 // class java/util/NoSuchElementException\n 22: dup\n 23: invokespecial #162 // Method java/util/NoSuchElementException.\"<init>\":()V\n 26: athrow\n 27: aload_3\n 28: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 33: checkcast #104 // class day18/Cube\n 36: astore 4\n 38: iconst_0\n 39: istore 5\n 41: aload 4\n 43: invokevirtual #165 // Method day18/Cube.getX:()I\n 46: istore 4\n 48: aload_3\n 49: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 92\n 57: aload_3\n 58: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: checkcast #104 // class day18/Cube\n 66: astore 5\n 68: iconst_0\n 69: istore 6\n 71: aload 5\n 73: invokevirtual #165 // Method day18/Cube.getX:()I\n 76: istore 5\n 78: iload 4\n 80: iload 5\n 82: if_icmple 48\n 85: iload 5\n 87: istore 4\n 89: goto 48\n 92: iload 4\n 94: iconst_1\n 95: isub\n 96: istore_1\n 97: aload_0\n 98: checkcast #57 // class java/lang/Iterable\n 101: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 106: astore 4\n 108: aload 4\n 110: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 115: ifne 126\n 118: new #161 // class java/util/NoSuchElementException\n 121: dup\n 122: invokespecial #162 // Method java/util/NoSuchElementException.\"<init>\":()V\n 125: athrow\n 126: aload 4\n 128: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 133: checkcast #104 // class day18/Cube\n 136: astore 5\n 138: iconst_0\n 139: istore 6\n 141: aload 5\n 143: invokevirtual #165 // Method day18/Cube.getX:()I\n 146: istore 5\n 148: aload 4\n 150: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 155: ifeq 194\n 158: aload 4\n 160: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 165: checkcast #104 // class day18/Cube\n 168: astore 6\n 170: iconst_0\n 171: istore 7\n 173: aload 6\n 175: invokevirtual #165 // Method day18/Cube.getX:()I\n 178: istore 6\n 180: iload 5\n 182: iload 6\n 184: if_icmpge 148\n 187: iload 6\n 189: istore 5\n 191: goto 148\n 194: iload 5\n 196: iconst_1\n 197: iadd\n 198: istore_2\n 199: aload_0\n 200: checkcast #57 // class java/lang/Iterable\n 203: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 208: astore 5\n 210: aload 5\n 212: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 217: ifne 228\n 220: new #161 // class java/util/NoSuchElementException\n 223: dup\n 224: invokespecial #162 // Method java/util/NoSuchElementException.\"<init>\":()V\n 227: athrow\n 228: aload 5\n 230: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 235: checkcast #104 // class day18/Cube\n 238: astore 6\n 240: iconst_0\n 241: istore 7\n 243: aload 6\n 245: invokevirtual #168 // Method day18/Cube.getY:()I\n 248: istore 6\n 250: aload 5\n 252: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 257: ifeq 296\n 260: aload 5\n 262: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 267: checkcast #104 // class day18/Cube\n 270: astore 7\n 272: iconst_0\n 273: istore 8\n 275: aload 7\n 277: invokevirtual #168 // Method day18/Cube.getY:()I\n 280: istore 7\n 282: iload 6\n 284: iload 7\n 286: if_icmple 250\n 289: iload 7\n 291: istore 6\n 293: goto 250\n 296: iload 6\n 298: iconst_1\n 299: isub\n 300: istore_3\n 301: aload_0\n 302: checkcast #57 // class java/lang/Iterable\n 305: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 310: astore 6\n 312: aload 6\n 314: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 319: ifne 330\n 322: new #161 // class java/util/NoSuchElementException\n 325: dup\n 326: invokespecial #162 // Method java/util/NoSuchElementException.\"<init>\":()V\n 329: athrow\n 330: aload 6\n 332: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 337: checkcast #104 // class day18/Cube\n 340: astore 7\n 342: iconst_0\n 343: istore 8\n 345: aload 7\n 347: invokevirtual #168 // Method day18/Cube.getY:()I\n 350: istore 7\n 352: aload 6\n 354: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 359: ifeq 398\n 362: aload 6\n 364: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 369: checkcast #104 // class day18/Cube\n 372: astore 8\n 374: iconst_0\n 375: istore 9\n 377: aload 8\n 379: invokevirtual #168 // Method day18/Cube.getY:()I\n 382: istore 8\n 384: iload 7\n 386: iload 8\n 388: if_icmpge 352\n 391: iload 8\n 393: istore 7\n 395: goto 352\n 398: iload 7\n 400: iconst_1\n 401: iadd\n 402: istore 4\n 404: aload_0\n 405: checkcast #57 // class java/lang/Iterable\n 408: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 413: astore 7\n 415: aload 7\n 417: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 422: ifne 433\n 425: new #161 // class java/util/NoSuchElementException\n 428: dup\n 429: invokespecial #162 // Method java/util/NoSuchElementException.\"<init>\":()V\n 432: athrow\n 433: aload 7\n 435: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 440: checkcast #104 // class day18/Cube\n 443: astore 8\n 445: iconst_0\n 446: istore 9\n 448: aload 8\n 450: invokevirtual #171 // Method day18/Cube.getZ:()I\n 453: istore 8\n 455: aload 7\n 457: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 462: ifeq 501\n 465: aload 7\n 467: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 472: checkcast #104 // class day18/Cube\n 475: astore 9\n 477: iconst_0\n 478: istore 10\n 480: aload 9\n 482: invokevirtual #171 // Method day18/Cube.getZ:()I\n 485: istore 9\n 487: iload 8\n 489: iload 9\n 491: if_icmple 455\n 494: iload 9\n 496: istore 8\n 498: goto 455\n 501: iload 8\n 503: iconst_1\n 504: isub\n 505: istore 5\n 507: aload_0\n 508: checkcast #57 // class java/lang/Iterable\n 511: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 516: astore 8\n 518: aload 8\n 520: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 525: ifne 536\n 528: new #161 // class java/util/NoSuchElementException\n 531: dup\n 532: invokespecial #162 // Method java/util/NoSuchElementException.\"<init>\":()V\n 535: athrow\n 536: aload 8\n 538: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 543: checkcast #104 // class day18/Cube\n 546: astore 9\n 548: iconst_0\n 549: istore 10\n 551: aload 9\n 553: invokevirtual #171 // Method day18/Cube.getZ:()I\n 556: istore 9\n 558: aload 8\n 560: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 565: ifeq 604\n 568: aload 8\n 570: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 575: checkcast #104 // class day18/Cube\n 578: astore 10\n 580: iconst_0\n 581: istore 11\n 583: aload 10\n 585: invokevirtual #171 // Method day18/Cube.getZ:()I\n 588: istore 10\n 590: iload 9\n 592: iload 10\n 594: if_icmpge 558\n 597: iload 10\n 599: istore 9\n 601: goto 558\n 604: iload 9\n 606: iconst_1\n 607: iadd\n 608: istore 6\n 610: new #173 // class java/util/LinkedHashSet\n 613: dup\n 614: invokespecial #174 // Method java/util/LinkedHashSet.\"<init>\":()V\n 617: checkcast #176 // class java/util/Set\n 620: astore 7\n 622: iconst_1\n 623: anewarray #104 // class day18/Cube\n 626: astore 9\n 628: aload 9\n 630: iconst_0\n 631: new #104 // class day18/Cube\n 634: dup\n 635: iload_1\n 636: iload_3\n 637: iload 5\n 639: invokespecial #113 // Method day18/Cube.\"<init>\":(III)V\n 642: aastore\n 643: aload 9\n 645: invokestatic #180 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 648: astore 8\n 650: aload 8\n 652: checkcast #70 // class java/util/Collection\n 655: invokeinterface #183, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 660: ifne 667\n 663: iconst_1\n 664: goto 668\n 667: iconst_0\n 668: ifeq 830\n 671: aload 8\n 673: invokeinterface #186, 1 // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;\n 678: dup\n 679: ldc #188 // String removeLast(...)\n 681: invokestatic #191 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 684: checkcast #104 // class day18/Cube\n 687: astore 9\n 689: aload_0\n 690: aload 9\n 692: invokeinterface #144, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 697: ifne 650\n 700: aload 9\n 702: invokevirtual #194 // Method day18/Cube.component1:()I\n 705: istore 10\n 707: aload 9\n 709: invokevirtual #197 // Method day18/Cube.component2:()I\n 712: istore 11\n 714: aload 9\n 716: invokevirtual #200 // Method day18/Cube.component3:()I\n 719: istore 12\n 721: iload_1\n 722: iload 10\n 724: if_icmpgt 741\n 727: iload 10\n 729: iload_2\n 730: if_icmpgt 737\n 733: iconst_1\n 734: goto 742\n 737: iconst_0\n 738: goto 742\n 741: iconst_0\n 742: ifeq 650\n 745: iload_3\n 746: iload 11\n 748: if_icmpgt 766\n 751: iload 11\n 753: iload 4\n 755: if_icmpgt 762\n 758: iconst_1\n 759: goto 767\n 762: iconst_0\n 763: goto 767\n 766: iconst_0\n 767: ifeq 650\n 770: iload 5\n 772: iload 12\n 774: if_icmpgt 792\n 777: iload 12\n 779: iload 6\n 781: if_icmpgt 788\n 784: iconst_1\n 785: goto 793\n 788: iconst_0\n 789: goto 793\n 792: iconst_0\n 793: ifne 799\n 796: goto 650\n 799: aload 7\n 801: aload 9\n 803: invokeinterface #201, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 808: ifeq 650\n 811: aload 8\n 813: aload 9\n 815: invokevirtual #139 // Method day18/Cube.neighbours:()Ljava/util/List;\n 818: checkcast #70 // class java/util/Collection\n 821: invokeinterface #205, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 826: pop\n 827: goto 650\n 830: aload_0\n 831: checkcast #57 // class java/lang/Iterable\n 834: astore 9\n 836: iconst_0\n 837: istore 10\n 839: aload 9\n 841: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 846: astore 11\n 848: aload 11\n 850: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 855: ifeq 999\n 858: aload 11\n 860: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 865: astore 12\n 867: iload 10\n 869: aload 12\n 871: checkcast #104 // class day18/Cube\n 874: astore 13\n 876: istore 24\n 878: iconst_0\n 879: istore 14\n 881: aload 13\n 883: invokevirtual #139 // Method day18/Cube.neighbours:()Ljava/util/List;\n 886: checkcast #57 // class java/lang/Iterable\n 889: astore 15\n 891: iconst_0\n 892: istore 16\n 894: aload 15\n 896: astore 17\n 898: new #59 // class java/util/ArrayList\n 901: dup\n 902: invokespecial #141 // Method java/util/ArrayList.\"<init>\":()V\n 905: checkcast #70 // class java/util/Collection\n 908: astore 18\n 910: iconst_0\n 911: istore 19\n 913: aload 17\n 915: invokeinterface #74, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 920: astore 20\n 922: aload 20\n 924: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 929: ifeq 976\n 932: aload 20\n 934: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 939: astore 21\n 941: aload 21\n 943: checkcast #104 // class day18/Cube\n 946: astore 22\n 948: iconst_0\n 949: istore 23\n 951: aload 7\n 953: aload 22\n 955: invokeinterface #206, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 960: ifeq 922\n 963: aload 18\n 965: aload 21\n 967: invokeinterface #117, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 972: pop\n 973: goto 922\n 976: aload 18\n 978: checkcast #98 // class java/util/List\n 981: nop\n 982: invokeinterface #148, 1 // InterfaceMethod java/util/List.size:()I\n 987: istore 25\n 989: iload 24\n 991: iload 25\n 993: iadd\n 994: istore 10\n 996: goto 848\n 999: iload 10\n 1001: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #228 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day20/day20.kt
package day20 import readInput const val encryptionKey = 811589153L fun main() { val input = readInput("main/day20/Day20_test") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Long { val original = input.mapIndexed { index, s -> Num(originalPosition = index, number = s.toLong()) }.toMutableList() val mixed = mix(original) return summedCoordinates(mixed) } fun part2(input: List<String>): Long { val original = input.mapIndexed { index, s -> Num(originalPosition = index, number = s.toLong() * encryptionKey) }.toMutableList() val mixed = generateSequence(original) { mix(original, it).toMutableList() }.drop(10).first() return summedCoordinates(mixed) } private fun mix(list: MutableList<Num>, original: MutableList<Num> = list, position: Int = 0): List<Num> { if (position == list.size) return list val index = list.indexOfFirst { it == original.firstOrNull { o -> o.originalPosition == position } } val current = list[index] var newIndex = (index + current.number) % (list.size - 1) if (newIndex <= 0) newIndex += list.size - 1 list.removeAt(index) list.add(newIndex.toInt(), current.move()) return mix(list = list, original = list, position = position + 1) } private fun summedCoordinates(mixed: List<Num>): Long { val zero = mixed.indexOfFirst { it.number == 0L } val a = mixed[(zero + 1000) % mixed.size].number val b = mixed[(zero + 2000) % mixed.size].number val c = mixed[(zero + 3000) % mixed.size].number return a + b + c } data class Num(val originalPosition: Int, val currentPosition: Int = originalPosition, val number: Long, val moved: Int = 0) { fun move() = copy(moved = moved + 1) }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day20/Day20Kt.class", "javap": "Compiled from \"day20.kt\"\npublic final class day20.Day20Kt {\n public static final long encryptionKey;\n\n public static final void main();\n Code:\n 0: ldc #8 // String main/day20/Day20_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method part1:(Ljava/util/List;)J\n 10: lstore_1\n 11: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: lload_1\n 15: invokevirtual #30 // Method java/io/PrintStream.println:(J)V\n 18: aload_0\n 19: invokestatic #33 // Method part2:(Ljava/util/List;)J\n 22: lstore_1\n 23: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: lload_1\n 27: invokevirtual #30 // Method java/io/PrintStream.println:(J)V\n 30: return\n\n public static final long part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #46 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #48 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #54 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #58 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #60 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: iconst_0\n 38: istore 7\n 40: aload 4\n 42: invokeinterface #64, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 47: astore 8\n 49: aload 8\n 51: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 56: ifeq 132\n 59: aload 8\n 61: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 66: astore 9\n 68: aload 5\n 70: iload 7\n 72: iinc 7, 1\n 75: istore 10\n 77: iload 10\n 79: ifge 85\n 82: invokestatic #77 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 85: iload 10\n 87: aload 9\n 89: checkcast #79 // class java/lang/String\n 92: astore 11\n 94: istore 12\n 96: astore 14\n 98: iconst_0\n 99: istore 13\n 101: new #81 // class day20/Num\n 104: dup\n 105: iload 12\n 107: iconst_0\n 108: aload 11\n 110: invokestatic #87 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 113: iconst_0\n 114: bipush 10\n 116: aconst_null\n 117: invokespecial #90 // Method day20/Num.\"<init>\":(IIJIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 120: aload 14\n 122: swap\n 123: invokeinterface #94, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 128: pop\n 129: goto 49\n 132: aload 5\n 134: checkcast #96 // class java/util/List\n 137: nop\n 138: checkcast #60 // class java/util/Collection\n 141: invokestatic #100 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 144: astore_1\n 145: aload_1\n 146: aconst_null\n 147: iconst_0\n 148: bipush 6\n 150: aconst_null\n 151: invokestatic #104 // Method mix$default:(Ljava/util/List;Ljava/util/List;IILjava/lang/Object;)Ljava/util/List;\n 154: astore_2\n 155: aload_2\n 156: invokestatic #107 // Method summedCoordinates:(Ljava/util/List;)J\n 159: lreturn\n\n public static final long part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #46 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #48 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #54 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #58 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #60 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: iconst_0\n 38: istore 7\n 40: aload 4\n 42: invokeinterface #64, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 47: astore 8\n 49: aload 8\n 51: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 56: ifeq 136\n 59: aload 8\n 61: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 66: astore 9\n 68: aload 5\n 70: iload 7\n 72: iinc 7, 1\n 75: istore 10\n 77: iload 10\n 79: ifge 85\n 82: invokestatic #77 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 85: iload 10\n 87: aload 9\n 89: checkcast #79 // class java/lang/String\n 92: astore 11\n 94: istore 12\n 96: astore 14\n 98: iconst_0\n 99: istore 13\n 101: new #81 // class day20/Num\n 104: dup\n 105: iload 12\n 107: iconst_0\n 108: aload 11\n 110: invokestatic #87 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 113: ldc2_w #125 // long 811589153l\n 116: lmul\n 117: iconst_0\n 118: bipush 10\n 120: aconst_null\n 121: invokespecial #90 // Method day20/Num.\"<init>\":(IIJIILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 124: aload 14\n 126: swap\n 127: invokeinterface #94, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 132: pop\n 133: goto 49\n 136: aload 5\n 138: checkcast #96 // class java/util/List\n 141: nop\n 142: checkcast #60 // class java/util/Collection\n 145: invokestatic #100 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 148: astore_1\n 149: aload_1\n 150: aload_1\n 151: invokedynamic #146, 0 // InvokeDynamic #0:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 156: invokestatic #152 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 159: bipush 10\n 161: invokestatic #156 // Method kotlin/sequences/SequencesKt.drop:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;\n 164: invokestatic #160 // Method kotlin/sequences/SequencesKt.first:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;\n 167: checkcast #96 // class java/util/List\n 170: astore_2\n 171: aload_2\n 172: invokestatic #107 // Method summedCoordinates:(Ljava/util/List;)J\n 175: lreturn\n\n private static final java.util.List<day20.Num> mix(java.util.List<day20.Num>, java.util.List<day20.Num>, int);\n Code:\n 0: iload_2\n 1: aload_0\n 2: invokeinterface #168, 1 // InterfaceMethod java/util/List.size:()I\n 7: if_icmpne 12\n 10: aload_0\n 11: areturn\n 12: aload_0\n 13: astore 4\n 15: iconst_0\n 16: istore 5\n 18: iconst_0\n 19: istore 6\n 21: aload 4\n 23: invokeinterface #169, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 28: astore 7\n 30: aload 7\n 32: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 37: ifeq 154\n 40: aload 7\n 42: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 47: astore 8\n 49: aload 8\n 51: checkcast #81 // class day20/Num\n 54: astore 9\n 56: iconst_0\n 57: istore 10\n 59: aload 9\n 61: aload_1\n 62: checkcast #46 // class java/lang/Iterable\n 65: astore 11\n 67: astore 12\n 69: iconst_0\n 70: istore 13\n 72: aload 11\n 74: invokeinterface #64, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 79: astore 14\n 81: aload 14\n 83: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 88: ifeq 132\n 91: aload 14\n 93: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 98: astore 15\n 100: aload 15\n 102: checkcast #81 // class day20/Num\n 105: astore 16\n 107: iconst_0\n 108: istore 17\n 110: aload 16\n 112: invokevirtual #172 // Method day20/Num.getOriginalPosition:()I\n 115: iload_2\n 116: if_icmpne 123\n 119: iconst_1\n 120: goto 124\n 123: iconst_0\n 124: ifeq 81\n 127: aload 15\n 129: goto 133\n 132: aconst_null\n 133: aload 12\n 135: swap\n 136: invokestatic #176 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 139: nop\n 140: ifeq 148\n 143: iload 6\n 145: goto 155\n 148: iinc 6, 1\n 151: goto 30\n 154: iconst_m1\n 155: istore_3\n 156: aload_0\n 157: iload_3\n 158: invokeinterface #180, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 163: checkcast #81 // class day20/Num\n 166: astore 4\n 168: iload_3\n 169: i2l\n 170: aload 4\n 172: invokevirtual #184 // Method day20/Num.getNumber:()J\n 175: ladd\n 176: aload_0\n 177: invokeinterface #168, 1 // InterfaceMethod java/util/List.size:()I\n 182: iconst_1\n 183: isub\n 184: i2l\n 185: lrem\n 186: lstore 5\n 188: lload 5\n 190: lconst_0\n 191: lcmp\n 192: ifgt 209\n 195: lload 5\n 197: aload_0\n 198: invokeinterface #168, 1 // InterfaceMethod java/util/List.size:()I\n 203: iconst_1\n 204: isub\n 205: i2l\n 206: ladd\n 207: lstore 5\n 209: aload_0\n 210: iload_3\n 211: invokeinterface #187, 2 // InterfaceMethod java/util/List.remove:(I)Ljava/lang/Object;\n 216: pop\n 217: aload_0\n 218: lload 5\n 220: l2i\n 221: aload 4\n 223: invokevirtual #191 // Method day20/Num.move:()Lday20/Num;\n 226: invokeinterface #194, 3 // InterfaceMethod java/util/List.add:(ILjava/lang/Object;)V\n 231: aload_0\n 232: aload_0\n 233: iload_2\n 234: iconst_1\n 235: iadd\n 236: invokestatic #196 // Method mix:(Ljava/util/List;Ljava/util/List;I)Ljava/util/List;\n 239: areturn\n\n static java.util.List mix$default(java.util.List, java.util.List, int, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_2\n 2: iand\n 3: ifeq 8\n 6: aload_0\n 7: astore_1\n 8: iload_3\n 9: iconst_4\n 10: iand\n 11: ifeq 16\n 14: iconst_0\n 15: istore_2\n 16: aload_0\n 17: aload_1\n 18: iload_2\n 19: invokestatic #196 // Method mix:(Ljava/util/List;Ljava/util/List;I)Ljava/util/List;\n 22: areturn\n\n private static final long summedCoordinates(java.util.List<day20.Num>);\n Code:\n 0: aload_0\n 1: astore_2\n 2: iconst_0\n 3: istore_3\n 4: iconst_0\n 5: istore 4\n 7: aload_2\n 8: invokeinterface #169, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 13: astore 5\n 15: aload 5\n 17: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 22: ifeq 73\n 25: aload 5\n 27: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 32: astore 6\n 34: aload 6\n 36: checkcast #81 // class day20/Num\n 39: astore 7\n 41: iconst_0\n 42: istore 8\n 44: aload 7\n 46: invokevirtual #184 // Method day20/Num.getNumber:()J\n 49: lconst_0\n 50: lcmp\n 51: ifne 58\n 54: iconst_1\n 55: goto 59\n 58: iconst_0\n 59: ifeq 67\n 62: iload 4\n 64: goto 74\n 67: iinc 4, 1\n 70: goto 15\n 73: iconst_m1\n 74: istore_1\n 75: aload_0\n 76: iload_1\n 77: sipush 1000\n 80: iadd\n 81: aload_0\n 82: invokeinterface #168, 1 // InterfaceMethod java/util/List.size:()I\n 87: irem\n 88: invokeinterface #180, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 93: checkcast #81 // class day20/Num\n 96: invokevirtual #184 // Method day20/Num.getNumber:()J\n 99: lstore_2\n 100: aload_0\n 101: iload_1\n 102: sipush 2000\n 105: iadd\n 106: aload_0\n 107: invokeinterface #168, 1 // InterfaceMethod java/util/List.size:()I\n 112: irem\n 113: invokeinterface #180, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 118: checkcast #81 // class day20/Num\n 121: invokevirtual #184 // Method day20/Num.getNumber:()J\n 124: lstore 4\n 126: aload_0\n 127: iload_1\n 128: sipush 3000\n 131: iadd\n 132: aload_0\n 133: invokeinterface #168, 1 // InterfaceMethod java/util/List.size:()I\n 138: irem\n 139: invokeinterface #180, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 144: checkcast #81 // class day20/Num\n 147: invokevirtual #184 // Method day20/Num.getNumber:()J\n 150: lstore 6\n 152: lload_2\n 153: lload 4\n 155: ladd\n 156: lload 6\n 158: ladd\n 159: lreturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #222 // Method main:()V\n 3: return\n\n private static final java.util.List part2$lambda$2(java.util.List, java.util.List);\n Code:\n 0: aload_1\n 1: ldc #225 // String it\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: iconst_0\n 9: iconst_4\n 10: aconst_null\n 11: invokestatic #104 // Method mix$default:(Ljava/util/List;Ljava/util/List;IILjava/lang/Object;)Ljava/util/List;\n 14: checkcast #60 // class java/util/Collection\n 17: invokestatic #100 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 20: areturn\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day16/day16.kt
package day16 import kotlin.math.max import readInput const val START = "AA" val flowRegex = """(\d+)""".toRegex() val valveRegex = """[A-Z]{2}""".toRegex() var totalTime = 30 var maxPressureRelease = 0 var allValves: Map<String, Valve> = mapOf() var shortestPaths: MutableMap<String, MutableMap<String, Int>> = mutableMapOf() fun main() { val input = readInput("main/day16/Day16_test") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int { prepareSearch(input) checkAllPaths(0, START, emptySet(), 0) return maxPressureRelease } fun part2(input: List<String>): Int { totalTime = 26 prepareSearch(input) checkAllPaths(0, START, emptySet(), 0, true) return maxPressureRelease } private fun prepareSearch(input: List<String>) { maxPressureRelease = 0 val valves = input.map { it.parse() } allValves = valves.associateBy { it.id } shortestPaths = shortestPathsFromEachTunnelToAllOtherTunnels( valves.associate { it.id to it.neighbouringValves.associateWith { 1 } .toMutableMap() }.toMutableMap() ) } private fun checkAllPaths(currentPressureRelease: Int, currentValveId: String, visited: Set<String>, time: Int, withElefant: Boolean = false) { maxPressureRelease = max(maxPressureRelease, currentPressureRelease) shortestPaths[currentValveId]!!.forEach { (valveId, distance) -> if (!visited.contains(valveId) && time + distance + 1 < totalTime) { checkAllPaths( currentPressureRelease = currentPressureRelease + (totalTime - time - distance - 1) * allValves[valveId]?.flow!!, currentValveId = valveId, visited = visited + valveId, time = time + distance + 1, withElefant = withElefant ) } } if (withElefant) { checkAllPaths(currentPressureRelease, START, visited, 0, false) } } private fun shortestPathsFromEachTunnelToAllOtherTunnels(shortestPaths: MutableMap<String, MutableMap<String, Int>>): MutableMap<String, MutableMap<String, Int>> { shortestPaths.keys.forEach { a -> shortestPaths.keys.forEach { b -> shortestPaths.keys.forEach { c -> val ab = shortestPaths[b]?.get(a) ?: 100 val ac = shortestPaths[a]?.get(c) ?: 100 val bc = shortestPaths[b]?.get(c) ?: 100 if (ab + ac < bc) shortestPaths[b]?.set(c, ab + ac) } } } shortestPaths.values.forEach { it.keys.mapNotNull { key -> if (allValves[key]?.flow == 0) key else null } .forEach { uselessValve -> it.remove(uselessValve) } } return shortestPaths } fun String.parse(): Valve { val valves = valveRegex.findAll(this).map { it.groupValues.first() }.toList() val flow = flowRegex.findAll(this).first().groupValues.first().toInt() val tunnels = valves.drop(1) return Valve(id = valves.first(), flow = flow, neighbouringValves = tunnels) } data class Valve(val id: String, val flow: Int, val neighbouringValves: List<String>)
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day16/Day16Kt.class", "javap": "Compiled from \"day16.kt\"\npublic final class day16.Day16Kt {\n public static final java.lang.String START;\n\n private static final kotlin.text.Regex flowRegex;\n\n private static final kotlin.text.Regex valveRegex;\n\n private static int totalTime;\n\n private static int maxPressureRelease;\n\n private static java.util.Map<java.lang.String, day16.Valve> allValves;\n\n private static java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.Integer>> shortestPaths;\n\n public static final kotlin.text.Regex getFlowRegex();\n Code:\n 0: getstatic #11 // Field flowRegex:Lkotlin/text/Regex;\n 3: areturn\n\n public static final kotlin.text.Regex getValveRegex();\n Code:\n 0: getstatic #15 // Field valveRegex:Lkotlin/text/Regex;\n 3: areturn\n\n public static final int getTotalTime();\n Code:\n 0: getstatic #21 // Field totalTime:I\n 3: ireturn\n\n public static final void setTotalTime(int);\n Code:\n 0: iload_0\n 1: putstatic #21 // Field totalTime:I\n 4: return\n\n public static final int getMaxPressureRelease();\n Code:\n 0: getstatic #28 // Field maxPressureRelease:I\n 3: ireturn\n\n public static final void setMaxPressureRelease(int);\n Code:\n 0: iload_0\n 1: putstatic #28 // Field maxPressureRelease:I\n 4: return\n\n public static final java.util.Map<java.lang.String, day16.Valve> getAllValves();\n Code:\n 0: getstatic #36 // Field allValves:Ljava/util/Map;\n 3: areturn\n\n public static final void setAllValves(java.util.Map<java.lang.String, day16.Valve>);\n Code:\n 0: aload_0\n 1: ldc #40 // String <set-?>\n 3: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: putstatic #36 // Field allValves:Ljava/util/Map;\n 10: return\n\n public static final java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.Integer>> getShortestPaths();\n Code:\n 0: getstatic #51 // Field shortestPaths:Ljava/util/Map;\n 3: areturn\n\n public static final void setShortestPaths(java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: ldc #40 // String <set-?>\n 3: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: putstatic #51 // Field shortestPaths:Ljava/util/Map;\n 10: return\n\n public static final void main();\n Code:\n 0: ldc #57 // String main/day16/Day16_test\n 2: invokestatic #63 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #67 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #73 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #78 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #81 // Method part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #73 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #78 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #85 // String input\n 3: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #89 // Method prepareSearch:(Ljava/util/List;)V\n 10: iconst_0\n 11: ldc #91 // String AA\n 13: invokestatic #97 // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;\n 16: iconst_0\n 17: iconst_0\n 18: bipush 16\n 20: aconst_null\n 21: invokestatic #101 // Method checkAllPaths$default:(ILjava/lang/String;Ljava/util/Set;IZILjava/lang/Object;)V\n 24: getstatic #28 // Field maxPressureRelease:I\n 27: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #85 // String input\n 3: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: bipush 26\n 8: putstatic #21 // Field totalTime:I\n 11: aload_0\n 12: invokestatic #89 // Method prepareSearch:(Ljava/util/List;)V\n 15: iconst_0\n 16: ldc #91 // String AA\n 18: invokestatic #97 // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;\n 21: iconst_0\n 22: iconst_1\n 23: invokestatic #105 // Method checkAllPaths:(ILjava/lang/String;Ljava/util/Set;IZ)V\n 26: getstatic #28 // Field maxPressureRelease:I\n 29: ireturn\n\n private static final void prepareSearch(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: putstatic #28 // Field maxPressureRelease:I\n 4: aload_0\n 5: checkcast #108 // class java/lang/Iterable\n 8: astore_2\n 9: iconst_0\n 10: istore_3\n 11: aload_2\n 12: astore 4\n 14: new #110 // class java/util/ArrayList\n 17: dup\n 18: aload_2\n 19: bipush 10\n 21: invokestatic #116 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 24: invokespecial #119 // Method java/util/ArrayList.\"<init>\":(I)V\n 27: checkcast #121 // class java/util/Collection\n 30: astore 5\n 32: iconst_0\n 33: istore 6\n 35: aload 4\n 37: invokeinterface #125, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 7\n 44: aload 7\n 46: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 94\n 54: aload 7\n 56: invokeinterface #135, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 8\n 63: aload 5\n 65: aload 8\n 67: checkcast #137 // class java/lang/String\n 70: astore 9\n 72: astore 26\n 74: iconst_0\n 75: istore 10\n 77: aload 9\n 79: invokestatic #141 // Method parse:(Ljava/lang/String;)Lday16/Valve;\n 82: aload 26\n 84: swap\n 85: invokeinterface #145, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 90: pop\n 91: goto 44\n 94: aload 5\n 96: checkcast #147 // class java/util/List\n 99: nop\n 100: astore_1\n 101: aload_1\n 102: checkcast #108 // class java/lang/Iterable\n 105: astore_2\n 106: iconst_0\n 107: istore_3\n 108: aload_2\n 109: bipush 10\n 111: invokestatic #116 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 114: invokestatic #153 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 117: bipush 16\n 119: invokestatic #159 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 122: istore 4\n 124: aload_2\n 125: astore 5\n 127: new #161 // class java/util/LinkedHashMap\n 130: dup\n 131: iload 4\n 133: invokespecial #162 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 136: checkcast #164 // class java/util/Map\n 139: astore 6\n 141: iconst_0\n 142: istore 7\n 144: aload 5\n 146: invokeinterface #125, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 151: astore 8\n 153: aload 8\n 155: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 160: ifeq 205\n 163: aload 8\n 165: invokeinterface #135, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 170: astore 9\n 172: aload 6\n 174: aload 9\n 176: checkcast #166 // class day16/Valve\n 179: astore 10\n 181: astore 26\n 183: iconst_0\n 184: istore 11\n 186: aload 10\n 188: invokevirtual #170 // Method day16/Valve.getId:()Ljava/lang/String;\n 191: aload 26\n 193: swap\n 194: aload 9\n 196: invokeinterface #174, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 201: pop\n 202: goto 153\n 205: aload 6\n 207: nop\n 208: putstatic #36 // Field allValves:Ljava/util/Map;\n 211: aload_1\n 212: checkcast #108 // class java/lang/Iterable\n 215: astore_2\n 216: iconst_0\n 217: istore_3\n 218: aload_2\n 219: bipush 10\n 221: invokestatic #116 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 224: invokestatic #153 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 227: bipush 16\n 229: invokestatic #159 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 232: istore 4\n 234: aload_2\n 235: astore 5\n 237: new #161 // class java/util/LinkedHashMap\n 240: dup\n 241: iload 4\n 243: invokespecial #162 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 246: checkcast #164 // class java/util/Map\n 249: astore 6\n 251: iconst_0\n 252: istore 7\n 254: aload 5\n 256: invokeinterface #125, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 261: astore 8\n 263: aload 8\n 265: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 270: ifeq 456\n 273: aload 8\n 275: invokeinterface #135, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 280: astore 9\n 282: aload 6\n 284: astore 10\n 286: aload 9\n 288: checkcast #166 // class day16/Valve\n 291: astore 11\n 293: iconst_0\n 294: istore 12\n 296: aload 11\n 298: invokevirtual #170 // Method day16/Valve.getId:()Ljava/lang/String;\n 301: aload 11\n 303: invokevirtual #178 // Method day16/Valve.getNeighbouringValves:()Ljava/util/List;\n 306: checkcast #108 // class java/lang/Iterable\n 309: astore 13\n 311: astore 14\n 313: iconst_0\n 314: istore 15\n 316: new #161 // class java/util/LinkedHashMap\n 319: dup\n 320: aload 13\n 322: bipush 10\n 324: invokestatic #116 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 327: invokestatic #153 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 330: bipush 16\n 332: invokestatic #159 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 335: invokespecial #162 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 338: astore 16\n 340: aload 13\n 342: astore 17\n 344: iconst_0\n 345: istore 18\n 347: aload 17\n 349: invokeinterface #125, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 354: astore 19\n 356: aload 19\n 358: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 363: ifeq 417\n 366: aload 19\n 368: invokeinterface #135, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 373: astore 20\n 375: aload 16\n 377: checkcast #164 // class java/util/Map\n 380: aload 20\n 382: aload 20\n 384: checkcast #137 // class java/lang/String\n 387: astore 21\n 389: astore 22\n 391: astore 23\n 393: iconst_0\n 394: istore 24\n 396: iconst_1\n 397: invokestatic #184 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 400: astore 25\n 402: aload 23\n 404: aload 22\n 406: aload 25\n 408: invokeinterface #174, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 413: pop\n 414: goto 356\n 417: aload 16\n 419: checkcast #164 // class java/util/Map\n 422: nop\n 423: aload 14\n 425: swap\n 426: invokestatic #188 // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;\n 429: invokestatic #194 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 432: nop\n 433: astore 11\n 435: aload 10\n 437: aload 11\n 439: invokevirtual #199 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 442: aload 11\n 444: invokevirtual #202 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 447: invokeinterface #174, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 452: pop\n 453: goto 263\n 456: aload 6\n 458: nop\n 459: invokestatic #188 // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;\n 462: invokestatic #205 // Method shortestPathsFromEachTunnelToAllOtherTunnels:(Ljava/util/Map;)Ljava/util/Map;\n 465: putstatic #51 // Field shortestPaths:Ljava/util/Map;\n 468: return\n\n private static final void checkAllPaths(int, java.lang.String, java.util.Set<java.lang.String>, int, boolean);\n Code:\n 0: getstatic #28 // Field maxPressureRelease:I\n 3: iload_0\n 4: invokestatic #244 // Method java/lang/Math.max:(II)I\n 7: putstatic #28 // Field maxPressureRelease:I\n 10: getstatic #51 // Field shortestPaths:Ljava/util/Map;\n 13: aload_1\n 14: invokeinterface #248, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 19: dup\n 20: invokestatic #252 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 23: checkcast #164 // class java/util/Map\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 5\n 33: invokeinterface #255, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 38: invokeinterface #258, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 43: astore 7\n 45: aload 7\n 47: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 52: ifeq 196\n 55: aload 7\n 57: invokeinterface #135, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 62: checkcast #260 // class java/util/Map$Entry\n 65: astore 8\n 67: aload 8\n 69: astore 9\n 71: iconst_0\n 72: istore 10\n 74: aload 9\n 76: invokeinterface #263, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 81: checkcast #137 // class java/lang/String\n 84: astore 11\n 86: aload 9\n 88: invokeinterface #266, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 93: checkcast #268 // class java/lang/Number\n 96: invokevirtual #271 // Method java/lang/Number.intValue:()I\n 99: istore 12\n 101: aload_2\n 102: aload 11\n 104: invokeinterface #274, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 109: ifne 191\n 112: iload_3\n 113: iload 12\n 115: iadd\n 116: iconst_1\n 117: iadd\n 118: getstatic #21 // Field totalTime:I\n 121: if_icmpge 191\n 124: iload_0\n 125: getstatic #21 // Field totalTime:I\n 128: iload_3\n 129: isub\n 130: iload 12\n 132: isub\n 133: iconst_1\n 134: isub\n 135: getstatic #36 // Field allValves:Ljava/util/Map;\n 138: aload 11\n 140: invokeinterface #248, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 145: checkcast #166 // class day16/Valve\n 148: dup\n 149: ifnull 161\n 152: invokevirtual #277 // Method day16/Valve.getFlow:()I\n 155: invokestatic #184 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 158: goto 163\n 161: pop\n 162: aconst_null\n 163: dup\n 164: invokestatic #252 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 167: invokevirtual #278 // Method java/lang/Integer.intValue:()I\n 170: imul\n 171: iadd\n 172: aload 11\n 174: aload_2\n 175: aload 11\n 177: invokestatic #282 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Object;)Ljava/util/Set;\n 180: iload_3\n 181: iload 12\n 183: iadd\n 184: iconst_1\n 185: iadd\n 186: iload 4\n 188: invokestatic #105 // Method checkAllPaths:(ILjava/lang/String;Ljava/util/Set;IZ)V\n 191: nop\n 192: nop\n 193: goto 45\n 196: nop\n 197: iload 4\n 199: ifeq 211\n 202: iload_0\n 203: ldc #91 // String AA\n 205: aload_2\n 206: iconst_0\n 207: iconst_0\n 208: invokestatic #105 // Method checkAllPaths:(ILjava/lang/String;Ljava/util/Set;IZ)V\n 211: return\n\n static void checkAllPaths$default(int, java.lang.String, java.util.Set, int, boolean, int, java.lang.Object);\n Code:\n 0: iload 5\n 2: bipush 16\n 4: iand\n 5: ifeq 11\n 8: iconst_0\n 9: istore 4\n 11: iload_0\n 12: aload_1\n 13: aload_2\n 14: iload_3\n 15: iload 4\n 17: invokestatic #105 // Method checkAllPaths:(ILjava/lang/String;Ljava/util/Set;IZ)V\n 20: return\n\n private static final java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.Integer>> shortestPathsFromEachTunnelToAllOtherTunnels(java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: invokeinterface #300, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 6: checkcast #108 // class java/lang/Iterable\n 9: astore_1\n 10: iconst_0\n 11: istore_2\n 12: aload_1\n 13: invokeinterface #125, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 18: astore_3\n 19: aload_3\n 20: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 25: ifeq 333\n 28: aload_3\n 29: invokeinterface #135, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 34: astore 4\n 36: aload 4\n 38: checkcast #137 // class java/lang/String\n 41: astore 5\n 43: iconst_0\n 44: istore 6\n 46: aload_0\n 47: invokeinterface #300, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 52: checkcast #108 // class java/lang/Iterable\n 55: astore 7\n 57: iconst_0\n 58: istore 8\n 60: aload 7\n 62: invokeinterface #125, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 67: astore 9\n 69: aload 9\n 71: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 76: ifeq 327\n 79: aload 9\n 81: invokeinterface #135, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: astore 10\n 88: aload 10\n 90: checkcast #137 // class java/lang/String\n 93: astore 11\n 95: iconst_0\n 96: istore 12\n 98: aload_0\n 99: invokeinterface #300, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 104: checkcast #108 // class java/lang/Iterable\n 107: astore 13\n 109: iconst_0\n 110: istore 14\n 112: aload 13\n 114: invokeinterface #125, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 119: astore 15\n 121: aload 15\n 123: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 128: ifeq 321\n 131: aload 15\n 133: invokeinterface #135, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 138: astore 16\n 140: aload 16\n 142: checkcast #137 // class java/lang/String\n 145: astore 17\n 147: iconst_0\n 148: istore 18\n 150: aload_0\n 151: aload 11\n 153: invokeinterface #248, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 158: checkcast #164 // class java/util/Map\n 161: dup\n 162: ifnull 185\n 165: aload 5\n 167: invokeinterface #248, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 172: checkcast #180 // class java/lang/Integer\n 175: dup\n 176: ifnull 185\n 179: invokevirtual #278 // Method java/lang/Integer.intValue:()I\n 182: goto 188\n 185: pop\n 186: bipush 100\n 188: istore 19\n 190: aload_0\n 191: aload 5\n 193: invokeinterface #248, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 198: checkcast #164 // class java/util/Map\n 201: dup\n 202: ifnull 225\n 205: aload 17\n 207: invokeinterface #248, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 212: checkcast #180 // class java/lang/Integer\n 215: dup\n 216: ifnull 225\n 219: invokevirtual #278 // Method java/lang/Integer.intValue:()I\n 222: goto 228\n 225: pop\n 226: bipush 100\n 228: istore 20\n 230: aload_0\n 231: aload 11\n 233: invokeinterface #248, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 238: checkcast #164 // class java/util/Map\n 241: dup\n 242: ifnull 265\n 245: aload 17\n 247: invokeinterface #248, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 252: checkcast #180 // class java/lang/Integer\n 255: dup\n 256: ifnull 265\n 259: invokevirtual #278 // Method java/lang/Integer.intValue:()I\n 262: goto 268\n 265: pop\n 266: bipush 100\n 268: istore 21\n 270: iload 19\n 272: iload 20\n 274: iadd\n 275: iload 21\n 277: if_icmpge 316\n 280: aload_0\n 281: aload 11\n 283: invokeinterface #248, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 288: checkcast #164 // class java/util/Map\n 291: dup\n 292: ifnull 314\n 295: aload 17\n 297: iload 19\n 299: iload 20\n 301: iadd\n 302: invokestatic #184 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 305: invokeinterface #174, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 310: pop\n 311: goto 316\n 314: pop\n 315: nop\n 316: nop\n 317: nop\n 318: goto 121\n 321: nop\n 322: nop\n 323: nop\n 324: goto 69\n 327: nop\n 328: nop\n 329: nop\n 330: goto 19\n 333: nop\n 334: aload_0\n 335: invokeinterface #304, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 340: checkcast #108 // class java/lang/Iterable\n 343: astore_1\n 344: iconst_0\n 345: istore_2\n 346: aload_1\n 347: invokeinterface #125, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 352: astore_3\n 353: aload_3\n 354: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 359: ifeq 610\n 362: aload_3\n 363: invokeinterface #135, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 368: astore 4\n 370: aload 4\n 372: checkcast #164 // class java/util/Map\n 375: astore 5\n 377: iconst_0\n 378: istore 6\n 380: aload 5\n 382: invokeinterface #300, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 387: checkcast #108 // class java/lang/Iterable\n 390: astore 7\n 392: iconst_0\n 393: istore 8\n 395: aload 7\n 397: astore 9\n 399: new #110 // class java/util/ArrayList\n 402: dup\n 403: invokespecial #306 // Method java/util/ArrayList.\"<init>\":()V\n 406: checkcast #121 // class java/util/Collection\n 409: astore 10\n 411: iconst_0\n 412: istore 11\n 414: aload 9\n 416: astore 12\n 418: iconst_0\n 419: istore 13\n 421: aload 12\n 423: invokeinterface #125, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 428: astore 14\n 430: aload 14\n 432: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 437: ifeq 535\n 440: aload 14\n 442: invokeinterface #135, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 447: astore 15\n 449: aload 15\n 451: astore 16\n 453: iconst_0\n 454: istore 17\n 456: aload 16\n 458: checkcast #137 // class java/lang/String\n 461: astore 18\n 463: iconst_0\n 464: istore 19\n 466: getstatic #36 // Field allValves:Ljava/util/Map;\n 469: aload 18\n 471: invokeinterface #248, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 476: checkcast #166 // class day16/Valve\n 479: dup\n 480: ifnull 497\n 483: invokevirtual #277 // Method day16/Valve.getFlow:()I\n 486: ifne 493\n 489: iconst_1\n 490: goto 499\n 493: iconst_0\n 494: goto 499\n 497: pop\n 498: iconst_0\n 499: ifeq 507\n 502: aload 18\n 504: goto 508\n 507: aconst_null\n 508: dup\n 509: ifnull 530\n 512: astore 20\n 514: iconst_0\n 515: istore 21\n 517: aload 10\n 519: aload 20\n 521: invokeinterface #145, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 526: pop\n 527: goto 531\n 530: pop\n 531: nop\n 532: goto 430\n 535: nop\n 536: aload 10\n 538: checkcast #147 // class java/util/List\n 541: nop\n 542: checkcast #108 // class java/lang/Iterable\n 545: astore 7\n 547: nop\n 548: iconst_0\n 549: istore 8\n 551: aload 7\n 553: invokeinterface #125, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 558: astore 9\n 560: aload 9\n 562: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 567: ifeq 604\n 570: aload 9\n 572: invokeinterface #135, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 577: astore 10\n 579: aload 10\n 581: checkcast #137 // class java/lang/String\n 584: astore 11\n 586: iconst_0\n 587: istore 12\n 589: aload 5\n 591: aload 11\n 593: invokeinterface #309, 2 // InterfaceMethod java/util/Map.remove:(Ljava/lang/Object;)Ljava/lang/Object;\n 598: pop\n 599: nop\n 600: nop\n 601: goto 560\n 604: nop\n 605: nop\n 606: nop\n 607: goto 353\n 610: nop\n 611: aload_0\n 612: areturn\n\n public static final day16.Valve parse(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #334 // String <this>\n 4: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: getstatic #15 // Field valveRegex:Lkotlin/text/Regex;\n 10: aload_0\n 11: checkcast #336 // class java/lang/CharSequence\n 14: iconst_0\n 15: iconst_2\n 16: aconst_null\n 17: invokestatic #342 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 20: invokedynamic #360, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 25: invokestatic #366 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 28: invokestatic #370 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 31: astore_1\n 32: getstatic #11 // Field flowRegex:Lkotlin/text/Regex;\n 35: aload_0\n 36: checkcast #336 // class java/lang/CharSequence\n 39: iconst_0\n 40: iconst_2\n 41: aconst_null\n 42: invokestatic #342 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 45: invokestatic #374 // Method kotlin/sequences/SequencesKt.first:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;\n 48: checkcast #376 // class kotlin/text/MatchResult\n 51: invokeinterface #379, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 56: invokestatic #382 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 59: checkcast #137 // class java/lang/String\n 62: invokestatic #386 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 65: istore_2\n 66: aload_1\n 67: checkcast #108 // class java/lang/Iterable\n 70: iconst_1\n 71: invokestatic #390 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 74: astore_3\n 75: new #166 // class day16/Valve\n 78: dup\n 79: aload_1\n 80: invokestatic #382 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 83: checkcast #137 // class java/lang/String\n 86: iload_2\n 87: aload_3\n 88: invokespecial #393 // Method day16/Valve.\"<init>\":(Ljava/lang/String;ILjava/util/List;)V\n 91: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #399 // Method main:()V\n 3: return\n\n private static final java.lang.String parse$lambda$11(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc_w #402 // String it\n 4: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokeinterface #379, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 13: invokestatic #382 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 16: checkcast #137 // class java/lang/String\n 19: areturn\n\n static {};\n Code:\n 0: new #338 // class kotlin/text/Regex\n 3: dup\n 4: ldc_w #406 // String (\\\\d+)\n 7: invokespecial #409 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 10: putstatic #11 // Field flowRegex:Lkotlin/text/Regex;\n 13: new #338 // class kotlin/text/Regex\n 16: dup\n 17: ldc_w #411 // String [A-Z]{2}\n 20: invokespecial #409 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 23: putstatic #15 // Field valveRegex:Lkotlin/text/Regex;\n 26: bipush 30\n 28: putstatic #21 // Field totalTime:I\n 31: invokestatic #414 // Method kotlin/collections/MapsKt.emptyMap:()Ljava/util/Map;\n 34: putstatic #36 // Field allValves:Ljava/util/Map;\n 37: new #161 // class java/util/LinkedHashMap\n 40: dup\n 41: invokespecial #415 // Method java/util/LinkedHashMap.\"<init>\":()V\n 44: checkcast #164 // class java/util/Map\n 47: putstatic #51 // Field shortestPaths:Ljava/util/Map;\n 50: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day10/day10.kt
package day10 import readInput fun main() { val input = readInput("main/day10/Day10") println(part1(input)) part2(input) } fun part1(input: List<String>): Int { val cycles = input.toCycles() val interestingCycles = listOf(20, 60, 100, 140, 180, 220) return interestingCycles.sumOf { cycles[it - 1] * it } } fun part2(input: List<String>) { val cycleMap = input.toCycles() val crt = cycleMap.mapIndexed { index, register -> val sprite = register - 1..register + 1 if (index % 40 in sprite) "#" else " " } crt.forEachIndexed { index, s -> print(s) if (index % 40 == 39) println() } } private fun List<String>.toCycles(): List<Int> { var x = 1 val cycles = mutableListOf<Int>() forEach { if (it.startsWith("noop")) { cycles.add(x) } else { repeat(2) { cycles.add(x) } x += it.split(" ").last().toInt() } } return cycles }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day10/Day10Kt.class", "javap": "Compiled from \"day10.kt\"\npublic final class day10.Day10Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String main/day10/Day10\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #34 // Method part2:(Ljava/util/List;)V\n 22: return\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #39 // String input\n 3: invokestatic #45 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #49 // Method toCycles:(Ljava/util/List;)Ljava/util/List;\n 10: astore_1\n 11: bipush 6\n 13: anewarray #51 // class java/lang/Integer\n 16: astore_3\n 17: aload_3\n 18: iconst_0\n 19: bipush 20\n 21: invokestatic #55 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 24: aastore\n 25: aload_3\n 26: iconst_1\n 27: bipush 60\n 29: invokestatic #55 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 32: aastore\n 33: aload_3\n 34: iconst_2\n 35: bipush 100\n 37: invokestatic #55 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 40: aastore\n 41: aload_3\n 42: iconst_3\n 43: sipush 140\n 46: invokestatic #55 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 49: aastore\n 50: aload_3\n 51: iconst_4\n 52: sipush 180\n 55: invokestatic #55 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 58: aastore\n 59: aload_3\n 60: iconst_5\n 61: sipush 220\n 64: invokestatic #55 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 67: aastore\n 68: aload_3\n 69: invokestatic #61 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 72: astore_2\n 73: aload_2\n 74: checkcast #63 // class java/lang/Iterable\n 77: astore_3\n 78: iconst_0\n 79: istore 4\n 81: aload_3\n 82: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 87: astore 5\n 89: aload 5\n 91: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 96: ifeq 156\n 99: aload 5\n 101: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 106: astore 6\n 108: iload 4\n 110: aload 6\n 112: checkcast #79 // class java/lang/Number\n 115: invokevirtual #83 // Method java/lang/Number.intValue:()I\n 118: istore 7\n 120: istore 9\n 122: iconst_0\n 123: istore 8\n 125: aload_1\n 126: iload 7\n 128: iconst_1\n 129: isub\n 130: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 135: checkcast #79 // class java/lang/Number\n 138: invokevirtual #83 // Method java/lang/Number.intValue:()I\n 141: iload 7\n 143: imul\n 144: istore 10\n 146: iload 9\n 148: iload 10\n 150: iadd\n 151: istore 4\n 153: goto 89\n 156: iload 4\n 158: ireturn\n\n public static final void part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #39 // String input\n 3: invokestatic #45 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #49 // Method toCycles:(Ljava/util/List;)Ljava/util/List;\n 10: astore_1\n 11: aload_1\n 12: checkcast #63 // class java/lang/Iterable\n 15: astore_3\n 16: iconst_0\n 17: istore 4\n 19: aload_3\n 20: astore 5\n 22: new #97 // class java/util/ArrayList\n 25: dup\n 26: aload_3\n 27: bipush 10\n 29: invokestatic #101 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 32: invokespecial #104 // Method java/util/ArrayList.\"<init>\":(I)V\n 35: checkcast #106 // class java/util/Collection\n 38: astore 6\n 40: iconst_0\n 41: istore 7\n 43: iconst_0\n 44: istore 8\n 46: aload 5\n 48: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 53: astore 9\n 55: aload 9\n 57: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 62: ifeq 193\n 65: aload 9\n 67: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 72: astore 10\n 74: aload 6\n 76: iload 8\n 78: iinc 8, 1\n 81: istore 11\n 83: iload 11\n 85: ifge 91\n 88: invokestatic #109 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 91: iload 11\n 93: aload 10\n 95: checkcast #79 // class java/lang/Number\n 98: invokevirtual #83 // Method java/lang/Number.intValue:()I\n 101: istore 12\n 103: istore 13\n 105: astore 19\n 107: iconst_0\n 108: istore 14\n 110: new #111 // class kotlin/ranges/IntRange\n 113: dup\n 114: iload 12\n 116: iconst_1\n 117: isub\n 118: iload 12\n 120: iconst_1\n 121: iadd\n 122: invokespecial #114 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 125: astore 15\n 127: aload 15\n 129: invokevirtual #117 // Method kotlin/ranges/IntRange.getFirst:()I\n 132: istore 16\n 134: aload 15\n 136: invokevirtual #120 // Method kotlin/ranges/IntRange.getLast:()I\n 139: istore 17\n 141: iload 13\n 143: bipush 40\n 145: irem\n 146: istore 18\n 148: iload 16\n 150: iload 18\n 152: if_icmpgt 170\n 155: iload 18\n 157: iload 17\n 159: if_icmpgt 166\n 162: iconst_1\n 163: goto 171\n 166: iconst_0\n 167: goto 171\n 170: iconst_0\n 171: ifeq 179\n 174: ldc #122 // String #\n 176: goto 181\n 179: ldc #124 // String\n 181: aload 19\n 183: swap\n 184: invokeinterface #128, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 189: pop\n 190: goto 55\n 193: aload 6\n 195: checkcast #85 // class java/util/List\n 198: nop\n 199: astore_2\n 200: aload_2\n 201: checkcast #63 // class java/lang/Iterable\n 204: astore_3\n 205: iconst_0\n 206: istore 4\n 208: iconst_0\n 209: istore 5\n 211: aload_3\n 212: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 217: astore 6\n 219: aload 6\n 221: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 226: ifeq 296\n 229: aload 6\n 231: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 236: astore 7\n 238: iload 5\n 240: iinc 5, 1\n 243: istore 8\n 245: iload 8\n 247: ifge 253\n 250: invokestatic #109 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 253: iload 8\n 255: aload 7\n 257: checkcast #130 // class java/lang/String\n 260: astore 9\n 262: istore 10\n 264: iconst_0\n 265: istore 11\n 267: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 270: aload 9\n 272: invokevirtual #134 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 275: iload 10\n 277: bipush 40\n 279: irem\n 280: bipush 39\n 282: if_icmpne 291\n 285: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 288: invokevirtual #136 // Method java/io/PrintStream.println:()V\n 291: nop\n 292: nop\n 293: goto 219\n 296: nop\n 297: return\n\n private static final java.util.List<java.lang.Integer> toCycles(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: iconst_1\n 3: istore_1\n 4: new #97 // class java/util/ArrayList\n 7: dup\n 8: invokespecial #163 // Method java/util/ArrayList.\"<init>\":()V\n 11: checkcast #85 // class java/util/List\n 14: astore_2\n 15: aload_0\n 16: checkcast #63 // class java/lang/Iterable\n 19: astore_3\n 20: iconst_0\n 21: istore 4\n 23: aload_3\n 24: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 29: astore 5\n 31: aload 5\n 33: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 38: ifeq 168\n 41: aload 5\n 43: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 48: astore 6\n 50: aload 6\n 52: checkcast #130 // class java/lang/String\n 55: astore 7\n 57: iconst_0\n 58: istore 8\n 60: aload 7\n 62: ldc #165 // String noop\n 64: iconst_0\n 65: iconst_2\n 66: aconst_null\n 67: invokestatic #171 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 70: ifeq 87\n 73: aload_2\n 74: iload_1\n 75: invokestatic #55 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 78: invokeinterface #172, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 83: pop\n 84: goto 163\n 87: iconst_2\n 88: istore 9\n 90: iconst_0\n 91: istore 10\n 93: iload 10\n 95: iload 9\n 97: if_icmpge 124\n 100: iload 10\n 102: istore 11\n 104: iconst_0\n 105: istore 12\n 107: aload_2\n 108: iload_1\n 109: invokestatic #55 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 112: invokeinterface #172, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 117: pop\n 118: iinc 10, 1\n 121: goto 93\n 124: iload_1\n 125: aload 7\n 127: checkcast #174 // class java/lang/CharSequence\n 130: iconst_1\n 131: anewarray #130 // class java/lang/String\n 134: astore 9\n 136: aload 9\n 138: iconst_0\n 139: ldc #124 // String\n 141: aastore\n 142: aload 9\n 144: iconst_0\n 145: iconst_0\n 146: bipush 6\n 148: aconst_null\n 149: invokestatic #178 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 152: invokestatic #182 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 155: checkcast #130 // class java/lang/String\n 158: invokestatic #186 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 161: iadd\n 162: istore_1\n 163: nop\n 164: nop\n 165: goto 31\n 168: nop\n 169: aload_2\n 170: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #196 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day17/day17.kt
package day17 import Point import day17.Direction.DOWN import day17.Direction.LEFT import day17.Direction.RIGHT import findPattern import readInput import second const val leftWall = 0 const val rightWall = 6 typealias TetrisCave = MutableSet<Point> typealias TetrisRock = Set<Point> data class Jets(val jets: List<Direction>) { private var index = 0 fun next() = jets[index++ % jets.size] } enum class Direction { DOWN, LEFT, RIGHT } val fallingRocks = listOf( setOf(Point(0, 0), Point(1, 0), Point(2, 0), Point(3, 0)), setOf(Point(1, 0), Point(0, 1), Point(1, 1), Point(2, 1), Point(1, 2)), setOf(Point(0, 0), Point(1, 0), Point(2, 0), Point(2, 1), Point(2, 2)), setOf(Point(0, 0), Point(0, 1), Point(0, 2), Point(0, 3)), setOf(Point(0, 0), Point(1, 0), Point(0, 1), Point(1, 1)) ) fun main() { val input = readInput("main/day17/Day17") val heightDiffs = heightDiffs(input) val (rocksBeforePattern, patternSize) = heightDiffs.findPattern(1650) println("$rocksBeforePattern, $patternSize") println("Part1: ${solve(heightDiffs, rocksBeforePattern, patternSize, 2022)}") println("Part1: ${solve(heightDiffs, rocksBeforePattern, patternSize, 1000000000000L)}") } private fun solve(heightDiffs: List<Int>, rocksBeforePattern: Int, patternSize: Int, numberOfRocks: Long): Long { val rocksLeft = numberOfRocks - rocksBeforePattern val pattern = heightDiffs.drop(rocksBeforePattern - 1).take(patternSize) val patternSum = pattern.sum() return heightDiffs.take(rocksBeforePattern).sum() + (rocksLeft / patternSize * patternSum + pattern.take((rocksLeft - rocksLeft / patternSize * patternSize).toInt()).sum()) } fun heightDiffs(input: List<String>): List<Int> { val cave = emptyCaveWithFloor() val jets = input.first().parse() return (0..5000).map { var rock = cave.nextRock(shapeFor(it)) do { rock = cave.moveRock(rock, jets.next()).first val result = cave.moveRock(rock, DOWN) rock = result.first } while (result.second) cave.addAll(rock) cave.height() }.windowed(2).map { (it.second() - it.first()).toInt() } } private fun shapeFor(it: Int) = fallingRocks[it % fallingRocks.size] private fun emptyCaveWithFloor() = mutableSetOf( Point(0, 0), Point(1, 0), Point(2, 0), Point(3, 0), Point(4, 0), Point(5, 0), Point(6, 0), ) private fun TetrisCave.height() = maxOf { it.y }.toLong() fun TetrisCave.moveRock(rock: TetrisRock, direction: Direction): Pair<TetrisRock, Boolean> { var movedRock: TetrisRock = rock var rockMoved = false when (direction) { DOWN -> { val probedRock = rock.map { Point(it.x, it.y - 1) } if (probedRock.none { this.contains(it) }) { movedRock = probedRock.toSet() rockMoved = true } } LEFT -> { val probedRock = rock.map { Point(it.x - 1, it.y) } if (probedRock.none { this.contains(it) || it.x < leftWall }) { movedRock = probedRock.toSet() rockMoved = true } } RIGHT -> { val probedRock = rock.map { Point(it.x + 1, it.y) } if (probedRock.none { this.contains(it) || it.x > rightWall }) { movedRock = probedRock.toSet() rockMoved = true } } } return movedRock to rockMoved } fun TetrisCave.nextRock(rock: TetrisRock): TetrisRock { val xOffset = 2 val yOffset = maxOf { it.y } + 4 return rock.map { Point(it.x + xOffset, it.y + yOffset) }.toSet() } fun String.parse(): Jets = map { when (it) { '<' -> LEFT '>' -> RIGHT else -> error("illegal input") } }.let { Jets(it) }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day17/Day17Kt$WhenMappings.class", "javap": "Compiled from \"day17.kt\"\npublic final class day17.Day17Kt$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method day17/Direction.values:()[Lday17/Direction;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field day17/Direction.DOWN:Lday17/Direction;\n 12: invokevirtual #22 // Method day17/Direction.ordinal:()I\n 15: iconst_1\n 16: iastore\n 17: goto 21\n 20: astore_1\n 21: nop\n 22: aload_0\n 23: getstatic #25 // Field day17/Direction.LEFT:Lday17/Direction;\n 26: invokevirtual #22 // Method day17/Direction.ordinal:()I\n 29: iconst_2\n 30: iastore\n 31: goto 35\n 34: astore_1\n 35: nop\n 36: aload_0\n 37: getstatic #28 // Field day17/Direction.RIGHT:Lday17/Direction;\n 40: invokevirtual #22 // Method day17/Direction.ordinal:()I\n 43: iconst_3\n 44: iastore\n 45: goto 49\n 48: astore_1\n 49: aload_0\n 50: putstatic #32 // Field $EnumSwitchMapping$0:[I\n 53: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n 21 31 34 Class java/lang/NoSuchFieldError\n 35 45 48 Class java/lang/NoSuchFieldError\n}\n", "javap_err": "" }, { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day17/Day17Kt.class", "javap": "Compiled from \"day17.kt\"\npublic final class day17.Day17Kt {\n public static final int leftWall;\n\n public static final int rightWall;\n\n private static final java.util.List<java.util.Set<Point>> fallingRocks;\n\n public static final java.util.List<java.util.Set<Point>> getFallingRocks();\n Code:\n 0: getstatic #12 // Field fallingRocks:Ljava/util/List;\n 3: areturn\n\n public static final void main();\n Code:\n 0: ldc #16 // String main/day17/Day17\n 2: invokestatic #22 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #26 // Method heightDiffs:(Ljava/util/List;)Ljava/util/List;\n 10: astore_1\n 11: aload_1\n 12: sipush 1650\n 15: invokestatic #30 // Method UtilsKt.findPattern:(Ljava/util/List;I)Lkotlin/Pair;\n 18: astore_2\n 19: aload_2\n 20: invokevirtual #36 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 23: checkcast #38 // class java/lang/Number\n 26: invokevirtual #42 // Method java/lang/Number.intValue:()I\n 29: istore_3\n 30: aload_2\n 31: invokevirtual #45 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 34: checkcast #38 // class java/lang/Number\n 37: invokevirtual #42 // Method java/lang/Number.intValue:()I\n 40: istore 4\n 42: new #47 // class java/lang/StringBuilder\n 45: dup\n 46: invokespecial #50 // Method java/lang/StringBuilder.\"<init>\":()V\n 49: iload_3\n 50: invokevirtual #54 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 53: ldc #56 // String ,\n 55: invokevirtual #59 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 58: iload 4\n 60: invokevirtual #54 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 63: invokevirtual #63 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 66: getstatic #69 // Field java/lang/System.out:Ljava/io/PrintStream;\n 69: swap\n 70: invokevirtual #75 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 73: new #47 // class java/lang/StringBuilder\n 76: dup\n 77: invokespecial #50 // Method java/lang/StringBuilder.\"<init>\":()V\n 80: ldc #77 // String Part1:\n 82: invokevirtual #59 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 85: aload_1\n 86: iload_3\n 87: iload 4\n 89: ldc2_w #78 // long 2022l\n 92: invokestatic #83 // Method solve:(Ljava/util/List;IIJ)J\n 95: invokevirtual #86 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 98: invokevirtual #63 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 101: getstatic #69 // Field java/lang/System.out:Ljava/io/PrintStream;\n 104: swap\n 105: invokevirtual #75 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 108: new #47 // class java/lang/StringBuilder\n 111: dup\n 112: invokespecial #50 // Method java/lang/StringBuilder.\"<init>\":()V\n 115: ldc #77 // String Part1:\n 117: invokevirtual #59 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 120: aload_1\n 121: iload_3\n 122: iload 4\n 124: ldc2_w #87 // long 1000000000000l\n 127: invokestatic #83 // Method solve:(Ljava/util/List;IIJ)J\n 130: invokevirtual #86 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 133: invokevirtual #63 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 136: getstatic #69 // Field java/lang/System.out:Ljava/io/PrintStream;\n 139: swap\n 140: invokevirtual #75 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 143: return\n\n private static final long solve(java.util.List<java.lang.Integer>, int, int, long);\n Code:\n 0: lload_3\n 1: iload_1\n 2: i2l\n 3: lsub\n 4: lstore 5\n 6: aload_0\n 7: checkcast #95 // class java/lang/Iterable\n 10: iload_1\n 11: iconst_1\n 12: isub\n 13: invokestatic #101 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 16: checkcast #95 // class java/lang/Iterable\n 19: iload_2\n 20: invokestatic #104 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 23: astore 7\n 25: aload 7\n 27: checkcast #95 // class java/lang/Iterable\n 30: invokestatic #108 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 33: istore 8\n 35: aload_0\n 36: checkcast #95 // class java/lang/Iterable\n 39: iload_1\n 40: invokestatic #104 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 43: checkcast #95 // class java/lang/Iterable\n 46: invokestatic #108 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 49: i2l\n 50: lload 5\n 52: iload_2\n 53: i2l\n 54: ldiv\n 55: iload 8\n 57: i2l\n 58: lmul\n 59: aload 7\n 61: checkcast #95 // class java/lang/Iterable\n 64: lload 5\n 66: lload 5\n 68: iload_2\n 69: i2l\n 70: ldiv\n 71: iload_2\n 72: i2l\n 73: lmul\n 74: lsub\n 75: l2i\n 76: invokestatic #104 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 79: checkcast #95 // class java/lang/Iterable\n 82: invokestatic #108 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 85: i2l\n 86: ladd\n 87: ladd\n 88: lreturn\n\n public static final java.util.List<java.lang.Integer> heightDiffs(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #115 // String input\n 3: invokestatic #121 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: invokestatic #125 // Method emptyCaveWithFloor:()Ljava/util/Set;\n 9: astore_1\n 10: aload_0\n 11: invokestatic #129 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 14: checkcast #131 // class java/lang/String\n 17: invokestatic #135 // Method parse:(Ljava/lang/String;)Lday17/Jets;\n 20: astore_2\n 21: new #137 // class kotlin/ranges/IntRange\n 24: dup\n 25: iconst_0\n 26: sipush 5000\n 29: invokespecial #140 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 32: checkcast #95 // class java/lang/Iterable\n 35: astore_3\n 36: iconst_0\n 37: istore 4\n 39: aload_3\n 40: astore 5\n 42: new #142 // class java/util/ArrayList\n 45: dup\n 46: aload_3\n 47: bipush 10\n 49: invokestatic #146 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 52: invokespecial #149 // Method java/util/ArrayList.\"<init>\":(I)V\n 55: checkcast #151 // class java/util/Collection\n 58: astore 6\n 60: iconst_0\n 61: istore 7\n 63: aload 5\n 65: invokeinterface #155, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 70: astore 8\n 72: aload 8\n 74: invokeinterface #161, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 79: ifeq 198\n 82: aload 8\n 84: checkcast #163 // class kotlin/collections/IntIterator\n 87: invokevirtual #166 // Method kotlin/collections/IntIterator.nextInt:()I\n 90: istore 9\n 92: aload 6\n 94: iload 9\n 96: istore 10\n 98: astore 14\n 100: iconst_0\n 101: istore 11\n 103: aload_1\n 104: iload 10\n 106: invokestatic #170 // Method shapeFor:(I)Ljava/util/Set;\n 109: invokestatic #174 // Method nextRock:(Ljava/util/Set;Ljava/util/Set;)Ljava/util/Set;\n 112: astore 12\n 114: aload_1\n 115: aload 12\n 117: aload_2\n 118: invokevirtual #180 // Method day17/Jets.next:()Lday17/Direction;\n 121: invokestatic #184 // Method moveRock:(Ljava/util/Set;Ljava/util/Set;Lday17/Direction;)Lkotlin/Pair;\n 124: invokevirtual #187 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 127: checkcast #189 // class java/util/Set\n 130: astore 12\n 132: aload_1\n 133: aload 12\n 135: getstatic #195 // Field day17/Direction.DOWN:Lday17/Direction;\n 138: invokestatic #184 // Method moveRock:(Ljava/util/Set;Ljava/util/Set;Lday17/Direction;)Lkotlin/Pair;\n 141: astore 13\n 143: aload 13\n 145: invokevirtual #187 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 148: checkcast #189 // class java/util/Set\n 151: astore 12\n 153: aload 13\n 155: invokevirtual #198 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 158: checkcast #200 // class java/lang/Boolean\n 161: invokevirtual #203 // Method java/lang/Boolean.booleanValue:()Z\n 164: ifne 114\n 167: aload_1\n 168: aload 12\n 170: checkcast #151 // class java/util/Collection\n 173: invokeinterface #207, 2 // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z\n 178: pop\n 179: aload_1\n 180: invokestatic #211 // Method height:(Ljava/util/Set;)J\n 183: invokestatic #217 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 186: aload 14\n 188: swap\n 189: invokeinterface #221, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 194: pop\n 195: goto 72\n 198: aload 6\n 200: checkcast #223 // class java/util/List\n 203: nop\n 204: checkcast #95 // class java/lang/Iterable\n 207: iconst_2\n 208: iconst_0\n 209: iconst_0\n 210: bipush 6\n 212: aconst_null\n 213: invokestatic #227 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;\n 216: checkcast #95 // class java/lang/Iterable\n 219: astore_3\n 220: iconst_0\n 221: istore 4\n 223: aload_3\n 224: astore 5\n 226: new #142 // class java/util/ArrayList\n 229: dup\n 230: aload_3\n 231: bipush 10\n 233: invokestatic #146 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 236: invokespecial #149 // Method java/util/ArrayList.\"<init>\":(I)V\n 239: checkcast #151 // class java/util/Collection\n 242: astore 6\n 244: iconst_0\n 245: istore 7\n 247: aload 5\n 249: invokeinterface #155, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 254: astore 8\n 256: aload 8\n 258: invokeinterface #161, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 263: ifeq 328\n 266: aload 8\n 268: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 273: astore 9\n 275: aload 6\n 277: aload 9\n 279: checkcast #223 // class java/util/List\n 282: astore 10\n 284: astore 14\n 286: iconst_0\n 287: istore 11\n 289: aload 10\n 291: invokestatic #232 // Method UtilsKt.second:(Ljava/util/List;)Ljava/lang/Object;\n 294: checkcast #38 // class java/lang/Number\n 297: invokevirtual #236 // Method java/lang/Number.longValue:()J\n 300: aload 10\n 302: invokestatic #129 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 305: checkcast #38 // class java/lang/Number\n 308: invokevirtual #236 // Method java/lang/Number.longValue:()J\n 311: lsub\n 312: l2i\n 313: invokestatic #241 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 316: aload 14\n 318: swap\n 319: invokeinterface #221, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 324: pop\n 325: goto 256\n 328: aload 6\n 330: checkcast #223 // class java/util/List\n 333: nop\n 334: areturn\n\n private static final java.util.Set<Point> shapeFor(int);\n Code:\n 0: getstatic #12 // Field fallingRocks:Ljava/util/List;\n 3: iload_0\n 4: getstatic #12 // Field fallingRocks:Ljava/util/List;\n 7: invokeinterface #264, 1 // InterfaceMethod java/util/List.size:()I\n 12: irem\n 13: invokeinterface #268, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 18: checkcast #189 // class java/util/Set\n 21: areturn\n\n private static final java.util.Set<Point> emptyCaveWithFloor();\n Code:\n 0: bipush 7\n 2: anewarray #271 // class Point\n 5: astore_0\n 6: aload_0\n 7: iconst_0\n 8: new #271 // class Point\n 11: dup\n 12: iconst_0\n 13: iconst_0\n 14: invokespecial #272 // Method Point.\"<init>\":(II)V\n 17: aastore\n 18: aload_0\n 19: iconst_1\n 20: new #271 // class Point\n 23: dup\n 24: iconst_1\n 25: iconst_0\n 26: invokespecial #272 // Method Point.\"<init>\":(II)V\n 29: aastore\n 30: aload_0\n 31: iconst_2\n 32: new #271 // class Point\n 35: dup\n 36: iconst_2\n 37: iconst_0\n 38: invokespecial #272 // Method Point.\"<init>\":(II)V\n 41: aastore\n 42: aload_0\n 43: iconst_3\n 44: new #271 // class Point\n 47: dup\n 48: iconst_3\n 49: iconst_0\n 50: invokespecial #272 // Method Point.\"<init>\":(II)V\n 53: aastore\n 54: aload_0\n 55: iconst_4\n 56: new #271 // class Point\n 59: dup\n 60: iconst_4\n 61: iconst_0\n 62: invokespecial #272 // Method Point.\"<init>\":(II)V\n 65: aastore\n 66: aload_0\n 67: iconst_5\n 68: new #271 // class Point\n 71: dup\n 72: iconst_5\n 73: iconst_0\n 74: invokespecial #272 // Method Point.\"<init>\":(II)V\n 77: aastore\n 78: aload_0\n 79: bipush 6\n 81: new #271 // class Point\n 84: dup\n 85: bipush 6\n 87: iconst_0\n 88: invokespecial #272 // Method Point.\"<init>\":(II)V\n 91: aastore\n 92: aload_0\n 93: invokestatic #278 // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;\n 96: areturn\n\n private static final long height(java.util.Set<Point>);\n Code:\n 0: aload_0\n 1: checkcast #95 // class java/lang/Iterable\n 4: invokeinterface #155, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 9: astore_1\n 10: aload_1\n 11: invokeinterface #161, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 16: ifne 27\n 19: new #281 // class java/util/NoSuchElementException\n 22: dup\n 23: invokespecial #282 // Method java/util/NoSuchElementException.\"<init>\":()V\n 26: athrow\n 27: aload_1\n 28: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 33: checkcast #271 // class Point\n 36: astore_2\n 37: iconst_0\n 38: istore_3\n 39: aload_2\n 40: invokevirtual #285 // Method Point.getY:()I\n 43: istore_2\n 44: aload_1\n 45: invokeinterface #161, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 50: ifeq 81\n 53: aload_1\n 54: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 59: checkcast #271 // class Point\n 62: astore_3\n 63: iconst_0\n 64: istore 4\n 66: aload_3\n 67: invokevirtual #285 // Method Point.getY:()I\n 70: istore_3\n 71: iload_2\n 72: iload_3\n 73: if_icmpge 44\n 76: iload_3\n 77: istore_2\n 78: goto 44\n 81: iload_2\n 82: i2l\n 83: lreturn\n\n public static final kotlin.Pair<java.util.Set<Point>, java.lang.Boolean> moveRock(java.util.Set<Point>, java.util.Set<Point>, day17.Direction);\n Code:\n 0: aload_0\n 1: ldc_w #291 // String <this>\n 4: invokestatic #121 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: ldc_w #292 // String rock\n 11: invokestatic #121 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: aload_2\n 15: ldc_w #294 // String direction\n 18: invokestatic #121 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 21: aload_1\n 22: astore_3\n 23: iconst_0\n 24: istore 4\n 26: aload_2\n 27: getstatic #300 // Field day17/Day17Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 30: swap\n 31: invokevirtual #303 // Method day17/Direction.ordinal:()I\n 34: iaload\n 35: tableswitch { // 1 to 3\n 1: 60\n 2: 283\n 3: 522\n default: 763\n }\n 60: aload_1\n 61: checkcast #95 // class java/lang/Iterable\n 64: astore 6\n 66: iconst_0\n 67: istore 7\n 69: aload 6\n 71: astore 8\n 73: new #142 // class java/util/ArrayList\n 76: dup\n 77: aload 6\n 79: bipush 10\n 81: invokestatic #146 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 84: invokespecial #149 // Method java/util/ArrayList.\"<init>\":(I)V\n 87: checkcast #151 // class java/util/Collection\n 90: astore 9\n 92: iconst_0\n 93: istore 10\n 95: aload 8\n 97: invokeinterface #155, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 102: astore 11\n 104: aload 11\n 106: invokeinterface #161, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 111: ifeq 168\n 114: aload 11\n 116: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 121: astore 12\n 123: aload 9\n 125: aload 12\n 127: checkcast #271 // class Point\n 130: astore 13\n 132: astore 15\n 134: iconst_0\n 135: istore 14\n 137: new #271 // class Point\n 140: dup\n 141: aload 13\n 143: invokevirtual #306 // Method Point.getX:()I\n 146: aload 13\n 148: invokevirtual #285 // Method Point.getY:()I\n 151: iconst_1\n 152: isub\n 153: invokespecial #272 // Method Point.\"<init>\":(II)V\n 156: aload 15\n 158: swap\n 159: invokeinterface #221, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 164: pop\n 165: goto 104\n 168: aload 9\n 170: checkcast #223 // class java/util/List\n 173: nop\n 174: astore 5\n 176: aload 5\n 178: checkcast #95 // class java/lang/Iterable\n 181: astore 6\n 183: iconst_0\n 184: istore 7\n 186: aload 6\n 188: instanceof #151 // class java/util/Collection\n 191: ifeq 211\n 194: aload 6\n 196: checkcast #151 // class java/util/Collection\n 199: invokeinterface #309, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 204: ifeq 211\n 207: iconst_1\n 208: goto 265\n 211: aload 6\n 213: invokeinterface #155, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 218: astore 8\n 220: aload 8\n 222: invokeinterface #161, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 227: ifeq 264\n 230: aload 8\n 232: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 237: astore 9\n 239: aload 9\n 241: checkcast #271 // class Point\n 244: astore 10\n 246: iconst_0\n 247: istore 11\n 249: aload_0\n 250: aload 10\n 252: invokeinterface #312, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 257: ifeq 220\n 260: iconst_0\n 261: goto 265\n 264: iconst_1\n 265: ifeq 771\n 268: aload 5\n 270: checkcast #95 // class java/lang/Iterable\n 273: invokestatic #316 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 276: astore_3\n 277: iconst_1\n 278: istore 4\n 280: goto 771\n 283: aload_1\n 284: checkcast #95 // class java/lang/Iterable\n 287: astore 6\n 289: iconst_0\n 290: istore 7\n 292: aload 6\n 294: astore 8\n 296: new #142 // class java/util/ArrayList\n 299: dup\n 300: aload 6\n 302: bipush 10\n 304: invokestatic #146 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 307: invokespecial #149 // Method java/util/ArrayList.\"<init>\":(I)V\n 310: checkcast #151 // class java/util/Collection\n 313: astore 9\n 315: iconst_0\n 316: istore 10\n 318: aload 8\n 320: invokeinterface #155, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 325: astore 11\n 327: aload 11\n 329: invokeinterface #161, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 334: ifeq 391\n 337: aload 11\n 339: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 344: astore 12\n 346: aload 9\n 348: aload 12\n 350: checkcast #271 // class Point\n 353: astore 13\n 355: astore 15\n 357: iconst_0\n 358: istore 14\n 360: new #271 // class Point\n 363: dup\n 364: aload 13\n 366: invokevirtual #306 // Method Point.getX:()I\n 369: iconst_1\n 370: isub\n 371: aload 13\n 373: invokevirtual #285 // Method Point.getY:()I\n 376: invokespecial #272 // Method Point.\"<init>\":(II)V\n 379: aload 15\n 381: swap\n 382: invokeinterface #221, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 387: pop\n 388: goto 327\n 391: aload 9\n 393: checkcast #223 // class java/util/List\n 396: nop\n 397: astore 5\n 399: aload 5\n 401: checkcast #95 // class java/lang/Iterable\n 404: astore 6\n 406: iconst_0\n 407: istore 7\n 409: aload 6\n 411: instanceof #151 // class java/util/Collection\n 414: ifeq 434\n 417: aload 6\n 419: checkcast #151 // class java/util/Collection\n 422: invokeinterface #309, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 427: ifeq 434\n 430: iconst_1\n 431: goto 504\n 434: aload 6\n 436: invokeinterface #155, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 441: astore 8\n 443: aload 8\n 445: invokeinterface #161, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 450: ifeq 503\n 453: aload 8\n 455: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 460: astore 9\n 462: aload 9\n 464: checkcast #271 // class Point\n 467: astore 10\n 469: iconst_0\n 470: istore 11\n 472: aload_0\n 473: aload 10\n 475: invokeinterface #312, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 480: ifne 491\n 483: aload 10\n 485: invokevirtual #306 // Method Point.getX:()I\n 488: ifge 495\n 491: iconst_1\n 492: goto 496\n 495: iconst_0\n 496: ifeq 443\n 499: iconst_0\n 500: goto 504\n 503: iconst_1\n 504: ifeq 771\n 507: aload 5\n 509: checkcast #95 // class java/lang/Iterable\n 512: invokestatic #316 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 515: astore_3\n 516: iconst_1\n 517: istore 4\n 519: goto 771\n 522: aload_1\n 523: checkcast #95 // class java/lang/Iterable\n 526: astore 6\n 528: iconst_0\n 529: istore 7\n 531: aload 6\n 533: astore 8\n 535: new #142 // class java/util/ArrayList\n 538: dup\n 539: aload 6\n 541: bipush 10\n 543: invokestatic #146 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 546: invokespecial #149 // Method java/util/ArrayList.\"<init>\":(I)V\n 549: checkcast #151 // class java/util/Collection\n 552: astore 9\n 554: iconst_0\n 555: istore 10\n 557: aload 8\n 559: invokeinterface #155, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 564: astore 11\n 566: aload 11\n 568: invokeinterface #161, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 573: ifeq 630\n 576: aload 11\n 578: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 583: astore 12\n 585: aload 9\n 587: aload 12\n 589: checkcast #271 // class Point\n 592: astore 13\n 594: astore 15\n 596: iconst_0\n 597: istore 14\n 599: new #271 // class Point\n 602: dup\n 603: aload 13\n 605: invokevirtual #306 // Method Point.getX:()I\n 608: iconst_1\n 609: iadd\n 610: aload 13\n 612: invokevirtual #285 // Method Point.getY:()I\n 615: invokespecial #272 // Method Point.\"<init>\":(II)V\n 618: aload 15\n 620: swap\n 621: invokeinterface #221, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 626: pop\n 627: goto 566\n 630: aload 9\n 632: checkcast #223 // class java/util/List\n 635: nop\n 636: astore 5\n 638: aload 5\n 640: checkcast #95 // class java/lang/Iterable\n 643: astore 6\n 645: iconst_0\n 646: istore 7\n 648: aload 6\n 650: instanceof #151 // class java/util/Collection\n 653: ifeq 673\n 656: aload 6\n 658: checkcast #151 // class java/util/Collection\n 661: invokeinterface #309, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 666: ifeq 673\n 669: iconst_1\n 670: goto 745\n 673: aload 6\n 675: invokeinterface #155, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 680: astore 8\n 682: aload 8\n 684: invokeinterface #161, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 689: ifeq 744\n 692: aload 8\n 694: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 699: astore 9\n 701: aload 9\n 703: checkcast #271 // class Point\n 706: astore 10\n 708: iconst_0\n 709: istore 11\n 711: aload_0\n 712: aload 10\n 714: invokeinterface #312, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 719: ifne 732\n 722: aload 10\n 724: invokevirtual #306 // Method Point.getX:()I\n 727: bipush 6\n 729: if_icmple 736\n 732: iconst_1\n 733: goto 737\n 736: iconst_0\n 737: ifeq 682\n 740: iconst_0\n 741: goto 745\n 744: iconst_1\n 745: ifeq 771\n 748: aload 5\n 750: checkcast #95 // class java/lang/Iterable\n 753: invokestatic #316 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 756: astore_3\n 757: iconst_1\n 758: istore 4\n 760: goto 771\n 763: new #318 // class kotlin/NoWhenBranchMatchedException\n 766: dup\n 767: invokespecial #319 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 770: athrow\n 771: aload_3\n 772: iload 4\n 774: invokestatic #322 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 777: invokestatic #328 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 780: areturn\n\n public static final java.util.Set<Point> nextRock(java.util.Set<Point>, java.util.Set<Point>);\n Code:\n 0: aload_0\n 1: ldc_w #291 // String <this>\n 4: invokestatic #121 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: ldc_w #292 // String rock\n 11: invokestatic #121 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: iconst_2\n 15: istore_2\n 16: aload_0\n 17: checkcast #95 // class java/lang/Iterable\n 20: invokeinterface #155, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 25: astore 5\n 27: aload 5\n 29: invokeinterface #161, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 34: ifne 45\n 37: new #281 // class java/util/NoSuchElementException\n 40: dup\n 41: invokespecial #282 // Method java/util/NoSuchElementException.\"<init>\":()V\n 44: athrow\n 45: aload 5\n 47: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 52: checkcast #271 // class Point\n 55: astore 6\n 57: iconst_0\n 58: istore 7\n 60: aload 6\n 62: invokevirtual #285 // Method Point.getY:()I\n 65: istore 6\n 67: aload 5\n 69: invokeinterface #161, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 74: ifeq 113\n 77: aload 5\n 79: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 84: checkcast #271 // class Point\n 87: astore 7\n 89: iconst_0\n 90: istore 8\n 92: aload 7\n 94: invokevirtual #285 // Method Point.getY:()I\n 97: istore 7\n 99: iload 6\n 101: iload 7\n 103: if_icmpge 67\n 106: iload 7\n 108: istore 6\n 110: goto 67\n 113: iload 6\n 115: iconst_4\n 116: iadd\n 117: istore_3\n 118: aload_1\n 119: checkcast #95 // class java/lang/Iterable\n 122: astore 4\n 124: iconst_0\n 125: istore 5\n 127: aload 4\n 129: astore 6\n 131: new #142 // class java/util/ArrayList\n 134: dup\n 135: aload 4\n 137: bipush 10\n 139: invokestatic #146 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 142: invokespecial #149 // Method java/util/ArrayList.\"<init>\":(I)V\n 145: checkcast #151 // class java/util/Collection\n 148: astore 7\n 150: iconst_0\n 151: istore 8\n 153: aload 6\n 155: invokeinterface #155, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 160: astore 9\n 162: aload 9\n 164: invokeinterface #161, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 169: ifeq 228\n 172: aload 9\n 174: invokeinterface #229, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 179: astore 10\n 181: aload 7\n 183: aload 10\n 185: checkcast #271 // class Point\n 188: astore 11\n 190: astore 13\n 192: iconst_0\n 193: istore 12\n 195: new #271 // class Point\n 198: dup\n 199: aload 11\n 201: invokevirtual #306 // Method Point.getX:()I\n 204: iload_2\n 205: iadd\n 206: aload 11\n 208: invokevirtual #285 // Method Point.getY:()I\n 211: iload_3\n 212: iadd\n 213: invokespecial #272 // Method Point.\"<init>\":(II)V\n 216: aload 13\n 218: swap\n 219: invokeinterface #221, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 224: pop\n 225: goto 162\n 228: aload 7\n 230: checkcast #223 // class java/util/List\n 233: nop\n 234: checkcast #95 // class java/lang/Iterable\n 237: invokestatic #316 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 240: areturn\n\n public static final day17.Jets parse(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #291 // String <this>\n 4: invokestatic #121 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: checkcast #350 // class java/lang/CharSequence\n 11: astore_1\n 12: iconst_0\n 13: istore_2\n 14: aload_1\n 15: astore_3\n 16: new #142 // class java/util/ArrayList\n 19: dup\n 20: aload_1\n 21: invokeinterface #353, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 26: invokespecial #149 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #151 // class java/util/Collection\n 32: astore 4\n 34: iconst_0\n 35: istore 5\n 37: iconst_0\n 38: istore 6\n 40: iload 6\n 42: aload_3\n 43: invokeinterface #353, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 48: if_icmpge 142\n 51: aload_3\n 52: iload 6\n 54: invokeinterface #357, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 59: istore 7\n 61: aload 4\n 63: iload 7\n 65: istore 8\n 67: astore 10\n 69: iconst_0\n 70: istore 9\n 72: iload 8\n 74: tableswitch { // 60 to 62\n 60: 100\n 61: 112\n 62: 106\n default: 112\n }\n 100: getstatic #360 // Field day17/Direction.LEFT:Lday17/Direction;\n 103: goto 126\n 106: getstatic #363 // Field day17/Direction.RIGHT:Lday17/Direction;\n 109: goto 126\n 112: new #365 // class java/lang/IllegalStateException\n 115: dup\n 116: ldc_w #367 // String illegal input\n 119: invokevirtual #368 // Method java/lang/Object.toString:()Ljava/lang/String;\n 122: invokespecial #371 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 125: athrow\n 126: nop\n 127: aload 10\n 129: swap\n 130: invokeinterface #221, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 135: pop\n 136: iinc 6, 1\n 139: goto 40\n 142: aload 4\n 144: checkcast #223 // class java/util/List\n 147: nop\n 148: astore_2\n 149: iconst_0\n 150: istore_3\n 151: new #176 // class day17/Jets\n 154: dup\n 155: aload_2\n 156: invokespecial #374 // Method day17/Jets.\"<init>\":(Ljava/util/List;)V\n 159: nop\n 160: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #383 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: iconst_5\n 1: anewarray #189 // class java/util/Set\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: iconst_4\n 8: anewarray #271 // class Point\n 11: astore_1\n 12: aload_1\n 13: iconst_0\n 14: new #271 // class Point\n 17: dup\n 18: iconst_0\n 19: iconst_0\n 20: invokespecial #272 // Method Point.\"<init>\":(II)V\n 23: aastore\n 24: aload_1\n 25: iconst_1\n 26: new #271 // class Point\n 29: dup\n 30: iconst_1\n 31: iconst_0\n 32: invokespecial #272 // Method Point.\"<init>\":(II)V\n 35: aastore\n 36: aload_1\n 37: iconst_2\n 38: new #271 // class Point\n 41: dup\n 42: iconst_2\n 43: iconst_0\n 44: invokespecial #272 // Method Point.\"<init>\":(II)V\n 47: aastore\n 48: aload_1\n 49: iconst_3\n 50: new #271 // class Point\n 53: dup\n 54: iconst_3\n 55: iconst_0\n 56: invokespecial #272 // Method Point.\"<init>\":(II)V\n 59: aastore\n 60: aload_1\n 61: invokestatic #389 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 64: aastore\n 65: aload_0\n 66: iconst_1\n 67: iconst_5\n 68: anewarray #271 // class Point\n 71: astore_1\n 72: aload_1\n 73: iconst_0\n 74: new #271 // class Point\n 77: dup\n 78: iconst_1\n 79: iconst_0\n 80: invokespecial #272 // Method Point.\"<init>\":(II)V\n 83: aastore\n 84: aload_1\n 85: iconst_1\n 86: new #271 // class Point\n 89: dup\n 90: iconst_0\n 91: iconst_1\n 92: invokespecial #272 // Method Point.\"<init>\":(II)V\n 95: aastore\n 96: aload_1\n 97: iconst_2\n 98: new #271 // class Point\n 101: dup\n 102: iconst_1\n 103: iconst_1\n 104: invokespecial #272 // Method Point.\"<init>\":(II)V\n 107: aastore\n 108: aload_1\n 109: iconst_3\n 110: new #271 // class Point\n 113: dup\n 114: iconst_2\n 115: iconst_1\n 116: invokespecial #272 // Method Point.\"<init>\":(II)V\n 119: aastore\n 120: aload_1\n 121: iconst_4\n 122: new #271 // class Point\n 125: dup\n 126: iconst_1\n 127: iconst_2\n 128: invokespecial #272 // Method Point.\"<init>\":(II)V\n 131: aastore\n 132: aload_1\n 133: invokestatic #389 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 136: aastore\n 137: aload_0\n 138: iconst_2\n 139: iconst_5\n 140: anewarray #271 // class Point\n 143: astore_1\n 144: aload_1\n 145: iconst_0\n 146: new #271 // class Point\n 149: dup\n 150: iconst_0\n 151: iconst_0\n 152: invokespecial #272 // Method Point.\"<init>\":(II)V\n 155: aastore\n 156: aload_1\n 157: iconst_1\n 158: new #271 // class Point\n 161: dup\n 162: iconst_1\n 163: iconst_0\n 164: invokespecial #272 // Method Point.\"<init>\":(II)V\n 167: aastore\n 168: aload_1\n 169: iconst_2\n 170: new #271 // class Point\n 173: dup\n 174: iconst_2\n 175: iconst_0\n 176: invokespecial #272 // Method Point.\"<init>\":(II)V\n 179: aastore\n 180: aload_1\n 181: iconst_3\n 182: new #271 // class Point\n 185: dup\n 186: iconst_2\n 187: iconst_1\n 188: invokespecial #272 // Method Point.\"<init>\":(II)V\n 191: aastore\n 192: aload_1\n 193: iconst_4\n 194: new #271 // class Point\n 197: dup\n 198: iconst_2\n 199: iconst_2\n 200: invokespecial #272 // Method Point.\"<init>\":(II)V\n 203: aastore\n 204: aload_1\n 205: invokestatic #389 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 208: aastore\n 209: aload_0\n 210: iconst_3\n 211: iconst_4\n 212: anewarray #271 // class Point\n 215: astore_1\n 216: aload_1\n 217: iconst_0\n 218: new #271 // class Point\n 221: dup\n 222: iconst_0\n 223: iconst_0\n 224: invokespecial #272 // Method Point.\"<init>\":(II)V\n 227: aastore\n 228: aload_1\n 229: iconst_1\n 230: new #271 // class Point\n 233: dup\n 234: iconst_0\n 235: iconst_1\n 236: invokespecial #272 // Method Point.\"<init>\":(II)V\n 239: aastore\n 240: aload_1\n 241: iconst_2\n 242: new #271 // class Point\n 245: dup\n 246: iconst_0\n 247: iconst_2\n 248: invokespecial #272 // Method Point.\"<init>\":(II)V\n 251: aastore\n 252: aload_1\n 253: iconst_3\n 254: new #271 // class Point\n 257: dup\n 258: iconst_0\n 259: iconst_3\n 260: invokespecial #272 // Method Point.\"<init>\":(II)V\n 263: aastore\n 264: aload_1\n 265: invokestatic #389 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 268: aastore\n 269: aload_0\n 270: iconst_4\n 271: iconst_4\n 272: anewarray #271 // class Point\n 275: astore_1\n 276: aload_1\n 277: iconst_0\n 278: new #271 // class Point\n 281: dup\n 282: iconst_0\n 283: iconst_0\n 284: invokespecial #272 // Method Point.\"<init>\":(II)V\n 287: aastore\n 288: aload_1\n 289: iconst_1\n 290: new #271 // class Point\n 293: dup\n 294: iconst_1\n 295: iconst_0\n 296: invokespecial #272 // Method Point.\"<init>\":(II)V\n 299: aastore\n 300: aload_1\n 301: iconst_2\n 302: new #271 // class Point\n 305: dup\n 306: iconst_0\n 307: iconst_1\n 308: invokespecial #272 // Method Point.\"<init>\":(II)V\n 311: aastore\n 312: aload_1\n 313: iconst_3\n 314: new #271 // class Point\n 317: dup\n 318: iconst_1\n 319: iconst_1\n 320: invokespecial #272 // Method Point.\"<init>\":(II)V\n 323: aastore\n 324: aload_1\n 325: invokestatic #389 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 328: aastore\n 329: aload_0\n 330: invokestatic #393 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 333: putstatic #12 // Field fallingRocks:Ljava/util/List;\n 336: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day21/day21.kt
package day21 import readInput fun main() { val input = readInput("main/day21/Day21") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Long { val monkeys = input.map { it.toMonkey() }.associateBy { it.name } return solvePart1(monkeys.toMutableMap(), monkeys["root"]!!) } fun part2(input: List<String>): Long { var humanNumber = 1000000000000L val monkeys = input.map { it.toMonkey() }.associateBy { it.name } while (true) { if (humanNumber % 10000L == 0L) println(humanNumber) if (checkForMatch(monkeys.toMutableMap(), humanNumber)) return humanNumber humanNumber++ } return -1 } fun checkForMatch(monkeys: MutableMap<String, Monkey>, humanNumber: Long): Boolean { val rootMonkey = monkeys["root"]!! val human = monkeys["humn"]!!.copy(number = humanNumber) monkeys["humn"] = human val firstMonkey = monkeys[rootMonkey.op?.first!!]!! val secondMonkey = monkeys[rootMonkey.op.second]!! val first = solvePart1(monkeys, firstMonkey) val second = solvePart1(monkeys, secondMonkey) return (first != null && first == second) } fun solvePart1(monkeys: MutableMap<String, Monkey>, current: Monkey): Long = if (current.number != null) { current.number } else { val firstMonkey = monkeys[current.op?.first] ?: error("out of monkeys") val secondMonkey = monkeys[current.op?.second] ?: error("out of monkeys") val firstNumber = solvePart1(monkeys, firstMonkey) monkeys[firstMonkey.name] = firstMonkey.copy(number = firstNumber) val secondNumber = solvePart1(monkeys, secondMonkey) monkeys[secondMonkey.name] = secondMonkey.copy(number = secondNumber) val func = current.op?.operator?.func!! func.invoke(firstNumber, secondNumber) } fun String.toMonkey(): Monkey { return split(": ").let { (name, rest) -> if (rest.all(Char::isDigit)) { Monkey(name = name, number = rest.toLong()) } else { rest.split(" ").let { (first, op, second) -> Monkey(name = name, op = MonkeyOp(first = first, second = second, operator = Operator.fromString(op))) } } } } data class Monkey(val name: String, val number: Long? = null, val op: MonkeyOp? = null) data class MonkeyOp(val first: String, val second: String, val operator: Operator) enum class Operator(val func: (Long, Long) -> Long) { PLUS({ a, b -> a + b }), MINUS({ a, b -> a - b }), TIMES({ a, b -> a * b }), DIV({ a, b -> a / b }); fun opposite() = when (this) { PLUS -> MINUS MINUS -> PLUS TIMES -> DIV DIV -> TIMES } companion object { fun fromString(operation: String) = when (operation.trim()) { "+" -> PLUS "-" -> MINUS "*" -> TIMES "/" -> DIV else -> error("illegal operation") } } }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day21/Day21Kt.class", "javap": "Compiled from \"day21.kt\"\npublic final class day21.Day21Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String main/day21/Day21\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method part1:(Ljava/util/List;)J\n 10: lstore_1\n 11: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: lload_1\n 15: invokevirtual #30 // Method java/io/PrintStream.println:(J)V\n 18: aload_0\n 19: invokestatic #33 // Method part2:(Ljava/util/List;)J\n 22: lstore_1\n 23: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: lload_1\n 27: invokevirtual #30 // Method java/io/PrintStream.println:(J)V\n 30: return\n\n public static final long part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #46 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #48 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #54 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #58 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #60 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #64, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 96\n 56: aload 7\n 58: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #76 // class java/lang/String\n 72: astore 9\n 74: astore 12\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: invokestatic #80 // Method toMonkey:(Ljava/lang/String;)Lday21/Monkey;\n 84: aload 12\n 86: swap\n 87: invokeinterface #84, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 92: pop\n 93: goto 46\n 96: aload 5\n 98: checkcast #86 // class java/util/List\n 101: nop\n 102: checkcast #46 // class java/lang/Iterable\n 105: astore_2\n 106: nop\n 107: iconst_0\n 108: istore_3\n 109: aload_2\n 110: bipush 10\n 112: invokestatic #54 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 115: invokestatic #92 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 118: bipush 16\n 120: invokestatic #98 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 123: istore 4\n 125: aload_2\n 126: astore 5\n 128: new #100 // class java/util/LinkedHashMap\n 131: dup\n 132: iload 4\n 134: invokespecial #101 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 137: checkcast #103 // class java/util/Map\n 140: astore 6\n 142: iconst_0\n 143: istore 7\n 145: aload 5\n 147: invokeinterface #64, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 152: astore 8\n 154: aload 8\n 156: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 161: ifeq 206\n 164: aload 8\n 166: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 171: astore 9\n 173: aload 6\n 175: aload 9\n 177: checkcast #105 // class day21/Monkey\n 180: astore 10\n 182: astore 12\n 184: iconst_0\n 185: istore 11\n 187: aload 10\n 189: invokevirtual #109 // Method day21/Monkey.getName:()Ljava/lang/String;\n 192: aload 12\n 194: swap\n 195: aload 9\n 197: invokeinterface #113, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 202: pop\n 203: goto 154\n 206: aload 6\n 208: nop\n 209: astore_1\n 210: aload_1\n 211: invokestatic #117 // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;\n 214: aload_1\n 215: ldc #119 // String root\n 217: invokeinterface #123, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 222: dup\n 223: invokestatic #127 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 226: checkcast #105 // class day21/Monkey\n 229: invokestatic #131 // Method solvePart1:(Ljava/util/Map;Lday21/Monkey;)J\n 232: lreturn\n\n public static final long part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc2_w #155 // long 1000000000000l\n 9: lstore_1\n 10: aload_0\n 11: checkcast #46 // class java/lang/Iterable\n 14: astore 4\n 16: iconst_0\n 17: istore 5\n 19: aload 4\n 21: astore 6\n 23: new #48 // class java/util/ArrayList\n 26: dup\n 27: aload 4\n 29: bipush 10\n 31: invokestatic #54 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 34: invokespecial #58 // Method java/util/ArrayList.\"<init>\":(I)V\n 37: checkcast #60 // class java/util/Collection\n 40: astore 7\n 42: iconst_0\n 43: istore 8\n 45: aload 6\n 47: invokeinterface #64, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 52: astore 9\n 54: aload 9\n 56: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 61: ifeq 104\n 64: aload 9\n 66: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 71: astore 10\n 73: aload 7\n 75: aload 10\n 77: checkcast #76 // class java/lang/String\n 80: astore 11\n 82: astore 14\n 84: iconst_0\n 85: istore 12\n 87: aload 11\n 89: invokestatic #80 // Method toMonkey:(Ljava/lang/String;)Lday21/Monkey;\n 92: aload 14\n 94: swap\n 95: invokeinterface #84, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 100: pop\n 101: goto 54\n 104: aload 7\n 106: checkcast #86 // class java/util/List\n 109: nop\n 110: checkcast #46 // class java/lang/Iterable\n 113: astore 4\n 115: nop\n 116: iconst_0\n 117: istore 5\n 119: aload 4\n 121: bipush 10\n 123: invokestatic #54 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 126: invokestatic #92 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 129: bipush 16\n 131: invokestatic #98 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 134: istore 6\n 136: aload 4\n 138: astore 7\n 140: new #100 // class java/util/LinkedHashMap\n 143: dup\n 144: iload 6\n 146: invokespecial #101 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 149: checkcast #103 // class java/util/Map\n 152: astore 8\n 154: iconst_0\n 155: istore 9\n 157: aload 7\n 159: invokeinterface #64, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 164: astore 10\n 166: aload 10\n 168: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 173: ifeq 218\n 176: aload 10\n 178: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 183: astore 11\n 185: aload 8\n 187: aload 11\n 189: checkcast #105 // class day21/Monkey\n 192: astore 12\n 194: astore 14\n 196: iconst_0\n 197: istore 13\n 199: aload 12\n 201: invokevirtual #109 // Method day21/Monkey.getName:()Ljava/lang/String;\n 204: aload 14\n 206: swap\n 207: aload 11\n 209: invokeinterface #113, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 214: pop\n 215: goto 166\n 218: aload 8\n 220: nop\n 221: astore_3\n 222: nop\n 223: lload_1\n 224: ldc2_w #157 // long 10000l\n 227: lrem\n 228: lconst_0\n 229: lcmp\n 230: ifne 240\n 233: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 236: lload_1\n 237: invokevirtual #30 // Method java/io/PrintStream.println:(J)V\n 240: aload_3\n 241: invokestatic #117 // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;\n 244: lload_1\n 245: invokestatic #162 // Method checkForMatch:(Ljava/util/Map;J)Z\n 248: ifeq 253\n 251: lload_1\n 252: lreturn\n 253: lload_1\n 254: lstore 4\n 256: lload 4\n 258: lconst_1\n 259: ladd\n 260: lstore_1\n 261: goto 222\n\n public static final boolean checkForMatch(java.util.Map<java.lang.String, day21.Monkey>, long);\n Code:\n 0: aload_0\n 1: ldc #168 // String monkeys\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: ldc #119 // String root\n 9: invokeinterface #123, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 14: dup\n 15: invokestatic #127 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 18: checkcast #105 // class day21/Monkey\n 21: astore_3\n 22: aload_0\n 23: ldc #170 // String humn\n 25: invokeinterface #123, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 30: dup\n 31: invokestatic #127 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 34: checkcast #105 // class day21/Monkey\n 37: aconst_null\n 38: lload_1\n 39: invokestatic #176 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 42: aconst_null\n 43: iconst_5\n 44: aconst_null\n 45: invokestatic #180 // Method day21/Monkey.copy$default:(Lday21/Monkey;Ljava/lang/String;Ljava/lang/Long;Lday21/MonkeyOp;ILjava/lang/Object;)Lday21/Monkey;\n 48: astore 4\n 50: aload_0\n 51: ldc #170 // String humn\n 53: aload 4\n 55: invokeinterface #113, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 60: pop\n 61: aload_0\n 62: aload_3\n 63: invokevirtual #184 // Method day21/Monkey.getOp:()Lday21/MonkeyOp;\n 66: dup\n 67: ifnull 76\n 70: invokevirtual #189 // Method day21/MonkeyOp.getFirst:()Ljava/lang/String;\n 73: goto 78\n 76: pop\n 77: aconst_null\n 78: dup\n 79: invokestatic #127 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 82: invokeinterface #123, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 87: dup\n 88: invokestatic #127 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 91: checkcast #105 // class day21/Monkey\n 94: astore 5\n 96: aload_0\n 97: aload_3\n 98: invokevirtual #184 // Method day21/Monkey.getOp:()Lday21/MonkeyOp;\n 101: invokevirtual #192 // Method day21/MonkeyOp.getSecond:()Ljava/lang/String;\n 104: invokeinterface #123, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 109: dup\n 110: invokestatic #127 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 113: checkcast #105 // class day21/Monkey\n 116: astore 6\n 118: aload_0\n 119: aload 5\n 121: invokestatic #131 // Method solvePart1:(Ljava/util/Map;Lday21/Monkey;)J\n 124: lstore 7\n 126: aload_0\n 127: aload 6\n 129: invokestatic #131 // Method solvePart1:(Ljava/util/Map;Lday21/Monkey;)J\n 132: lstore 9\n 134: lload 7\n 136: lload 9\n 138: lcmp\n 139: ifne 146\n 142: iconst_1\n 143: goto 147\n 146: iconst_0\n 147: ireturn\n\n public static final long solvePart1(java.util.Map<java.lang.String, day21.Monkey>, day21.Monkey);\n Code:\n 0: aload_0\n 1: ldc #168 // String monkeys\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #201 // String current\n 9: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: invokevirtual #205 // Method day21/Monkey.getNumber:()Ljava/lang/Long;\n 16: ifnull 29\n 19: aload_1\n 20: invokevirtual #205 // Method day21/Monkey.getNumber:()Ljava/lang/Long;\n 23: invokevirtual #209 // Method java/lang/Long.longValue:()J\n 26: goto 241\n 29: aload_0\n 30: astore 4\n 32: aload_1\n 33: invokevirtual #184 // Method day21/Monkey.getOp:()Lday21/MonkeyOp;\n 36: dup\n 37: ifnull 46\n 40: invokevirtual #189 // Method day21/MonkeyOp.getFirst:()Ljava/lang/String;\n 43: goto 48\n 46: pop\n 47: aconst_null\n 48: aload 4\n 50: swap\n 51: invokeinterface #123, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 56: checkcast #105 // class day21/Monkey\n 59: dup\n 60: ifnonnull 77\n 63: pop\n 64: new #211 // class java/lang/IllegalStateException\n 67: dup\n 68: ldc #213 // String out of monkeys\n 70: invokevirtual #216 // Method java/lang/Object.toString:()Ljava/lang/String;\n 73: invokespecial #219 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 76: athrow\n 77: astore_2\n 78: aload_0\n 79: astore 5\n 81: aload_1\n 82: invokevirtual #184 // Method day21/Monkey.getOp:()Lday21/MonkeyOp;\n 85: dup\n 86: ifnull 95\n 89: invokevirtual #192 // Method day21/MonkeyOp.getSecond:()Ljava/lang/String;\n 92: goto 97\n 95: pop\n 96: aconst_null\n 97: aload 5\n 99: swap\n 100: invokeinterface #123, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 105: checkcast #105 // class day21/Monkey\n 108: dup\n 109: ifnonnull 126\n 112: pop\n 113: new #211 // class java/lang/IllegalStateException\n 116: dup\n 117: ldc #213 // String out of monkeys\n 119: invokevirtual #216 // Method java/lang/Object.toString:()Ljava/lang/String;\n 122: invokespecial #219 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 125: athrow\n 126: astore_3\n 127: aload_0\n 128: aload_2\n 129: invokestatic #131 // Method solvePart1:(Ljava/util/Map;Lday21/Monkey;)J\n 132: lstore 4\n 134: aload_0\n 135: aload_2\n 136: invokevirtual #109 // Method day21/Monkey.getName:()Ljava/lang/String;\n 139: aload_2\n 140: aconst_null\n 141: lload 4\n 143: invokestatic #176 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 146: aconst_null\n 147: iconst_5\n 148: aconst_null\n 149: invokestatic #180 // Method day21/Monkey.copy$default:(Lday21/Monkey;Ljava/lang/String;Ljava/lang/Long;Lday21/MonkeyOp;ILjava/lang/Object;)Lday21/Monkey;\n 152: invokeinterface #113, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 157: pop\n 158: aload_0\n 159: aload_3\n 160: invokestatic #131 // Method solvePart1:(Ljava/util/Map;Lday21/Monkey;)J\n 163: lstore 6\n 165: aload_0\n 166: aload_3\n 167: invokevirtual #109 // Method day21/Monkey.getName:()Ljava/lang/String;\n 170: aload_3\n 171: aconst_null\n 172: lload 6\n 174: invokestatic #176 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 177: aconst_null\n 178: iconst_5\n 179: aconst_null\n 180: invokestatic #180 // Method day21/Monkey.copy$default:(Lday21/Monkey;Ljava/lang/String;Ljava/lang/Long;Lday21/MonkeyOp;ILjava/lang/Object;)Lday21/Monkey;\n 183: invokeinterface #113, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 188: pop\n 189: aload_1\n 190: invokevirtual #184 // Method day21/Monkey.getOp:()Lday21/MonkeyOp;\n 193: dup\n 194: ifnull 210\n 197: invokevirtual #223 // Method day21/MonkeyOp.getOperator:()Lday21/Operator;\n 200: dup\n 201: ifnull 210\n 204: invokevirtual #229 // Method day21/Operator.getFunc:()Lkotlin/jvm/functions/Function2;\n 207: goto 212\n 210: pop\n 211: aconst_null\n 212: dup\n 213: invokestatic #127 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 216: astore 8\n 218: aload 8\n 220: lload 4\n 222: invokestatic #176 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 225: lload 6\n 227: invokestatic #176 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 230: invokeinterface #234, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 235: checkcast #236 // class java/lang/Number\n 238: invokevirtual #237 // Method java/lang/Number.longValue:()J\n 241: lreturn\n\n public static final day21.Monkey toMonkey(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #243 // String <this>\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #245 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #76 // class java/lang/String\n 14: astore_1\n 15: aload_1\n 16: iconst_0\n 17: ldc #247 // String :\n 19: aastore\n 20: aload_1\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #253 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: astore_2\n 30: iconst_0\n 31: istore_3\n 32: aload_2\n 33: iconst_0\n 34: invokeinterface #256, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 39: checkcast #76 // class java/lang/String\n 42: astore 4\n 44: aload_2\n 45: iconst_1\n 46: invokeinterface #256, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 51: checkcast #76 // class java/lang/String\n 54: astore 5\n 56: aload 5\n 58: checkcast #245 // class java/lang/CharSequence\n 61: astore 6\n 63: iconst_0\n 64: istore 7\n 66: iconst_0\n 67: istore 8\n 69: iload 8\n 71: aload 6\n 73: invokeinterface #260, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 78: if_icmpge 118\n 81: aload 6\n 83: iload 8\n 85: invokeinterface #264, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 90: istore 9\n 92: iload 9\n 94: istore 10\n 96: iconst_0\n 97: istore 11\n 99: iload 10\n 101: invokestatic #270 // Method java/lang/Character.isDigit:(C)Z\n 104: nop\n 105: ifne 112\n 108: iconst_0\n 109: goto 119\n 112: iinc 8, 1\n 115: goto 69\n 118: iconst_1\n 119: ifeq 145\n 122: new #105 // class day21/Monkey\n 125: dup\n 126: aload 4\n 128: aload 5\n 130: invokestatic #274 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 133: invokestatic #176 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 136: aconst_null\n 137: iconst_4\n 138: aconst_null\n 139: invokespecial #277 // Method day21/Monkey.\"<init>\":(Ljava/lang/String;Ljava/lang/Long;Lday21/MonkeyOp;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 142: goto 249\n 145: aload 5\n 147: checkcast #245 // class java/lang/CharSequence\n 150: iconst_1\n 151: anewarray #76 // class java/lang/String\n 154: astore 6\n 156: aload 6\n 158: iconst_0\n 159: ldc_w #279 // String\n 162: aastore\n 163: aload 6\n 165: iconst_0\n 166: iconst_0\n 167: bipush 6\n 169: aconst_null\n 170: invokestatic #253 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 173: astore 7\n 175: iconst_0\n 176: istore 8\n 178: aload 7\n 180: iconst_0\n 181: invokeinterface #256, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 186: checkcast #76 // class java/lang/String\n 189: astore 9\n 191: aload 7\n 193: iconst_1\n 194: invokeinterface #256, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 199: checkcast #76 // class java/lang/String\n 202: astore 10\n 204: aload 7\n 206: iconst_2\n 207: invokeinterface #256, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 212: checkcast #76 // class java/lang/String\n 215: astore 11\n 217: new #105 // class day21/Monkey\n 220: dup\n 221: aload 4\n 223: aconst_null\n 224: new #186 // class day21/MonkeyOp\n 227: dup\n 228: aload 9\n 230: aload 11\n 232: getstatic #283 // Field day21/Operator.Companion:Lday21/Operator$Companion;\n 235: aload 10\n 237: invokevirtual #289 // Method day21/Operator$Companion.fromString:(Ljava/lang/String;)Lday21/Operator;\n 240: invokespecial #292 // Method day21/MonkeyOp.\"<init>\":(Ljava/lang/String;Ljava/lang/String;Lday21/Operator;)V\n 243: iconst_2\n 244: aconst_null\n 245: invokespecial #277 // Method day21/Monkey.\"<init>\":(Ljava/lang/String;Ljava/lang/Long;Lday21/MonkeyOp;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 248: nop\n 249: nop\n 250: nop\n 251: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #310 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/day19/day19.kt
package day19 import day19.Resource.CLAY import day19.Resource.GEODE import day19.Resource.NONE import day19.Resource.OBSIDIAN import day19.Resource.ORE import kotlin.math.max import readInput val regex = """.+ (\d+).+ (\d+) .+ (\d+) .+ (\d+) .+ (\d+) .+ (\d+).+ (\d+) .*""".toRegex() fun main() { val input = readInput("main/day19/Day19_test") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int { val bluePrints = input.toBlueprints() return bluePrints.sumOf { it.id * it.maxGeodes(0) } } fun part2(input: List<String>): Long { return -1 } enum class Resource { NONE, ORE, CLAY, OBSIDIAN, GEODE } fun List<String>.toBlueprints() = map { line -> regex.matchEntire(line)?.destructured?.let { (id, oreRobotOre, clayRoboTOre, obsidianRobotOre, obsidianRobotClay, geodeRobotOre, geodeRobotObsidian) -> BluePrint( id = id.toInt(), oreRobotTemplate = OreRobot(cost = listOf(Cost(ORE, oreRobotOre.toInt()))), clayRobotTemplate = ClayRobot(cost = listOf(Cost(ORE, clayRoboTOre.toInt()))), obsidianRobotTemplate = ObsidianRobot(cost = listOf(Cost(ORE, obsidianRobotOre.toInt()), Cost(CLAY, obsidianRobotClay.toInt()))), geodeRobotTemplate = GeodeRobot(cost = listOf(Cost(ORE, geodeRobotOre.toInt()), Cost(OBSIDIAN, geodeRobotObsidian.toInt()))), ) } ?: error("PARSER ERROR") } data class Cost(val resource: Resource, val amount: Int) data class BluePrint( val id: Int, val oreRobotTemplate: OreRobot, val clayRobotTemplate: ClayRobot, val obsidianRobotTemplate: ObsidianRobot, val geodeRobotTemplate: GeodeRobot ) { private val allTemplates = listOf(oreRobotTemplate, clayRobotTemplate, obsidianRobotTemplate, geodeRobotTemplate).reversed() fun maxGeodes( maxSoFar: Int, robots: List<Robot> = listOf(oreRobotTemplate.instance()), resources: MutableList<Resource> = mutableListOf(), timeLeft: Int = 24 ): Int { if (timeLeft > 0) { val buildableRobots = buildableRobots(resources) buildableRobots.forEach { newRobot -> newRobot.cost.forEach { repeat(it.amount) { _ -> resources.remove(it.resource) } } return maxGeodes( max(maxSoFar, resources.count { it == GEODE }), robots + newRobot, resources.filter { it != NONE }.toMutableList(), timeLeft - 1 ) } robots.forEach { resources.add(it.resource) } return maxGeodes(max(maxSoFar, resources.count { it == GEODE }), robots, resources, timeLeft - 1) } else return maxSoFar } private fun buildableRobots(resources: List<Resource>): MutableList<Robot> { return allTemplates.filter { it.canBeBuiltFrom(resources) }.map { it.instance() }.toMutableList() } } sealed interface Robot { val resource: Resource val cost: List<Cost> fun canBeBuiltFrom(resources: List<Resource>): Boolean fun instance(): Robot } data class OreRobot(override val resource: Resource = ORE, override val cost: List<Cost>) : Robot { override fun canBeBuiltFrom(resources: List<Resource>): Boolean { return cost.all { cost -> resources.count { it == cost.resource } >= cost.amount } } override fun instance(): Robot { return copy() } } data class ClayRobot(override val resource: Resource = CLAY, override val cost: List<Cost>) : Robot { override fun canBeBuiltFrom(resources: List<Resource>): Boolean { return cost.all { cost -> resources.count { it == cost.resource } >= cost.amount } } override fun instance(): Robot { return copy() } } data class ObsidianRobot(override val resource: Resource = OBSIDIAN, override val cost: List<Cost>) : Robot { override fun canBeBuiltFrom(resources: List<Resource>): Boolean { return cost.all { cost -> resources.count { it == cost.resource } >= cost.amount } } override fun instance(): Robot { return copy() } } data class GeodeRobot(override val resource: Resource = GEODE, override val cost: List<Cost>) : Robot { override fun canBeBuiltFrom(resources: List<Resource>): Boolean { return cost.all { cost -> resources.count { it == cost.resource } >= cost.amount } } override fun instance(): Robot { return copy() } } //object NoOp : Robot { // override val resource: Resource // get() = NONE // override val cost: List<Cost> // get() = emptyList() // // override fun canBeBuiltFrom(resources: List<Resource>): Boolean = true // // override fun instance(): Robot { // return this // } //}
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/day19/Day19Kt.class", "javap": "Compiled from \"day19.kt\"\npublic final class day19.Day19Kt {\n private static final kotlin.text.Regex regex;\n\n public static final kotlin.text.Regex getRegex();\n Code:\n 0: getstatic #11 // Field regex:Lkotlin/text/Regex;\n 3: areturn\n\n public static final void main();\n Code:\n 0: ldc #15 // String main/day19/Day19_test\n 2: invokestatic #21 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #25 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #31 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #37 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #41 // Method part2:(Ljava/util/List;)J\n 22: lstore_1\n 23: getstatic #31 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: lload_1\n 27: invokevirtual #44 // Method java/io/PrintStream.println:(J)V\n 30: return\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #48 // String input\n 3: invokestatic #54 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #58 // Method toBlueprints:(Ljava/util/List;)Ljava/util/List;\n 10: astore_1\n 11: aload_1\n 12: checkcast #60 // class java/lang/Iterable\n 15: astore_2\n 16: iconst_0\n 17: istore_3\n 18: aload_2\n 19: invokeinterface #64, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 24: astore 4\n 26: aload 4\n 28: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 33: ifeq 87\n 36: aload 4\n 38: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 43: astore 5\n 45: iload_3\n 46: aload 5\n 48: checkcast #76 // class day19/BluePrint\n 51: astore 6\n 53: istore 8\n 55: iconst_0\n 56: istore 7\n 58: aload 6\n 60: invokevirtual #80 // Method day19/BluePrint.getId:()I\n 63: aload 6\n 65: iconst_0\n 66: aconst_null\n 67: aconst_null\n 68: iconst_0\n 69: bipush 14\n 71: aconst_null\n 72: invokestatic #84 // Method day19/BluePrint.maxGeodes$default:(Lday19/BluePrint;ILjava/util/List;Ljava/util/List;IILjava/lang/Object;)I\n 75: imul\n 76: istore 9\n 78: iload 8\n 80: iload 9\n 82: iadd\n 83: istore_3\n 84: goto 26\n 87: iload_3\n 88: ireturn\n\n public static final long part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #48 // String input\n 3: invokestatic #54 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc2_w #93 // long -1l\n 9: lreturn\n\n public static final java.util.List<day19.BluePrint> toBlueprints(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #97 // String <this>\n 3: invokestatic #54 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #60 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: astore_3\n 15: new #99 // class java/util/ArrayList\n 18: dup\n 19: aload_1\n 20: bipush 10\n 22: invokestatic #105 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 25: invokespecial #108 // Method java/util/ArrayList.\"<init>\":(I)V\n 28: checkcast #110 // class java/util/Collection\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: aload_3\n 37: invokeinterface #64, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 6\n 44: aload 6\n 46: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 472\n 54: aload 6\n 56: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 7\n 63: aload 4\n 65: aload 7\n 67: checkcast #112 // class java/lang/String\n 70: astore 8\n 72: astore 20\n 74: iconst_0\n 75: istore 9\n 77: getstatic #11 // Field regex:Lkotlin/text/Regex;\n 80: aload 8\n 82: checkcast #114 // class java/lang/CharSequence\n 85: invokevirtual #120 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 88: dup\n 89: ifnull 446\n 92: invokeinterface #126, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 97: dup\n 98: ifnull 446\n 101: astore 10\n 103: iconst_0\n 104: istore 11\n 106: aload 10\n 108: invokevirtual #132 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 111: invokeinterface #136, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 116: iconst_1\n 117: invokeinterface #140, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 122: checkcast #112 // class java/lang/String\n 125: astore 12\n 127: aload 10\n 129: invokevirtual #132 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 132: invokeinterface #136, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 137: iconst_2\n 138: invokeinterface #140, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 143: checkcast #112 // class java/lang/String\n 146: astore 13\n 148: aload 10\n 150: invokevirtual #132 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 153: invokeinterface #136, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 158: iconst_3\n 159: invokeinterface #140, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 164: checkcast #112 // class java/lang/String\n 167: astore 14\n 169: aload 10\n 171: invokevirtual #132 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 174: invokeinterface #136, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 179: iconst_4\n 180: invokeinterface #140, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 185: checkcast #112 // class java/lang/String\n 188: astore 15\n 190: aload 10\n 192: invokevirtual #132 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 195: invokeinterface #136, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 200: iconst_5\n 201: invokeinterface #140, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 206: checkcast #112 // class java/lang/String\n 209: astore 16\n 211: aload 10\n 213: invokevirtual #132 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 216: invokeinterface #136, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 221: bipush 6\n 223: invokeinterface #140, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 228: checkcast #112 // class java/lang/String\n 231: astore 17\n 233: aload 10\n 235: invokevirtual #132 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 238: invokeinterface #136, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 243: bipush 7\n 245: invokeinterface #140, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 250: checkcast #112 // class java/lang/String\n 253: astore 18\n 255: new #76 // class day19/BluePrint\n 258: dup\n 259: aload 12\n 261: invokestatic #146 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 264: new #148 // class day19/OreRobot\n 267: dup\n 268: aconst_null\n 269: new #150 // class day19/Cost\n 272: dup\n 273: getstatic #156 // Field day19/Resource.ORE:Lday19/Resource;\n 276: aload 13\n 278: invokestatic #146 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 281: invokespecial #159 // Method day19/Cost.\"<init>\":(Lday19/Resource;I)V\n 284: invokestatic #163 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 287: iconst_1\n 288: aconst_null\n 289: invokespecial #166 // Method day19/OreRobot.\"<init>\":(Lday19/Resource;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 292: new #168 // class day19/ClayRobot\n 295: dup\n 296: aconst_null\n 297: new #150 // class day19/Cost\n 300: dup\n 301: getstatic #156 // Field day19/Resource.ORE:Lday19/Resource;\n 304: aload 14\n 306: invokestatic #146 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 309: invokespecial #159 // Method day19/Cost.\"<init>\":(Lday19/Resource;I)V\n 312: invokestatic #163 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 315: iconst_1\n 316: aconst_null\n 317: invokespecial #169 // Method day19/ClayRobot.\"<init>\":(Lday19/Resource;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 320: new #171 // class day19/ObsidianRobot\n 323: dup\n 324: aconst_null\n 325: iconst_2\n 326: anewarray #150 // class day19/Cost\n 329: astore 19\n 331: aload 19\n 333: iconst_0\n 334: new #150 // class day19/Cost\n 337: dup\n 338: getstatic #156 // Field day19/Resource.ORE:Lday19/Resource;\n 341: aload 15\n 343: invokestatic #146 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 346: invokespecial #159 // Method day19/Cost.\"<init>\":(Lday19/Resource;I)V\n 349: aastore\n 350: aload 19\n 352: iconst_1\n 353: new #150 // class day19/Cost\n 356: dup\n 357: getstatic #174 // Field day19/Resource.CLAY:Lday19/Resource;\n 360: aload 16\n 362: invokestatic #146 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 365: invokespecial #159 // Method day19/Cost.\"<init>\":(Lday19/Resource;I)V\n 368: aastore\n 369: aload 19\n 371: invokestatic #177 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 374: iconst_1\n 375: aconst_null\n 376: invokespecial #178 // Method day19/ObsidianRobot.\"<init>\":(Lday19/Resource;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 379: new #180 // class day19/GeodeRobot\n 382: dup\n 383: aconst_null\n 384: iconst_2\n 385: anewarray #150 // class day19/Cost\n 388: astore 19\n 390: aload 19\n 392: iconst_0\n 393: new #150 // class day19/Cost\n 396: dup\n 397: getstatic #156 // Field day19/Resource.ORE:Lday19/Resource;\n 400: aload 17\n 402: invokestatic #146 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 405: invokespecial #159 // Method day19/Cost.\"<init>\":(Lday19/Resource;I)V\n 408: aastore\n 409: aload 19\n 411: iconst_1\n 412: new #150 // class day19/Cost\n 415: dup\n 416: getstatic #183 // Field day19/Resource.OBSIDIAN:Lday19/Resource;\n 419: aload 18\n 421: invokestatic #146 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 424: invokespecial #159 // Method day19/Cost.\"<init>\":(Lday19/Resource;I)V\n 427: aastore\n 428: aload 19\n 430: invokestatic #177 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 433: iconst_1\n 434: aconst_null\n 435: invokespecial #184 // Method day19/GeodeRobot.\"<init>\":(Lday19/Resource;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 438: invokespecial #187 // Method day19/BluePrint.\"<init>\":(ILday19/OreRobot;Lday19/ClayRobot;Lday19/ObsidianRobot;Lday19/GeodeRobot;)V\n 441: nop\n 442: nop\n 443: goto 460\n 446: pop\n 447: new #189 // class java/lang/IllegalStateException\n 450: dup\n 451: ldc #191 // String PARSER ERROR\n 453: invokevirtual #195 // Method java/lang/Object.toString:()Ljava/lang/String;\n 456: invokespecial #198 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 459: athrow\n 460: aload 20\n 462: swap\n 463: invokeinterface #202, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 468: pop\n 469: goto 44\n 472: aload 4\n 474: checkcast #91 // class java/util/List\n 477: nop\n 478: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #228 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: new #116 // class kotlin/text/Regex\n 3: dup\n 4: ldc #233 // String .+ (\\\\d+).+ (\\\\d+) .+ (\\\\d+) .+ (\\\\d+) .+ (\\\\d+) .+ (\\\\d+).+ (\\\\d+) .*\n 6: invokespecial #234 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: putstatic #11 // Field regex:Lkotlin/text/Regex;\n 12: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/year_2016/day12/day16.kt
package year_2016.day12 import readInput fun main() { val input = readInput("main/year_2016/day12/Day12") println(part1(input)) println(part2(input)) } val registers = mutableMapOf( "a" to 0, "b" to 0, "c" to 0, "d" to 0, ) fun part1(input: List<String>): Int { var index = 0 while (index < input.size) { val line = input[index] when (line.substring(0, 3)) { "cpy" -> { val (_, x, reg) = line.split(" ") if (x in listOf("a", "b", "c", "d")) registers[reg] = registers[x]!! else registers[reg] = x.toInt() index++ } "inc" -> { val (_, reg) = line.split(" ") registers[reg] = registers[reg]!! + 1 index++ } "dec" -> { val (_, reg) = line.split(" ") registers[reg] = registers[reg]!! - 1 index++ } "jnz" -> { val (_, x, y) = line.split(" ") if (x.all { it.isDigit() }) { if (x.toInt() != 0) index += y.toInt() } else { if (registers[x] != 0) index += y.toInt() else index++ } } } } return registers["a"]!! } fun part2(input: List<String>): Int { registers["c"] = 1 return part1(input) }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/year_2016/day12/Day16Kt.class", "javap": "Compiled from \"day16.kt\"\npublic final class year_2016.day12.Day16Kt {\n private static final java.util.Map<java.lang.String, java.lang.Integer> registers;\n\n public static final void main();\n Code:\n 0: ldc #8 // String main/year_2016/day12/Day12\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #33 // Method part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static final java.util.Map<java.lang.String, java.lang.Integer> getRegisters();\n Code:\n 0: getstatic #43 // Field registers:Ljava/util/Map;\n 3: areturn\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #45 // String input\n 3: invokestatic #51 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_1\n 8: iload_1\n 9: aload_0\n 10: invokeinterface #57, 1 // InterfaceMethod java/util/List.size:()I\n 15: if_icmpge 632\n 18: aload_0\n 19: iload_1\n 20: invokeinterface #61, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 25: checkcast #63 // class java/lang/String\n 28: astore_2\n 29: aload_2\n 30: iconst_0\n 31: iconst_3\n 32: invokevirtual #67 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 35: dup\n 36: ldc #69 // String substring(...)\n 38: invokestatic #72 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 41: astore_3\n 42: aload_3\n 43: invokevirtual #75 // Method java/lang/String.hashCode:()I\n 46: lookupswitch { // 4\n 98732: 112\n 99330: 88\n 104414: 124\n 105398: 100\n default: 629\n }\n 88: aload_3\n 89: ldc #77 // String dec\n 91: invokevirtual #81 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 94: ifne 368\n 97: goto 8\n 100: aload_3\n 101: ldc #83 // String jnz\n 103: invokevirtual #81 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 106: ifne 447\n 109: goto 8\n 112: aload_3\n 113: ldc #85 // String cpy\n 115: invokevirtual #81 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 118: ifne 136\n 121: goto 8\n 124: aload_3\n 125: ldc #87 // String inc\n 127: invokevirtual #81 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 130: ifne 289\n 133: goto 8\n 136: aload_2\n 137: checkcast #89 // class java/lang/CharSequence\n 140: iconst_1\n 141: anewarray #63 // class java/lang/String\n 144: astore 5\n 146: aload 5\n 148: iconst_0\n 149: ldc #91 // String\n 151: aastore\n 152: aload 5\n 154: iconst_0\n 155: iconst_0\n 156: bipush 6\n 158: aconst_null\n 159: invokestatic #97 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 162: astore 4\n 164: aload 4\n 166: iconst_1\n 167: invokeinterface #61, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 172: checkcast #63 // class java/lang/String\n 175: astore 5\n 177: aload 4\n 179: iconst_2\n 180: invokeinterface #61, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 185: checkcast #63 // class java/lang/String\n 188: astore 6\n 190: iconst_4\n 191: anewarray #63 // class java/lang/String\n 194: astore 7\n 196: aload 7\n 198: iconst_0\n 199: ldc #99 // String a\n 201: aastore\n 202: aload 7\n 204: iconst_1\n 205: ldc #101 // String b\n 207: aastore\n 208: aload 7\n 210: iconst_2\n 211: ldc #103 // String c\n 213: aastore\n 214: aload 7\n 216: iconst_3\n 217: ldc #105 // String d\n 219: aastore\n 220: aload 7\n 222: invokestatic #111 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 225: aload 5\n 227: invokeinterface #114, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 232: ifeq 263\n 235: getstatic #43 // Field registers:Ljava/util/Map;\n 238: aload 6\n 240: getstatic #43 // Field registers:Ljava/util/Map;\n 243: aload 5\n 245: invokeinterface #119, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 250: dup\n 251: invokestatic #123 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 254: invokeinterface #127, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 259: pop\n 260: goto 283\n 263: nop\n 264: getstatic #43 // Field registers:Ljava/util/Map;\n 267: aload 6\n 269: aload 5\n 271: invokestatic #133 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 274: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 277: invokeinterface #127, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 282: pop\n 283: iinc 1, 1\n 286: goto 8\n 289: aload_2\n 290: checkcast #89 // class java/lang/CharSequence\n 293: iconst_1\n 294: anewarray #63 // class java/lang/String\n 297: astore 5\n 299: aload 5\n 301: iconst_0\n 302: ldc #91 // String\n 304: aastore\n 305: aload 5\n 307: iconst_0\n 308: iconst_0\n 309: bipush 6\n 311: aconst_null\n 312: invokestatic #97 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 315: iconst_1\n 316: invokeinterface #61, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 321: checkcast #63 // class java/lang/String\n 324: astore 5\n 326: getstatic #43 // Field registers:Ljava/util/Map;\n 329: aload 5\n 331: getstatic #43 // Field registers:Ljava/util/Map;\n 334: aload 5\n 336: invokeinterface #119, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 341: dup\n 342: invokestatic #123 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 345: checkcast #139 // class java/lang/Number\n 348: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 351: iconst_1\n 352: iadd\n 353: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 356: invokeinterface #127, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 361: pop\n 362: iinc 1, 1\n 365: goto 8\n 368: aload_2\n 369: checkcast #89 // class java/lang/CharSequence\n 372: iconst_1\n 373: anewarray #63 // class java/lang/String\n 376: astore 5\n 378: aload 5\n 380: iconst_0\n 381: ldc #91 // String\n 383: aastore\n 384: aload 5\n 386: iconst_0\n 387: iconst_0\n 388: bipush 6\n 390: aconst_null\n 391: invokestatic #97 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 394: iconst_1\n 395: invokeinterface #61, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 400: checkcast #63 // class java/lang/String\n 403: astore 5\n 405: getstatic #43 // Field registers:Ljava/util/Map;\n 408: aload 5\n 410: getstatic #43 // Field registers:Ljava/util/Map;\n 413: aload 5\n 415: invokeinterface #119, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 420: dup\n 421: invokestatic #123 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 424: checkcast #139 // class java/lang/Number\n 427: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 430: iconst_1\n 431: isub\n 432: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 435: invokeinterface #127, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 440: pop\n 441: iinc 1, 1\n 444: goto 8\n 447: aload_2\n 448: checkcast #89 // class java/lang/CharSequence\n 451: iconst_1\n 452: anewarray #63 // class java/lang/String\n 455: astore 5\n 457: aload 5\n 459: iconst_0\n 460: ldc #91 // String\n 462: aastore\n 463: aload 5\n 465: iconst_0\n 466: iconst_0\n 467: bipush 6\n 469: aconst_null\n 470: invokestatic #97 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 473: astore 4\n 475: aload 4\n 477: iconst_1\n 478: invokeinterface #61, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 483: checkcast #63 // class java/lang/String\n 486: astore 5\n 488: aload 4\n 490: iconst_2\n 491: invokeinterface #61, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 496: checkcast #63 // class java/lang/String\n 499: astore 6\n 501: aload 5\n 503: checkcast #89 // class java/lang/CharSequence\n 506: astore 7\n 508: iconst_0\n 509: istore 8\n 511: iconst_0\n 512: istore 9\n 514: iload 9\n 516: aload 7\n 518: invokeinterface #145, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 523: if_icmpge 563\n 526: aload 7\n 528: iload 9\n 530: invokeinterface #149, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 535: istore 10\n 537: iload 10\n 539: istore 11\n 541: iconst_0\n 542: istore 12\n 544: iload 11\n 546: invokestatic #155 // Method java/lang/Character.isDigit:(C)Z\n 549: nop\n 550: ifne 557\n 553: iconst_0\n 554: goto 564\n 557: iinc 9, 1\n 560: goto 514\n 563: iconst_1\n 564: ifeq 586\n 567: aload 5\n 569: invokestatic #133 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 572: ifeq 8\n 575: iload_1\n 576: aload 6\n 578: invokestatic #133 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 581: iadd\n 582: istore_1\n 583: goto 8\n 586: getstatic #43 // Field registers:Ljava/util/Map;\n 589: aload 5\n 591: invokeinterface #119, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 596: checkcast #129 // class java/lang/Integer\n 599: dup\n 600: ifnonnull 607\n 603: pop\n 604: goto 613\n 607: invokevirtual #156 // Method java/lang/Integer.intValue:()I\n 610: ifeq 624\n 613: iload_1\n 614: aload 6\n 616: invokestatic #133 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 619: iadd\n 620: istore_1\n 621: goto 8\n 624: iload_1\n 625: iinc 1, 1\n 628: pop\n 629: goto 8\n 632: getstatic #43 // Field registers:Ljava/util/Map;\n 635: ldc #99 // String a\n 637: invokeinterface #119, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 642: dup\n 643: invokestatic #123 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 646: checkcast #139 // class java/lang/Number\n 649: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 652: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #45 // String input\n 3: invokestatic #51 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #43 // Field registers:Ljava/util/Map;\n 9: ldc #103 // String c\n 11: iconst_1\n 12: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 15: invokeinterface #127, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 20: pop\n 21: aload_0\n 22: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 25: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #175 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: iconst_4\n 1: anewarray #179 // class kotlin/Pair\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: ldc #99 // String a\n 9: iconst_0\n 10: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 13: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 16: aastore\n 17: aload_0\n 18: iconst_1\n 19: ldc #101 // String b\n 21: iconst_0\n 22: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 25: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 28: aastore\n 29: aload_0\n 30: iconst_2\n 31: ldc #103 // String c\n 33: iconst_0\n 34: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 37: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 40: aastore\n 41: aload_0\n 42: iconst_3\n 43: ldc #105 // String d\n 45: iconst_0\n 46: invokestatic #137 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 49: invokestatic #185 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 52: aastore\n 53: aload_0\n 54: invokestatic #191 // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 57: putstatic #43 // Field registers:Ljava/util/Map;\n 60: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/year_2016/day15/day15.kt
package year_2016.day15 import readInput val reg = """\b\d+\b""".toRegex() fun main() { val input = readInput("main/year_2016/day15/Day15") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int { return part2(input.dropLast(1)) } fun part2(input: List<String>): Int { val discs = input.map(String::toDisc) var time = 0 while (true) { if (discs.all { (it.layer + it.startingPosition + time) % it.positions == 0 }) return time time++ } } data class Disc( val layer: Int, val positions: Int, val startingPosition: Int ) fun String.toDisc(): Disc { val (layer, positions, _, startingPosition) = reg.findAll(this).toList() return Disc(layer.value.toInt(), positions.value.toInt(), startingPosition.value.toInt()) }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/year_2016/day15/Day15Kt.class", "javap": "Compiled from \"day15.kt\"\npublic final class year_2016.day15.Day15Kt {\n private static final kotlin.text.Regex reg;\n\n public static final kotlin.text.Regex getReg();\n Code:\n 0: getstatic #11 // Field reg:Lkotlin/text/Regex;\n 3: areturn\n\n public static final void main();\n Code:\n 0: ldc #15 // String main/year_2016/day15/Day15\n 2: invokestatic #21 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #25 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #31 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #37 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #40 // Method part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #31 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #37 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #44 // String input\n 3: invokestatic #50 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iconst_1\n 8: invokestatic #56 // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;\n 11: invokestatic #40 // Method part2:(Ljava/util/List;)I\n 14: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #44 // String input\n 3: invokestatic #50 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #58 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #60 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #64 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #67 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #69 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #73, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #79, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 96\n 56: aload 7\n 58: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #85 // class java/lang/String\n 72: astore 9\n 74: astore 11\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: invokestatic #89 // Method toDisc:(Ljava/lang/String;)Lyear_2016/day15/Disc;\n 84: aload 11\n 86: swap\n 87: invokeinterface #93, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 92: pop\n 93: goto 46\n 96: aload 5\n 98: checkcast #95 // class java/util/List\n 101: nop\n 102: astore_1\n 103: iconst_0\n 104: istore_2\n 105: nop\n 106: aload_1\n 107: checkcast #58 // class java/lang/Iterable\n 110: astore_3\n 111: iconst_0\n 112: istore 4\n 114: aload_3\n 115: instanceof #69 // class java/util/Collection\n 118: ifeq 137\n 121: aload_3\n 122: checkcast #69 // class java/util/Collection\n 125: invokeinterface #98, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 130: ifeq 137\n 133: iconst_1\n 134: goto 209\n 137: aload_3\n 138: invokeinterface #73, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 143: astore 5\n 145: aload 5\n 147: invokeinterface #79, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 152: ifeq 208\n 155: aload 5\n 157: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 162: astore 6\n 164: aload 6\n 166: checkcast #100 // class year_2016/day15/Disc\n 169: astore 7\n 171: iconst_0\n 172: istore 8\n 174: aload 7\n 176: invokevirtual #104 // Method year_2016/day15/Disc.getLayer:()I\n 179: aload 7\n 181: invokevirtual #107 // Method year_2016/day15/Disc.getStartingPosition:()I\n 184: iadd\n 185: iload_2\n 186: iadd\n 187: aload 7\n 189: invokevirtual #110 // Method year_2016/day15/Disc.getPositions:()I\n 192: irem\n 193: ifne 200\n 196: iconst_1\n 197: goto 201\n 200: iconst_0\n 201: ifne 145\n 204: iconst_0\n 205: goto 209\n 208: iconst_1\n 209: ifeq 214\n 212: iload_2\n 213: ireturn\n 214: iload_2\n 215: istore_3\n 216: iload_3\n 217: iconst_1\n 218: iadd\n 219: istore_2\n 220: goto 105\n\n public static final year_2016.day15.Disc toDisc(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #133 // String <this>\n 3: invokestatic #50 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #11 // Field reg:Lkotlin/text/Regex;\n 9: aload_0\n 10: checkcast #135 // class java/lang/CharSequence\n 13: iconst_0\n 14: iconst_2\n 15: aconst_null\n 16: invokestatic #141 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 19: invokestatic #147 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 22: astore_1\n 23: aload_1\n 24: iconst_0\n 25: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 30: checkcast #153 // class kotlin/text/MatchResult\n 33: astore_2\n 34: aload_1\n 35: iconst_1\n 36: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 41: checkcast #153 // class kotlin/text/MatchResult\n 44: astore_3\n 45: aload_1\n 46: iconst_3\n 47: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 52: checkcast #153 // class kotlin/text/MatchResult\n 55: astore 4\n 57: new #100 // class year_2016/day15/Disc\n 60: dup\n 61: aload_2\n 62: invokeinterface #157, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 67: invokestatic #163 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 70: aload_3\n 71: invokeinterface #157, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 76: invokestatic #163 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 79: aload 4\n 81: invokeinterface #157, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 86: invokestatic #163 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 89: invokespecial #166 // Method year_2016/day15/Disc.\"<init>\":(III)V\n 92: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #174 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: new #137 // class kotlin/text/Regex\n 3: dup\n 4: ldc #179 // String \\\\b\\\\d+\\\\b\n 6: invokespecial #182 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: putstatic #11 // Field reg:Lkotlin/text/Regex;\n 12: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/year_2016/day18/day18.kt
package year_2016.day18 const val input: Row = ".^^.^^^..^.^..^.^^.^^^^.^^.^^...^..^...^^^..^^...^..^^^^^^..^.^^^..^.^^^^.^^^.^...^^^.^^.^^^.^.^^.^." typealias Row = String fun main() { println(part1()) println(part2()) } fun part1(): Int = generateSequence(input) { s -> s.nextRow() }.take(40).sumOf { it.count { c -> c == '.' } } fun part2(): Int = generateSequence(input) { s -> s.nextRow() }.take(400000).sumOf { it.count { c -> c == '.' } } fun Row.nextRow(): Row { return this.mapIndexed { index, c -> if (leftIsTrap(index) && centerIsTrap(index) && !rightIsTrap(index)) '^' else if (!leftIsTrap(index) && centerIsTrap(index) && rightIsTrap(index)) '^' else if (leftIsTrap(index) && !centerIsTrap(index) && !rightIsTrap(index)) '^' else if (!leftIsTrap(index) && !centerIsTrap(index) && rightIsTrap(index)) '^' else '.' }.joinToString("") } fun Row.leftIsTrap(i: Int) = i > 0 && this[i - 1] == '^' fun Row.rightIsTrap(i: Int) = i < length - 1 && this[i + 1] == '^' fun Row.centerIsTrap(i: Int) = this[i] == '^'
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/year_2016/day18/Day18Kt.class", "javap": "Compiled from \"day18.kt\"\npublic final class year_2016.day18.Day18Kt {\n public static final java.lang.String input;\n\n public static final void main();\n Code:\n 0: invokestatic #10 // Method part1:()I\n 3: istore_0\n 4: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 7: iload_0\n 8: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 11: invokestatic #25 // Method part2:()I\n 14: istore_0\n 15: getstatic #16 // Field java/lang/System.out:Ljava/io/PrintStream;\n 18: iload_0\n 19: invokevirtual #22 // Method java/io/PrintStream.println:(I)V\n 22: return\n\n public static final int part1();\n Code:\n 0: ldc #27 // String .^^.^^^..^.^..^.^^.^^^^.^^.^^...^..^...^^^..^^...^..^^^^^^..^.^^^..^.^^^^.^^^.^...^^^.^^.^^^.^.^^.^.\n 2: invokedynamic #46, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 7: invokestatic #52 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 10: bipush 40\n 12: invokestatic #56 // Method kotlin/sequences/SequencesKt.take:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;\n 15: astore_0\n 16: iconst_0\n 17: istore_1\n 18: aload_0\n 19: invokeinterface #62, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 24: astore_2\n 25: aload_2\n 26: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 31: ifeq 137\n 34: aload_2\n 35: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 40: astore_3\n 41: iload_1\n 42: aload_3\n 43: checkcast #74 // class java/lang/String\n 46: astore 4\n 48: istore 13\n 50: iconst_0\n 51: istore 5\n 53: aload 4\n 55: checkcast #76 // class java/lang/CharSequence\n 58: astore 6\n 60: iconst_0\n 61: istore 7\n 63: iconst_0\n 64: istore 8\n 66: iconst_0\n 67: istore 9\n 69: iload 9\n 71: aload 6\n 73: invokeinterface #79, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 78: if_icmpge 123\n 81: aload 6\n 83: iload 9\n 85: invokeinterface #83, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 90: istore 10\n 92: iload 10\n 94: istore 11\n 96: iconst_0\n 97: istore 12\n 99: iload 11\n 101: bipush 46\n 103: if_icmpne 110\n 106: iconst_1\n 107: goto 111\n 110: iconst_0\n 111: ifeq 117\n 114: iinc 8, 1\n 117: iinc 9, 1\n 120: goto 69\n 123: iload 8\n 125: nop\n 126: istore 14\n 128: iload 13\n 130: iload 14\n 132: iadd\n 133: istore_1\n 134: goto 25\n 137: iload_1\n 138: ireturn\n\n public static final int part2();\n Code:\n 0: ldc #27 // String .^^.^^^..^.^..^.^^.^^^^.^^.^^...^..^...^^^..^^...^..^^^^^^..^.^^^..^.^^^^.^^^.^...^^^.^^.^^^.^.^^.^.\n 2: invokedynamic #100, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 7: invokestatic #52 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 10: ldc #101 // int 400000\n 12: invokestatic #56 // Method kotlin/sequences/SequencesKt.take:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;\n 15: astore_0\n 16: iconst_0\n 17: istore_1\n 18: aload_0\n 19: invokeinterface #62, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 24: astore_2\n 25: aload_2\n 26: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 31: ifeq 137\n 34: aload_2\n 35: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 40: astore_3\n 41: iload_1\n 42: aload_3\n 43: checkcast #74 // class java/lang/String\n 46: astore 4\n 48: istore 13\n 50: iconst_0\n 51: istore 5\n 53: aload 4\n 55: checkcast #76 // class java/lang/CharSequence\n 58: astore 6\n 60: iconst_0\n 61: istore 7\n 63: iconst_0\n 64: istore 8\n 66: iconst_0\n 67: istore 9\n 69: iload 9\n 71: aload 6\n 73: invokeinterface #79, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 78: if_icmpge 123\n 81: aload 6\n 83: iload 9\n 85: invokeinterface #83, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 90: istore 10\n 92: iload 10\n 94: istore 11\n 96: iconst_0\n 97: istore 12\n 99: iload 11\n 101: bipush 46\n 103: if_icmpne 110\n 106: iconst_1\n 107: goto 111\n 110: iconst_0\n 111: ifeq 117\n 114: iinc 8, 1\n 117: iinc 9, 1\n 120: goto 69\n 123: iload 8\n 125: nop\n 126: istore 14\n 128: iload 13\n 130: iload 14\n 132: iadd\n 133: istore_1\n 134: goto 25\n 137: iload_1\n 138: ireturn\n\n public static final java.lang.String nextRow(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #107 // String <this>\n 3: invokestatic #113 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #76 // class java/lang/CharSequence\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: astore_3\n 15: new #115 // class java/util/ArrayList\n 18: dup\n 19: aload_1\n 20: invokeinterface #79, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 25: invokespecial #118 // Method java/util/ArrayList.\"<init>\":(I)V\n 28: checkcast #120 // class java/util/Collection\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: iconst_0\n 37: istore 6\n 39: iconst_0\n 40: istore 7\n 42: iload 7\n 44: aload_3\n 45: invokeinterface #79, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 50: if_icmpge 229\n 53: aload_3\n 54: iload 7\n 56: invokeinterface #83, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 61: istore 8\n 63: aload 4\n 65: iload 6\n 67: iinc 6, 1\n 70: iload 8\n 72: istore 9\n 74: istore 10\n 76: astore 12\n 78: iconst_0\n 79: istore 11\n 81: aload_0\n 82: iload 10\n 84: invokestatic #124 // Method leftIsTrap:(Ljava/lang/String;I)Z\n 87: ifeq 113\n 90: aload_0\n 91: iload 10\n 93: invokestatic #127 // Method centerIsTrap:(Ljava/lang/String;I)Z\n 96: ifeq 113\n 99: aload_0\n 100: iload 10\n 102: invokestatic #130 // Method rightIsTrap:(Ljava/lang/String;I)Z\n 105: ifne 113\n 108: bipush 94\n 110: goto 211\n 113: aload_0\n 114: iload 10\n 116: invokestatic #124 // Method leftIsTrap:(Ljava/lang/String;I)Z\n 119: ifne 145\n 122: aload_0\n 123: iload 10\n 125: invokestatic #127 // Method centerIsTrap:(Ljava/lang/String;I)Z\n 128: ifeq 145\n 131: aload_0\n 132: iload 10\n 134: invokestatic #130 // Method rightIsTrap:(Ljava/lang/String;I)Z\n 137: ifeq 145\n 140: bipush 94\n 142: goto 211\n 145: aload_0\n 146: iload 10\n 148: invokestatic #124 // Method leftIsTrap:(Ljava/lang/String;I)Z\n 151: ifeq 177\n 154: aload_0\n 155: iload 10\n 157: invokestatic #127 // Method centerIsTrap:(Ljava/lang/String;I)Z\n 160: ifne 177\n 163: aload_0\n 164: iload 10\n 166: invokestatic #130 // Method rightIsTrap:(Ljava/lang/String;I)Z\n 169: ifne 177\n 172: bipush 94\n 174: goto 211\n 177: aload_0\n 178: iload 10\n 180: invokestatic #124 // Method leftIsTrap:(Ljava/lang/String;I)Z\n 183: ifne 209\n 186: aload_0\n 187: iload 10\n 189: invokestatic #127 // Method centerIsTrap:(Ljava/lang/String;I)Z\n 192: ifne 209\n 195: aload_0\n 196: iload 10\n 198: invokestatic #130 // Method rightIsTrap:(Ljava/lang/String;I)Z\n 201: ifeq 209\n 204: bipush 94\n 206: goto 211\n 209: bipush 46\n 211: invokestatic #136 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 214: aload 12\n 216: swap\n 217: invokeinterface #140, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 222: pop\n 223: iinc 7, 1\n 226: goto 42\n 229: aload 4\n 231: checkcast #142 // class java/util/List\n 234: nop\n 235: checkcast #144 // class java/lang/Iterable\n 238: ldc #146 // String\n 240: checkcast #76 // class java/lang/CharSequence\n 243: aconst_null\n 244: aconst_null\n 245: iconst_0\n 246: aconst_null\n 247: aconst_null\n 248: bipush 62\n 250: aconst_null\n 251: invokestatic #152 // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;\n 254: areturn\n\n public static final boolean leftIsTrap(java.lang.String, int);\n Code:\n 0: aload_0\n 1: ldc #107 // String <this>\n 3: invokestatic #113 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_1\n 7: ifle 26\n 10: aload_0\n 11: iload_1\n 12: iconst_1\n 13: isub\n 14: invokevirtual #164 // Method java/lang/String.charAt:(I)C\n 17: bipush 94\n 19: if_icmpne 26\n 22: iconst_1\n 23: goto 27\n 26: iconst_0\n 27: ireturn\n\n public static final boolean rightIsTrap(java.lang.String, int);\n Code:\n 0: aload_0\n 1: ldc #107 // String <this>\n 3: invokestatic #113 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_1\n 7: aload_0\n 8: invokevirtual #167 // Method java/lang/String.length:()I\n 11: iconst_1\n 12: isub\n 13: if_icmpge 32\n 16: aload_0\n 17: iload_1\n 18: iconst_1\n 19: iadd\n 20: invokevirtual #164 // Method java/lang/String.charAt:(I)C\n 23: bipush 94\n 25: if_icmpne 32\n 28: iconst_1\n 29: goto 33\n 32: iconst_0\n 33: ireturn\n\n public static final boolean centerIsTrap(java.lang.String, int);\n Code:\n 0: aload_0\n 1: ldc #107 // String <this>\n 3: invokestatic #113 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iload_1\n 8: invokevirtual #164 // Method java/lang/String.charAt:(I)C\n 11: bipush 94\n 13: if_icmpne 20\n 16: iconst_1\n 17: goto 21\n 20: iconst_0\n 21: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #172 // Method main:()V\n 3: return\n\n private static final java.lang.String part1$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #176 // String s\n 3: invokestatic #113 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #178 // Method nextRow:(Ljava/lang/String;)Ljava/lang/String;\n 10: areturn\n\n private static final java.lang.String part2$lambda$3(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #176 // String s\n 3: invokestatic #113 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #178 // Method nextRow:(Ljava/lang/String;)Ljava/lang/String;\n 10: areturn\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/year_2018/day18/day18.kt
package year_2018.day18 import Point import findPattern import readInput typealias Forest = Map<Point, Char> private const val TREE = '|' private const val OPEN = '.' private const val LUMBER_YARD = '#' fun main() { val input = readInput("main/year_2018/day18/Day18") println(part1(input)) println(part2(input)) } fun part1(input: List<String>): Int { val forest = input.parse() return forest.resourceValueList(11).last() } fun part2(input: List<String>): Int { val stepCount = 1000000000 val forest = input.parse() val resourceValueList = forest.resourceValueList() val (stepsBeforePattern, patternSize) = resourceValueList.findPattern() val indexInCycle = (stepCount - stepsBeforePattern) % patternSize return resourceValueList.drop(stepsBeforePattern)[indexInCycle] } fun Forest.step(): Forest = this.keys.associateWith { here -> when (this[here]) { OPEN -> if (this.countNeighborsOfKind(here, TREE) >= 3) TREE else OPEN TREE -> if (this.countNeighborsOfKind(here, LUMBER_YARD) >= 3) LUMBER_YARD else TREE LUMBER_YARD -> if (countNeighborsOfKind(here, LUMBER_YARD) > 0 && countNeighborsOfKind(here, TREE) > 0) LUMBER_YARD else OPEN else -> error("Something went wrong: $here, ${this[here]}") } } private fun Forest.resourceValue(): Int = count { it.value == LUMBER_YARD } * count { it.value == TREE } fun Forest.resourceValueList(n: Int = 600): List<Int> = generateSequence(this) { it.step() }.take(n).map { it.resourceValue() }.toList() fun Forest.countNeighborsOfKind(p: Point, c: Char) = p.allNeighbours().count { this[it] == c } fun List<String>.parse(): Forest = mutableMapOf<Point, Char>().apply { forEachIndexed { y, line -> line.forEachIndexed { x, c -> this[Point(x, y)] = c } } }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/year_2018/day18/Day18Kt.class", "javap": "Compiled from \"day18.kt\"\npublic final class year_2018.day18.Day18Kt {\n private static final char TREE;\n\n private static final char OPEN;\n\n private static final char LUMBER_YARD;\n\n public static final void main();\n Code:\n 0: ldc #8 // String main/year_2018/day18/Day18\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #33 // Method part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #48 // Method parse:(Ljava/util/List;)Ljava/util/Map;\n 10: astore_1\n 11: aload_1\n 12: bipush 11\n 14: invokestatic #52 // Method resourceValueList:(Ljava/util/Map;I)Ljava/util/List;\n 17: invokestatic #58 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 20: checkcast #60 // class java/lang/Number\n 23: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 26: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #38 // String input\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #67 // int 1000000000\n 8: istore_1\n 9: aload_0\n 10: invokestatic #48 // Method parse:(Ljava/util/List;)Ljava/util/Map;\n 13: astore_2\n 14: aload_2\n 15: iconst_0\n 16: iconst_1\n 17: aconst_null\n 18: invokestatic #71 // Method resourceValueList$default:(Ljava/util/Map;IILjava/lang/Object;)Ljava/util/List;\n 21: astore_3\n 22: aload_3\n 23: iconst_0\n 24: iconst_1\n 25: aconst_null\n 26: invokestatic #75 // Method UtilsKt.findPattern$default:(Ljava/util/List;IILjava/lang/Object;)Lkotlin/Pair;\n 29: astore 4\n 31: aload 4\n 33: invokevirtual #81 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 36: checkcast #60 // class java/lang/Number\n 39: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 42: istore 5\n 44: aload 4\n 46: invokevirtual #84 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 49: checkcast #60 // class java/lang/Number\n 52: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 55: istore 6\n 57: iload_1\n 58: iload 5\n 60: isub\n 61: iload 6\n 63: irem\n 64: istore 7\n 66: aload_3\n 67: checkcast #86 // class java/lang/Iterable\n 70: iload 5\n 72: invokestatic #90 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 75: iload 7\n 77: invokeinterface #96, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 82: checkcast #60 // class java/lang/Number\n 85: invokevirtual #64 // Method java/lang/Number.intValue:()I\n 88: ireturn\n\n public static final java.util.Map<Point, java.lang.Character> step(java.util.Map<Point, java.lang.Character>);\n Code:\n 0: aload_0\n 1: ldc #106 // String <this>\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #112, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 12: checkcast #86 // class java/lang/Iterable\n 15: astore_1\n 16: iconst_0\n 17: istore_2\n 18: new #114 // class java/util/LinkedHashMap\n 21: dup\n 22: aload_1\n 23: bipush 10\n 25: invokestatic #118 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 28: invokestatic #124 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 31: bipush 16\n 33: invokestatic #130 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 36: invokespecial #133 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 39: astore_3\n 40: aload_1\n 41: astore 4\n 43: iconst_0\n 44: istore 5\n 46: aload 4\n 48: invokeinterface #137, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 53: astore 6\n 55: aload 6\n 57: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 62: ifeq 317\n 65: aload 6\n 67: invokeinterface #146, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 72: astore 7\n 74: aload_3\n 75: checkcast #108 // class java/util/Map\n 78: aload 7\n 80: aload 7\n 82: checkcast #148 // class Point\n 85: astore 8\n 87: astore 13\n 89: astore 12\n 91: iconst_0\n 92: istore 9\n 94: aload_0\n 95: aload 8\n 97: invokeinterface #151, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 102: checkcast #153 // class java/lang/Character\n 105: astore 10\n 107: aload 10\n 109: bipush 46\n 111: istore 11\n 113: dup\n 114: ifnonnull 121\n 117: pop\n 118: goto 151\n 121: invokevirtual #157 // Method java/lang/Character.charValue:()C\n 124: iload 11\n 126: if_icmpne 151\n 129: aload_0\n 130: aload 8\n 132: bipush 124\n 134: invokestatic #161 // Method countNeighborsOfKind:(Ljava/util/Map;LPoint;C)I\n 137: iconst_3\n 138: if_icmplt 146\n 141: bipush 124\n 143: goto 296\n 146: bipush 46\n 148: goto 296\n 151: aload 10\n 153: bipush 124\n 155: istore 11\n 157: dup\n 158: ifnonnull 165\n 161: pop\n 162: goto 195\n 165: invokevirtual #157 // Method java/lang/Character.charValue:()C\n 168: iload 11\n 170: if_icmpne 195\n 173: aload_0\n 174: aload 8\n 176: bipush 35\n 178: invokestatic #161 // Method countNeighborsOfKind:(Ljava/util/Map;LPoint;C)I\n 181: iconst_3\n 182: if_icmplt 190\n 185: bipush 35\n 187: goto 296\n 190: bipush 124\n 192: goto 296\n 195: aload 10\n 197: bipush 35\n 199: istore 11\n 201: dup\n 202: ifnonnull 209\n 205: pop\n 206: goto 249\n 209: invokevirtual #157 // Method java/lang/Character.charValue:()C\n 212: iload 11\n 214: if_icmpne 249\n 217: aload_0\n 218: aload 8\n 220: bipush 35\n 222: invokestatic #161 // Method countNeighborsOfKind:(Ljava/util/Map;LPoint;C)I\n 225: ifle 244\n 228: aload_0\n 229: aload 8\n 231: bipush 124\n 233: invokestatic #161 // Method countNeighborsOfKind:(Ljava/util/Map;LPoint;C)I\n 236: ifle 244\n 239: bipush 35\n 241: goto 296\n 244: bipush 46\n 246: goto 296\n 249: new #163 // class java/lang/IllegalStateException\n 252: dup\n 253: new #165 // class java/lang/StringBuilder\n 256: dup\n 257: invokespecial #167 // Method java/lang/StringBuilder.\"<init>\":()V\n 260: ldc #169 // String Something went wrong:\n 262: invokevirtual #173 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 265: aload 8\n 267: invokevirtual #176 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 270: ldc #178 // String ,\n 272: invokevirtual #173 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 275: aload_0\n 276: aload 8\n 278: invokeinterface #151, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 283: invokevirtual #176 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 286: invokevirtual #182 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 289: invokevirtual #183 // Method java/lang/Object.toString:()Ljava/lang/String;\n 292: invokespecial #186 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 295: athrow\n 296: nop\n 297: invokestatic #190 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 300: astore 14\n 302: aload 12\n 304: aload 13\n 306: aload 14\n 308: invokeinterface #194, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 313: pop\n 314: goto 55\n 317: aload_3\n 318: checkcast #108 // class java/util/Map\n 321: nop\n 322: areturn\n\n private static final int resourceValue(java.util.Map<Point, java.lang.Character>);\n Code:\n 0: aload_0\n 1: astore_1\n 2: iconst_0\n 3: istore_2\n 4: aload_1\n 5: invokeinterface #213, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 10: ifeq 17\n 13: iconst_0\n 14: goto 94\n 17: iconst_0\n 18: istore_3\n 19: aload_1\n 20: invokeinterface #216, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 25: invokeinterface #219, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 30: astore 4\n 32: aload 4\n 34: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 39: ifeq 93\n 42: aload 4\n 44: invokeinterface #146, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 49: checkcast #221 // class java/util/Map$Entry\n 52: astore 5\n 54: aload 5\n 56: astore 6\n 58: iconst_0\n 59: istore 7\n 61: aload 6\n 63: invokeinterface #224, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 68: checkcast #153 // class java/lang/Character\n 71: invokevirtual #157 // Method java/lang/Character.charValue:()C\n 74: bipush 35\n 76: if_icmpne 83\n 79: iconst_1\n 80: goto 84\n 83: iconst_0\n 84: ifeq 32\n 87: iinc 3, 1\n 90: goto 32\n 93: iload_3\n 94: aload_0\n 95: astore_1\n 96: istore 8\n 98: iconst_0\n 99: istore_2\n 100: aload_1\n 101: invokeinterface #213, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 106: ifeq 113\n 109: iconst_0\n 110: goto 190\n 113: iconst_0\n 114: istore_3\n 115: aload_1\n 116: invokeinterface #216, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 121: invokeinterface #219, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 126: astore 4\n 128: aload 4\n 130: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 135: ifeq 189\n 138: aload 4\n 140: invokeinterface #146, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 145: checkcast #221 // class java/util/Map$Entry\n 148: astore 5\n 150: aload 5\n 152: astore 6\n 154: iconst_0\n 155: istore 7\n 157: aload 6\n 159: invokeinterface #224, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 164: checkcast #153 // class java/lang/Character\n 167: invokevirtual #157 // Method java/lang/Character.charValue:()C\n 170: bipush 124\n 172: if_icmpne 179\n 175: iconst_1\n 176: goto 180\n 179: iconst_0\n 180: ifeq 128\n 183: iinc 3, 1\n 186: goto 128\n 189: iload_3\n 190: istore 9\n 192: iload 8\n 194: iload 9\n 196: imul\n 197: ireturn\n\n public static final java.util.List<java.lang.Integer> resourceValueList(java.util.Map<Point, java.lang.Character>, int);\n Code:\n 0: aload_0\n 1: ldc #106 // String <this>\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokedynamic #251, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 12: invokestatic #257 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 15: iload_1\n 16: invokestatic #261 // Method kotlin/sequences/SequencesKt.take:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;\n 19: invokedynamic #268, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 24: invokestatic #272 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 27: invokestatic #276 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 30: areturn\n\n public static java.util.List resourceValueList$default(java.util.Map, int, int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 10\n 6: sipush 600\n 9: istore_1\n 10: aload_0\n 11: iload_1\n 12: invokestatic #52 // Method resourceValueList:(Ljava/util/Map;I)Ljava/util/List;\n 15: areturn\n\n public static final int countNeighborsOfKind(java.util.Map<Point, java.lang.Character>, Point, char);\n Code:\n 0: aload_0\n 1: ldc #106 // String <this>\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc_w #281 // String p\n 10: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: aload_1\n 14: invokevirtual #284 // Method Point.allNeighbours:()Ljava/util/Set;\n 17: checkcast #86 // class java/lang/Iterable\n 20: astore_3\n 21: iconst_0\n 22: istore 4\n 24: aload_3\n 25: instanceof #286 // class java/util/Collection\n 28: ifeq 47\n 31: aload_3\n 32: checkcast #286 // class java/util/Collection\n 35: invokeinterface #287, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 40: ifeq 47\n 43: iconst_0\n 44: goto 141\n 47: iconst_0\n 48: istore 5\n 50: aload_3\n 51: invokeinterface #137, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 56: astore 6\n 58: aload 6\n 60: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 65: ifeq 139\n 68: aload 6\n 70: invokeinterface #146, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 75: astore 7\n 77: aload 7\n 79: checkcast #148 // class Point\n 82: astore 8\n 84: iconst_0\n 85: istore 9\n 87: aload_0\n 88: aload 8\n 90: invokeinterface #151, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 95: checkcast #153 // class java/lang/Character\n 98: iload_2\n 99: istore 10\n 101: dup\n 102: ifnonnull 109\n 105: pop\n 106: goto 121\n 109: invokevirtual #157 // Method java/lang/Character.charValue:()C\n 112: iload 10\n 114: if_icmpne 121\n 117: iconst_1\n 118: goto 122\n 121: iconst_0\n 122: ifeq 58\n 125: iinc 5, 1\n 128: iload 5\n 130: ifge 58\n 133: invokestatic #290 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 136: goto 58\n 139: iload 5\n 141: ireturn\n\n public static final java.util.Map<Point, java.lang.Character> parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #106 // String <this>\n 3: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #114 // class java/util/LinkedHashMap\n 9: dup\n 10: invokespecial #296 // Method java/util/LinkedHashMap.\"<init>\":()V\n 13: checkcast #108 // class java/util/Map\n 16: astore_1\n 17: aload_1\n 18: astore_2\n 19: iconst_0\n 20: istore_3\n 21: aload_0\n 22: checkcast #86 // class java/lang/Iterable\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: iconst_0\n 31: istore 6\n 33: aload 4\n 35: invokeinterface #137, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 40: astore 7\n 42: aload 7\n 44: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 49: ifeq 184\n 52: aload 7\n 54: invokeinterface #146, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 59: astore 8\n 61: iload 6\n 63: iinc 6, 1\n 66: istore 9\n 68: iload 9\n 70: ifge 76\n 73: invokestatic #299 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 76: iload 9\n 78: aload 8\n 80: checkcast #301 // class java/lang/String\n 83: astore 10\n 85: istore 11\n 87: iconst_0\n 88: istore 12\n 90: aload 10\n 92: checkcast #303 // class java/lang/CharSequence\n 95: astore 13\n 97: iconst_0\n 98: istore 14\n 100: iconst_0\n 101: istore 15\n 103: iconst_0\n 104: istore 16\n 106: iload 16\n 108: aload 13\n 110: invokeinterface #306, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 115: if_icmpge 178\n 118: aload 13\n 120: iload 16\n 122: invokeinterface #310, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 127: istore 17\n 129: iload 15\n 131: iinc 15, 1\n 134: iload 17\n 136: istore 18\n 138: istore 19\n 140: iconst_0\n 141: istore 20\n 143: iload 18\n 145: invokestatic #190 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 148: astore 21\n 150: aload_2\n 151: new #148 // class Point\n 154: dup\n 155: iload 19\n 157: iload 11\n 159: invokespecial #313 // Method Point.\"<init>\":(II)V\n 162: aload 21\n 164: invokeinterface #194, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 169: pop\n 170: nop\n 171: nop\n 172: iinc 16, 1\n 175: goto 106\n 178: nop\n 179: nop\n 180: nop\n 181: goto 42\n 184: nop\n 185: nop\n 186: aload_1\n 187: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #330 // Method main:()V\n 3: return\n\n private static final java.util.Map resourceValueList$lambda$3(java.util.Map);\n Code:\n 0: aload_0\n 1: ldc_w #333 // String it\n 4: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokestatic #335 // Method step:(Ljava/util/Map;)Ljava/util/Map;\n 11: areturn\n\n private static final int resourceValueList$lambda$4(java.util.Map);\n Code:\n 0: aload_0\n 1: ldc_w #333 // String it\n 4: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokestatic #337 // Method resourceValue:(Ljava/util/Map;)I\n 11: ireturn\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/year_2017/day07/day07.kt
package year_2017.day07 import kotlin.math.absoluteValue import readInput import second fun part1(input: List<String>): String { val programs = input.map(String::parse) return programs.findBottomProgram() } fun part2(input: List<String>): Int { val programs = input.map(String::parse) allPrograms = programs.associateBy { it.name }.toMutableMap() return allPrograms[programs.findBottomProgram()]!!.findImbalance() } var allPrograms: Map<String, Program> = mapOf() fun main() { val input = readInput("main/year_2017/day07/Day07") println(part1(input)) println(part2(input)) } fun Collection<Program>.findBottomProgram(): String { val allNames = this.flatMap { p -> listOf(p.name.trim()) + p.programsCarried.map { it.trim() } } val nameCounts = allNames.associateBy { s -> allNames.count { it == s } } return nameCounts[1]!! } data class Program( val name: String, val weight: Int, val programsCarried: List<String> ) { private fun totalWeightCarried(): Int { return weight + programsCarried .sumOf { name -> allPrograms[name.trim()]!!.totalWeightCarried() } } private fun childrenAreBalanced() = programsCarried.map { allPrograms[it.trim()]!!.totalWeightCarried() }.distinct().size == 1 fun findImbalance(imbalance: Int? = null): Int = if (imbalance != null && childrenAreBalanced()) { weight - imbalance } else { val subTrees = programsCarried.groupBy { allPrograms[it.trim()]!!.totalWeightCarried() } val outOfBalanceTree = subTrees.minBy { it.value.size }.value.first().trim() allPrograms[outOfBalanceTree]!!.findImbalance(imbalance = imbalance ?: subTrees.keys.reduce { a, b -> a - b }.absoluteValue) } } fun String.parse(): Program { return this.split("->").let { val split = it.first().split((" (")) val name = split.first().trim() val weight = split.second().trim().dropLast(1).toInt() val programs = if (it.size > 1) { it.second().split((", ").trim()) } else emptyList() Program(name.trim(), weight, programs.map(String::trim)) } }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/year_2017/day07/Day07Kt.class", "javap": "Compiled from \"day07.kt\"\npublic final class year_2017.day07.Day07Kt {\n private static java.util.Map<java.lang.String, year_2017.day07.Program> allPrograms;\n\n public static final java.lang.String part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #18 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #20 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #26 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #30 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #32 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 96\n 56: aload 7\n 58: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #48 // class java/lang/String\n 72: astore 9\n 74: astore 11\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: invokestatic #52 // Method parse:(Ljava/lang/String;)Lyear_2017/day07/Program;\n 84: aload 11\n 86: swap\n 87: invokeinterface #56, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 92: pop\n 93: goto 46\n 96: aload 5\n 98: checkcast #58 // class java/util/List\n 101: nop\n 102: astore_1\n 103: aload_1\n 104: checkcast #32 // class java/util/Collection\n 107: invokestatic #62 // Method findBottomProgram:(Ljava/util/Collection;)Ljava/lang/String;\n 110: areturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #18 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #20 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #26 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #30 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #32 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 96\n 56: aload 7\n 58: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #48 // class java/lang/String\n 72: astore 9\n 74: astore 12\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: invokestatic #52 // Method parse:(Ljava/lang/String;)Lyear_2017/day07/Program;\n 84: aload 12\n 86: swap\n 87: invokeinterface #56, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 92: pop\n 93: goto 46\n 96: aload 5\n 98: checkcast #58 // class java/util/List\n 101: nop\n 102: astore_1\n 103: aload_1\n 104: checkcast #18 // class java/lang/Iterable\n 107: astore_2\n 108: iconst_0\n 109: istore_3\n 110: aload_2\n 111: bipush 10\n 113: invokestatic #26 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 116: invokestatic #86 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 119: bipush 16\n 121: invokestatic #92 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 124: istore 4\n 126: aload_2\n 127: astore 5\n 129: new #94 // class java/util/LinkedHashMap\n 132: dup\n 133: iload 4\n 135: invokespecial #95 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 138: checkcast #97 // class java/util/Map\n 141: astore 6\n 143: iconst_0\n 144: istore 7\n 146: aload 5\n 148: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 153: astore 8\n 155: aload 8\n 157: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 162: ifeq 207\n 165: aload 8\n 167: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 172: astore 9\n 174: aload 6\n 176: aload 9\n 178: checkcast #99 // class year_2017/day07/Program\n 181: astore 10\n 183: astore 12\n 185: iconst_0\n 186: istore 11\n 188: aload 10\n 190: invokevirtual #103 // Method year_2017/day07/Program.getName:()Ljava/lang/String;\n 193: aload 12\n 195: swap\n 196: aload 9\n 198: invokeinterface #107, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 203: pop\n 204: goto 155\n 207: aload 6\n 209: nop\n 210: invokestatic #111 // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;\n 213: putstatic #115 // Field allPrograms:Ljava/util/Map;\n 216: getstatic #115 // Field allPrograms:Ljava/util/Map;\n 219: aload_1\n 220: checkcast #32 // class java/util/Collection\n 223: invokestatic #62 // Method findBottomProgram:(Ljava/util/Collection;)Ljava/lang/String;\n 226: invokeinterface #119, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 231: dup\n 232: invokestatic #123 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 235: checkcast #99 // class year_2017/day07/Program\n 238: aconst_null\n 239: iconst_1\n 240: aconst_null\n 241: invokestatic #127 // Method year_2017/day07/Program.findImbalance$default:(Lyear_2017/day07/Program;Ljava/lang/Integer;ILjava/lang/Object;)I\n 244: ireturn\n\n public static final java.util.Map<java.lang.String, year_2017.day07.Program> getAllPrograms();\n Code:\n 0: getstatic #115 // Field allPrograms:Ljava/util/Map;\n 3: areturn\n\n public static final void setAllPrograms(java.util.Map<java.lang.String, year_2017.day07.Program>);\n Code:\n 0: aload_0\n 1: ldc #145 // String <set-?>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: putstatic #115 // Field allPrograms:Ljava/util/Map;\n 10: return\n\n public static final void main();\n Code:\n 0: ldc #149 // String main/year_2017/day07/Day07\n 2: invokestatic #155 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #157 // Method part1:(Ljava/util/List;)Ljava/lang/String;\n 10: getstatic #163 // Field java/lang/System.out:Ljava/io/PrintStream;\n 13: swap\n 14: invokevirtual #168 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 17: aload_0\n 18: invokestatic #170 // Method part2:(Ljava/util/List;)I\n 21: istore_1\n 22: getstatic #163 // Field java/lang/System.out:Ljava/io/PrintStream;\n 25: iload_1\n 26: invokevirtual #172 // Method java/io/PrintStream.println:(I)V\n 29: return\n\n public static final java.lang.String findBottomProgram(java.util.Collection<year_2017.day07.Program>);\n Code:\n 0: aload_0\n 1: ldc #175 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #18 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #20 // class java/util/ArrayList\n 19: dup\n 20: invokespecial #177 // Method java/util/ArrayList.\"<init>\":()V\n 23: checkcast #32 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 227\n 50: aload 7\n 52: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 8\n 61: checkcast #99 // class year_2017/day07/Program\n 64: astore 9\n 66: iconst_0\n 67: istore 10\n 69: aload 9\n 71: invokevirtual #103 // Method year_2017/day07/Program.getName:()Ljava/lang/String;\n 74: checkcast #179 // class java/lang/CharSequence\n 77: invokestatic #185 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 80: invokevirtual #188 // Method java/lang/Object.toString:()Ljava/lang/String;\n 83: invokestatic #192 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 86: checkcast #32 // class java/util/Collection\n 89: aload 9\n 91: invokevirtual #196 // Method year_2017/day07/Program.getProgramsCarried:()Ljava/util/List;\n 94: checkcast #18 // class java/lang/Iterable\n 97: astore 11\n 99: astore 12\n 101: iconst_0\n 102: istore 13\n 104: aload 11\n 106: astore 14\n 108: new #20 // class java/util/ArrayList\n 111: dup\n 112: aload 11\n 114: bipush 10\n 116: invokestatic #26 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 119: invokespecial #30 // Method java/util/ArrayList.\"<init>\":(I)V\n 122: checkcast #32 // class java/util/Collection\n 125: astore 15\n 127: iconst_0\n 128: istore 16\n 130: aload 14\n 132: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 137: astore 17\n 139: aload 17\n 141: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 146: ifeq 196\n 149: aload 17\n 151: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 156: astore 18\n 158: aload 15\n 160: aload 18\n 162: checkcast #48 // class java/lang/String\n 165: astore 19\n 167: astore 20\n 169: iconst_0\n 170: istore 21\n 172: aload 19\n 174: checkcast #179 // class java/lang/CharSequence\n 177: invokestatic #185 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 180: invokevirtual #188 // Method java/lang/Object.toString:()Ljava/lang/String;\n 183: nop\n 184: aload 20\n 186: swap\n 187: invokeinterface #56, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 192: pop\n 193: goto 139\n 196: aload 15\n 198: checkcast #58 // class java/util/List\n 201: nop\n 202: aload 12\n 204: swap\n 205: checkcast #18 // class java/lang/Iterable\n 208: invokestatic #200 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 211: checkcast #18 // class java/lang/Iterable\n 214: astore 9\n 216: aload 5\n 218: aload 9\n 220: invokestatic #204 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 223: pop\n 224: goto 40\n 227: aload 5\n 229: checkcast #58 // class java/util/List\n 232: nop\n 233: astore_1\n 234: aload_1\n 235: checkcast #18 // class java/lang/Iterable\n 238: astore_3\n 239: iconst_0\n 240: istore 4\n 242: aload_3\n 243: bipush 10\n 245: invokestatic #26 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 248: invokestatic #86 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 251: bipush 16\n 253: invokestatic #92 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 256: istore 5\n 258: aload_3\n 259: astore 6\n 261: new #94 // class java/util/LinkedHashMap\n 264: dup\n 265: iload 5\n 267: invokespecial #95 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 270: checkcast #97 // class java/util/Map\n 273: astore 7\n 275: iconst_0\n 276: istore 8\n 278: aload 6\n 280: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 285: astore 9\n 287: aload 9\n 289: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 294: ifeq 439\n 297: aload 9\n 299: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 304: astore 10\n 306: aload 7\n 308: aload 10\n 310: checkcast #48 // class java/lang/String\n 313: astore 11\n 315: astore 22\n 317: iconst_0\n 318: istore 12\n 320: aload_1\n 321: checkcast #18 // class java/lang/Iterable\n 324: astore 13\n 326: iconst_0\n 327: istore 14\n 329: aload 13\n 331: instanceof #32 // class java/util/Collection\n 334: ifeq 354\n 337: aload 13\n 339: checkcast #32 // class java/util/Collection\n 342: invokeinterface #207, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 347: ifeq 354\n 350: iconst_0\n 351: goto 421\n 354: iconst_0\n 355: istore 15\n 357: aload 13\n 359: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 364: astore 16\n 366: aload 16\n 368: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 373: ifeq 419\n 376: aload 16\n 378: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 383: astore 17\n 385: aload 17\n 387: checkcast #48 // class java/lang/String\n 390: astore 18\n 392: iconst_0\n 393: istore 19\n 395: aload 18\n 397: aload 11\n 399: invokestatic #211 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 402: ifeq 366\n 405: iinc 15, 1\n 408: iload 15\n 410: ifge 366\n 413: invokestatic #214 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 416: goto 366\n 419: iload 15\n 421: nop\n 422: invokestatic #220 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 425: aload 22\n 427: swap\n 428: aload 10\n 430: invokeinterface #107, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 435: pop\n 436: goto 287\n 439: aload 7\n 441: nop\n 442: astore_2\n 443: aload_2\n 444: iconst_1\n 445: invokestatic #220 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 448: invokeinterface #119, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 453: dup\n 454: invokestatic #123 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 457: checkcast #48 // class java/lang/String\n 460: areturn\n\n public static final year_2017.day07.Program parse(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #175 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #179 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #48 // class java/lang/String\n 14: astore_1\n 15: aload_1\n 16: iconst_0\n 17: ldc #240 // String ->\n 19: aastore\n 20: aload_1\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #244 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: astore_2\n 30: iconst_0\n 31: istore_3\n 32: aload_2\n 33: invokestatic #248 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 36: checkcast #179 // class java/lang/CharSequence\n 39: iconst_1\n 40: anewarray #48 // class java/lang/String\n 43: astore 4\n 45: aload 4\n 47: iconst_0\n 48: ldc #250 // String (\n 50: aastore\n 51: aload 4\n 53: iconst_0\n 54: iconst_0\n 55: bipush 6\n 57: aconst_null\n 58: invokestatic #244 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 61: astore 5\n 63: aload 5\n 65: invokestatic #248 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 68: checkcast #48 // class java/lang/String\n 71: checkcast #179 // class java/lang/CharSequence\n 74: invokestatic #185 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 77: invokevirtual #188 // Method java/lang/Object.toString:()Ljava/lang/String;\n 80: astore 4\n 82: aload 5\n 84: invokestatic #253 // Method UtilsKt.second:(Ljava/util/List;)Ljava/lang/Object;\n 87: checkcast #48 // class java/lang/String\n 90: checkcast #179 // class java/lang/CharSequence\n 93: invokestatic #185 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 96: invokevirtual #188 // Method java/lang/Object.toString:()Ljava/lang/String;\n 99: iconst_1\n 100: invokestatic #257 // Method kotlin/text/StringsKt.dropLast:(Ljava/lang/String;I)Ljava/lang/String;\n 103: invokestatic #261 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 106: istore 6\n 108: aload_2\n 109: invokeinterface #265, 1 // InterfaceMethod java/util/List.size:()I\n 114: iconst_1\n 115: if_icmple 160\n 118: aload_2\n 119: invokestatic #253 // Method UtilsKt.second:(Ljava/util/List;)Ljava/lang/Object;\n 122: checkcast #179 // class java/lang/CharSequence\n 125: iconst_1\n 126: anewarray #48 // class java/lang/String\n 129: astore 7\n 131: aload 7\n 133: iconst_0\n 134: ldc_w #267 // String ,\n 137: checkcast #179 // class java/lang/CharSequence\n 140: invokestatic #185 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 143: invokevirtual #188 // Method java/lang/Object.toString:()Ljava/lang/String;\n 146: aastore\n 147: aload 7\n 149: iconst_0\n 150: iconst_0\n 151: bipush 6\n 153: aconst_null\n 154: invokestatic #244 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 157: goto 163\n 160: invokestatic #270 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 163: astore 8\n 165: aload 4\n 167: checkcast #179 // class java/lang/CharSequence\n 170: invokestatic #185 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 173: invokevirtual #188 // Method java/lang/Object.toString:()Ljava/lang/String;\n 176: iload 6\n 178: aload 8\n 180: checkcast #18 // class java/lang/Iterable\n 183: astore 7\n 185: istore 9\n 187: astore 10\n 189: iconst_0\n 190: istore 11\n 192: aload 7\n 194: astore 12\n 196: new #20 // class java/util/ArrayList\n 199: dup\n 200: aload 7\n 202: bipush 10\n 204: invokestatic #26 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 207: invokespecial #30 // Method java/util/ArrayList.\"<init>\":(I)V\n 210: checkcast #32 // class java/util/Collection\n 213: astore 13\n 215: iconst_0\n 216: istore 14\n 218: aload 12\n 220: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 225: astore 15\n 227: aload 15\n 229: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 234: ifeq 284\n 237: aload 15\n 239: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 244: astore 16\n 246: aload 13\n 248: aload 16\n 250: checkcast #48 // class java/lang/String\n 253: astore 17\n 255: astore 18\n 257: iconst_0\n 258: istore 19\n 260: aload 17\n 262: checkcast #179 // class java/lang/CharSequence\n 265: invokestatic #185 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 268: invokevirtual #188 // Method java/lang/Object.toString:()Ljava/lang/String;\n 271: nop\n 272: aload 18\n 274: swap\n 275: invokeinterface #56, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 280: pop\n 281: goto 227\n 284: aload 13\n 286: checkcast #58 // class java/util/List\n 289: nop\n 290: astore 18\n 292: aload 10\n 294: iload 9\n 296: aload 18\n 298: astore 20\n 300: istore 21\n 302: astore 22\n 304: new #99 // class year_2017/day07/Program\n 307: dup\n 308: aload 22\n 310: iload 21\n 312: aload 20\n 314: invokespecial #273 // Method year_2017/day07/Program.\"<init>\":(Ljava/lang/String;ILjava/util/List;)V\n 317: nop\n 318: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #284 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: invokestatic #289 // Method kotlin/collections/MapsKt.emptyMap:()Ljava/util/Map;\n 3: putstatic #115 // Field allPrograms:Ljava/util/Map;\n 6: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/year_2017/day23/day23.kt
package year_2017.day23 import readInput import second val registers = mutableMapOf( 'a' to 0, 'b' to 0, 'c' to 0, 'd' to 0, 'e' to 0, 'f' to 0, 'g' to 0, 'h' to 0, ) fun part1(input: List<String>): Int { val instructions = input.map(String::toInstruction) return runInstructions(instructions) } private fun runInstructions(instructions: List<Instruction>): Int { var counter = 0 var index = 0 while (index in instructions.indices) { print("index $index, counter $counter \r") val instruction = instructions[index] when (instruction.command) { "set" -> { registers[instruction.x] = if (instruction.yIsNumber()) instruction.y.toInt() else registers[instruction.y.first()]!! index++ } "sub" -> { registers[instruction.x] = registers[instruction.x]!! - if (instruction.yIsNumber()) instruction.y.toInt() else registers[instruction.y.first()]!! index++ } "mul" -> { registers[instruction.x] = registers[instruction.x]!! * if (instruction.yIsNumber()) instruction.y.toInt() else registers[instruction.y.first()]!! counter++ index++ } "jnz" -> { val v = if (instruction.x.isDigit()) instruction.x.digitToInt() else registers[instruction.x]!! if (v != 0) index += instruction.y.toInt() else index++ } else -> error("unknown instruction ${instruction.command}") } } return counter } fun part2(input: List<String>): Int { val start = input.first().split(" ")[2].toInt() * 100 + 100000 return (start..start + 17000 step 17).count { !it.toBigInteger().isProbablePrime(5) } } fun main() { val input = readInput("main/year_2017/day23/Day23") println(part1(input)) println(part2(input)) } fun String.toInstruction(): Instruction { return this.split(" ").let { Instruction(command = it.first(), x = it.second().first(), y = it[2]) } } data class Instruction(val command: String, val x: Char, val y: String) { fun yIsNumber() = y.first().isDigit() || y.first() == '-' }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/year_2017/day23/Day23Kt.class", "javap": "Compiled from \"day23.kt\"\npublic final class year_2017.day23.Day23Kt {\n private static final java.util.Map<java.lang.Character, java.lang.Integer> registers;\n\n public static final java.util.Map<java.lang.Character, java.lang.Integer> getRegisters();\n Code:\n 0: getstatic #12 // Field registers:Ljava/util/Map;\n 3: areturn\n\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #17 // String input\n 3: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #25 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #27 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #33 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #37 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #39 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 96\n 56: aload 7\n 58: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #55 // class java/lang/String\n 72: astore 9\n 74: astore 11\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: invokestatic #59 // Method toInstruction:(Ljava/lang/String;)Lyear_2017/day23/Instruction;\n 84: aload 11\n 86: swap\n 87: invokeinterface #63, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 92: pop\n 93: goto 46\n 96: aload 5\n 98: checkcast #65 // class java/util/List\n 101: nop\n 102: astore_1\n 103: aload_1\n 104: invokestatic #68 // Method runInstructions:(Ljava/util/List;)I\n 107: ireturn\n\n private static final int runInstructions(java.util.List<year_2017.day23.Instruction>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: iconst_0\n 3: istore_2\n 4: iconst_0\n 5: iload_2\n 6: if_icmpgt 30\n 9: iload_2\n 10: aload_0\n 11: checkcast #39 // class java/util/Collection\n 14: invokeinterface #88, 1 // InterfaceMethod java/util/Collection.size:()I\n 19: if_icmpge 26\n 22: iconst_1\n 23: goto 31\n 26: iconst_0\n 27: goto 31\n 30: iconst_0\n 31: ifeq 580\n 34: new #90 // class java/lang/StringBuilder\n 37: dup\n 38: invokespecial #93 // Method java/lang/StringBuilder.\"<init>\":()V\n 41: ldc #95 // String index\n 43: invokevirtual #99 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 46: iload_2\n 47: invokevirtual #102 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 50: ldc #104 // String , counter\n 52: invokevirtual #99 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: iload_1\n 56: invokevirtual #102 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 59: ldc #106 // String \\r\n 61: invokevirtual #99 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 64: invokevirtual #110 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 67: getstatic #116 // Field java/lang/System.out:Ljava/io/PrintStream;\n 70: swap\n 71: invokevirtual #122 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 74: aload_0\n 75: iload_2\n 76: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 81: checkcast #128 // class year_2017/day23/Instruction\n 84: astore_3\n 85: aload_3\n 86: invokevirtual #131 // Method year_2017/day23/Instruction.getCommand:()Ljava/lang/String;\n 89: astore 4\n 91: aload 4\n 93: invokevirtual #134 // Method java/lang/String.hashCode:()I\n 96: lookupswitch { // 4\n 105398: 179\n 108484: 166\n 113762: 153\n 114240: 140\n default: 547\n }\n 140: aload 4\n 142: ldc #136 // String sub\n 144: invokevirtual #139 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 147: ifne 267\n 150: goto 547\n 153: aload 4\n 155: ldc #141 // String set\n 157: invokevirtual #139 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 160: ifne 192\n 163: goto 547\n 166: aload 4\n 168: ldc #143 // String mul\n 170: invokevirtual #139 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 173: ifne 369\n 176: goto 547\n 179: aload 4\n 181: ldc #145 // String jnz\n 183: invokevirtual #139 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 186: ifne 474\n 189: goto 547\n 192: getstatic #12 // Field registers:Ljava/util/Map;\n 195: aload_3\n 196: invokevirtual #149 // Method year_2017/day23/Instruction.getX:()C\n 199: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 202: aload_3\n 203: invokevirtual #158 // Method year_2017/day23/Instruction.yIsNumber:()Z\n 206: ifeq 219\n 209: aload_3\n 210: invokevirtual #161 // Method year_2017/day23/Instruction.getY:()Ljava/lang/String;\n 213: invokestatic #167 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 216: goto 250\n 219: getstatic #12 // Field registers:Ljava/util/Map;\n 222: aload_3\n 223: invokevirtual #161 // Method year_2017/day23/Instruction.getY:()Ljava/lang/String;\n 226: checkcast #169 // class java/lang/CharSequence\n 229: invokestatic #175 // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C\n 232: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 235: invokeinterface #180, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 240: dup\n 241: invokestatic #183 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 244: checkcast #185 // class java/lang/Number\n 247: invokevirtual #188 // Method java/lang/Number.intValue:()I\n 250: invokestatic #191 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 253: invokeinterface #195, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 258: pop\n 259: iload_2\n 260: iinc 2, 1\n 263: pop\n 264: goto 4\n 267: nop\n 268: getstatic #12 // Field registers:Ljava/util/Map;\n 271: aload_3\n 272: invokevirtual #149 // Method year_2017/day23/Instruction.getX:()C\n 275: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 278: getstatic #12 // Field registers:Ljava/util/Map;\n 281: aload_3\n 282: invokevirtual #149 // Method year_2017/day23/Instruction.getX:()C\n 285: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 288: invokeinterface #180, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 293: dup\n 294: invokestatic #183 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 297: checkcast #185 // class java/lang/Number\n 300: invokevirtual #188 // Method java/lang/Number.intValue:()I\n 303: aload_3\n 304: invokevirtual #158 // Method year_2017/day23/Instruction.yIsNumber:()Z\n 307: ifeq 320\n 310: aload_3\n 311: invokevirtual #161 // Method year_2017/day23/Instruction.getY:()Ljava/lang/String;\n 314: invokestatic #167 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 317: goto 351\n 320: getstatic #12 // Field registers:Ljava/util/Map;\n 323: aload_3\n 324: invokevirtual #161 // Method year_2017/day23/Instruction.getY:()Ljava/lang/String;\n 327: checkcast #169 // class java/lang/CharSequence\n 330: invokestatic #175 // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C\n 333: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 336: invokeinterface #180, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 341: dup\n 342: invokestatic #183 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 345: checkcast #185 // class java/lang/Number\n 348: invokevirtual #188 // Method java/lang/Number.intValue:()I\n 351: isub\n 352: invokestatic #191 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 355: invokeinterface #195, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 360: pop\n 361: iload_2\n 362: iinc 2, 1\n 365: pop\n 366: goto 4\n 369: nop\n 370: getstatic #12 // Field registers:Ljava/util/Map;\n 373: aload_3\n 374: invokevirtual #149 // Method year_2017/day23/Instruction.getX:()C\n 377: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 380: getstatic #12 // Field registers:Ljava/util/Map;\n 383: aload_3\n 384: invokevirtual #149 // Method year_2017/day23/Instruction.getX:()C\n 387: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 390: invokeinterface #180, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 395: dup\n 396: invokestatic #183 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 399: checkcast #185 // class java/lang/Number\n 402: invokevirtual #188 // Method java/lang/Number.intValue:()I\n 405: aload_3\n 406: invokevirtual #158 // Method year_2017/day23/Instruction.yIsNumber:()Z\n 409: ifeq 422\n 412: aload_3\n 413: invokevirtual #161 // Method year_2017/day23/Instruction.getY:()Ljava/lang/String;\n 416: invokestatic #167 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 419: goto 453\n 422: getstatic #12 // Field registers:Ljava/util/Map;\n 425: aload_3\n 426: invokevirtual #161 // Method year_2017/day23/Instruction.getY:()Ljava/lang/String;\n 429: checkcast #169 // class java/lang/CharSequence\n 432: invokestatic #175 // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C\n 435: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 438: invokeinterface #180, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 443: dup\n 444: invokestatic #183 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 447: checkcast #185 // class java/lang/Number\n 450: invokevirtual #188 // Method java/lang/Number.intValue:()I\n 453: imul\n 454: invokestatic #191 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 457: invokeinterface #195, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 462: pop\n 463: iinc 1, 1\n 466: iload_2\n 467: iinc 2, 1\n 470: pop\n 471: goto 4\n 474: aload_3\n 475: invokevirtual #149 // Method year_2017/day23/Instruction.getX:()C\n 478: invokestatic #199 // Method java/lang/Character.isDigit:(C)Z\n 481: ifeq 494\n 484: aload_3\n 485: invokevirtual #149 // Method year_2017/day23/Instruction.getX:()C\n 488: invokestatic #205 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 491: goto 519\n 494: getstatic #12 // Field registers:Ljava/util/Map;\n 497: aload_3\n 498: invokevirtual #149 // Method year_2017/day23/Instruction.getX:()C\n 501: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 504: invokeinterface #180, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 509: dup\n 510: invokestatic #183 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 513: checkcast #185 // class java/lang/Number\n 516: invokevirtual #188 // Method java/lang/Number.intValue:()I\n 519: istore 5\n 521: iload 5\n 523: ifeq 539\n 526: iload_2\n 527: aload_3\n 528: invokevirtual #161 // Method year_2017/day23/Instruction.getY:()Ljava/lang/String;\n 531: invokestatic #167 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 534: iadd\n 535: istore_2\n 536: goto 4\n 539: iload_2\n 540: iinc 2, 1\n 543: pop\n 544: goto 4\n 547: new #207 // class java/lang/IllegalStateException\n 550: dup\n 551: new #90 // class java/lang/StringBuilder\n 554: dup\n 555: invokespecial #93 // Method java/lang/StringBuilder.\"<init>\":()V\n 558: ldc #209 // String unknown instruction\n 560: invokevirtual #99 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 563: aload_3\n 564: invokevirtual #131 // Method year_2017/day23/Instruction.getCommand:()Ljava/lang/String;\n 567: invokevirtual #99 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 570: invokevirtual #110 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 573: invokevirtual #210 // Method java/lang/Object.toString:()Ljava/lang/String;\n 576: invokespecial #213 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 579: athrow\n 580: iload_1\n 581: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #17 // String input\n 3: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #222 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 10: checkcast #169 // class java/lang/CharSequence\n 13: iconst_1\n 14: anewarray #55 // class java/lang/String\n 17: astore_2\n 18: aload_2\n 19: iconst_0\n 20: ldc #224 // String\n 22: aastore\n 23: aload_2\n 24: iconst_0\n 25: iconst_0\n 26: bipush 6\n 28: aconst_null\n 29: invokestatic #228 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 32: iconst_2\n 33: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 38: checkcast #55 // class java/lang/String\n 41: invokestatic #167 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 44: bipush 100\n 46: imul\n 47: ldc #229 // int 100000\n 49: iadd\n 50: istore_1\n 51: new #231 // class kotlin/ranges/IntRange\n 54: dup\n 55: iload_1\n 56: iload_1\n 57: sipush 17000\n 60: iadd\n 61: invokespecial #234 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 64: checkcast #236 // class kotlin/ranges/IntProgression\n 67: bipush 17\n 69: invokestatic #242 // Method kotlin/ranges/RangesKt.step:(Lkotlin/ranges/IntProgression;I)Lkotlin/ranges/IntProgression;\n 72: checkcast #25 // class java/lang/Iterable\n 75: astore_2\n 76: iconst_0\n 77: istore_3\n 78: aload_2\n 79: instanceof #39 // class java/util/Collection\n 82: ifeq 101\n 85: aload_2\n 86: checkcast #39 // class java/util/Collection\n 89: invokeinterface #245, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 94: ifeq 101\n 97: iconst_0\n 98: goto 183\n 101: iconst_0\n 102: istore 4\n 104: aload_2\n 105: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 110: astore 5\n 112: aload 5\n 114: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 119: ifeq 181\n 122: aload 5\n 124: checkcast #247 // class kotlin/collections/IntIterator\n 127: invokevirtual #250 // Method kotlin/collections/IntIterator.nextInt:()I\n 130: istore 6\n 132: iload 6\n 134: istore 7\n 136: iconst_0\n 137: istore 8\n 139: iload 7\n 141: i2l\n 142: invokestatic #255 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 145: dup\n 146: ldc_w #257 // String valueOf(...)\n 149: invokestatic #260 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 152: iconst_5\n 153: invokevirtual #264 // Method java/math/BigInteger.isProbablePrime:(I)Z\n 156: ifne 163\n 159: iconst_1\n 160: goto 164\n 163: iconst_0\n 164: ifeq 112\n 167: iinc 4, 1\n 170: iload 4\n 172: ifge 112\n 175: invokestatic #267 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 178: goto 112\n 181: iload 4\n 183: ireturn\n\n public static final void main();\n Code:\n 0: ldc_w #277 // String main/year_2017/day23/Day23\n 3: invokestatic #283 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 6: astore_0\n 7: aload_0\n 8: invokestatic #285 // Method part1:(Ljava/util/List;)I\n 11: istore_1\n 12: getstatic #116 // Field java/lang/System.out:Ljava/io/PrintStream;\n 15: iload_1\n 16: invokevirtual #288 // Method java/io/PrintStream.println:(I)V\n 19: aload_0\n 20: invokestatic #290 // Method part2:(Ljava/util/List;)I\n 23: istore_1\n 24: getstatic #116 // Field java/lang/System.out:Ljava/io/PrintStream;\n 27: iload_1\n 28: invokevirtual #288 // Method java/io/PrintStream.println:(I)V\n 31: return\n\n public static final year_2017.day23.Instruction toInstruction(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #292 // String <this>\n 4: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: checkcast #169 // class java/lang/CharSequence\n 11: iconst_1\n 12: anewarray #55 // class java/lang/String\n 15: astore_1\n 16: aload_1\n 17: iconst_0\n 18: ldc #224 // String\n 20: aastore\n 21: aload_1\n 22: iconst_0\n 23: iconst_0\n 24: bipush 6\n 26: aconst_null\n 27: invokestatic #228 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 30: astore_2\n 31: iconst_0\n 32: istore_3\n 33: new #128 // class year_2017/day23/Instruction\n 36: dup\n 37: aload_2\n 38: invokestatic #222 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 41: checkcast #55 // class java/lang/String\n 44: aload_2\n 45: invokestatic #295 // Method UtilsKt.second:(Ljava/util/List;)Ljava/lang/Object;\n 48: checkcast #169 // class java/lang/CharSequence\n 51: invokestatic #175 // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C\n 54: aload_2\n 55: iconst_2\n 56: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 61: checkcast #55 // class java/lang/String\n 64: invokespecial #298 // Method year_2017/day23/Instruction.\"<init>\":(Ljava/lang/String;CLjava/lang/String;)V\n 67: nop\n 68: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #303 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: bipush 8\n 2: anewarray #308 // class kotlin/Pair\n 5: astore_0\n 6: aload_0\n 7: iconst_0\n 8: bipush 97\n 10: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 13: iconst_0\n 14: invokestatic #191 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 17: invokestatic #314 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 20: aastore\n 21: aload_0\n 22: iconst_1\n 23: bipush 98\n 25: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 28: iconst_0\n 29: invokestatic #191 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 32: invokestatic #314 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 35: aastore\n 36: aload_0\n 37: iconst_2\n 38: bipush 99\n 40: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 43: iconst_0\n 44: invokestatic #191 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 47: invokestatic #314 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 50: aastore\n 51: aload_0\n 52: iconst_3\n 53: bipush 100\n 55: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 58: iconst_0\n 59: invokestatic #191 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 62: invokestatic #314 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 65: aastore\n 66: aload_0\n 67: iconst_4\n 68: bipush 101\n 70: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 73: iconst_0\n 74: invokestatic #191 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 77: invokestatic #314 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 80: aastore\n 81: aload_0\n 82: iconst_5\n 83: bipush 102\n 85: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 88: iconst_0\n 89: invokestatic #191 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 92: invokestatic #314 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 95: aastore\n 96: aload_0\n 97: bipush 6\n 99: bipush 103\n 101: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 104: iconst_0\n 105: invokestatic #191 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 108: invokestatic #314 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 111: aastore\n 112: aload_0\n 113: bipush 7\n 115: bipush 104\n 117: invokestatic #155 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 120: iconst_0\n 121: invokestatic #191 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 124: invokestatic #314 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 127: aastore\n 128: aload_0\n 129: invokestatic #320 // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 132: putstatic #12 // Field registers:Ljava/util/Map;\n 135: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/year_2017/day02/day03.kt
package year_2017.day02 import readInput fun part1(input: List<String>): Int = input.map { line -> line.split(" ").map { it.toInt() }.sortedDescending() }.sumOf { it.first() - it.last() } fun part2(input: List<String>): Int = input.map { line -> line.split(" ").map { it.toInt() }.sortedDescending() }.sumOf { line -> line.findDivisionResult() } fun main() { val input = readInput("main/year_2017/day02/Day02") println(part1(input)) println(part2(input)) } fun List<Int>.findDivisionResult(): Int { forEachIndexed { index, candidate -> (index + 1 until size).forEach { if (candidate % this[it] == 0) return candidate / this[it] } } error("no even division found") }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/year_2017/day02/Day03Kt.class", "javap": "Compiled from \"day03.kt\"\npublic final class year_2017.day02.Day03Kt {\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #18 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: astore_3\n 15: new #20 // class java/util/ArrayList\n 18: dup\n 19: aload_1\n 20: bipush 10\n 22: invokestatic #26 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 25: invokespecial #30 // Method java/util/ArrayList.\"<init>\":(I)V\n 28: checkcast #32 // class java/util/Collection\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: aload_3\n 37: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 6\n 44: aload 6\n 46: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 225\n 54: aload 6\n 56: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 7\n 63: aload 4\n 65: aload 7\n 67: checkcast #48 // class java/lang/String\n 70: astore 8\n 72: astore 20\n 74: iconst_0\n 75: istore 9\n 77: aload 8\n 79: checkcast #50 // class java/lang/CharSequence\n 82: iconst_1\n 83: anewarray #48 // class java/lang/String\n 86: astore 10\n 88: aload 10\n 90: iconst_0\n 91: ldc #52 // String\n 93: aastore\n 94: aload 10\n 96: iconst_0\n 97: iconst_0\n 98: bipush 6\n 100: aconst_null\n 101: invokestatic #58 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 104: checkcast #18 // class java/lang/Iterable\n 107: astore 10\n 109: iconst_0\n 110: istore 11\n 112: aload 10\n 114: astore 12\n 116: new #20 // class java/util/ArrayList\n 119: dup\n 120: aload 10\n 122: bipush 10\n 124: invokestatic #26 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 127: invokespecial #30 // Method java/util/ArrayList.\"<init>\":(I)V\n 130: checkcast #32 // class java/util/Collection\n 133: astore 13\n 135: iconst_0\n 136: istore 14\n 138: aload 12\n 140: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 145: astore 15\n 147: aload 15\n 149: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 154: ifeq 201\n 157: aload 15\n 159: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 164: astore 16\n 166: aload 13\n 168: aload 16\n 170: checkcast #48 // class java/lang/String\n 173: astore 17\n 175: astore 18\n 177: iconst_0\n 178: istore 19\n 180: aload 17\n 182: invokestatic #64 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 185: nop\n 186: invokestatic #68 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 189: aload 18\n 191: swap\n 192: invokeinterface #72, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 197: pop\n 198: goto 147\n 201: aload 13\n 203: checkcast #74 // class java/util/List\n 206: nop\n 207: checkcast #18 // class java/lang/Iterable\n 210: invokestatic #78 // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;\n 213: aload 20\n 215: swap\n 216: invokeinterface #72, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 221: pop\n 222: goto 44\n 225: aload 4\n 227: checkcast #74 // class java/util/List\n 230: nop\n 231: checkcast #18 // class java/lang/Iterable\n 234: astore_1\n 235: iconst_0\n 236: istore_2\n 237: aload_1\n 238: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 243: astore_3\n 244: aload_3\n 245: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 250: ifeq 308\n 253: aload_3\n 254: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 259: astore 4\n 261: iload_2\n 262: aload 4\n 264: checkcast #74 // class java/util/List\n 267: astore 5\n 269: istore 20\n 271: iconst_0\n 272: istore 6\n 274: aload 5\n 276: invokestatic #82 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 279: checkcast #84 // class java/lang/Number\n 282: invokevirtual #88 // Method java/lang/Number.intValue:()I\n 285: aload 5\n 287: invokestatic #91 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 290: checkcast #84 // class java/lang/Number\n 293: invokevirtual #88 // Method java/lang/Number.intValue:()I\n 296: isub\n 297: istore 21\n 299: iload 20\n 301: iload 21\n 303: iadd\n 304: istore_2\n 305: goto 244\n 308: iload_2\n 309: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #18 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: astore_3\n 15: new #20 // class java/util/ArrayList\n 18: dup\n 19: aload_1\n 20: bipush 10\n 22: invokestatic #26 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 25: invokespecial #30 // Method java/util/ArrayList.\"<init>\":(I)V\n 28: checkcast #32 // class java/util/Collection\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: aload_3\n 37: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 6\n 44: aload 6\n 46: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 225\n 54: aload 6\n 56: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 7\n 63: aload 4\n 65: aload 7\n 67: checkcast #48 // class java/lang/String\n 70: astore 8\n 72: astore 20\n 74: iconst_0\n 75: istore 9\n 77: aload 8\n 79: checkcast #50 // class java/lang/CharSequence\n 82: iconst_1\n 83: anewarray #48 // class java/lang/String\n 86: astore 10\n 88: aload 10\n 90: iconst_0\n 91: ldc #52 // String\n 93: aastore\n 94: aload 10\n 96: iconst_0\n 97: iconst_0\n 98: bipush 6\n 100: aconst_null\n 101: invokestatic #58 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 104: checkcast #18 // class java/lang/Iterable\n 107: astore 10\n 109: iconst_0\n 110: istore 11\n 112: aload 10\n 114: astore 12\n 116: new #20 // class java/util/ArrayList\n 119: dup\n 120: aload 10\n 122: bipush 10\n 124: invokestatic #26 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 127: invokespecial #30 // Method java/util/ArrayList.\"<init>\":(I)V\n 130: checkcast #32 // class java/util/Collection\n 133: astore 13\n 135: iconst_0\n 136: istore 14\n 138: aload 12\n 140: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 145: astore 15\n 147: aload 15\n 149: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 154: ifeq 201\n 157: aload 15\n 159: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 164: astore 16\n 166: aload 13\n 168: aload 16\n 170: checkcast #48 // class java/lang/String\n 173: astore 17\n 175: astore 18\n 177: iconst_0\n 178: istore 19\n 180: aload 17\n 182: invokestatic #64 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 185: nop\n 186: invokestatic #68 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 189: aload 18\n 191: swap\n 192: invokeinterface #72, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 197: pop\n 198: goto 147\n 201: aload 13\n 203: checkcast #74 // class java/util/List\n 206: nop\n 207: checkcast #18 // class java/lang/Iterable\n 210: invokestatic #78 // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;\n 213: aload 20\n 215: swap\n 216: invokeinterface #72, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 221: pop\n 222: goto 44\n 225: aload 4\n 227: checkcast #74 // class java/util/List\n 230: nop\n 231: checkcast #18 // class java/lang/Iterable\n 234: astore_1\n 235: iconst_0\n 236: istore_2\n 237: aload_1\n 238: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 243: astore_3\n 244: aload_3\n 245: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 250: ifeq 290\n 253: aload_3\n 254: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 259: astore 4\n 261: iload_2\n 262: aload 4\n 264: checkcast #74 // class java/util/List\n 267: astore 5\n 269: istore 20\n 271: iconst_0\n 272: istore 6\n 274: aload 5\n 276: invokestatic #112 // Method findDivisionResult:(Ljava/util/List;)I\n 279: istore 21\n 281: iload 20\n 283: iload 21\n 285: iadd\n 286: istore_2\n 287: goto 244\n 290: iload_2\n 291: ireturn\n\n public static final void main();\n Code:\n 0: ldc #119 // String main/year_2017/day02/Day02\n 2: invokestatic #125 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #127 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #133 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #138 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #140 // Method part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #133 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #138 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static final int findDivisionResult(java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #143 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #18 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: iconst_0\n 14: istore_3\n 15: aload_1\n 16: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 21: astore 4\n 23: aload 4\n 25: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 30: ifeq 179\n 33: aload 4\n 35: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 40: astore 5\n 42: iload_3\n 43: iinc 3, 1\n 46: istore 6\n 48: iload 6\n 50: ifge 56\n 53: invokestatic #146 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 56: iload 6\n 58: aload 5\n 60: checkcast #84 // class java/lang/Number\n 63: invokevirtual #88 // Method java/lang/Number.intValue:()I\n 66: istore 7\n 68: istore 8\n 70: iconst_0\n 71: istore 9\n 73: iload 8\n 75: iconst_1\n 76: iadd\n 77: aload_0\n 78: invokeinterface #149, 1 // InterfaceMethod java/util/List.size:()I\n 83: invokestatic #155 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 86: checkcast #18 // class java/lang/Iterable\n 89: astore 10\n 91: iconst_0\n 92: istore 11\n 94: aload 10\n 96: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 101: astore 12\n 103: aload 12\n 105: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 110: ifeq 173\n 113: aload 12\n 115: checkcast #157 // class kotlin/collections/IntIterator\n 118: invokevirtual #160 // Method kotlin/collections/IntIterator.nextInt:()I\n 121: istore 13\n 123: iload 13\n 125: istore 14\n 127: iconst_0\n 128: istore 15\n 130: iload 7\n 132: aload_0\n 133: iload 14\n 135: invokeinterface #164, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 140: checkcast #84 // class java/lang/Number\n 143: invokevirtual #88 // Method java/lang/Number.intValue:()I\n 146: irem\n 147: ifne 168\n 150: iload 7\n 152: aload_0\n 153: iload 14\n 155: invokeinterface #164, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 160: checkcast #84 // class java/lang/Number\n 163: invokevirtual #88 // Method java/lang/Number.intValue:()I\n 166: idiv\n 167: ireturn\n 168: nop\n 169: nop\n 170: goto 103\n 173: nop\n 174: nop\n 175: nop\n 176: goto 23\n 179: nop\n 180: new #166 // class java/lang/IllegalStateException\n 183: dup\n 184: ldc #168 // String no even division found\n 186: invokevirtual #172 // Method java/lang/Object.toString:()Ljava/lang/String;\n 189: invokespecial #175 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 192: athrow\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #190 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
rolf-rosenbaum__aoc-2022__59cd426/src/main/year_2017/day11/day11.kt
package year_2017.day11 import kotlin.math.absoluteValue import readInput fun part1(input: List<String>): Int { val directions = input.first().split(",") val origin = HexPoint(0, 0, 0) val endPoint = directions.fold(origin) { point, dir -> point.step(dir) } return origin.distance(endPoint) } fun part2(input: List<String>): Int { val directions = input.first().split(",") val origin = HexPoint(0, 0, 0) val steps = mutableListOf(origin) directions.forEach { dir -> steps.add(steps.last().step(dir)) } return steps.maxOf { it.distance(origin) } } fun main() { val input = readInput("main/year_2017/day11/Day11") println(part1(input)) println(part2(input)) } data class HexPoint(val x: Int, val y: Int, val z: Int) { fun step(direction: String): HexPoint = when (direction) { "n" -> HexPoint(x, y + 1, z - 1) "s" -> HexPoint(x, y - 1, z + 1) "ne" -> HexPoint(x + 1, y, z - 1) "nw" -> HexPoint(x - 1, y + 1, z) "se" -> HexPoint(x + 1, y - 1, z) "sw" -> HexPoint(x - 1, y, z + 1) else -> error("illegal direction") } fun distance(other: HexPoint): Int = maxOf( (this.x - other.x).absoluteValue, (this.y - other.y).absoluteValue, (this.z - other.z).absoluteValue ) }
[ { "class_path": "rolf-rosenbaum__aoc-2022__59cd426/year_2017/day11/Day11Kt.class", "javap": "Compiled from \"day11.kt\"\npublic final class year_2017.day11.Day11Kt {\n public static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #22 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 10: checkcast #24 // class java/lang/CharSequence\n 13: iconst_1\n 14: anewarray #26 // class java/lang/String\n 17: astore_2\n 18: aload_2\n 19: iconst_0\n 20: ldc #28 // String ,\n 22: aastore\n 23: aload_2\n 24: iconst_0\n 25: iconst_0\n 26: bipush 6\n 28: aconst_null\n 29: invokestatic #34 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 32: astore_1\n 33: new #36 // class year_2017/day11/HexPoint\n 36: dup\n 37: iconst_0\n 38: iconst_0\n 39: iconst_0\n 40: invokespecial #40 // Method year_2017/day11/HexPoint.\"<init>\":(III)V\n 43: astore_2\n 44: aload_1\n 45: checkcast #42 // class java/lang/Iterable\n 48: astore 4\n 50: iconst_0\n 51: istore 5\n 53: aload_2\n 54: astore 6\n 56: aload 4\n 58: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 63: astore 7\n 65: aload 7\n 67: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 72: ifeq 110\n 75: aload 7\n 77: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 82: astore 8\n 84: aload 6\n 86: aload 8\n 88: checkcast #26 // class java/lang/String\n 91: astore 9\n 93: astore 10\n 95: iconst_0\n 96: istore 11\n 98: aload 10\n 100: aload 9\n 102: invokevirtual #60 // Method year_2017/day11/HexPoint.step:(Ljava/lang/String;)Lyear_2017/day11/HexPoint;\n 105: astore 6\n 107: goto 65\n 110: aload 6\n 112: astore_3\n 113: aload_2\n 114: aload_3\n 115: invokevirtual #64 // Method year_2017/day11/HexPoint.distance:(Lyear_2017/day11/HexPoint;)I\n 118: ireturn\n\n public static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #22 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 10: checkcast #24 // class java/lang/CharSequence\n 13: iconst_1\n 14: anewarray #26 // class java/lang/String\n 17: astore_2\n 18: aload_2\n 19: iconst_0\n 20: ldc #28 // String ,\n 22: aastore\n 23: aload_2\n 24: iconst_0\n 25: iconst_0\n 26: bipush 6\n 28: aconst_null\n 29: invokestatic #34 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 32: astore_1\n 33: new #36 // class year_2017/day11/HexPoint\n 36: dup\n 37: iconst_0\n 38: iconst_0\n 39: iconst_0\n 40: invokespecial #40 // Method year_2017/day11/HexPoint.\"<init>\":(III)V\n 43: astore_2\n 44: iconst_1\n 45: anewarray #36 // class year_2017/day11/HexPoint\n 48: astore 4\n 50: aload 4\n 52: iconst_0\n 53: aload_2\n 54: aastore\n 55: aload 4\n 57: invokestatic #87 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 60: astore_3\n 61: aload_1\n 62: checkcast #42 // class java/lang/Iterable\n 65: astore 4\n 67: iconst_0\n 68: istore 5\n 70: aload 4\n 72: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 77: astore 6\n 79: aload 6\n 81: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 86: ifeq 132\n 89: aload 6\n 91: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 96: astore 7\n 98: aload 7\n 100: checkcast #26 // class java/lang/String\n 103: astore 8\n 105: iconst_0\n 106: istore 9\n 108: aload_3\n 109: aload_3\n 110: invokestatic #90 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 113: checkcast #36 // class year_2017/day11/HexPoint\n 116: aload 8\n 118: invokevirtual #60 // Method year_2017/day11/HexPoint.step:(Ljava/lang/String;)Lyear_2017/day11/HexPoint;\n 121: invokeinterface #94, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 126: pop\n 127: nop\n 128: nop\n 129: goto 79\n 132: nop\n 133: aload_3\n 134: checkcast #42 // class java/lang/Iterable\n 137: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 142: astore 5\n 144: aload 5\n 146: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 151: ifne 162\n 154: new #96 // class java/util/NoSuchElementException\n 157: dup\n 158: invokespecial #99 // Method java/util/NoSuchElementException.\"<init>\":()V\n 161: athrow\n 162: aload 5\n 164: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 169: checkcast #36 // class year_2017/day11/HexPoint\n 172: astore 6\n 174: iconst_0\n 175: istore 7\n 177: aload 6\n 179: aload_2\n 180: invokevirtual #64 // Method year_2017/day11/HexPoint.distance:(Lyear_2017/day11/HexPoint;)I\n 183: istore 6\n 185: aload 5\n 187: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 192: ifeq 232\n 195: aload 5\n 197: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 202: checkcast #36 // class year_2017/day11/HexPoint\n 205: astore 7\n 207: iconst_0\n 208: istore 8\n 210: aload 7\n 212: aload_2\n 213: invokevirtual #64 // Method year_2017/day11/HexPoint.distance:(Lyear_2017/day11/HexPoint;)I\n 216: istore 7\n 218: iload 6\n 220: iload 7\n 222: if_icmpge 185\n 225: iload 7\n 227: istore 6\n 229: goto 185\n 232: iload 6\n 234: ireturn\n\n public static final void main();\n Code:\n 0: ldc #108 // String main/year_2017/day11/Day11\n 2: invokestatic #114 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #116 // Method part1:(Ljava/util/List;)I\n 10: istore_1\n 11: getstatic #122 // Field java/lang/System.out:Ljava/io/PrintStream;\n 14: iload_1\n 15: invokevirtual #128 // Method java/io/PrintStream.println:(I)V\n 18: aload_0\n 19: invokestatic #130 // Method part2:(Ljava/util/List;)I\n 22: istore_1\n 23: getstatic #122 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_1\n 27: invokevirtual #128 // Method java/io/PrintStream.println:(I)V\n 30: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #133 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
aurelioklv__enigma__2110e20/src/main/kotlin/enigma/util/Util.kt
package com.aurelioklv.enigma.util val alphabet = ('A'..'Z').joinToString(separator = "") val defaultWiring: Map<Char, Char> = ('A'..'Z').associateWith { it } fun validateWiring(wiring: Map<Char, Char>, kind: String) { require(wiring.isNotEmpty()) { "Wiring is empty" } require(wiring.all { (key, value) -> key.isLetter() && key.isUpperCase() && value.isLetter() && value.isUpperCase() }) { "Each character should be an uppercase letter" } when (kind) { in listOf("rotor", "plugboard") -> { require(alphabet.all { wiring.containsKey(it) && wiring.containsValue(it) }) } "reflector" -> { require(wiring.all { (key, value) -> wiring.getOrDefault(value, ' ') == key }) { "Invalid wiring $wiring" } } } wiring.mapKeys { it.key.uppercaseChar() }.mapValues { it.value.uppercaseChar() } } fun String.toWiring(kind: String): Map<Char, Char> { val input = this.uppercase() val result = when (kind) { in listOf("rotor", "reflector") -> { require(input.length == alphabet.length) { "String must be ${alphabet.length} characters long. Got ${input.length}" } alphabet.zip(input).toMap() } "plugboard" -> { val wiring = input.chunked(2).flatMap { pair -> pair.map { it to pair[(pair.indexOf(it) + 1) % 2] } }.toMap().toMutableMap() val existingChar = input.toSet() wiring += defaultWiring.filterKeys { it !in existingChar } wiring } else -> { throw IllegalArgumentException("Unknown kind: $kind") } } return result } fun String.toListOfInt(): List<Int> { return map { char -> when { char.isLetter() -> char.uppercaseChar().minus('A') else -> throw IllegalArgumentException("Invalid character: $char") } } }
[ { "class_path": "aurelioklv__enigma__2110e20/com/aurelioklv/enigma/util/UtilKt.class", "javap": "Compiled from \"Util.kt\"\npublic final class com.aurelioklv.enigma.util.UtilKt {\n private static final java.lang.String alphabet;\n\n private static final java.util.Map<java.lang.Character, java.lang.Character> defaultWiring;\n\n public static final java.lang.String getAlphabet();\n Code:\n 0: getstatic #11 // Field alphabet:Ljava/lang/String;\n 3: areturn\n\n public static final java.util.Map<java.lang.Character, java.lang.Character> getDefaultWiring();\n Code:\n 0: getstatic #18 // Field defaultWiring:Ljava/util/Map;\n 3: areturn\n\n public static final void validateWiring(java.util.Map<java.lang.Character, java.lang.Character>, java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #23 // String wiring\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #31 // String kind\n 9: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokeinterface #37, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 18: ifne 25\n 21: iconst_1\n 22: goto 26\n 25: iconst_0\n 26: ifne 46\n 29: iconst_0\n 30: istore_3\n 31: ldc #39 // String Wiring is empty\n 33: astore_3\n 34: new #41 // class java/lang/IllegalArgumentException\n 37: dup\n 38: aload_3\n 39: invokevirtual #44 // Method java/lang/Object.toString:()Ljava/lang/String;\n 42: invokespecial #48 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 45: athrow\n 46: aload_0\n 47: astore_2\n 48: iconst_0\n 49: istore_3\n 50: aload_2\n 51: invokeinterface #37, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 56: ifeq 63\n 59: iconst_1\n 60: goto 180\n 63: aload_2\n 64: invokeinterface #52, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 69: invokeinterface #58, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 74: astore 4\n 76: aload 4\n 78: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 83: ifeq 179\n 86: aload 4\n 88: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 93: checkcast #69 // class java/util/Map$Entry\n 96: astore 5\n 98: aload 5\n 100: astore 6\n 102: iconst_0\n 103: istore 7\n 105: aload 6\n 107: invokeinterface #72, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 112: checkcast #74 // class java/lang/Character\n 115: invokevirtual #78 // Method java/lang/Character.charValue:()C\n 118: istore 8\n 120: aload 6\n 122: invokeinterface #81, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 127: checkcast #74 // class java/lang/Character\n 130: invokevirtual #78 // Method java/lang/Character.charValue:()C\n 133: istore 9\n 135: iload 8\n 137: invokestatic #85 // Method java/lang/Character.isLetter:(C)Z\n 140: ifeq 171\n 143: iload 8\n 145: invokestatic #88 // Method java/lang/Character.isUpperCase:(C)Z\n 148: ifeq 171\n 151: iload 9\n 153: invokestatic #85 // Method java/lang/Character.isLetter:(C)Z\n 156: ifeq 171\n 159: iload 9\n 161: invokestatic #88 // Method java/lang/Character.isUpperCase:(C)Z\n 164: ifeq 171\n 167: iconst_1\n 168: goto 172\n 171: iconst_0\n 172: ifne 76\n 175: iconst_0\n 176: goto 180\n 179: iconst_1\n 180: ifne 200\n 183: iconst_0\n 184: istore_3\n 185: ldc #90 // String Each character should be an uppercase letter\n 187: astore_3\n 188: new #41 // class java/lang/IllegalArgumentException\n 191: dup\n 192: aload_3\n 193: invokevirtual #44 // Method java/lang/Object.toString:()Ljava/lang/String;\n 196: invokespecial #48 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 199: athrow\n 200: aload_1\n 201: astore_2\n 202: iconst_2\n 203: anewarray #92 // class java/lang/String\n 206: astore_3\n 207: aload_3\n 208: iconst_0\n 209: ldc #94 // String rotor\n 211: aastore\n 212: aload_3\n 213: iconst_1\n 214: ldc #96 // String plugboard\n 216: aastore\n 217: aload_3\n 218: invokestatic #102 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 221: aload_2\n 222: invokeinterface #108, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 227: ifeq 338\n 230: getstatic #11 // Field alphabet:Ljava/lang/String;\n 233: checkcast #110 // class java/lang/CharSequence\n 236: astore_3\n 237: iconst_0\n 238: istore 4\n 240: iconst_0\n 241: istore 5\n 243: iload 5\n 245: aload_3\n 246: invokeinterface #114, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 251: if_icmpge 317\n 254: aload_3\n 255: iload 5\n 257: invokeinterface #118, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 262: istore 6\n 264: iload 6\n 266: istore 7\n 268: iconst_0\n 269: istore 8\n 271: aload_0\n 272: iload 7\n 274: invokestatic #122 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 277: invokeinterface #125, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 282: ifeq 303\n 285: aload_0\n 286: iload 7\n 288: invokestatic #122 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 291: invokeinterface #128, 2 // InterfaceMethod java/util/Map.containsValue:(Ljava/lang/Object;)Z\n 296: ifeq 303\n 299: iconst_1\n 300: goto 304\n 303: iconst_0\n 304: ifne 311\n 307: iconst_0\n 308: goto 318\n 311: iinc 5, 1\n 314: goto 243\n 317: iconst_1\n 318: ifne 517\n 321: ldc #130 // String Failed requirement.\n 323: astore 4\n 325: new #41 // class java/lang/IllegalArgumentException\n 328: dup\n 329: aload 4\n 331: invokevirtual #44 // Method java/lang/Object.toString:()Ljava/lang/String;\n 334: invokespecial #48 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 337: athrow\n 338: aload_2\n 339: ldc #132 // String reflector\n 341: invokestatic #136 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 344: ifeq 517\n 347: aload_0\n 348: astore_3\n 349: iconst_0\n 350: istore 4\n 352: aload_3\n 353: invokeinterface #37, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 358: ifeq 365\n 361: iconst_1\n 362: goto 477\n 365: aload_3\n 366: invokeinterface #52, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 371: invokeinterface #58, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 376: astore 5\n 378: aload 5\n 380: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 385: ifeq 476\n 388: aload 5\n 390: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 395: checkcast #69 // class java/util/Map$Entry\n 398: astore 6\n 400: aload 6\n 402: astore 7\n 404: iconst_0\n 405: istore 8\n 407: aload 7\n 409: invokeinterface #72, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 414: checkcast #74 // class java/lang/Character\n 417: invokevirtual #78 // Method java/lang/Character.charValue:()C\n 420: istore 9\n 422: aload 7\n 424: invokeinterface #81, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 429: checkcast #74 // class java/lang/Character\n 432: invokevirtual #78 // Method java/lang/Character.charValue:()C\n 435: istore 10\n 437: aload_0\n 438: iload 10\n 440: invokestatic #122 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 443: bipush 32\n 445: invokestatic #122 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 448: invokeinterface #140, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 453: checkcast #74 // class java/lang/Character\n 456: invokevirtual #78 // Method java/lang/Character.charValue:()C\n 459: iload 9\n 461: if_icmpne 468\n 464: iconst_1\n 465: goto 469\n 468: iconst_0\n 469: ifne 378\n 472: iconst_0\n 473: goto 477\n 476: iconst_1\n 477: ifne 517\n 480: iconst_0\n 481: istore 4\n 483: new #142 // class java/lang/StringBuilder\n 486: dup\n 487: invokespecial #145 // Method java/lang/StringBuilder.\"<init>\":()V\n 490: ldc #147 // String Invalid wiring\n 492: invokevirtual #151 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 495: aload_0\n 496: invokevirtual #154 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 499: invokevirtual #155 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 502: astore 4\n 504: new #41 // class java/lang/IllegalArgumentException\n 507: dup\n 508: aload 4\n 510: invokevirtual #44 // Method java/lang/Object.toString:()Ljava/lang/String;\n 513: invokespecial #48 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 516: athrow\n 517: aload_0\n 518: astore_2\n 519: iconst_0\n 520: istore_3\n 521: aload_2\n 522: astore 4\n 524: new #157 // class java/util/LinkedHashMap\n 527: dup\n 528: aload_2\n 529: invokeinterface #160, 1 // InterfaceMethod java/util/Map.size:()I\n 534: invokestatic #166 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 537: invokespecial #169 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 540: checkcast #33 // class java/util/Map\n 543: astore 5\n 545: iconst_0\n 546: istore 6\n 548: aload 4\n 550: invokeinterface #52, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 555: checkcast #171 // class java/lang/Iterable\n 558: astore 7\n 560: iconst_0\n 561: istore 8\n 563: aload 7\n 565: invokeinterface #172, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 570: astore 9\n 572: aload 9\n 574: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 579: ifeq 666\n 582: aload 9\n 584: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 589: astore 10\n 591: aload 5\n 593: aload 10\n 595: checkcast #69 // class java/util/Map$Entry\n 598: astore 11\n 600: astore 17\n 602: iconst_0\n 603: istore 12\n 605: aload 11\n 607: invokeinterface #72, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 612: checkcast #74 // class java/lang/Character\n 615: invokevirtual #78 // Method java/lang/Character.charValue:()C\n 618: invokestatic #176 // Method java/lang/Character.toUpperCase:(C)C\n 621: nop\n 622: invokestatic #122 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 625: aload 17\n 627: swap\n 628: aload 10\n 630: checkcast #69 // class java/util/Map$Entry\n 633: astore 13\n 635: astore 14\n 637: astore 15\n 639: iconst_0\n 640: istore 16\n 642: aload 13\n 644: invokeinterface #81, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 649: astore 11\n 651: aload 15\n 653: aload 14\n 655: aload 11\n 657: invokeinterface #179, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 662: pop\n 663: goto 572\n 666: aload 5\n 668: nop\n 669: nop\n 670: astore_2\n 671: nop\n 672: iconst_0\n 673: istore_3\n 674: aload_2\n 675: astore 4\n 677: new #157 // class java/util/LinkedHashMap\n 680: dup\n 681: aload_2\n 682: invokeinterface #160, 1 // InterfaceMethod java/util/Map.size:()I\n 687: invokestatic #166 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 690: invokespecial #169 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 693: checkcast #33 // class java/util/Map\n 696: astore 5\n 698: iconst_0\n 699: istore 6\n 701: aload 4\n 703: invokeinterface #52, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 708: checkcast #171 // class java/lang/Iterable\n 711: astore 7\n 713: iconst_0\n 714: istore 8\n 716: aload 7\n 718: invokeinterface #172, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 723: astore 9\n 725: aload 9\n 727: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 732: ifeq 819\n 735: aload 9\n 737: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 742: astore 10\n 744: aload 5\n 746: aload 10\n 748: checkcast #69 // class java/util/Map$Entry\n 751: astore 11\n 753: astore 12\n 755: iconst_0\n 756: istore 13\n 758: aload 11\n 760: invokeinterface #72, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 765: aload 12\n 767: swap\n 768: aload 10\n 770: checkcast #69 // class java/util/Map$Entry\n 773: astore 14\n 775: astore 18\n 777: astore 17\n 779: iconst_0\n 780: istore 15\n 782: aload 14\n 784: invokeinterface #81, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 789: checkcast #74 // class java/lang/Character\n 792: invokevirtual #78 // Method java/lang/Character.charValue:()C\n 795: invokestatic #176 // Method java/lang/Character.toUpperCase:(C)C\n 798: nop\n 799: invokestatic #122 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 802: astore 19\n 804: aload 17\n 806: aload 18\n 808: aload 19\n 810: invokeinterface #179, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 815: pop\n 816: goto 725\n 819: nop\n 820: nop\n 821: nop\n 822: return\n\n public static final java.util.Map<java.lang.Character, java.lang.Character> toWiring(java.lang.String, java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #221 // String <this>\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #31 // String kind\n 9: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: getstatic #227 // Field java/util/Locale.ROOT:Ljava/util/Locale;\n 16: invokevirtual #230 // Method java/lang/String.toUpperCase:(Ljava/util/Locale;)Ljava/lang/String;\n 19: dup\n 20: ldc #232 // String toUpperCase(...)\n 22: invokestatic #235 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 25: astore_2\n 26: aload_1\n 27: astore 4\n 29: iconst_2\n 30: anewarray #92 // class java/lang/String\n 33: astore 5\n 35: aload 5\n 37: iconst_0\n 38: ldc #94 // String rotor\n 40: aastore\n 41: aload 5\n 43: iconst_1\n 44: ldc #132 // String reflector\n 46: aastore\n 47: aload 5\n 49: invokestatic #102 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 52: aload 4\n 54: invokeinterface #108, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 59: ifeq 159\n 62: aload_2\n 63: invokevirtual #236 // Method java/lang/String.length:()I\n 66: getstatic #11 // Field alphabet:Ljava/lang/String;\n 69: invokevirtual #236 // Method java/lang/String.length:()I\n 72: if_icmpne 79\n 75: iconst_1\n 76: goto 80\n 79: iconst_0\n 80: ifne 137\n 83: iconst_0\n 84: istore 6\n 86: new #142 // class java/lang/StringBuilder\n 89: dup\n 90: invokespecial #145 // Method java/lang/StringBuilder.\"<init>\":()V\n 93: ldc #238 // String String must be\n 95: invokevirtual #151 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 98: getstatic #11 // Field alphabet:Ljava/lang/String;\n 101: invokevirtual #236 // Method java/lang/String.length:()I\n 104: invokevirtual #241 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 107: ldc #243 // String characters long. Got\n 109: invokevirtual #151 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 112: aload_2\n 113: invokevirtual #236 // Method java/lang/String.length:()I\n 116: invokevirtual #241 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 119: invokevirtual #155 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 122: astore 6\n 124: new #41 // class java/lang/IllegalArgumentException\n 127: dup\n 128: aload 6\n 130: invokevirtual #44 // Method java/lang/Object.toString:()Ljava/lang/String;\n 133: invokespecial #48 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 136: athrow\n 137: getstatic #11 // Field alphabet:Ljava/lang/String;\n 140: checkcast #110 // class java/lang/CharSequence\n 143: aload_2\n 144: checkcast #110 // class java/lang/CharSequence\n 147: invokestatic #249 // Method kotlin/text/StringsKt.zip:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/util/List;\n 150: checkcast #171 // class java/lang/Iterable\n 153: invokestatic #253 // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;\n 156: goto 584\n 159: aload 4\n 161: ldc #96 // String plugboard\n 163: invokestatic #136 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 166: ifeq 556\n 169: aload_2\n 170: checkcast #110 // class java/lang/CharSequence\n 173: iconst_2\n 174: invokestatic #257 // Method kotlin/text/StringsKt.chunked:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 177: checkcast #171 // class java/lang/Iterable\n 180: astore 6\n 182: iconst_0\n 183: istore 7\n 185: aload 6\n 187: astore 8\n 189: new #259 // class java/util/ArrayList\n 192: dup\n 193: invokespecial #260 // Method java/util/ArrayList.\"<init>\":()V\n 196: checkcast #262 // class java/util/Collection\n 199: astore 9\n 201: iconst_0\n 202: istore 10\n 204: aload 8\n 206: invokeinterface #172, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 211: astore 11\n 213: aload 11\n 215: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 220: ifeq 388\n 223: aload 11\n 225: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 230: astore 12\n 232: aload 12\n 234: checkcast #92 // class java/lang/String\n 237: astore 13\n 239: iconst_0\n 240: istore 14\n 242: aload 13\n 244: checkcast #110 // class java/lang/CharSequence\n 247: astore 15\n 249: iconst_0\n 250: istore 16\n 252: aload 15\n 254: astore 17\n 256: new #259 // class java/util/ArrayList\n 259: dup\n 260: aload 15\n 262: invokeinterface #114, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 267: invokespecial #263 // Method java/util/ArrayList.\"<init>\":(I)V\n 270: checkcast #262 // class java/util/Collection\n 273: astore 18\n 275: iconst_0\n 276: istore 19\n 278: iconst_0\n 279: istore 20\n 281: iload 20\n 283: aload 17\n 285: invokeinterface #114, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 290: if_icmpge 365\n 293: aload 17\n 295: iload 20\n 297: invokeinterface #118, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 302: istore 21\n 304: aload 18\n 306: iload 21\n 308: istore 22\n 310: astore 23\n 312: iconst_0\n 313: istore 24\n 315: iload 22\n 317: invokestatic #122 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 320: aload 13\n 322: aload 13\n 324: checkcast #110 // class java/lang/CharSequence\n 327: iload 22\n 329: iconst_0\n 330: iconst_0\n 331: bipush 6\n 333: aconst_null\n 334: invokestatic #267 // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;CIZILjava/lang/Object;)I\n 337: iconst_1\n 338: iadd\n 339: iconst_2\n 340: irem\n 341: invokevirtual #268 // Method java/lang/String.charAt:(I)C\n 344: invokestatic #122 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 347: invokestatic #274 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 350: aload 23\n 352: swap\n 353: invokeinterface #277, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 358: pop\n 359: iinc 20, 1\n 362: goto 281\n 365: aload 18\n 367: checkcast #104 // class java/util/List\n 370: nop\n 371: checkcast #171 // class java/lang/Iterable\n 374: nop\n 375: astore 13\n 377: aload 9\n 379: aload 13\n 381: invokestatic #281 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 384: pop\n 385: goto 213\n 388: aload 9\n 390: checkcast #104 // class java/util/List\n 393: nop\n 394: checkcast #171 // class java/lang/Iterable\n 397: invokestatic #253 // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;\n 400: invokestatic #285 // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;\n 403: astore 5\n 405: aload_2\n 406: checkcast #110 // class java/lang/CharSequence\n 409: invokestatic #289 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 412: astore 6\n 414: aload 5\n 416: astore 7\n 418: getstatic #18 // Field defaultWiring:Ljava/util/Map;\n 421: astore 8\n 423: iconst_0\n 424: istore 9\n 426: new #157 // class java/util/LinkedHashMap\n 429: dup\n 430: invokespecial #290 // Method java/util/LinkedHashMap.\"<init>\":()V\n 433: astore 10\n 435: aload 8\n 437: invokeinterface #52, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 442: invokeinterface #58, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 447: astore 11\n 449: aload 11\n 451: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 456: ifeq 535\n 459: aload 11\n 461: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 466: checkcast #69 // class java/util/Map$Entry\n 469: astore 12\n 471: aload 12\n 473: invokeinterface #72, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 478: checkcast #74 // class java/lang/Character\n 481: invokevirtual #78 // Method java/lang/Character.charValue:()C\n 484: istore 13\n 486: iconst_0\n 487: istore 14\n 489: aload 6\n 491: iload 13\n 493: invokestatic #122 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 496: invokeinterface #291, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 501: ifne 508\n 504: iconst_1\n 505: goto 509\n 508: iconst_0\n 509: ifeq 449\n 512: aload 10\n 514: aload 12\n 516: invokeinterface #72, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 521: aload 12\n 523: invokeinterface #81, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 528: invokevirtual #292 // Method java/util/LinkedHashMap.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 531: pop\n 532: goto 449\n 535: aload 10\n 537: checkcast #33 // class java/util/Map\n 540: astore 8\n 542: aload 7\n 544: aload 8\n 546: invokeinterface #296, 2 // InterfaceMethod java/util/Map.putAll:(Ljava/util/Map;)V\n 551: aload 5\n 553: goto 584\n 556: new #41 // class java/lang/IllegalArgumentException\n 559: dup\n 560: new #142 // class java/lang/StringBuilder\n 563: dup\n 564: invokespecial #145 // Method java/lang/StringBuilder.\"<init>\":()V\n 567: ldc_w #298 // String Unknown kind:\n 570: invokevirtual #151 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 573: aload_1\n 574: invokevirtual #151 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 577: invokevirtual #155 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 580: invokespecial #48 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 583: athrow\n 584: astore_3\n 585: aload_3\n 586: areturn\n\n public static final java.util.List<java.lang.Integer> toListOfInt(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #221 // String <this>\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #110 // class java/lang/CharSequence\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: astore_3\n 15: new #259 // class java/util/ArrayList\n 18: dup\n 19: aload_1\n 20: invokeinterface #114, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 25: invokespecial #263 // Method java/util/ArrayList.\"<init>\":(I)V\n 28: checkcast #262 // class java/util/Collection\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: iconst_0\n 37: istore 6\n 39: iload 6\n 41: aload_3\n 42: invokeinterface #114, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 47: if_icmpge 139\n 50: aload_3\n 51: iload 6\n 53: invokeinterface #118, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 58: istore 7\n 60: aload 4\n 62: iload 7\n 64: istore 8\n 66: astore 10\n 68: iconst_0\n 69: istore 9\n 71: nop\n 72: iload 8\n 74: invokestatic #85 // Method java/lang/Character.isLetter:(C)Z\n 77: ifeq 91\n 80: iload 8\n 82: invokestatic #176 // Method java/lang/Character.toUpperCase:(C)C\n 85: bipush 65\n 87: isub\n 88: goto 120\n 91: new #41 // class java/lang/IllegalArgumentException\n 94: dup\n 95: new #142 // class java/lang/StringBuilder\n 98: dup\n 99: invokespecial #145 // Method java/lang/StringBuilder.\"<init>\":()V\n 102: ldc_w #330 // String Invalid character:\n 105: invokevirtual #151 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 108: iload 8\n 110: invokevirtual #333 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 113: invokevirtual #155 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 116: invokespecial #48 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 119: athrow\n 120: nop\n 121: invokestatic #338 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 124: aload 10\n 126: swap\n 127: invokeinterface #277, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 132: pop\n 133: iinc 6, 1\n 136: goto 39\n 139: aload 4\n 141: checkcast #104 // class java/util/List\n 144: nop\n 145: areturn\n\n static {};\n Code:\n 0: new #344 // class kotlin/ranges/CharRange\n 3: dup\n 4: bipush 65\n 6: bipush 90\n 8: invokespecial #347 // Method kotlin/ranges/CharRange.\"<init>\":(CC)V\n 11: checkcast #171 // class java/lang/Iterable\n 14: ldc_w #349 // String\n 17: checkcast #110 // class java/lang/CharSequence\n 20: aconst_null\n 21: aconst_null\n 22: iconst_0\n 23: aconst_null\n 24: aconst_null\n 25: bipush 62\n 27: aconst_null\n 28: invokestatic #353 // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;\n 31: putstatic #11 // Field alphabet:Ljava/lang/String;\n 34: new #344 // class kotlin/ranges/CharRange\n 37: dup\n 38: bipush 65\n 40: bipush 90\n 42: invokespecial #347 // Method kotlin/ranges/CharRange.\"<init>\":(CC)V\n 45: checkcast #171 // class java/lang/Iterable\n 48: astore_0\n 49: iconst_0\n 50: istore_1\n 51: new #157 // class java/util/LinkedHashMap\n 54: dup\n 55: aload_0\n 56: bipush 10\n 58: invokestatic #357 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 61: invokestatic #166 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 64: bipush 16\n 66: invokestatic #363 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 69: invokespecial #169 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 72: astore_2\n 73: aload_0\n 74: astore_3\n 75: iconst_0\n 76: istore 4\n 78: aload_3\n 79: invokeinterface #172, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 84: astore 5\n 86: aload 5\n 88: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 93: ifeq 150\n 96: aload 5\n 98: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 103: astore 6\n 105: aload_2\n 106: checkcast #33 // class java/util/Map\n 109: aload 6\n 111: aload 6\n 113: checkcast #74 // class java/lang/Character\n 116: invokevirtual #78 // Method java/lang/Character.charValue:()C\n 119: istore 7\n 121: astore 10\n 123: astore 9\n 125: iconst_0\n 126: istore 8\n 128: iload 7\n 130: invokestatic #122 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 133: astore 11\n 135: aload 9\n 137: aload 10\n 139: aload 11\n 141: invokeinterface #179, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 146: pop\n 147: goto 86\n 150: aload_2\n 151: checkcast #33 // class java/util/Map\n 154: nop\n 155: putstatic #18 // Field defaultWiring:Ljava/util/Map;\n 158: return\n}\n", "javap_err": "" } ]
xu33liang33__actioninkotlin__cdc74e4/src/chapter07/Intro_运算符重载.kt
package chapter07 import java.lang.IndexOutOfBoundsException import java.math.BigDecimal import java.time.LocalDate import kotlin.ranges.ClosedRange as ClosedRange1 /** * *运算符重载 * BigDecimal运算 * 约定 operator * * a * b | times * a / b | div * a % b | mod * a + b | plus * a - b | minus * */ fun main(args: Array<String>) { BigDecimal.ZERO var p1 = Point(10, 20) val p2 = Point(30, 40) println(p1 + p2) println(p1.plus(p2)) p1 += p2 println(p1) println(p2 * 5.toDouble()) var bd = BigDecimal.ZERO println(++bd) val a = Point(10, 20) == Point(10, 20) println("equal: $a") val p111 = Person722("Alice", "Smith") val p222 = Person722("Bob", "Johnson") println(p111 < p222) println(p2[1]) println('a' in "abc") } data class Point(val x: Int, val y: Int) { operator fun plus(other: Point): Point { return Point(x + other.x, y + other.y) } fun and(other: Point): Point { return Point(x + other.x, y + other.y) } /** * Point(10,20) == Point(10,20) */ override fun equals(obj: Any?): Boolean { if (obj === this) return true if (obj !is Point) return false return obj.x == x && obj.y == y } } operator fun Point.times(scale: Double): Point { return Point((x * scale).toInt(), (y * scale).toInt()) } /** * * 重载一元运算符 * * +a | unaryPlus * -a | unaryMinus * !a | not * ++a,a++ | inc * --a,a-- | dec * */ operator fun Point.unaryMinus(): Point { return Point(-x, -y) } operator fun BigDecimal.inc() = this + BigDecimal.ONE /** * 比较运算符 * * equals * == 运算符 * */ /** * * 排序运算符 * compareTo 接口 * */ class Person722(val firstName: String, val lastName: String) : Comparable<Person722> { override fun compareTo(other: Person722): Int { return compareValuesBy(this, other, Person722::lastName, Person722::firstName) } } /** * 集合与区别的约定 * a[b] 下标运算符 "get"和"set" * * */ operator fun Point.get(index: Int): Int { return when (index) { 0 -> x 1 -> y else -> throw IndexOutOfBoundsException("Invalid coordinate $index") } } /** * "in"的约定 * contains * * */ data class Rectangle732(val upperLeft: Point, val lowerRight: Point) operator fun Rectangle732.contains(p: Point): Boolean { return p.x in upperLeft.x until lowerRight.x && p.y in upperLeft.y until lowerRight.y } /** * rangeTo 约定 * ".."符号 1..10 *实现了Comparable 接口就不需要实现rangeTo了~因为标准库已经实现 */ //operator fun<T:Comparable<T>> T.rangeTo(that:T) : kotlin.ranges.ClosedRange<T> { // 1..10 //} /** * for循环中使用iterator的约定 * * * */
[ { "class_path": "xu33liang33__actioninkotlin__cdc74e4/chapter07/Intro_运算符重载Kt.class", "javap": "Compiled from \"Intro_运算符重载.kt\"\npublic final class chapter07.Intro_运算符重载Kt {\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 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #21 // Field java/math/BigDecimal.ZERO:Ljava/math/BigDecimal;\n 9: pop\n 10: new #23 // class chapter07/Point\n 13: dup\n 14: bipush 10\n 16: bipush 20\n 18: invokespecial #27 // Method chapter07/Point.\"<init>\":(II)V\n 21: astore_1\n 22: new #23 // class chapter07/Point\n 25: dup\n 26: bipush 30\n 28: bipush 40\n 30: invokespecial #27 // Method chapter07/Point.\"<init>\":(II)V\n 33: astore_2\n 34: aload_1\n 35: aload_2\n 36: invokevirtual #31 // Method chapter07/Point.plus:(Lchapter07/Point;)Lchapter07/Point;\n 39: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 42: swap\n 43: invokevirtual #43 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 46: aload_1\n 47: aload_2\n 48: invokevirtual #31 // Method chapter07/Point.plus:(Lchapter07/Point;)Lchapter07/Point;\n 51: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 54: swap\n 55: invokevirtual #43 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 58: aload_1\n 59: aload_2\n 60: invokevirtual #31 // Method chapter07/Point.plus:(Lchapter07/Point;)Lchapter07/Point;\n 63: astore_1\n 64: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 67: aload_1\n 68: invokevirtual #43 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 71: aload_2\n 72: ldc2_w #44 // double 5.0d\n 75: invokestatic #49 // Method times:(Lchapter07/Point;D)Lchapter07/Point;\n 78: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 81: swap\n 82: invokevirtual #43 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 85: getstatic #21 // Field java/math/BigDecimal.ZERO:Ljava/math/BigDecimal;\n 88: astore_3\n 89: aload_3\n 90: astore 4\n 92: aload 4\n 94: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 97: aload 4\n 99: invokestatic #56 // Method inc:(Ljava/math/BigDecimal;)Ljava/math/BigDecimal;\n 102: astore_3\n 103: aload_3\n 104: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 107: swap\n 108: invokevirtual #43 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 111: new #23 // class chapter07/Point\n 114: dup\n 115: bipush 10\n 117: bipush 20\n 119: invokespecial #27 // Method chapter07/Point.\"<init>\":(II)V\n 122: new #23 // class chapter07/Point\n 125: dup\n 126: bipush 10\n 128: bipush 20\n 130: invokespecial #27 // Method chapter07/Point.\"<init>\":(II)V\n 133: invokestatic #60 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 136: istore 4\n 138: new #62 // class java/lang/StringBuilder\n 141: dup\n 142: invokespecial #65 // Method java/lang/StringBuilder.\"<init>\":()V\n 145: ldc #67 // String equal:\n 147: invokevirtual #71 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 150: iload 4\n 152: invokevirtual #74 // Method java/lang/StringBuilder.append:(Z)Ljava/lang/StringBuilder;\n 155: invokevirtual #78 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 158: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 161: swap\n 162: invokevirtual #43 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 165: new #80 // class chapter07/Person722\n 168: dup\n 169: ldc #82 // String Alice\n 171: ldc #84 // String Smith\n 173: invokespecial #87 // Method chapter07/Person722.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 176: astore 5\n 178: new #80 // class chapter07/Person722\n 181: dup\n 182: ldc #89 // String Bob\n 184: ldc #91 // String Johnson\n 186: invokespecial #87 // Method chapter07/Person722.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 189: astore 6\n 191: aload 5\n 193: aload 6\n 195: invokevirtual #95 // Method chapter07/Person722.compareTo:(Lchapter07/Person722;)I\n 198: ifge 205\n 201: iconst_1\n 202: goto 206\n 205: iconst_0\n 206: istore 7\n 208: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 211: iload 7\n 213: invokevirtual #98 // Method java/io/PrintStream.println:(Z)V\n 216: aload_2\n 217: iconst_1\n 218: invokestatic #102 // Method get:(Lchapter07/Point;I)I\n 221: istore 7\n 223: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 226: iload 7\n 228: invokevirtual #105 // Method java/io/PrintStream.println:(I)V\n 231: ldc #107 // String abc\n 233: checkcast #109 // class java/lang/CharSequence\n 236: bipush 97\n 238: iconst_0\n 239: iconst_2\n 240: aconst_null\n 241: invokestatic #115 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;CZILjava/lang/Object;)Z\n 244: istore 7\n 246: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 249: iload 7\n 251: invokevirtual #98 // Method java/io/PrintStream.println:(Z)V\n 254: return\n\n public static final chapter07.Point times(chapter07.Point, double);\n Code:\n 0: aload_0\n 1: ldc #128 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #23 // class chapter07/Point\n 9: dup\n 10: aload_0\n 11: invokevirtual #132 // Method chapter07/Point.getX:()I\n 14: i2d\n 15: dload_1\n 16: dmul\n 17: d2i\n 18: aload_0\n 19: invokevirtual #135 // Method chapter07/Point.getY:()I\n 22: i2d\n 23: dload_1\n 24: dmul\n 25: d2i\n 26: invokespecial #27 // Method chapter07/Point.\"<init>\":(II)V\n 29: areturn\n\n public static final chapter07.Point unaryMinus(chapter07.Point);\n Code:\n 0: aload_0\n 1: ldc #128 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #23 // class chapter07/Point\n 9: dup\n 10: aload_0\n 11: invokevirtual #132 // Method chapter07/Point.getX:()I\n 14: ineg\n 15: aload_0\n 16: invokevirtual #135 // Method chapter07/Point.getY:()I\n 19: ineg\n 20: invokespecial #27 // Method chapter07/Point.\"<init>\":(II)V\n 23: areturn\n\n public static final java.math.BigDecimal inc(java.math.BigDecimal);\n Code:\n 0: aload_0\n 1: ldc #128 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: astore_1\n 8: getstatic #143 // Field java/math/BigDecimal.ONE:Ljava/math/BigDecimal;\n 11: dup\n 12: ldc #144 // String ONE\n 14: invokestatic #147 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 17: aload_1\n 18: swap\n 19: invokevirtual #150 // Method java/math/BigDecimal.add:(Ljava/math/BigDecimal;)Ljava/math/BigDecimal;\n 22: dup\n 23: ldc #152 // String add(...)\n 25: invokestatic #147 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 28: areturn\n\n public static final int get(chapter07.Point, int);\n Code:\n 0: aload_0\n 1: ldc #128 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_1\n 7: tableswitch { // 0 to 1\n 0: 28\n 1: 35\n default: 42\n }\n 28: aload_0\n 29: invokevirtual #132 // Method chapter07/Point.getX:()I\n 32: goto 69\n 35: aload_0\n 36: invokevirtual #135 // Method chapter07/Point.getY:()I\n 39: goto 69\n 42: new #155 // class java/lang/IndexOutOfBoundsException\n 45: dup\n 46: new #62 // class java/lang/StringBuilder\n 49: dup\n 50: invokespecial #65 // Method java/lang/StringBuilder.\"<init>\":()V\n 53: ldc #157 // String Invalid coordinate\n 55: invokevirtual #71 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 58: iload_1\n 59: invokevirtual #160 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 62: invokevirtual #78 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 65: invokespecial #163 // Method java/lang/IndexOutOfBoundsException.\"<init>\":(Ljava/lang/String;)V\n 68: athrow\n 69: ireturn\n\n public static final boolean contains(chapter07.Rectangle732, chapter07.Point);\n Code:\n 0: aload_0\n 1: ldc #128 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #170 // String p\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokevirtual #176 // Method chapter07/Rectangle732.getUpperLeft:()Lchapter07/Point;\n 16: invokevirtual #132 // Method chapter07/Point.getX:()I\n 19: istore_2\n 20: aload_0\n 21: invokevirtual #179 // Method chapter07/Rectangle732.getLowerRight:()Lchapter07/Point;\n 24: invokevirtual #132 // Method chapter07/Point.getX:()I\n 27: istore_3\n 28: aload_1\n 29: invokevirtual #132 // Method chapter07/Point.getX:()I\n 32: istore 4\n 34: iload_2\n 35: iload 4\n 37: if_icmpgt 54\n 40: iload 4\n 42: iload_3\n 43: if_icmpge 50\n 46: iconst_1\n 47: goto 55\n 50: iconst_0\n 51: goto 55\n 54: iconst_0\n 55: ifeq 108\n 58: aload_0\n 59: invokevirtual #176 // Method chapter07/Rectangle732.getUpperLeft:()Lchapter07/Point;\n 62: invokevirtual #135 // Method chapter07/Point.getY:()I\n 65: istore_2\n 66: aload_0\n 67: invokevirtual #179 // Method chapter07/Rectangle732.getLowerRight:()Lchapter07/Point;\n 70: invokevirtual #135 // Method chapter07/Point.getY:()I\n 73: istore_3\n 74: aload_1\n 75: invokevirtual #135 // Method chapter07/Point.getY:()I\n 78: istore 4\n 80: iload_2\n 81: iload 4\n 83: if_icmpgt 100\n 86: iload 4\n 88: iload_3\n 89: if_icmpge 96\n 92: iconst_1\n 93: goto 101\n 96: iconst_0\n 97: goto 101\n 100: iconst_0\n 101: ifeq 108\n 104: iconst_1\n 105: goto 109\n 108: iconst_0\n 109: ireturn\n}\n", "javap_err": "" } ]
xu33liang33__actioninkotlin__cdc74e4/src/chapter08/_8_1_2/_8_1_6_去除重复代码.kt
package chapter08._8_1_2 data class SiteVisit( val path: String, val dutation: Double, val os: OS ) //函数类型和lambda 一起去除重复代码 enum class OS { WINDOWS, LINUX, MAC, IOS, ANDROID } fun main(args: Array<String>) { val log = listOf( SiteVisit("/", 34.0, OS.WINDOWS), SiteVisit("/", 22.0, OS.MAC), SiteVisit("/login", 12.0, OS.WINDOWS), SiteVisit("/signup", 8.0, OS.IOS), SiteVisit("/", 16.3, OS.ANDROID) ) println(log.filter { it.os == OS.WINDOWS } .map(SiteVisit::dutation)) //计算windows平均时间 val averageWindows = log.filter { it.os == OS.WINDOWS } .map(SiteVisit::dutation) .average() println(averageWindows) // println(log.filter { it.os == OS.WINDOWS } // .map(SiteVisit::dutation)) val averageMobile = log.filter { it.os in setOf(OS.IOS, OS.ANDROID) } .map(SiteVisit::dutation) .average() println(averageMobile) /** * 普通去重方法 */ println() println("log.averageDuration(OS.ANDROID)") println(log.averageDuration(OS.ANDROID)) println("------------------------") /** * 将需要的条件抽到函数类型参数中 */ println(log.averageDurationFor { it.os in setOf(OS.ANDROID, OS.IOS) }) println(log.averageDurationFor { it.os == OS.IOS && it.path == "/signup" }) } /** * 普通方法去重 */ fun List<SiteVisit>.averageDuration(os: OS) = filter { it.os == os } .map(SiteVisit::dutation) .average() /** * 将需要的条件抽到函数类型参数中 * 不仅抽取重复数据,也能抽取重复行为 */ fun List<SiteVisit>.averageDurationFor(predicate: (SiteVisit) -> Boolean) = filter(predicate) .map(SiteVisit::dutation) .average()
[ { "class_path": "xu33liang33__actioninkotlin__cdc74e4/chapter08/_8_1_2/_8_1_6_去除重复代码Kt.class", "javap": "Compiled from \"_8_1_6_去除重复代码.kt\"\npublic final class chapter08._8_1_2._8_1_6_去除重复代码Kt {\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 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_5\n 7: anewarray #17 // class chapter08/_8_1_2/SiteVisit\n 10: astore_2\n 11: aload_2\n 12: iconst_0\n 13: new #17 // class chapter08/_8_1_2/SiteVisit\n 16: dup\n 17: ldc #19 // String /\n 19: ldc2_w #20 // double 34.0d\n 22: getstatic #27 // Field chapter08/_8_1_2/OS.WINDOWS:Lchapter08/_8_1_2/OS;\n 25: invokespecial #31 // Method chapter08/_8_1_2/SiteVisit.\"<init>\":(Ljava/lang/String;DLchapter08/_8_1_2/OS;)V\n 28: aastore\n 29: aload_2\n 30: iconst_1\n 31: new #17 // class chapter08/_8_1_2/SiteVisit\n 34: dup\n 35: ldc #19 // String /\n 37: ldc2_w #32 // double 22.0d\n 40: getstatic #36 // Field chapter08/_8_1_2/OS.MAC:Lchapter08/_8_1_2/OS;\n 43: invokespecial #31 // Method chapter08/_8_1_2/SiteVisit.\"<init>\":(Ljava/lang/String;DLchapter08/_8_1_2/OS;)V\n 46: aastore\n 47: aload_2\n 48: iconst_2\n 49: new #17 // class chapter08/_8_1_2/SiteVisit\n 52: dup\n 53: ldc #38 // String /login\n 55: ldc2_w #39 // double 12.0d\n 58: getstatic #27 // Field chapter08/_8_1_2/OS.WINDOWS:Lchapter08/_8_1_2/OS;\n 61: invokespecial #31 // Method chapter08/_8_1_2/SiteVisit.\"<init>\":(Ljava/lang/String;DLchapter08/_8_1_2/OS;)V\n 64: aastore\n 65: aload_2\n 66: iconst_3\n 67: new #17 // class chapter08/_8_1_2/SiteVisit\n 70: dup\n 71: ldc #42 // String /signup\n 73: ldc2_w #43 // double 8.0d\n 76: getstatic #47 // Field chapter08/_8_1_2/OS.IOS:Lchapter08/_8_1_2/OS;\n 79: invokespecial #31 // Method chapter08/_8_1_2/SiteVisit.\"<init>\":(Ljava/lang/String;DLchapter08/_8_1_2/OS;)V\n 82: aastore\n 83: aload_2\n 84: iconst_4\n 85: new #17 // class chapter08/_8_1_2/SiteVisit\n 88: dup\n 89: ldc #19 // String /\n 91: ldc2_w #48 // double 16.3d\n 94: getstatic #52 // Field chapter08/_8_1_2/OS.ANDROID:Lchapter08/_8_1_2/OS;\n 97: invokespecial #31 // Method chapter08/_8_1_2/SiteVisit.\"<init>\":(Ljava/lang/String;DLchapter08/_8_1_2/OS;)V\n 100: aastore\n 101: aload_2\n 102: invokestatic #58 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 105: astore_1\n 106: aload_1\n 107: checkcast #60 // class java/lang/Iterable\n 110: astore_2\n 111: iconst_0\n 112: istore_3\n 113: aload_2\n 114: astore 4\n 116: new #62 // class java/util/ArrayList\n 119: dup\n 120: invokespecial #65 // Method java/util/ArrayList.\"<init>\":()V\n 123: checkcast #67 // class java/util/Collection\n 126: astore 5\n 128: iconst_0\n 129: istore 6\n 131: aload 4\n 133: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 138: astore 7\n 140: aload 7\n 142: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 147: ifeq 201\n 150: aload 7\n 152: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 157: astore 8\n 159: aload 8\n 161: checkcast #17 // class chapter08/_8_1_2/SiteVisit\n 164: astore 9\n 166: iconst_0\n 167: istore 10\n 169: aload 9\n 171: invokevirtual #85 // Method chapter08/_8_1_2/SiteVisit.getOs:()Lchapter08/_8_1_2/OS;\n 174: getstatic #27 // Field chapter08/_8_1_2/OS.WINDOWS:Lchapter08/_8_1_2/OS;\n 177: if_acmpne 184\n 180: iconst_1\n 181: goto 185\n 184: iconst_0\n 185: ifeq 140\n 188: aload 5\n 190: aload 8\n 192: invokeinterface #89, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 197: pop\n 198: goto 140\n 201: aload 5\n 203: checkcast #91 // class java/util/List\n 206: nop\n 207: checkcast #60 // class java/lang/Iterable\n 210: astore_2\n 211: nop\n 212: iconst_0\n 213: istore_3\n 214: aload_2\n 215: astore 4\n 217: new #62 // class java/util/ArrayList\n 220: dup\n 221: aload_2\n 222: bipush 10\n 224: invokestatic #95 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 227: invokespecial #98 // Method java/util/ArrayList.\"<init>\":(I)V\n 230: checkcast #67 // class java/util/Collection\n 233: astore 5\n 235: iconst_0\n 236: istore 6\n 238: aload 4\n 240: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 245: astore 7\n 247: aload 7\n 249: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 254: ifeq 300\n 257: aload 7\n 259: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 264: astore 8\n 266: aload 5\n 268: aload 8\n 270: checkcast #17 // class chapter08/_8_1_2/SiteVisit\n 273: astore 9\n 275: astore 16\n 277: iconst_0\n 278: istore 10\n 280: aload 9\n 282: invokevirtual #102 // Method chapter08/_8_1_2/SiteVisit.getDutation:()D\n 285: invokestatic #108 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 288: aload 16\n 290: swap\n 291: invokeinterface #89, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 296: pop\n 297: goto 247\n 300: aload 5\n 302: checkcast #91 // class java/util/List\n 305: nop\n 306: astore_2\n 307: getstatic #114 // Field java/lang/System.out:Ljava/io/PrintStream;\n 310: aload_2\n 311: invokevirtual #120 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 314: aload_1\n 315: checkcast #60 // class java/lang/Iterable\n 318: astore 4\n 320: iconst_0\n 321: istore 5\n 323: aload 4\n 325: astore 6\n 327: new #62 // class java/util/ArrayList\n 330: dup\n 331: invokespecial #65 // Method java/util/ArrayList.\"<init>\":()V\n 334: checkcast #67 // class java/util/Collection\n 337: astore 7\n 339: iconst_0\n 340: istore 8\n 342: aload 6\n 344: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 349: astore 9\n 351: aload 9\n 353: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 358: ifeq 412\n 361: aload 9\n 363: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 368: astore 10\n 370: aload 10\n 372: checkcast #17 // class chapter08/_8_1_2/SiteVisit\n 375: astore 11\n 377: iconst_0\n 378: istore 12\n 380: aload 11\n 382: invokevirtual #85 // Method chapter08/_8_1_2/SiteVisit.getOs:()Lchapter08/_8_1_2/OS;\n 385: getstatic #27 // Field chapter08/_8_1_2/OS.WINDOWS:Lchapter08/_8_1_2/OS;\n 388: if_acmpne 395\n 391: iconst_1\n 392: goto 396\n 395: iconst_0\n 396: ifeq 351\n 399: aload 7\n 401: aload 10\n 403: invokeinterface #89, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 408: pop\n 409: goto 351\n 412: aload 7\n 414: checkcast #91 // class java/util/List\n 417: nop\n 418: checkcast #60 // class java/lang/Iterable\n 421: astore 4\n 423: nop\n 424: iconst_0\n 425: istore 5\n 427: aload 4\n 429: astore 6\n 431: new #62 // class java/util/ArrayList\n 434: dup\n 435: aload 4\n 437: bipush 10\n 439: invokestatic #95 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 442: invokespecial #98 // Method java/util/ArrayList.\"<init>\":(I)V\n 445: checkcast #67 // class java/util/Collection\n 448: astore 7\n 450: iconst_0\n 451: istore 8\n 453: aload 6\n 455: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 460: astore 9\n 462: aload 9\n 464: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 469: ifeq 515\n 472: aload 9\n 474: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 479: astore 10\n 481: aload 7\n 483: aload 10\n 485: checkcast #17 // class chapter08/_8_1_2/SiteVisit\n 488: astore 11\n 490: astore 16\n 492: iconst_0\n 493: istore 12\n 495: aload 11\n 497: invokevirtual #102 // Method chapter08/_8_1_2/SiteVisit.getDutation:()D\n 500: invokestatic #108 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 503: aload 16\n 505: swap\n 506: invokeinterface #89, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 511: pop\n 512: goto 462\n 515: aload 7\n 517: checkcast #91 // class java/util/List\n 520: nop\n 521: checkcast #60 // class java/lang/Iterable\n 524: invokestatic #124 // Method kotlin/collections/CollectionsKt.averageOfDouble:(Ljava/lang/Iterable;)D\n 527: dstore_2\n 528: getstatic #114 // Field java/lang/System.out:Ljava/io/PrintStream;\n 531: dload_2\n 532: invokevirtual #127 // Method java/io/PrintStream.println:(D)V\n 535: aload_1\n 536: checkcast #60 // class java/lang/Iterable\n 539: astore 6\n 541: iconst_0\n 542: istore 7\n 544: aload 6\n 546: astore 8\n 548: new #62 // class java/util/ArrayList\n 551: dup\n 552: invokespecial #65 // Method java/util/ArrayList.\"<init>\":()V\n 555: checkcast #67 // class java/util/Collection\n 558: astore 9\n 560: iconst_0\n 561: istore 10\n 563: aload 8\n 565: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 570: astore 11\n 572: aload 11\n 574: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 579: ifeq 652\n 582: aload 11\n 584: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 589: astore 12\n 591: aload 12\n 593: checkcast #17 // class chapter08/_8_1_2/SiteVisit\n 596: astore 13\n 598: iconst_0\n 599: istore 14\n 601: iconst_2\n 602: anewarray #23 // class chapter08/_8_1_2/OS\n 605: astore 15\n 607: aload 15\n 609: iconst_0\n 610: getstatic #47 // Field chapter08/_8_1_2/OS.IOS:Lchapter08/_8_1_2/OS;\n 613: aastore\n 614: aload 15\n 616: iconst_1\n 617: getstatic #52 // Field chapter08/_8_1_2/OS.ANDROID:Lchapter08/_8_1_2/OS;\n 620: aastore\n 621: aload 15\n 623: invokestatic #133 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 626: aload 13\n 628: invokevirtual #85 // Method chapter08/_8_1_2/SiteVisit.getOs:()Lchapter08/_8_1_2/OS;\n 631: invokeinterface #138, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 636: ifeq 572\n 639: aload 9\n 641: aload 12\n 643: invokeinterface #89, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 648: pop\n 649: goto 572\n 652: aload 9\n 654: checkcast #91 // class java/util/List\n 657: nop\n 658: checkcast #60 // class java/lang/Iterable\n 661: astore 6\n 663: nop\n 664: iconst_0\n 665: istore 7\n 667: aload 6\n 669: astore 8\n 671: new #62 // class java/util/ArrayList\n 674: dup\n 675: aload 6\n 677: bipush 10\n 679: invokestatic #95 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 682: invokespecial #98 // Method java/util/ArrayList.\"<init>\":(I)V\n 685: checkcast #67 // class java/util/Collection\n 688: astore 9\n 690: iconst_0\n 691: istore 10\n 693: aload 8\n 695: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 700: astore 11\n 702: aload 11\n 704: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 709: ifeq 755\n 712: aload 11\n 714: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 719: astore 12\n 721: aload 9\n 723: aload 12\n 725: checkcast #17 // class chapter08/_8_1_2/SiteVisit\n 728: astore 13\n 730: astore 16\n 732: iconst_0\n 733: istore 14\n 735: aload 13\n 737: invokevirtual #102 // Method chapter08/_8_1_2/SiteVisit.getDutation:()D\n 740: invokestatic #108 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 743: aload 16\n 745: swap\n 746: invokeinterface #89, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 751: pop\n 752: goto 702\n 755: aload 9\n 757: checkcast #91 // class java/util/List\n 760: nop\n 761: checkcast #60 // class java/lang/Iterable\n 764: invokestatic #124 // Method kotlin/collections/CollectionsKt.averageOfDouble:(Ljava/lang/Iterable;)D\n 767: dstore 4\n 769: getstatic #114 // Field java/lang/System.out:Ljava/io/PrintStream;\n 772: dload 4\n 774: invokevirtual #127 // Method java/io/PrintStream.println:(D)V\n 777: getstatic #114 // Field java/lang/System.out:Ljava/io/PrintStream;\n 780: invokevirtual #140 // Method java/io/PrintStream.println:()V\n 783: ldc #142 // String log.averageDuration(OS.ANDROID)\n 785: getstatic #114 // Field java/lang/System.out:Ljava/io/PrintStream;\n 788: swap\n 789: invokevirtual #120 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 792: aload_1\n 793: getstatic #52 // Field chapter08/_8_1_2/OS.ANDROID:Lchapter08/_8_1_2/OS;\n 796: invokestatic #146 // Method averageDuration:(Ljava/util/List;Lchapter08/_8_1_2/OS;)D\n 799: dstore 6\n 801: getstatic #114 // Field java/lang/System.out:Ljava/io/PrintStream;\n 804: dload 6\n 806: invokevirtual #127 // Method java/io/PrintStream.println:(D)V\n 809: ldc #148 // String ------------------------\n 811: getstatic #114 // Field java/lang/System.out:Ljava/io/PrintStream;\n 814: swap\n 815: invokevirtual #120 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 818: aload_1\n 819: invokedynamic #168, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 824: invokestatic #172 // Method averageDurationFor:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)D\n 827: dstore 6\n 829: getstatic #114 // Field java/lang/System.out:Ljava/io/PrintStream;\n 832: dload 6\n 834: invokevirtual #127 // Method java/io/PrintStream.println:(D)V\n 837: aload_1\n 838: invokedynamic #177, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 843: invokestatic #172 // Method averageDurationFor:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)D\n 846: dstore 6\n 848: getstatic #114 // Field java/lang/System.out:Ljava/io/PrintStream;\n 851: dload 6\n 853: invokevirtual #127 // Method java/io/PrintStream.println:(D)V\n 856: return\n\n public static final double averageDuration(java.util.List<chapter08._8_1_2.SiteVisit>, chapter08._8_1_2.OS);\n Code:\n 0: aload_0\n 1: ldc #211 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #213 // String os\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: checkcast #60 // class java/lang/Iterable\n 16: astore_2\n 17: iconst_0\n 18: istore_3\n 19: aload_2\n 20: astore 4\n 22: new #62 // class java/util/ArrayList\n 25: dup\n 26: invokespecial #65 // Method java/util/ArrayList.\"<init>\":()V\n 29: checkcast #67 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 105\n 56: aload 7\n 58: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 8\n 67: checkcast #17 // class chapter08/_8_1_2/SiteVisit\n 70: astore 9\n 72: iconst_0\n 73: istore 10\n 75: aload 9\n 77: invokevirtual #85 // Method chapter08/_8_1_2/SiteVisit.getOs:()Lchapter08/_8_1_2/OS;\n 80: aload_1\n 81: if_acmpne 88\n 84: iconst_1\n 85: goto 89\n 88: iconst_0\n 89: ifeq 46\n 92: aload 5\n 94: aload 8\n 96: invokeinterface #89, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 101: pop\n 102: goto 46\n 105: aload 5\n 107: checkcast #91 // class java/util/List\n 110: nop\n 111: checkcast #60 // class java/lang/Iterable\n 114: astore_2\n 115: nop\n 116: iconst_0\n 117: istore_3\n 118: aload_2\n 119: astore 4\n 121: new #62 // class java/util/ArrayList\n 124: dup\n 125: aload_2\n 126: bipush 10\n 128: invokestatic #95 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 131: invokespecial #98 // Method java/util/ArrayList.\"<init>\":(I)V\n 134: checkcast #67 // class java/util/Collection\n 137: astore 5\n 139: iconst_0\n 140: istore 6\n 142: aload 4\n 144: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 149: astore 7\n 151: aload 7\n 153: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 158: ifeq 204\n 161: aload 7\n 163: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 168: astore 8\n 170: aload 5\n 172: aload 8\n 174: checkcast #17 // class chapter08/_8_1_2/SiteVisit\n 177: astore 9\n 179: astore 11\n 181: iconst_0\n 182: istore 10\n 184: aload 9\n 186: invokevirtual #102 // Method chapter08/_8_1_2/SiteVisit.getDutation:()D\n 189: invokestatic #108 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 192: aload 11\n 194: swap\n 195: invokeinterface #89, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 200: pop\n 201: goto 151\n 204: aload 5\n 206: checkcast #91 // class java/util/List\n 209: nop\n 210: checkcast #60 // class java/lang/Iterable\n 213: invokestatic #124 // Method kotlin/collections/CollectionsKt.averageOfDouble:(Ljava/lang/Iterable;)D\n 216: dreturn\n\n public static final double averageDurationFor(java.util.List<chapter08._8_1_2.SiteVisit>, kotlin.jvm.functions.Function1<? super chapter08._8_1_2.SiteVisit, java.lang.Boolean>);\n Code:\n 0: aload_0\n 1: ldc #211 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #219 // String predicate\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: checkcast #60 // class java/lang/Iterable\n 16: astore_2\n 17: iconst_0\n 18: istore_3\n 19: aload_2\n 20: astore 4\n 22: new #62 // class java/util/ArrayList\n 25: dup\n 26: invokespecial #65 // Method java/util/ArrayList.\"<init>\":()V\n 29: checkcast #67 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 95\n 56: aload 7\n 58: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload_1\n 66: aload 8\n 68: invokeinterface #223, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 73: checkcast #225 // class java/lang/Boolean\n 76: invokevirtual #228 // Method java/lang/Boolean.booleanValue:()Z\n 79: ifeq 46\n 82: aload 5\n 84: aload 8\n 86: invokeinterface #89, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 91: pop\n 92: goto 46\n 95: aload 5\n 97: checkcast #91 // class java/util/List\n 100: nop\n 101: checkcast #60 // class java/lang/Iterable\n 104: astore_2\n 105: nop\n 106: iconst_0\n 107: istore_3\n 108: aload_2\n 109: astore 4\n 111: new #62 // class java/util/ArrayList\n 114: dup\n 115: aload_2\n 116: bipush 10\n 118: invokestatic #95 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 121: invokespecial #98 // Method java/util/ArrayList.\"<init>\":(I)V\n 124: checkcast #67 // class java/util/Collection\n 127: astore 5\n 129: iconst_0\n 130: istore 6\n 132: aload 4\n 134: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 139: astore 7\n 141: aload 7\n 143: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 148: ifeq 194\n 151: aload 7\n 153: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 158: astore 8\n 160: aload 5\n 162: aload 8\n 164: checkcast #17 // class chapter08/_8_1_2/SiteVisit\n 167: astore 9\n 169: astore 11\n 171: iconst_0\n 172: istore 10\n 174: aload 9\n 176: invokevirtual #102 // Method chapter08/_8_1_2/SiteVisit.getDutation:()D\n 179: invokestatic #108 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 182: aload 11\n 184: swap\n 185: invokeinterface #89, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 190: pop\n 191: goto 141\n 194: aload 5\n 196: checkcast #91 // class java/util/List\n 199: nop\n 200: checkcast #60 // class java/lang/Iterable\n 203: invokestatic #124 // Method kotlin/collections/CollectionsKt.averageOfDouble:(Ljava/lang/Iterable;)D\n 206: dreturn\n\n private static final boolean main$lambda$5(chapter08._8_1_2.SiteVisit);\n Code:\n 0: aload_0\n 1: ldc #232 // String it\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_2\n 7: anewarray #23 // class chapter08/_8_1_2/OS\n 10: astore_1\n 11: aload_1\n 12: iconst_0\n 13: getstatic #52 // Field chapter08/_8_1_2/OS.ANDROID:Lchapter08/_8_1_2/OS;\n 16: aastore\n 17: aload_1\n 18: iconst_1\n 19: getstatic #47 // Field chapter08/_8_1_2/OS.IOS:Lchapter08/_8_1_2/OS;\n 22: aastore\n 23: aload_1\n 24: invokestatic #133 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 27: aload_0\n 28: invokevirtual #85 // Method chapter08/_8_1_2/SiteVisit.getOs:()Lchapter08/_8_1_2/OS;\n 31: invokeinterface #138, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 36: ireturn\n\n private static final boolean main$lambda$6(chapter08._8_1_2.SiteVisit);\n Code:\n 0: aload_0\n 1: ldc #232 // String it\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #85 // Method chapter08/_8_1_2/SiteVisit.getOs:()Lchapter08/_8_1_2/OS;\n 10: getstatic #47 // Field chapter08/_8_1_2/OS.IOS:Lchapter08/_8_1_2/OS;\n 13: if_acmpne 32\n 16: aload_0\n 17: invokevirtual #236 // Method chapter08/_8_1_2/SiteVisit.getPath:()Ljava/lang/String;\n 20: ldc #42 // String /signup\n 22: invokestatic #240 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 25: ifeq 32\n 28: iconst_1\n 29: goto 33\n 32: iconst_0\n 33: ireturn\n}\n", "javap_err": "" } ]
al-volkov__spbu_2020_kotlin_homeworks__5049681/src/main/kotlin/homework_5/Task1.kt
package homework_5 import java.io.File fun String.isNumber() = this.toIntOrNull() != null enum class OperationType(val operation: String) { Addition("+"), Multiplication("*"), Subtraction("-"), Division("/") } interface ArithmeticTreeNode { fun getValue(): Int override fun toString(): String } class Operand(private val value: Int) : ArithmeticTreeNode { override fun getValue() = value override fun toString() = value.toString() } class Operation( private val type: OperationType, private val leftNode: ArithmeticTreeNode, private val rightNode: ArithmeticTreeNode ) : ArithmeticTreeNode { override fun getValue(): Int { return when (type) { OperationType.Addition -> leftNode.getValue() + rightNode.getValue() OperationType.Multiplication -> leftNode.getValue() * rightNode.getValue() OperationType.Subtraction -> leftNode.getValue() - rightNode.getValue() OperationType.Division -> leftNode.getValue() / rightNode.getValue() } } override fun toString(): String = "(${type.operation} $leftNode $rightNode)" } class ArithmeticTree(path: String) { private val root: ArithmeticTreeNode init { val input = File(path).readText().replace("(", "").replace(")", "").split(" ") root = parseRecursive(input).node } data class RecursiveResult(val node: ArithmeticTreeNode, val newList: List<String>) private fun parseRecursive(list: List<String>): RecursiveResult { if (list.first().isNumber()) { return RecursiveResult(Operand(list.first().toInt()), list.slice(1..list.lastIndex)) } else { val type = when (list.first()) { "+" -> OperationType.Addition "*" -> OperationType.Multiplication "-" -> OperationType.Subtraction "/" -> OperationType.Division else -> throw IllegalArgumentException("arithmetic expression is not correct") } var result = parseRecursive(list.slice(1..list.lastIndex)) val leftNode = result.node result = parseRecursive(result.newList) val rightNode = result.node return RecursiveResult(Operation(type, leftNode, rightNode), result.newList) } } override fun toString() = root.toString() fun getValue() = root.getValue() }
[ { "class_path": "al-volkov__spbu_2020_kotlin_homeworks__5049681/homework_5/Task1Kt.class", "javap": "Compiled from \"Task1.kt\"\npublic final class homework_5.Task1Kt {\n public static final boolean isNumber(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #9 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #21 // Method kotlin/text/StringsKt.toIntOrNull:(Ljava/lang/String;)Ljava/lang/Integer;\n 10: ifnull 17\n 13: iconst_1\n 14: goto 18\n 17: iconst_0\n 18: ireturn\n}\n", "javap_err": "" } ]
mayabot__mynlp__b980da3/mynlp/src/main/java/com/mayabot/nlp/algorithm/TopIntMinK.kt
package com.mayabot.nlp.algorithm /** * Top K 最小值。 */ class TopIntMinK(private val k: Int) { private val heap = FloatArray(k) private val idIndex = IntArray(k) { -1 } var size = 0 fun push(id: Int, score: Float) { if (size < k) { heap[size] = score idIndex[size] = id size++ if (size == k) { buildMinHeap() } } else { // 如果这个数据小于最大值,那么有资格进入 if (score < heap[0]) { heap[0] = score idIndex[0] = id topify(0) } } } fun result(): ArrayList<Pair<Int, Float>> { val top = Math.min(k, size) val list = ArrayList<Pair<Int, Float>>(top) for (i in 0 until top) { list += idIndex[i] to heap[i] } list.sortBy { it.second } return list } private fun buildMinHeap() { for (i in k / 2 - 1 downTo 0) { topify(i)// 依次向上将当前子树最大堆化 } } private fun topify(i: Int) { val l = 2 * i + 1 val r = 2 * i + 2 var max: Int if (l < k && heap[l] > heap[i]) max = l else max = i if (r < k && heap[r] > heap[max]) { max = r } if (max == i || max >= k) // 如果largest等于i说明i是最大元素 // largest超出heap范围说明不存在比i节点大的子女 return swap(i, max) topify(max) } private fun swap(i: Int, j: Int) { val tmp = heap[i] heap[i] = heap[j] heap[j] = tmp val tmp2 = idIndex[i] idIndex[i] = idIndex[j] idIndex[j] = tmp2 } }
[ { "class_path": "mayabot__mynlp__b980da3/com/mayabot/nlp/algorithm/TopIntMinK$result$$inlined$sortBy$1.class", "javap": "Compiled from \"Comparisons.kt\"\npublic final class com.mayabot.nlp.algorithm.TopIntMinK$result$$inlined$sortBy$1<T> implements java.util.Comparator {\n public com.mayabot.nlp.algorithm.TopIntMinK$result$$inlined$sortBy$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_1\n 1: checkcast #23 // class kotlin/Pair\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 12: checkcast #29 // class java/lang/Float\n 15: checkcast #31 // class java/lang/Comparable\n 18: aload_2\n 19: checkcast #23 // class kotlin/Pair\n 22: astore_3\n 23: astore 5\n 25: iconst_0\n 26: istore 4\n 28: aload_3\n 29: invokevirtual #27 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 32: checkcast #29 // class java/lang/Float\n 35: aload 5\n 37: swap\n 38: checkcast #31 // class java/lang/Comparable\n 41: invokestatic #37 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 44: ireturn\n}\n", "javap_err": "" }, { "class_path": "mayabot__mynlp__b980da3/com/mayabot/nlp/algorithm/TopIntMinK.class", "javap": "Compiled from \"TopIntMinK.kt\"\npublic final class com.mayabot.nlp.algorithm.TopIntMinK {\n private final int k;\n\n private final float[] heap;\n\n private final int[] idIndex;\n\n private int size;\n\n public com.mayabot.nlp.algorithm.TopIntMinK(int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field k:I\n 9: aload_0\n 10: aload_0\n 11: getfield #13 // Field k:I\n 14: newarray float\n 16: putfield #17 // Field heap:[F\n 19: aload_0\n 20: iconst_0\n 21: istore_2\n 22: aload_0\n 23: getfield #13 // Field k:I\n 26: istore_3\n 27: iload_3\n 28: newarray int\n 30: astore 4\n 32: astore 6\n 34: iload_2\n 35: iload_3\n 36: if_icmpge 54\n 39: iload_2\n 40: istore 5\n 42: aload 4\n 44: iload 5\n 46: iconst_m1\n 47: iastore\n 48: iinc 2, 1\n 51: goto 34\n 54: aload 6\n 56: aload 4\n 58: putfield #21 // Field idIndex:[I\n 61: return\n\n public final int getSize();\n Code:\n 0: aload_0\n 1: getfield #29 // Field size:I\n 4: ireturn\n\n public final void setSize(int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #29 // Field size:I\n 5: return\n\n public final void push(int, float);\n Code:\n 0: aload_0\n 1: getfield #29 // Field size:I\n 4: aload_0\n 5: getfield #13 // Field k:I\n 8: if_icmpge 61\n 11: aload_0\n 12: getfield #17 // Field heap:[F\n 15: aload_0\n 16: getfield #29 // Field size:I\n 19: fload_2\n 20: fastore\n 21: aload_0\n 22: getfield #21 // Field idIndex:[I\n 25: aload_0\n 26: getfield #29 // Field size:I\n 29: iload_1\n 30: iastore\n 31: aload_0\n 32: getfield #29 // Field size:I\n 35: istore_3\n 36: aload_0\n 37: iload_3\n 38: iconst_1\n 39: iadd\n 40: putfield #29 // Field size:I\n 43: aload_0\n 44: getfield #29 // Field size:I\n 47: aload_0\n 48: getfield #13 // Field k:I\n 51: if_icmpne 91\n 54: aload_0\n 55: invokespecial #36 // Method buildMinHeap:()V\n 58: goto 91\n 61: fload_2\n 62: aload_0\n 63: getfield #17 // Field heap:[F\n 66: iconst_0\n 67: faload\n 68: fcmpg\n 69: ifge 91\n 72: aload_0\n 73: getfield #17 // Field heap:[F\n 76: iconst_0\n 77: fload_2\n 78: fastore\n 79: aload_0\n 80: getfield #21 // Field idIndex:[I\n 83: iconst_0\n 84: iload_1\n 85: iastore\n 86: aload_0\n 87: iconst_0\n 88: invokespecial #39 // Method topify:(I)V\n 91: return\n\n public final java.util.ArrayList<kotlin.Pair<java.lang.Integer, java.lang.Float>> result();\n Code:\n 0: aload_0\n 1: getfield #13 // Field k:I\n 4: aload_0\n 5: getfield #29 // Field size:I\n 8: invokestatic #52 // Method java/lang/Math.min:(II)I\n 11: istore_1\n 12: new #54 // class java/util/ArrayList\n 15: dup\n 16: iload_1\n 17: invokespecial #56 // Method java/util/ArrayList.\"<init>\":(I)V\n 20: astore_2\n 21: iconst_0\n 22: istore_3\n 23: iload_3\n 24: iload_1\n 25: if_icmpge 65\n 28: aload_2\n 29: checkcast #58 // class java/util/Collection\n 32: aload_0\n 33: getfield #21 // Field idIndex:[I\n 36: iload_3\n 37: iaload\n 38: invokestatic #64 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 41: aload_0\n 42: getfield #17 // Field heap:[F\n 45: iload_3\n 46: faload\n 47: invokestatic #69 // Method java/lang/Float.valueOf:(F)Ljava/lang/Float;\n 50: invokestatic #75 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 53: invokeinterface #79, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 58: pop\n 59: iinc 3, 1\n 62: goto 23\n 65: aload_2\n 66: checkcast #81 // class java/util/List\n 69: astore_3\n 70: iconst_0\n 71: istore 4\n 73: aload_3\n 74: invokeinterface #83, 1 // InterfaceMethod java/util/List.size:()I\n 79: iconst_1\n 80: if_icmple 97\n 83: aload_3\n 84: new #85 // class com/mayabot/nlp/algorithm/TopIntMinK$result$$inlined$sortBy$1\n 87: dup\n 88: invokespecial #86 // Method com/mayabot/nlp/algorithm/TopIntMinK$result$$inlined$sortBy$1.\"<init>\":()V\n 91: checkcast #88 // class java/util/Comparator\n 94: invokestatic #94 // Method kotlin/collections/CollectionsKt.sortWith:(Ljava/util/List;Ljava/util/Comparator;)V\n 97: nop\n 98: aload_2\n 99: areturn\n\n private final void buildMinHeap();\n Code:\n 0: aload_0\n 1: getfield #13 // Field k:I\n 4: iconst_2\n 5: idiv\n 6: iconst_1\n 7: isub\n 8: istore_1\n 9: iconst_m1\n 10: iload_1\n 11: if_icmpge 25\n 14: aload_0\n 15: iload_1\n 16: invokespecial #39 // Method topify:(I)V\n 19: iinc 1, -1\n 22: goto 9\n 25: return\n\n private final void topify(int);\n Code:\n 0: iconst_2\n 1: iload_1\n 2: imul\n 3: iconst_1\n 4: iadd\n 5: istore_2\n 6: iconst_2\n 7: iload_1\n 8: imul\n 9: iconst_2\n 10: iadd\n 11: istore_3\n 12: iconst_0\n 13: istore 4\n 15: iload_2\n 16: aload_0\n 17: getfield #13 // Field k:I\n 20: if_icmpge 45\n 23: aload_0\n 24: getfield #17 // Field heap:[F\n 27: iload_2\n 28: faload\n 29: aload_0\n 30: getfield #17 // Field heap:[F\n 33: iload_1\n 34: faload\n 35: fcmpl\n 36: ifle 45\n 39: iload_2\n 40: istore 4\n 42: goto 48\n 45: iload_1\n 46: istore 4\n 48: iload_3\n 49: aload_0\n 50: getfield #13 // Field k:I\n 53: if_icmpge 76\n 56: aload_0\n 57: getfield #17 // Field heap:[F\n 60: iload_3\n 61: faload\n 62: aload_0\n 63: getfield #17 // Field heap:[F\n 66: iload 4\n 68: faload\n 69: fcmpl\n 70: ifle 76\n 73: iload_3\n 74: istore 4\n 76: iload 4\n 78: iload_1\n 79: if_icmpeq 91\n 82: iload 4\n 84: aload_0\n 85: getfield #13 // Field k:I\n 88: if_icmplt 92\n 91: return\n 92: aload_0\n 93: iload_1\n 94: iload 4\n 96: invokespecial #105 // Method swap:(II)V\n 99: aload_0\n 100: iload 4\n 102: invokespecial #39 // Method topify:(I)V\n 105: return\n\n private final void swap(int, int);\n Code:\n 0: aload_0\n 1: getfield #17 // Field heap:[F\n 4: iload_1\n 5: faload\n 6: fstore_3\n 7: aload_0\n 8: getfield #17 // Field heap:[F\n 11: iload_1\n 12: aload_0\n 13: getfield #17 // Field heap:[F\n 16: iload_2\n 17: faload\n 18: fastore\n 19: aload_0\n 20: getfield #17 // Field heap:[F\n 23: iload_2\n 24: fload_3\n 25: fastore\n 26: aload_0\n 27: getfield #21 // Field idIndex:[I\n 30: iload_1\n 31: iaload\n 32: istore 4\n 34: aload_0\n 35: getfield #21 // Field idIndex:[I\n 38: iload_1\n 39: aload_0\n 40: getfield #21 // Field idIndex:[I\n 43: iload_2\n 44: iaload\n 45: iastore\n 46: aload_0\n 47: getfield #21 // Field idIndex:[I\n 50: iload_2\n 51: iload 4\n 53: iastore\n 54: return\n}\n", "javap_err": "" } ]
mayabot__mynlp__b980da3/mynlp/src/main/java/com/mayabot/nlp/module/nwd/ValueObjects.kt
package com.mayabot.nlp.module.nwd import kotlin.math.* class IntCount { var value : Int = 1 } /** * 词和词数量 */ class WordCount(val word: String, val count: Int) : Comparable<WordCount> { override fun compareTo(other: WordCount): Int { return other.count.compareTo(count) } } data class NewWord( val word: String, val len: Int, val freq: Int, val docFreq: Int, /** * 互信息。内聚程度 */ val mi: Float, val avg_mi: Float, /** * 左右最低熵.和两侧的黏连程度 */ val entropy: Float, val le: Float, val re: Float, val idf: Float, val isBlock: Boolean ) { var score: Float = 0f /** * 内置打分公式 */ fun doScore() { var ac = abs(le - re) if (ac == 0.0f) { ac = 0.00000000001f } score = avg_mi + log2((le * exp(re) + re * exp(le)) / ac) // score = avg_mi + entropy + idf * 1.5f + len * freq / docFreq if (isBlock) score += 1000 } } fun HashMap<Char, IntCount>.addTo(key: Char, count: Int) { this.getOrPut(key) { IntCount() }.value += count } class WordInfo(val word: String) { companion object { val empty = HashMap<Char, IntCount>() val emptySet = HashSet<Int>() } var count = 0 var mi = 0f var mi_avg = 0f // 是否被双引号 书名号包围 var isBlock = false var entropy = 0f var left = HashMap<Char, IntCount>(10) var right = HashMap<Char, IntCount>(10) var docSet = HashSet<Int>() var score = 0f var idf = 0f var doc = 0 var le = 0f var re = 0f // var tfIdf =0f fun tfIdf(docCount: Double, ziCount: Double) { val doc = docSet.size + 1 idf = log10(docCount / doc).toFloat() // tfIdf = (idf * (count/ziCount)).toFloat() docSet = emptySet this.doc = doc - 1 } fun entropy() { var leftEntropy = 0f for (entry in left) { val p = entry.value.value / count.toFloat() leftEntropy -= (p * ln(p.toDouble())).toFloat() } var rightEntropy = 0f for (entry in right) { val p = entry.value.value / count.toFloat() rightEntropy -= (p * ln(p.toDouble())).toFloat() } le = leftEntropy re = rightEntropy entropy = min(leftEntropy, rightEntropy) left = empty right = empty } }
[ { "class_path": "mayabot__mynlp__b980da3/com/mayabot/nlp/module/nwd/ValueObjectsKt.class", "javap": "Compiled from \"ValueObjects.kt\"\npublic final class com.mayabot.nlp.module.nwd.ValueObjectsKt {\n public static final void addTo(java.util.HashMap<java.lang.Character, com.mayabot.nlp.module.nwd.IntCount>, char, int);\n Code:\n 0: aload_0\n 1: ldc #10 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #18 // class java/util/Map\n 10: astore 4\n 12: iload_1\n 13: invokestatic #24 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 16: astore 5\n 18: iconst_0\n 19: istore 6\n 21: aload 4\n 23: aload 5\n 25: invokeinterface #28, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 30: astore 7\n 32: aload 7\n 34: ifnonnull 66\n 37: iconst_0\n 38: istore 8\n 40: new #30 // class com/mayabot/nlp/module/nwd/IntCount\n 43: dup\n 44: invokespecial #34 // Method com/mayabot/nlp/module/nwd/IntCount.\"<init>\":()V\n 47: astore 8\n 49: aload 4\n 51: aload 5\n 53: aload 8\n 55: invokeinterface #38, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 60: pop\n 61: aload 8\n 63: goto 68\n 66: aload 7\n 68: nop\n 69: checkcast #30 // class com/mayabot/nlp/module/nwd/IntCount\n 72: astore_3\n 73: aload_3\n 74: aload_3\n 75: invokevirtual #42 // Method com/mayabot/nlp/module/nwd/IntCount.getValue:()I\n 78: iload_2\n 79: iadd\n 80: invokevirtual #46 // Method com/mayabot/nlp/module/nwd/IntCount.setValue:(I)V\n 83: return\n}\n", "javap_err": "" } ]
mayabot__mynlp__b980da3/mynlp/src/main/java/com/mayabot/nlp/fasttext/utils/TopMaxK.kt
package com.mayabot.nlp.fasttext.utils import java.util.* import kotlin.math.min /** * 求最大Top K * 内部是小顶堆 * * @author jimichan */ class TopMaxK<T>(private val k: Int=10 ) { private val heap: FloatArray = FloatArray(k) private val idIndex: MutableList<T?> = MutableList(k){null} var size = 0 fun push(id: T, score: Float) { if (size < k) { heap[size] = score idIndex[size] = id size++ if (size == k) { buildMinHeap() } } else { // 如果这个数据大于最下值,那么有资格进入 if (score > heap[0]) { heap[0] = score idIndex[0] = id mintopify(0) } } } fun canPush(score: Float): Boolean { if (size < k) { return true } else { // 如果这个数据大于最下值,那么有资格进入 if (score > heap[0]) { return true } } return false } fun result(): ArrayList<Pair<T, Float>> { val top = min(k, size) val list = ArrayList<Pair<T, Float>>(top) for (i in 0 until top) { val v = idIndex[i] val s = heap[i] if(v!=null){ list += v to s } } list.sortByDescending { it.second } return list } private fun buildMinHeap() { for (i in k / 2 - 1 downTo 0) { // 依次向上将当前子树最大堆化 mintopify(i) } } /** * 让heap数组符合堆特性 * * @param i */ private fun mintopify(i: Int) { val l = 2 * i + 1 val r = 2 * i + 2 var min = 0 min = if (l < k && heap[l] < heap[i]) { l } else { i } if (r < k && heap[r] < heap[min]) { min = r } if (min == i || min >= k) { // 如果largest等于i说明i是最大元素 // largest超出heap范围说明不存在比i节点大的子女 return } swap(i, min) mintopify(min) } private fun swap(i: Int, j: Int) { val tmp = heap[i] heap[i] = heap[j] heap[j] = tmp val tmp2 = idIndex[i] idIndex[i] = idIndex[j] idIndex[j] = tmp2 } }
[ { "class_path": "mayabot__mynlp__b980da3/com/mayabot/nlp/fasttext/utils/TopMaxK$result$$inlined$sortByDescending$1.class", "javap": "Compiled from \"Comparisons.kt\"\npublic final class com.mayabot.nlp.fasttext.utils.TopMaxK$result$$inlined$sortByDescending$1<T> implements java.util.Comparator {\n public com.mayabot.nlp.fasttext.utils.TopMaxK$result$$inlined$sortByDescending$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_2\n 1: checkcast #23 // class kotlin/Pair\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 12: checkcast #29 // class java/lang/Float\n 15: checkcast #31 // class java/lang/Comparable\n 18: aload_1\n 19: checkcast #23 // class kotlin/Pair\n 22: astore_3\n 23: astore 5\n 25: iconst_0\n 26: istore 4\n 28: aload_3\n 29: invokevirtual #27 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 32: checkcast #29 // class java/lang/Float\n 35: aload 5\n 37: swap\n 38: checkcast #31 // class java/lang/Comparable\n 41: invokestatic #37 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 44: ireturn\n}\n", "javap_err": "" }, { "class_path": "mayabot__mynlp__b980da3/com/mayabot/nlp/fasttext/utils/TopMaxK.class", "javap": "Compiled from \"TopMaxK.kt\"\npublic final class com.mayabot.nlp.fasttext.utils.TopMaxK<T> {\n private final int k;\n\n private final float[] heap;\n\n private final java.util.List<T> idIndex;\n\n private int size;\n\n public com.mayabot.nlp.fasttext.utils.TopMaxK(int);\n Code:\n 0: aload_0\n 1: invokespecial #10 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #14 // Field k:I\n 9: aload_0\n 10: aload_0\n 11: getfield #14 // Field k:I\n 14: newarray float\n 16: putfield #18 // Field heap:[F\n 19: aload_0\n 20: aload_0\n 21: getfield #14 // Field k:I\n 24: istore_2\n 25: astore 8\n 27: new #20 // class java/util/ArrayList\n 30: dup\n 31: iload_2\n 32: invokespecial #22 // Method java/util/ArrayList.\"<init>\":(I)V\n 35: astore_3\n 36: iconst_0\n 37: istore 4\n 39: iload 4\n 41: iload_2\n 42: if_icmpge 73\n 45: iload 4\n 47: istore 5\n 49: aload_3\n 50: iload 5\n 52: istore 6\n 54: astore 9\n 56: iconst_0\n 57: istore 7\n 59: aconst_null\n 60: aload 9\n 62: swap\n 63: invokevirtual #26 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 66: pop\n 67: iinc 4, 1\n 70: goto 39\n 73: aload_3\n 74: checkcast #28 // class java/util/List\n 77: aload 8\n 79: swap\n 80: putfield #32 // Field idIndex:Ljava/util/List;\n 83: return\n\n public com.mayabot.nlp.fasttext.utils.TopMaxK(int, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 9\n 6: bipush 10\n 8: istore_1\n 9: aload_0\n 10: iload_1\n 11: invokespecial #38 // Method \"<init>\":(I)V\n 14: return\n\n public final int getSize();\n Code:\n 0: aload_0\n 1: getfield #43 // Field size:I\n 4: ireturn\n\n public final void setSize(int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #43 // Field size:I\n 5: return\n\n public final void push(T, float);\n Code:\n 0: aload_0\n 1: getfield #43 // Field size:I\n 4: aload_0\n 5: getfield #14 // Field k:I\n 8: if_icmpge 66\n 11: aload_0\n 12: getfield #18 // Field heap:[F\n 15: aload_0\n 16: getfield #43 // Field size:I\n 19: fload_2\n 20: fastore\n 21: aload_0\n 22: getfield #32 // Field idIndex:Ljava/util/List;\n 25: aload_0\n 26: getfield #43 // Field size:I\n 29: aload_1\n 30: invokeinterface #52, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 35: pop\n 36: aload_0\n 37: getfield #43 // Field size:I\n 40: istore_3\n 41: aload_0\n 42: iload_3\n 43: iconst_1\n 44: iadd\n 45: putfield #43 // Field size:I\n 48: aload_0\n 49: getfield #43 // Field size:I\n 52: aload_0\n 53: getfield #14 // Field k:I\n 56: if_icmpne 101\n 59: aload_0\n 60: invokespecial #55 // Method buildMinHeap:()V\n 63: goto 101\n 66: fload_2\n 67: aload_0\n 68: getfield #18 // Field heap:[F\n 71: iconst_0\n 72: faload\n 73: fcmpl\n 74: ifle 101\n 77: aload_0\n 78: getfield #18 // Field heap:[F\n 81: iconst_0\n 82: fload_2\n 83: fastore\n 84: aload_0\n 85: getfield #32 // Field idIndex:Ljava/util/List;\n 88: iconst_0\n 89: aload_1\n 90: invokeinterface #52, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 95: pop\n 96: aload_0\n 97: iconst_0\n 98: invokespecial #58 // Method mintopify:(I)V\n 101: return\n\n public final boolean canPush(float);\n Code:\n 0: aload_0\n 1: getfield #43 // Field size:I\n 4: aload_0\n 5: getfield #14 // Field k:I\n 8: if_icmpge 13\n 11: iconst_1\n 12: ireturn\n 13: fload_1\n 14: aload_0\n 15: getfield #18 // Field heap:[F\n 18: iconst_0\n 19: faload\n 20: fcmpl\n 21: ifle 26\n 24: iconst_1\n 25: ireturn\n 26: iconst_0\n 27: ireturn\n\n public final java.util.ArrayList<kotlin.Pair<T, java.lang.Float>> result();\n Code:\n 0: aload_0\n 1: getfield #14 // Field k:I\n 4: aload_0\n 5: getfield #43 // Field size:I\n 8: invokestatic #74 // Method java/lang/Math.min:(II)I\n 11: istore_1\n 12: new #20 // class java/util/ArrayList\n 15: dup\n 16: iload_1\n 17: invokespecial #22 // Method java/util/ArrayList.\"<init>\":(I)V\n 20: astore_2\n 21: iconst_0\n 22: istore_3\n 23: iload_3\n 24: iload_1\n 25: if_icmpge 79\n 28: aload_0\n 29: getfield #32 // Field idIndex:Ljava/util/List;\n 32: iload_3\n 33: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 38: astore 4\n 40: aload_0\n 41: getfield #18 // Field heap:[F\n 44: iload_3\n 45: faload\n 46: fstore 5\n 48: aload 4\n 50: ifnull 73\n 53: aload_2\n 54: checkcast #80 // class java/util/Collection\n 57: aload 4\n 59: fload 5\n 61: invokestatic #86 // Method java/lang/Float.valueOf:(F)Ljava/lang/Float;\n 64: invokestatic #92 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 67: invokeinterface #93, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 72: pop\n 73: iinc 3, 1\n 76: goto 23\n 79: aload_2\n 80: checkcast #28 // class java/util/List\n 83: astore_3\n 84: iconst_0\n 85: istore 4\n 87: aload_3\n 88: invokeinterface #95, 1 // InterfaceMethod java/util/List.size:()I\n 93: iconst_1\n 94: if_icmple 111\n 97: aload_3\n 98: new #97 // class com/mayabot/nlp/fasttext/utils/TopMaxK$result$$inlined$sortByDescending$1\n 101: dup\n 102: invokespecial #98 // Method com/mayabot/nlp/fasttext/utils/TopMaxK$result$$inlined$sortByDescending$1.\"<init>\":()V\n 105: checkcast #100 // class java/util/Comparator\n 108: invokestatic #106 // Method kotlin/collections/CollectionsKt.sortWith:(Ljava/util/List;Ljava/util/Comparator;)V\n 111: nop\n 112: aload_2\n 113: areturn\n\n private final void buildMinHeap();\n Code:\n 0: aload_0\n 1: getfield #14 // Field k:I\n 4: iconst_2\n 5: idiv\n 6: iconst_1\n 7: isub\n 8: istore_1\n 9: iconst_m1\n 10: iload_1\n 11: if_icmpge 25\n 14: aload_0\n 15: iload_1\n 16: invokespecial #58 // Method mintopify:(I)V\n 19: iinc 1, -1\n 22: goto 9\n 25: return\n\n private final void mintopify(int);\n Code:\n 0: iconst_2\n 1: iload_1\n 2: imul\n 3: iconst_1\n 4: iadd\n 5: istore_2\n 6: iconst_2\n 7: iload_1\n 8: imul\n 9: iconst_2\n 10: iadd\n 11: istore_3\n 12: iconst_0\n 13: istore 4\n 15: iload_2\n 16: aload_0\n 17: getfield #14 // Field k:I\n 20: if_icmpge 43\n 23: aload_0\n 24: getfield #18 // Field heap:[F\n 27: iload_2\n 28: faload\n 29: aload_0\n 30: getfield #18 // Field heap:[F\n 33: iload_1\n 34: faload\n 35: fcmpg\n 36: ifge 43\n 39: iload_2\n 40: goto 44\n 43: iload_1\n 44: istore 4\n 46: iload_3\n 47: aload_0\n 48: getfield #14 // Field k:I\n 51: if_icmpge 74\n 54: aload_0\n 55: getfield #18 // Field heap:[F\n 58: iload_3\n 59: faload\n 60: aload_0\n 61: getfield #18 // Field heap:[F\n 64: iload 4\n 66: faload\n 67: fcmpg\n 68: ifge 74\n 71: iload_3\n 72: istore 4\n 74: iload 4\n 76: iload_1\n 77: if_icmpeq 89\n 80: iload 4\n 82: aload_0\n 83: getfield #14 // Field k:I\n 86: if_icmplt 90\n 89: return\n 90: aload_0\n 91: iload_1\n 92: iload 4\n 94: invokespecial #118 // Method swap:(II)V\n 97: aload_0\n 98: iload 4\n 100: invokespecial #58 // Method mintopify:(I)V\n 103: return\n\n private final void swap(int, int);\n Code:\n 0: aload_0\n 1: getfield #18 // Field heap:[F\n 4: iload_1\n 5: faload\n 6: fstore_3\n 7: aload_0\n 8: getfield #18 // Field heap:[F\n 11: iload_1\n 12: aload_0\n 13: getfield #18 // Field heap:[F\n 16: iload_2\n 17: faload\n 18: fastore\n 19: aload_0\n 20: getfield #18 // Field heap:[F\n 23: iload_2\n 24: fload_3\n 25: fastore\n 26: aload_0\n 27: getfield #32 // Field idIndex:Ljava/util/List;\n 30: iload_1\n 31: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 36: astore 4\n 38: aload_0\n 39: getfield #32 // Field idIndex:Ljava/util/List;\n 42: iload_1\n 43: aload_0\n 44: getfield #32 // Field idIndex:Ljava/util/List;\n 47: iload_2\n 48: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 53: invokeinterface #52, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 58: pop\n 59: aload_0\n 60: getfield #32 // Field idIndex:Ljava/util/List;\n 63: iload_2\n 64: aload 4\n 66: invokeinterface #52, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 71: pop\n 72: return\n\n public com.mayabot.nlp.fasttext.utils.TopMaxK();\n Code:\n 0: aload_0\n 1: iconst_0\n 2: iconst_1\n 3: aconst_null\n 4: invokespecial #125 // Method \"<init>\":(IILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 7: return\n}\n", "javap_err": "" } ]
daincredibleholg__AdventOfCode2023__4aa7c68/src/main/kotlin/io/steinh/aoc/day06/BoatRace.kt
package io.steinh.aoc.day06 class BoatRace(private val input: BoatRaceStats) { fun calculateWaysToBeatTheRecord(): Int { val possibleWins = buildList { input.timeToDistance.forEach { (time, distance) -> add( buildList { for (i in 1..time) { if (((time - i).times(i)) > distance) { add(i) } } } ) } } return possibleWins.map { it.size }.reduce { acc, next -> acc * next } } fun calculateForOneLargeRace(): Int { val longTime = input.timeToDistance.keys.map { it.toString() }.reduce { acc, next -> "$acc$next" }.toLong() val longDistance = input.timeToDistance.values.map { it.toString() }.reduce { acc, next -> "$acc$next" }.toLong() var count = 0 for (i in 1..longTime) { if ((longTime - i).times(i) > longDistance) { count++ } } return count } } data class BoatRaceStats( val timeToDistance: Map<Int, Int> ) fun interpretStats(input: String): BoatRaceStats { val inputLines = input.split("\n") val times = "(\\d+)".toRegex().findAll(inputLines[0]) .map { it.groupValues[0].toInt() } .toList() val distances = "(\\d+)".toRegex().findAll(inputLines[1]) .map { it.groupValues[0].toInt() } .toList() return BoatRaceStats( timeToDistance = times.zip(distances) { t, d -> t to d }.toMap() ) } fun main() { val input = {}.javaClass.classLoader?.getResource("day06/input.txt")?.readText()!! val boatRace = BoatRace(interpretStats(input)) val partOneResult = boatRace.calculateWaysToBeatTheRecord() println("Result for day 06, part I: $partOneResult") val partTwoResult = boatRace.calculateForOneLargeRace() println("Result for day 06, part II: $partTwoResult") }
[ { "class_path": "daincredibleholg__AdventOfCode2023__4aa7c68/io/steinh/aoc/day06/BoatRace.class", "javap": "Compiled from \"BoatRace.kt\"\npublic final class io.steinh.aoc.day06.BoatRace {\n private final io.steinh.aoc.day06.BoatRaceStats input;\n\n public io.steinh.aoc.day06.BoatRace(io.steinh.aoc.day06.BoatRaceStats);\n Code:\n 0: aload_1\n 1: ldc #9 // String input\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #18 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #21 // Field input:Lio/steinh/aoc/day06/BoatRaceStats;\n 15: return\n\n public final int calculateWaysToBeatTheRecord();\n Code:\n 0: invokestatic #31 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 3: astore_2\n 4: aload_2\n 5: astore_3\n 6: iconst_0\n 7: istore 4\n 9: aload_0\n 10: getfield #21 // Field input:Lio/steinh/aoc/day06/BoatRaceStats;\n 13: invokevirtual #37 // Method io/steinh/aoc/day06/BoatRaceStats.getTimeToDistance:()Ljava/util/Map;\n 16: astore 5\n 18: iconst_0\n 19: istore 6\n 21: aload 5\n 23: invokeinterface #43, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 28: invokeinterface #49, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 33: astore 7\n 35: aload 7\n 37: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 42: ifeq 177\n 45: aload 7\n 47: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 52: checkcast #61 // class java/util/Map$Entry\n 55: astore 8\n 57: aload 8\n 59: astore 9\n 61: iconst_0\n 62: istore 10\n 64: aload 9\n 66: invokeinterface #64, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 71: checkcast #66 // class java/lang/Number\n 74: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 77: istore 11\n 79: aload 9\n 81: invokeinterface #72, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 86: checkcast #66 // class java/lang/Number\n 89: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 92: istore 12\n 94: aload_3\n 95: invokestatic #31 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 98: astore 13\n 100: aload 13\n 102: astore 14\n 104: astore 15\n 106: iconst_0\n 107: istore 16\n 109: iconst_1\n 110: istore 17\n 112: iload 17\n 114: iload 11\n 116: if_icmpgt 158\n 119: iload 11\n 121: iload 17\n 123: isub\n 124: iload 17\n 126: imul\n 127: iload 12\n 129: if_icmple 145\n 132: aload 14\n 134: iload 17\n 136: invokestatic #78 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 139: invokeinterface #84, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 144: pop\n 145: iload 17\n 147: iload 11\n 149: if_icmpeq 158\n 152: iinc 17, 1\n 155: goto 119\n 158: nop\n 159: aload 15\n 161: aload 13\n 163: invokestatic #88 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 166: invokeinterface #84, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 171: pop\n 172: nop\n 173: nop\n 174: goto 35\n 177: nop\n 178: nop\n 179: aload_2\n 180: invokestatic #88 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 183: astore_1\n 184: aload_1\n 185: checkcast #90 // class java/lang/Iterable\n 188: astore_2\n 189: iconst_0\n 190: istore_3\n 191: aload_2\n 192: astore 4\n 194: new #92 // class java/util/ArrayList\n 197: dup\n 198: aload_2\n 199: bipush 10\n 201: invokestatic #96 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 204: invokespecial #99 // Method java/util/ArrayList.\"<init>\":(I)V\n 207: checkcast #101 // class java/util/Collection\n 210: astore 5\n 212: iconst_0\n 213: istore 6\n 215: aload 4\n 217: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 222: astore 7\n 224: aload 7\n 226: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 231: ifeq 279\n 234: aload 7\n 236: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 241: astore 8\n 243: aload 5\n 245: aload 8\n 247: checkcast #80 // class java/util/List\n 250: astore 9\n 252: astore 18\n 254: iconst_0\n 255: istore 10\n 257: aload 9\n 259: invokeinterface #105, 1 // InterfaceMethod java/util/List.size:()I\n 264: invokestatic #78 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 267: aload 18\n 269: swap\n 270: invokeinterface #106, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 275: pop\n 276: goto 224\n 279: aload 5\n 281: checkcast #80 // class java/util/List\n 284: nop\n 285: checkcast #90 // class java/lang/Iterable\n 288: astore_2\n 289: nop\n 290: iconst_0\n 291: istore_3\n 292: aload_2\n 293: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 298: astore 4\n 300: aload 4\n 302: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 307: ifne 320\n 310: new #108 // class java/lang/UnsupportedOperationException\n 313: dup\n 314: ldc #110 // String Empty collection can\\'t be reduced.\n 316: invokespecial #113 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 319: athrow\n 320: aload 4\n 322: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 327: astore 5\n 329: aload 4\n 331: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 336: ifeq 380\n 339: aload 5\n 341: aload 4\n 343: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 348: checkcast #66 // class java/lang/Number\n 351: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 354: istore 6\n 356: checkcast #66 // class java/lang/Number\n 359: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 362: istore 7\n 364: iconst_0\n 365: istore 8\n 367: iload 7\n 369: iload 6\n 371: imul\n 372: invokestatic #78 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 375: astore 5\n 377: goto 329\n 380: aload 5\n 382: checkcast #66 // class java/lang/Number\n 385: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 388: ireturn\n\n public final int calculateForOneLargeRace();\n Code:\n 0: aload_0\n 1: getfield #21 // Field input:Lio/steinh/aoc/day06/BoatRaceStats;\n 4: invokevirtual #37 // Method io/steinh/aoc/day06/BoatRaceStats.getTimeToDistance:()Ljava/util/Map;\n 7: invokeinterface #151, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 12: checkcast #90 // class java/lang/Iterable\n 15: astore_3\n 16: iconst_0\n 17: istore 4\n 19: aload_3\n 20: astore 5\n 22: new #92 // class java/util/ArrayList\n 25: dup\n 26: aload_3\n 27: bipush 10\n 29: invokestatic #96 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 32: invokespecial #99 // Method java/util/ArrayList.\"<init>\":(I)V\n 35: checkcast #101 // class java/util/Collection\n 38: astore 6\n 40: iconst_0\n 41: istore 7\n 43: aload 5\n 45: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 8\n 52: aload 8\n 54: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 105\n 62: aload 8\n 64: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 9\n 71: aload 6\n 73: aload 9\n 75: checkcast #66 // class java/lang/Number\n 78: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 81: istore 10\n 83: astore 14\n 85: iconst_0\n 86: istore 11\n 88: iload 10\n 90: invokestatic #156 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 93: aload 14\n 95: swap\n 96: invokeinterface #106, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 101: pop\n 102: goto 52\n 105: aload 6\n 107: checkcast #80 // class java/util/List\n 110: nop\n 111: checkcast #90 // class java/lang/Iterable\n 114: astore_3\n 115: nop\n 116: iconst_0\n 117: istore 4\n 119: aload_3\n 120: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 125: astore 5\n 127: aload 5\n 129: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 134: ifne 147\n 137: new #108 // class java/lang/UnsupportedOperationException\n 140: dup\n 141: ldc #110 // String Empty collection can\\'t be reduced.\n 143: invokespecial #113 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 146: athrow\n 147: aload 5\n 149: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 154: astore 6\n 156: aload 5\n 158: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 163: ifeq 213\n 166: aload 6\n 168: aload 5\n 170: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 175: checkcast #153 // class java/lang/String\n 178: astore 7\n 180: checkcast #153 // class java/lang/String\n 183: astore 8\n 185: iconst_0\n 186: istore 9\n 188: new #158 // class java/lang/StringBuilder\n 191: dup\n 192: invokespecial #159 // Method java/lang/StringBuilder.\"<init>\":()V\n 195: aload 8\n 197: invokevirtual #163 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 200: aload 7\n 202: invokevirtual #163 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 205: invokevirtual #167 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 208: astore 6\n 210: goto 156\n 213: aload 6\n 215: checkcast #153 // class java/lang/String\n 218: invokestatic #173 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 221: lstore_1\n 222: aload_0\n 223: getfield #21 // Field input:Lio/steinh/aoc/day06/BoatRaceStats;\n 226: invokevirtual #37 // Method io/steinh/aoc/day06/BoatRaceStats.getTimeToDistance:()Ljava/util/Map;\n 229: invokeinterface #177, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 234: checkcast #90 // class java/lang/Iterable\n 237: astore 5\n 239: iconst_0\n 240: istore 6\n 242: aload 5\n 244: astore 7\n 246: new #92 // class java/util/ArrayList\n 249: dup\n 250: aload 5\n 252: bipush 10\n 254: invokestatic #96 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 257: invokespecial #99 // Method java/util/ArrayList.\"<init>\":(I)V\n 260: checkcast #101 // class java/util/Collection\n 263: astore 8\n 265: iconst_0\n 266: istore 9\n 268: aload 7\n 270: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 275: astore 10\n 277: aload 10\n 279: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 284: ifeq 330\n 287: aload 10\n 289: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 294: astore 11\n 296: aload 8\n 298: aload 11\n 300: checkcast #66 // class java/lang/Number\n 303: invokevirtual #69 // Method java/lang/Number.intValue:()I\n 306: istore 12\n 308: astore 14\n 310: iconst_0\n 311: istore 13\n 313: iload 12\n 315: invokestatic #156 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 318: aload 14\n 320: swap\n 321: invokeinterface #106, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 326: pop\n 327: goto 277\n 330: aload 8\n 332: checkcast #80 // class java/util/List\n 335: nop\n 336: checkcast #90 // class java/lang/Iterable\n 339: astore 5\n 341: nop\n 342: iconst_0\n 343: istore 6\n 345: aload 5\n 347: invokeinterface #102, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 352: astore 7\n 354: aload 7\n 356: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 361: ifne 374\n 364: new #108 // class java/lang/UnsupportedOperationException\n 367: dup\n 368: ldc #110 // String Empty collection can\\'t be reduced.\n 370: invokespecial #113 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 373: athrow\n 374: aload 7\n 376: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 381: astore 8\n 383: aload 7\n 385: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 390: ifeq 440\n 393: aload 8\n 395: aload 7\n 397: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 402: checkcast #153 // class java/lang/String\n 405: astore 9\n 407: checkcast #153 // class java/lang/String\n 410: astore 10\n 412: iconst_0\n 413: istore 11\n 415: new #158 // class java/lang/StringBuilder\n 418: dup\n 419: invokespecial #159 // Method java/lang/StringBuilder.\"<init>\":()V\n 422: aload 10\n 424: invokevirtual #163 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 427: aload 9\n 429: invokevirtual #163 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 432: invokevirtual #167 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 435: astore 8\n 437: goto 383\n 440: aload 8\n 442: checkcast #153 // class java/lang/String\n 445: invokestatic #173 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 448: lstore_3\n 449: iconst_0\n 450: istore 5\n 452: lconst_1\n 453: lstore 6\n 455: lload 6\n 457: lload_1\n 458: lcmp\n 459: ifgt 493\n 462: lload_1\n 463: lload 6\n 465: lsub\n 466: lload 6\n 468: lmul\n 469: lload_3\n 470: lcmp\n 471: ifle 477\n 474: iinc 5, 1\n 477: lload 6\n 479: lload_1\n 480: lcmp\n 481: ifeq 493\n 484: lload 6\n 486: lconst_1\n 487: ladd\n 488: lstore 6\n 490: goto 462\n 493: iload 5\n 495: ireturn\n}\n", "javap_err": "" }, { "class_path": "daincredibleholg__AdventOfCode2023__4aa7c68/io/steinh/aoc/day06/BoatRaceKt.class", "javap": "Compiled from \"BoatRace.kt\"\npublic final class io.steinh.aoc.day06.BoatRaceKt {\n public static final io.steinh.aoc.day06.BoatRaceStats interpretStats(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #9 // String input\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #17 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #19 // class java/lang/String\n 14: astore_2\n 15: aload_2\n 16: iconst_0\n 17: ldc #21 // String \\n\n 19: aastore\n 20: aload_2\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #27 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: astore_1\n 30: new #29 // class kotlin/text/Regex\n 33: dup\n 34: ldc #31 // String (\\\\d+)\n 36: invokespecial #35 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 39: aload_1\n 40: iconst_0\n 41: invokeinterface #41, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 46: checkcast #17 // class java/lang/CharSequence\n 49: iconst_0\n 50: iconst_2\n 51: aconst_null\n 52: invokestatic #45 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 55: invokedynamic #65, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 60: invokestatic #71 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 63: invokestatic #75 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 66: astore_2\n 67: new #29 // class kotlin/text/Regex\n 70: dup\n 71: ldc #31 // String (\\\\d+)\n 73: invokespecial #35 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 76: aload_1\n 77: iconst_1\n 78: invokeinterface #41, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 83: checkcast #17 // class java/lang/CharSequence\n 86: iconst_0\n 87: iconst_2\n 88: aconst_null\n 89: invokestatic #45 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 92: invokedynamic #80, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 97: invokestatic #71 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 100: invokestatic #75 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 103: astore_3\n 104: aload_2\n 105: checkcast #82 // class java/lang/Iterable\n 108: astore 4\n 110: iconst_0\n 111: istore 5\n 113: aload 4\n 115: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 120: astore 6\n 122: aload_3\n 123: checkcast #82 // class java/lang/Iterable\n 126: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 131: astore 7\n 133: new #88 // class java/util/ArrayList\n 136: dup\n 137: aload 4\n 139: bipush 10\n 141: invokestatic #94 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 144: aload_3\n 145: checkcast #82 // class java/lang/Iterable\n 148: bipush 10\n 150: invokestatic #94 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 153: invokestatic #100 // Method java/lang/Math.min:(II)I\n 156: invokespecial #103 // Method java/util/ArrayList.\"<init>\":(I)V\n 159: astore 8\n 161: aload 6\n 163: invokeinterface #109, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 168: ifeq 241\n 171: aload 7\n 173: invokeinterface #109, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 178: ifeq 241\n 181: aload 8\n 183: aload 6\n 185: invokeinterface #113, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 190: aload 7\n 192: invokeinterface #113, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 197: checkcast #115 // class java/lang/Number\n 200: invokevirtual #119 // Method java/lang/Number.intValue:()I\n 203: istore 9\n 205: checkcast #115 // class java/lang/Number\n 208: invokevirtual #119 // Method java/lang/Number.intValue:()I\n 211: istore 10\n 213: astore 12\n 215: iconst_0\n 216: istore 11\n 218: iload 10\n 220: invokestatic #125 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 223: iload 9\n 225: invokestatic #125 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 228: invokestatic #131 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 231: aload 12\n 233: swap\n 234: invokevirtual #135 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 237: pop\n 238: goto 161\n 241: aload 8\n 243: checkcast #37 // class java/util/List\n 246: checkcast #82 // class java/lang/Iterable\n 249: invokestatic #141 // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;\n 252: astore 13\n 254: new #143 // class io/steinh/aoc/day06/BoatRaceStats\n 257: dup\n 258: aload 13\n 260: invokespecial #146 // Method io/steinh/aoc/day06/BoatRaceStats.\"<init>\":(Ljava/util/Map;)V\n 263: areturn\n\n public static final void main();\n Code:\n 0: invokedynamic #175, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function0;\n 5: invokevirtual #179 // Method java/lang/Object.getClass:()Ljava/lang/Class;\n 8: invokevirtual #185 // Method java/lang/Class.getClassLoader:()Ljava/lang/ClassLoader;\n 11: dup\n 12: ifnull 50\n 15: ldc #187 // String day06/input.txt\n 17: invokevirtual #193 // Method java/lang/ClassLoader.getResource:(Ljava/lang/String;)Ljava/net/URL;\n 20: dup\n 21: ifnull 50\n 24: astore_3\n 25: getstatic #199 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 28: astore 4\n 30: aload_3\n 31: invokestatic #205 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B\n 34: astore 5\n 36: new #19 // class java/lang/String\n 39: dup\n 40: aload 5\n 42: aload 4\n 44: invokespecial #208 // Method java/lang/String.\"<init>\":([BLjava/nio/charset/Charset;)V\n 47: goto 52\n 50: pop\n 51: aconst_null\n 52: dup\n 53: invokestatic #212 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 56: astore_0\n 57: new #214 // class io/steinh/aoc/day06/BoatRace\n 60: dup\n 61: aload_0\n 62: invokestatic #216 // Method interpretStats:(Ljava/lang/String;)Lio/steinh/aoc/day06/BoatRaceStats;\n 65: invokespecial #219 // Method io/steinh/aoc/day06/BoatRace.\"<init>\":(Lio/steinh/aoc/day06/BoatRaceStats;)V\n 68: astore_1\n 69: aload_1\n 70: invokevirtual #222 // Method io/steinh/aoc/day06/BoatRace.calculateWaysToBeatTheRecord:()I\n 73: istore_2\n 74: new #224 // class java/lang/StringBuilder\n 77: dup\n 78: invokespecial #226 // Method java/lang/StringBuilder.\"<init>\":()V\n 81: ldc #228 // String Result for day 06, part I:\n 83: invokevirtual #232 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 86: iload_2\n 87: invokevirtual #235 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 90: invokevirtual #239 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 93: getstatic #245 // Field java/lang/System.out:Ljava/io/PrintStream;\n 96: swap\n 97: invokevirtual #250 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 100: aload_1\n 101: invokevirtual #253 // Method io/steinh/aoc/day06/BoatRace.calculateForOneLargeRace:()I\n 104: istore_3\n 105: new #224 // class java/lang/StringBuilder\n 108: dup\n 109: invokespecial #226 // Method java/lang/StringBuilder.\"<init>\":()V\n 112: ldc #255 // String Result for day 06, part II:\n 114: invokevirtual #232 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 117: iload_3\n 118: invokevirtual #235 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 121: invokevirtual #239 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 124: getstatic #245 // Field java/lang/System.out:Ljava/io/PrintStream;\n 127: swap\n 128: invokevirtual #250 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 131: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #262 // Method main:()V\n 3: return\n\n private static final int interpretStats$lambda$0(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc_w #266 // String it\n 4: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokeinterface #272, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 13: iconst_0\n 14: invokeinterface #41, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 19: checkcast #19 // class java/lang/String\n 22: invokestatic #276 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 25: ireturn\n\n private static final int interpretStats$lambda$1(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc_w #266 // String it\n 4: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokeinterface #272, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 13: iconst_0\n 14: invokeinterface #41, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 19: checkcast #19 // class java/lang/String\n 22: invokestatic #276 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 25: ireturn\n\n private static final kotlin.Unit main$lambda$3();\n Code:\n 0: getstatic #283 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 3: areturn\n}\n", "javap_err": "" } ]
daincredibleholg__AdventOfCode2023__4aa7c68/src/main/kotlin/io/steinh/aoc/day01/Trebuchet.kt
package io.steinh.aoc.day01 class Trebuchet { fun String.replace(vararg pairs: Pair<String, String>): String = pairs.fold(this) { acc, (old, new) -> acc.replace(old, new, ignoreCase = true) } fun calibrate(input: List<String>): Int { val transformedStrings = transform(input) return transformedStrings.sumOf { s -> "${ s.first { it.isDigit() }}${ s.last { it.isDigit() }}".toInt() } } private fun transform(input: List<String>): List<String> { val regex = Regex("^(one|two|three|four|five|six|seven|eight|nine)") return buildList { for (line in input) { var transformed = "" for (i in line.indices) { if (line[i].isDigit()) { transformed += line[i] } else { transformed += when (regex.find(line.substring(i))?.value) { "one" -> "1" "two" -> "2" "three" -> "3" "four" -> "4" "five" -> "5" "six" -> "6" "seven" -> "7" "eight" -> "8" "nine" -> "9" else -> "" } } } add(transformed) } } } } fun main() { val input = {}.javaClass.classLoader?.getResource("day01/input.txt")?.readText()?.lines() val trebuchet = Trebuchet() val sum = trebuchet.calibrate(input!!) print("Result 1: $sum") }
[ { "class_path": "daincredibleholg__AdventOfCode2023__4aa7c68/io/steinh/aoc/day01/TrebuchetKt.class", "javap": "Compiled from \"Trebuchet.kt\"\npublic final class io.steinh.aoc.day01.TrebuchetKt {\n public static final void main();\n Code:\n 0: invokedynamic #25, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function0;\n 5: invokevirtual #29 // Method java/lang/Object.getClass:()Ljava/lang/Class;\n 8: invokevirtual #35 // Method java/lang/Class.getClassLoader:()Ljava/lang/ClassLoader;\n 11: dup\n 12: ifnull 56\n 15: ldc #37 // String day01/input.txt\n 17: invokevirtual #43 // Method java/lang/ClassLoader.getResource:(Ljava/lang/String;)Ljava/net/URL;\n 20: dup\n 21: ifnull 56\n 24: astore_3\n 25: getstatic #49 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 28: astore 4\n 30: aload_3\n 31: invokestatic #55 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B\n 34: astore 5\n 36: new #57 // class java/lang/String\n 39: dup\n 40: aload 5\n 42: aload 4\n 44: invokespecial #61 // Method java/lang/String.\"<init>\":([BLjava/nio/charset/Charset;)V\n 47: checkcast #63 // class java/lang/CharSequence\n 50: invokestatic #69 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 53: goto 58\n 56: pop\n 57: aconst_null\n 58: astore_0\n 59: new #71 // class io/steinh/aoc/day01/Trebuchet\n 62: dup\n 63: invokespecial #73 // Method io/steinh/aoc/day01/Trebuchet.\"<init>\":()V\n 66: astore_1\n 67: aload_1\n 68: aload_0\n 69: dup\n 70: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 73: invokevirtual #83 // Method io/steinh/aoc/day01/Trebuchet.calibrate:(Ljava/util/List;)I\n 76: istore_2\n 77: new #85 // class java/lang/StringBuilder\n 80: dup\n 81: invokespecial #86 // Method java/lang/StringBuilder.\"<init>\":()V\n 84: ldc #88 // String Result 1:\n 86: invokevirtual #92 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 89: iload_2\n 90: invokevirtual #95 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 93: invokevirtual #99 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 96: getstatic #105 // Field java/lang/System.out:Ljava/io/PrintStream;\n 99: swap\n 100: invokevirtual #110 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 103: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #121 // Method main:()V\n 3: return\n\n private static final kotlin.Unit main$lambda$0();\n Code:\n 0: getstatic #129 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 3: areturn\n}\n", "javap_err": "" }, { "class_path": "daincredibleholg__AdventOfCode2023__4aa7c68/io/steinh/aoc/day01/Trebuchet.class", "javap": "Compiled from \"Trebuchet.kt\"\npublic final class io.steinh.aoc.day01.Trebuchet {\n public io.steinh.aoc.day01.Trebuchet();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final java.lang.String replace(java.lang.String, kotlin.Pair<java.lang.String, java.lang.String>...);\n Code:\n 0: aload_1\n 1: ldc #16 // String <this>\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #24 // String pairs\n 9: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_2\n 13: astore_3\n 14: iconst_0\n 15: istore 4\n 17: aload_1\n 18: astore 5\n 20: iconst_0\n 21: istore 6\n 23: aload_3\n 24: arraylength\n 25: istore 7\n 27: iload 6\n 29: iload 7\n 31: if_icmpge 89\n 34: aload_3\n 35: iload 6\n 37: aaload\n 38: astore 8\n 40: aload 5\n 42: aload 8\n 44: astore 9\n 46: astore 10\n 48: iconst_0\n 49: istore 11\n 51: aload 9\n 53: invokevirtual #30 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 56: checkcast #32 // class java/lang/String\n 59: astore 12\n 61: aload 9\n 63: invokevirtual #35 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 66: checkcast #32 // class java/lang/String\n 69: astore 13\n 71: aload 10\n 73: aload 12\n 75: aload 13\n 77: iconst_1\n 78: invokestatic #40 // Method kotlin/text/StringsKt.replace:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)Ljava/lang/String;\n 81: astore 5\n 83: iinc 6, 1\n 86: goto 27\n 89: aload 5\n 91: areturn\n\n public final int calibrate(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #60 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokespecial #64 // Method transform:(Ljava/util/List;)Ljava/util/List;\n 11: astore_2\n 12: aload_2\n 13: checkcast #66 // class java/lang/Iterable\n 16: astore_3\n 17: iconst_0\n 18: istore 4\n 20: aload_3\n 21: invokeinterface #70, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 26: astore 5\n 28: aload 5\n 30: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 35: ifeq 264\n 38: aload 5\n 40: invokeinterface #79, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 45: astore 6\n 47: iload 4\n 49: aload 6\n 51: checkcast #32 // class java/lang/String\n 54: astore 7\n 56: istore 18\n 58: iconst_0\n 59: istore 8\n 61: new #81 // class java/lang/StringBuilder\n 64: dup\n 65: invokespecial #82 // Method java/lang/StringBuilder.\"<init>\":()V\n 68: aload 7\n 70: checkcast #84 // class java/lang/CharSequence\n 73: astore 9\n 75: astore 10\n 77: iconst_0\n 78: istore 11\n 80: iconst_0\n 81: istore 12\n 83: iload 12\n 85: aload 9\n 87: invokeinterface #88, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 92: if_icmpge 133\n 95: aload 9\n 97: iload 12\n 99: invokeinterface #92, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 104: istore 13\n 106: iload 13\n 108: istore 14\n 110: iconst_0\n 111: istore 15\n 113: iload 14\n 115: invokestatic #98 // Method java/lang/Character.isDigit:(C)Z\n 118: nop\n 119: ifeq 127\n 122: iload 13\n 124: goto 143\n 127: iinc 12, 1\n 130: goto 83\n 133: new #100 // class java/util/NoSuchElementException\n 136: dup\n 137: ldc #102 // String Char sequence contains no character matching the predicate.\n 139: invokespecial #105 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 142: athrow\n 143: istore 16\n 145: aload 10\n 147: iload 16\n 149: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 152: aload 7\n 154: checkcast #84 // class java/lang/CharSequence\n 157: astore 9\n 159: astore 10\n 161: iconst_0\n 162: istore 11\n 164: aload 9\n 166: invokeinterface #88, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 171: iconst_m1\n 172: iadd\n 173: istore 12\n 175: iconst_0\n 176: iload 12\n 178: if_icmpgt 226\n 181: iload 12\n 183: istore 13\n 185: iinc 12, -1\n 188: aload 9\n 190: iload 13\n 192: invokeinterface #92, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 197: istore 14\n 199: iload 14\n 201: istore 15\n 203: iconst_0\n 204: istore 17\n 206: iload 15\n 208: invokestatic #98 // Method java/lang/Character.isDigit:(C)Z\n 211: nop\n 212: ifeq 220\n 215: iload 14\n 217: goto 236\n 220: iconst_0\n 221: iload 12\n 223: if_icmple 181\n 226: new #100 // class java/util/NoSuchElementException\n 229: dup\n 230: ldc #102 // String Char sequence contains no character matching the predicate.\n 232: invokespecial #105 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 235: athrow\n 236: istore 16\n 238: aload 10\n 240: iload 16\n 242: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 245: invokevirtual #113 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 248: invokestatic #119 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 251: nop\n 252: istore 19\n 254: iload 18\n 256: iload 19\n 258: iadd\n 259: istore 4\n 261: goto 28\n 264: iload 4\n 266: ireturn\n\n private final java.util.List<java.lang.String> transform(java.util.List<java.lang.String>);\n Code:\n 0: new #138 // class kotlin/text/Regex\n 3: dup\n 4: ldc #140 // String ^(one|two|three|four|five|six|seven|eight|nine)\n 6: invokespecial #141 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: astore_2\n 10: invokestatic #147 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 13: astore_3\n 14: aload_3\n 15: astore 4\n 17: iconst_0\n 18: istore 5\n 20: aload_1\n 21: invokeinterface #148, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 26: astore 6\n 28: aload 6\n 30: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 35: ifeq 455\n 38: aload 6\n 40: invokeinterface #79, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 45: checkcast #32 // class java/lang/String\n 48: astore 7\n 50: ldc #150 // String\n 52: astore 8\n 54: iconst_0\n 55: istore 9\n 57: aload 7\n 59: checkcast #84 // class java/lang/CharSequence\n 62: invokeinterface #88, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 67: istore 10\n 69: iload 9\n 71: iload 10\n 73: if_icmpge 442\n 76: aload 7\n 78: iload 9\n 80: invokevirtual #151 // Method java/lang/String.charAt:(I)C\n 83: invokestatic #98 // Method java/lang/Character.isDigit:(C)Z\n 86: ifeq 119\n 89: new #81 // class java/lang/StringBuilder\n 92: dup\n 93: invokespecial #82 // Method java/lang/StringBuilder.\"<init>\":()V\n 96: aload 8\n 98: invokevirtual #154 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 101: aload 7\n 103: iload 9\n 105: invokevirtual #151 // Method java/lang/String.charAt:(I)C\n 108: invokevirtual #109 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 111: invokevirtual #113 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 114: astore 8\n 116: goto 436\n 119: new #81 // class java/lang/StringBuilder\n 122: dup\n 123: invokespecial #82 // Method java/lang/StringBuilder.\"<init>\":()V\n 126: aload 8\n 128: invokevirtual #154 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 131: aload_2\n 132: aload 7\n 134: iload 9\n 136: invokevirtual #158 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 139: dup\n 140: ldc #160 // String substring(...)\n 142: invokestatic #163 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 145: checkcast #84 // class java/lang/CharSequence\n 148: iconst_0\n 149: iconst_2\n 150: aconst_null\n 151: invokestatic #167 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 154: dup\n 155: ifnull 166\n 158: invokeinterface #172, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 163: goto 168\n 166: pop\n 167: aconst_null\n 168: astore 11\n 170: aload 11\n 172: ifnull 426\n 175: aload 11\n 177: invokevirtual #175 // Method java/lang/String.hashCode:()I\n 180: lookupswitch { // 9\n 110182: 303\n 113890: 277\n 115276: 329\n 3143346: 355\n 3149094: 290\n 3381426: 264\n 96505999: 368\n 109330445: 316\n 110339486: 342\n default: 426\n }\n 264: aload 11\n 266: ldc #177 // String nine\n 268: invokevirtual #181 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 271: ifne 421\n 274: goto 426\n 277: aload 11\n 279: ldc #183 // String six\n 281: invokevirtual #181 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 284: ifne 406\n 287: goto 426\n 290: aload 11\n 292: ldc #185 // String four\n 294: invokevirtual #181 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 297: ifne 396\n 300: goto 426\n 303: aload 11\n 305: ldc #187 // String one\n 307: invokevirtual #181 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 310: ifne 381\n 313: goto 426\n 316: aload 11\n 318: ldc #189 // String seven\n 320: invokevirtual #181 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 323: ifne 411\n 326: goto 426\n 329: aload 11\n 331: ldc #191 // String two\n 333: invokevirtual #181 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 336: ifne 386\n 339: goto 426\n 342: aload 11\n 344: ldc #193 // String three\n 346: invokevirtual #181 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 349: ifne 391\n 352: goto 426\n 355: aload 11\n 357: ldc #195 // String five\n 359: invokevirtual #181 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 362: ifne 401\n 365: goto 426\n 368: aload 11\n 370: ldc #197 // String eight\n 372: invokevirtual #181 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 375: ifne 416\n 378: goto 426\n 381: ldc #199 // String 1\n 383: goto 428\n 386: ldc #201 // String 2\n 388: goto 428\n 391: ldc #203 // String 3\n 393: goto 428\n 396: ldc #205 // String 4\n 398: goto 428\n 401: ldc #207 // String 5\n 403: goto 428\n 406: ldc #209 // String 6\n 408: goto 428\n 411: ldc #211 // String 7\n 413: goto 428\n 416: ldc #213 // String 8\n 418: goto 428\n 421: ldc #215 // String 9\n 423: goto 428\n 426: ldc #150 // String\n 428: invokevirtual #154 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 431: invokevirtual #113 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 434: astore 8\n 436: iinc 9, 1\n 439: goto 69\n 442: aload 4\n 444: aload 8\n 446: invokeinterface #218, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 451: pop\n 452: goto 28\n 455: nop\n 456: aload_3\n 457: invokestatic #221 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 460: areturn\n}\n", "javap_err": "" } ]
daincredibleholg__AdventOfCode2023__4aa7c68/src/main/kotlin/io/steinh/aoc/day04/Scratchcard.kt
package io.steinh.aoc.day04 class Scratchcard { fun calculatePoints(lines: List<String>) = getMatchingNumbers(lines).sum() fun calculateNumberOfCardsWon(lines: List<String>): Int { val givenNumberOfCards = lines.size val numberOfCards = initCardStack(givenNumberOfCards) for (line in lines) { val firstSplit = line.split(":") val cardId = firstSplit[0].substringAfter("Card ").trim().toInt() println("Processing card #$cardId:") val instancesOfThisCard = numberOfCards[cardId] println("\texisting instances: $instancesOfThisCard") val numberOfMatches = extractWinningNumbers(firstSplit[1]).size println("\tno. matching numbers: $numberOfMatches") if (numberOfMatches == 0) { println("\tNo matches, continuing to next card. Done processing card #$cardId") continue } val start = cardId + 1 if (start <= givenNumberOfCards) { val end = if (cardId + numberOfMatches < givenNumberOfCards) cardId + numberOfMatches else givenNumberOfCards println("\tWill add $instancesOfThisCard instances to cards ##" + (start..end)) for (i in start..end) { numberOfCards[i] = numberOfCards[i]!! + instancesOfThisCard!! println("\t\tAdded $instancesOfThisCard to card #$i. This card has now ${numberOfCards[i]} " + "instances.") } } println("\tDone processing card $cardId\n") } return numberOfCards .map { it.value } .sum() } private fun initCardStack(givenNumberOfCards: Int): MutableMap<Int, Int> { val result = mutableMapOf<Int, Int>() for (i in 1..givenNumberOfCards) { result[i] = 1 } return result } private fun getMatchingNumbers(lines: List<String>) = buildList { for (line in lines) { val firstSplit = line.split(":") val intersection = extractWinningNumbers(firstSplit[1]) var result = 0 for (i in 1..intersection.size) { result = if (i == 1) 1 else result * 2 } add(result) } } private fun extractWinningNumbers(matchesAndGuesses: String): Set<Int> { val winnersAndGuesses = matchesAndGuesses.split("|") val winners = winnersAndGuesses[0].split(" ") .filter { it.isNotEmpty() } .map { it.toInt() } val guesses = winnersAndGuesses[1].split(" ") .filter { it.isNotEmpty() } .map { it.toInt() } val intersection = winners.intersect(guesses.toSet()) return intersection } } fun main() { val lines = {}.javaClass.classLoader?.getResource("day04/input.txt")?.readText()?.lines()!! val scratchcard = Scratchcard() val resultPart1 = scratchcard.calculatePoints(lines) val resultPart2 = scratchcard.calculateNumberOfCardsWon(lines) println("Result day 04, part I: $resultPart1") println("Result day 04, part II: $resultPart2") }
[ { "class_path": "daincredibleholg__AdventOfCode2023__4aa7c68/io/steinh/aoc/day04/Scratchcard.class", "javap": "Compiled from \"Scratchcard.kt\"\npublic final class io.steinh.aoc.day04.Scratchcard {\n public io.steinh.aoc.day04.Scratchcard();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int calculatePoints(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String lines\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokespecial #26 // Method getMatchingNumbers:(Ljava/util/List;)Ljava/util/List;\n 11: checkcast #28 // class java/lang/Iterable\n 14: invokestatic #34 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 17: ireturn\n\n public final int calculateNumberOfCardsWon(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String lines\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokeinterface #42, 1 // InterfaceMethod java/util/List.size:()I\n 12: istore_2\n 13: aload_0\n 14: iload_2\n 15: invokespecial #46 // Method initCardStack:(I)Ljava/util/Map;\n 18: astore_3\n 19: aload_1\n 20: invokeinterface #50, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 25: astore 4\n 27: aload 4\n 29: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 34: ifeq 519\n 37: aload 4\n 39: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 44: checkcast #62 // class java/lang/String\n 47: astore 5\n 49: aload 5\n 51: checkcast #64 // class java/lang/CharSequence\n 54: iconst_1\n 55: anewarray #62 // class java/lang/String\n 58: astore 7\n 60: aload 7\n 62: iconst_0\n 63: ldc #66 // String :\n 65: aastore\n 66: aload 7\n 68: iconst_0\n 69: iconst_0\n 70: bipush 6\n 72: aconst_null\n 73: invokestatic #72 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 76: astore 6\n 78: nop\n 79: aload 6\n 81: iconst_0\n 82: invokeinterface #76, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 87: checkcast #62 // class java/lang/String\n 90: ldc #78 // String Card\n 92: aconst_null\n 93: iconst_2\n 94: aconst_null\n 95: invokestatic #82 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 98: checkcast #64 // class java/lang/CharSequence\n 101: invokestatic #86 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 104: invokevirtual #90 // Method java/lang/Object.toString:()Ljava/lang/String;\n 107: invokestatic #96 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 110: istore 7\n 112: new #98 // class java/lang/StringBuilder\n 115: dup\n 116: invokespecial #99 // Method java/lang/StringBuilder.\"<init>\":()V\n 119: ldc #101 // String Processing card #\n 121: invokevirtual #105 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 124: iload 7\n 126: invokevirtual #108 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 129: bipush 58\n 131: invokevirtual #111 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 134: invokevirtual #112 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 137: getstatic #118 // Field java/lang/System.out:Ljava/io/PrintStream;\n 140: swap\n 141: invokevirtual #124 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 144: aload_3\n 145: iload 7\n 147: invokestatic #128 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 150: invokeinterface #133, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 155: checkcast #92 // class java/lang/Integer\n 158: astore 8\n 160: new #98 // class java/lang/StringBuilder\n 163: dup\n 164: invokespecial #99 // Method java/lang/StringBuilder.\"<init>\":()V\n 167: ldc #135 // String \\texisting instances:\n 169: invokevirtual #105 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 172: aload 8\n 174: invokevirtual #138 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 177: invokevirtual #112 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 180: getstatic #118 // Field java/lang/System.out:Ljava/io/PrintStream;\n 183: swap\n 184: invokevirtual #124 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 187: aload_0\n 188: aload 6\n 190: iconst_1\n 191: invokeinterface #76, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 196: checkcast #62 // class java/lang/String\n 199: invokespecial #142 // Method extractWinningNumbers:(Ljava/lang/String;)Ljava/util/Set;\n 202: invokeinterface #145, 1 // InterfaceMethod java/util/Set.size:()I\n 207: istore 9\n 209: new #98 // class java/lang/StringBuilder\n 212: dup\n 213: invokespecial #99 // Method java/lang/StringBuilder.\"<init>\":()V\n 216: ldc #147 // String \\tno. matching numbers:\n 218: invokevirtual #105 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 221: iload 9\n 223: invokevirtual #108 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 226: invokevirtual #112 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 229: getstatic #118 // Field java/lang/System.out:Ljava/io/PrintStream;\n 232: swap\n 233: invokevirtual #124 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 236: iload 9\n 238: ifne 271\n 241: new #98 // class java/lang/StringBuilder\n 244: dup\n 245: invokespecial #99 // Method java/lang/StringBuilder.\"<init>\":()V\n 248: ldc #149 // String \\tNo matches, continuing to next card. Done processing card #\n 250: invokevirtual #105 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 253: iload 7\n 255: invokevirtual #108 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 258: invokevirtual #112 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 261: getstatic #118 // Field java/lang/System.out:Ljava/io/PrintStream;\n 264: swap\n 265: invokevirtual #124 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 268: goto 27\n 271: iload 7\n 273: iconst_1\n 274: iadd\n 275: istore 10\n 277: iload 10\n 279: iload_2\n 280: if_icmpgt 484\n 283: iload 7\n 285: iload 9\n 287: iadd\n 288: iload_2\n 289: if_icmpge 300\n 292: iload 7\n 294: iload 9\n 296: iadd\n 297: goto 301\n 300: iload_2\n 301: istore 11\n 303: new #98 // class java/lang/StringBuilder\n 306: dup\n 307: invokespecial #99 // Method java/lang/StringBuilder.\"<init>\":()V\n 310: ldc #151 // String \\tWill add\n 312: invokevirtual #105 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 315: aload 8\n 317: invokevirtual #138 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 320: ldc #153 // String instances to cards ##\n 322: invokevirtual #105 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 325: new #155 // class kotlin/ranges/IntRange\n 328: dup\n 329: iload 10\n 331: iload 11\n 333: invokespecial #158 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 336: invokevirtual #138 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 339: invokevirtual #112 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 342: getstatic #118 // Field java/lang/System.out:Ljava/io/PrintStream;\n 345: swap\n 346: invokevirtual #124 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 349: iload 10\n 351: istore 12\n 353: iload 12\n 355: iload 11\n 357: if_icmpgt 484\n 360: iload 12\n 362: invokestatic #128 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 365: astore 13\n 367: aload_3\n 368: aload 13\n 370: aload_3\n 371: iload 12\n 373: invokestatic #128 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 376: invokeinterface #133, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 381: dup\n 382: invokestatic #161 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 385: checkcast #163 // class java/lang/Number\n 388: invokevirtual #166 // Method java/lang/Number.intValue:()I\n 391: aload 8\n 393: dup\n 394: invokestatic #161 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 397: invokevirtual #167 // Method java/lang/Integer.intValue:()I\n 400: iadd\n 401: invokestatic #128 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 404: invokeinterface #171, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 409: pop\n 410: new #98 // class java/lang/StringBuilder\n 413: dup\n 414: invokespecial #99 // Method java/lang/StringBuilder.\"<init>\":()V\n 417: ldc #173 // String \\t\\tAdded\n 419: invokevirtual #105 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 422: aload 8\n 424: invokevirtual #138 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 427: ldc #175 // String to card #\n 429: invokevirtual #105 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 432: iload 12\n 434: invokevirtual #108 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 437: ldc #177 // String . This card has now\n 439: invokevirtual #105 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 442: aload_3\n 443: iload 12\n 445: invokestatic #128 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 448: invokeinterface #133, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 453: invokevirtual #138 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 456: ldc #179 // String instances.\n 458: invokevirtual #105 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 461: invokevirtual #112 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 464: getstatic #118 // Field java/lang/System.out:Ljava/io/PrintStream;\n 467: swap\n 468: invokevirtual #124 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 471: iload 12\n 473: iload 11\n 475: if_icmpeq 484\n 478: iinc 12, 1\n 481: goto 360\n 484: new #98 // class java/lang/StringBuilder\n 487: dup\n 488: invokespecial #99 // Method java/lang/StringBuilder.\"<init>\":()V\n 491: ldc #181 // String \\tDone processing card\n 493: invokevirtual #105 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 496: iload 7\n 498: invokevirtual #108 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 501: bipush 10\n 503: invokevirtual #111 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 506: invokevirtual #112 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 509: getstatic #118 // Field java/lang/System.out:Ljava/io/PrintStream;\n 512: swap\n 513: invokevirtual #124 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 516: goto 27\n 519: aload_3\n 520: astore 4\n 522: nop\n 523: iconst_0\n 524: istore 5\n 526: aload 4\n 528: astore 6\n 530: new #183 // class java/util/ArrayList\n 533: dup\n 534: aload 4\n 536: invokeinterface #184, 1 // InterfaceMethod java/util/Map.size:()I\n 541: invokespecial #187 // Method java/util/ArrayList.\"<init>\":(I)V\n 544: checkcast #189 // class java/util/Collection\n 547: astore 7\n 549: iconst_0\n 550: istore 8\n 552: aload 6\n 554: invokeinterface #193, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 559: invokeinterface #194, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 564: astore 9\n 566: aload 9\n 568: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 573: ifeq 627\n 576: aload 9\n 578: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 583: checkcast #196 // class java/util/Map$Entry\n 586: astore 10\n 588: aload 7\n 590: aload 10\n 592: astore 11\n 594: astore 14\n 596: iconst_0\n 597: istore 12\n 599: aload 11\n 601: invokeinterface #199, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 606: checkcast #163 // class java/lang/Number\n 609: invokevirtual #166 // Method java/lang/Number.intValue:()I\n 612: invokestatic #128 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 615: aload 14\n 617: swap\n 618: invokeinterface #203, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 623: pop\n 624: goto 566\n 627: aload 7\n 629: checkcast #38 // class java/util/List\n 632: nop\n 633: checkcast #28 // class java/lang/Iterable\n 636: invokestatic #34 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 639: ireturn\n\n private final java.util.Map<java.lang.Integer, java.lang.Integer> initCardStack(int);\n Code:\n 0: new #230 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #231 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #130 // class java/util/Map\n 10: astore_2\n 11: iconst_1\n 12: istore_3\n 13: iload_3\n 14: iload_1\n 15: if_icmpgt 48\n 18: iload_3\n 19: invokestatic #128 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 22: astore 4\n 24: aload_2\n 25: aload 4\n 27: iconst_1\n 28: invokestatic #128 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 31: invokeinterface #171, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 36: pop\n 37: iload_3\n 38: iload_1\n 39: if_icmpeq 48\n 42: iinc 3, 1\n 45: goto 18\n 48: aload_2\n 49: areturn\n\n private final java.util.List<java.lang.Integer> getMatchingNumbers(java.util.List<java.lang.String>);\n Code:\n 0: invokestatic #237 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 3: astore_2\n 4: aload_2\n 5: astore_3\n 6: iconst_0\n 7: istore 4\n 9: aload_1\n 10: invokeinterface #50, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 15: astore 5\n 17: aload 5\n 19: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 24: ifeq 151\n 27: aload 5\n 29: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 34: checkcast #62 // class java/lang/String\n 37: astore 6\n 39: aload 6\n 41: checkcast #64 // class java/lang/CharSequence\n 44: iconst_1\n 45: anewarray #62 // class java/lang/String\n 48: astore 7\n 50: aload 7\n 52: iconst_0\n 53: ldc #66 // String :\n 55: aastore\n 56: aload 7\n 58: iconst_0\n 59: iconst_0\n 60: bipush 6\n 62: aconst_null\n 63: invokestatic #72 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 66: astore 8\n 68: aload_0\n 69: aload 8\n 71: iconst_1\n 72: invokeinterface #76, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 77: checkcast #62 // class java/lang/String\n 80: invokespecial #142 // Method extractWinningNumbers:(Ljava/lang/String;)Ljava/util/Set;\n 83: astore 7\n 85: iconst_0\n 86: istore 9\n 88: iconst_1\n 89: istore 10\n 91: aload 7\n 93: invokeinterface #145, 1 // InterfaceMethod java/util/Set.size:()I\n 98: istore 11\n 100: iload 10\n 102: iload 11\n 104: if_icmpgt 136\n 107: iload 10\n 109: iconst_1\n 110: if_icmpne 117\n 113: iconst_1\n 114: goto 121\n 117: iload 9\n 119: iconst_2\n 120: imul\n 121: istore 9\n 123: iload 10\n 125: iload 11\n 127: if_icmpeq 136\n 130: iinc 10, 1\n 133: goto 107\n 136: aload_3\n 137: iload 9\n 139: invokestatic #128 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 142: invokeinterface #238, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 147: pop\n 148: goto 17\n 151: nop\n 152: aload_2\n 153: invokestatic #241 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 156: areturn\n\n private final java.util.Set<java.lang.Integer> extractWinningNumbers(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #64 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #62 // class java/lang/String\n 8: astore_3\n 9: aload_3\n 10: iconst_0\n 11: ldc #248 // String |\n 13: aastore\n 14: aload_3\n 15: iconst_0\n 16: iconst_0\n 17: bipush 6\n 19: aconst_null\n 20: invokestatic #72 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: astore_2\n 24: aload_2\n 25: iconst_0\n 26: invokeinterface #76, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 31: checkcast #64 // class java/lang/CharSequence\n 34: iconst_1\n 35: anewarray #62 // class java/lang/String\n 38: astore 4\n 40: aload 4\n 42: iconst_0\n 43: ldc #250 // String\n 45: aastore\n 46: aload 4\n 48: iconst_0\n 49: iconst_0\n 50: bipush 6\n 52: aconst_null\n 53: invokestatic #72 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 56: checkcast #28 // class java/lang/Iterable\n 59: astore 4\n 61: nop\n 62: iconst_0\n 63: istore 5\n 65: aload 4\n 67: astore 6\n 69: new #183 // class java/util/ArrayList\n 72: dup\n 73: invokespecial #251 // Method java/util/ArrayList.\"<init>\":()V\n 76: checkcast #189 // class java/util/Collection\n 79: astore 7\n 81: iconst_0\n 82: istore 8\n 84: aload 6\n 86: invokeinterface #252, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 91: astore 9\n 93: aload 9\n 95: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 100: ifeq 157\n 103: aload 9\n 105: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 110: astore 10\n 112: aload 10\n 114: checkcast #62 // class java/lang/String\n 117: astore 11\n 119: iconst_0\n 120: istore 12\n 122: aload 11\n 124: checkcast #64 // class java/lang/CharSequence\n 127: invokeinterface #255, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 132: ifle 139\n 135: iconst_1\n 136: goto 140\n 139: iconst_0\n 140: nop\n 141: ifeq 93\n 144: aload 7\n 146: aload 10\n 148: invokeinterface #203, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 153: pop\n 154: goto 93\n 157: aload 7\n 159: checkcast #38 // class java/util/List\n 162: nop\n 163: checkcast #28 // class java/lang/Iterable\n 166: astore 4\n 168: nop\n 169: iconst_0\n 170: istore 5\n 172: aload 4\n 174: astore 6\n 176: new #183 // class java/util/ArrayList\n 179: dup\n 180: aload 4\n 182: bipush 10\n 184: invokestatic #259 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 187: invokespecial #187 // Method java/util/ArrayList.\"<init>\":(I)V\n 190: checkcast #189 // class java/util/Collection\n 193: astore 7\n 195: iconst_0\n 196: istore 8\n 198: aload 6\n 200: invokeinterface #252, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 205: astore 9\n 207: aload 9\n 209: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 214: ifeq 261\n 217: aload 9\n 219: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 224: astore 10\n 226: aload 7\n 228: aload 10\n 230: checkcast #62 // class java/lang/String\n 233: astore 11\n 235: astore 14\n 237: iconst_0\n 238: istore 12\n 240: aload 11\n 242: invokestatic #96 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 245: nop\n 246: invokestatic #128 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 249: aload 14\n 251: swap\n 252: invokeinterface #203, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 257: pop\n 258: goto 207\n 261: aload 7\n 263: checkcast #38 // class java/util/List\n 266: nop\n 267: astore_3\n 268: aload_2\n 269: iconst_1\n 270: invokeinterface #76, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 275: checkcast #64 // class java/lang/CharSequence\n 278: iconst_1\n 279: anewarray #62 // class java/lang/String\n 282: astore 5\n 284: aload 5\n 286: iconst_0\n 287: ldc #250 // String\n 289: aastore\n 290: aload 5\n 292: iconst_0\n 293: iconst_0\n 294: bipush 6\n 296: aconst_null\n 297: invokestatic #72 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 300: checkcast #28 // class java/lang/Iterable\n 303: astore 5\n 305: nop\n 306: iconst_0\n 307: istore 6\n 309: aload 5\n 311: astore 7\n 313: new #183 // class java/util/ArrayList\n 316: dup\n 317: invokespecial #251 // Method java/util/ArrayList.\"<init>\":()V\n 320: checkcast #189 // class java/util/Collection\n 323: astore 8\n 325: iconst_0\n 326: istore 9\n 328: aload 7\n 330: invokeinterface #252, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 335: astore 10\n 337: aload 10\n 339: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 344: ifeq 401\n 347: aload 10\n 349: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 354: astore 11\n 356: aload 11\n 358: checkcast #62 // class java/lang/String\n 361: astore 12\n 363: iconst_0\n 364: istore 13\n 366: aload 12\n 368: checkcast #64 // class java/lang/CharSequence\n 371: invokeinterface #255, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 376: ifle 383\n 379: iconst_1\n 380: goto 384\n 383: iconst_0\n 384: nop\n 385: ifeq 337\n 388: aload 8\n 390: aload 11\n 392: invokeinterface #203, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 397: pop\n 398: goto 337\n 401: aload 8\n 403: checkcast #38 // class java/util/List\n 406: nop\n 407: checkcast #28 // class java/lang/Iterable\n 410: astore 5\n 412: nop\n 413: iconst_0\n 414: istore 6\n 416: aload 5\n 418: astore 7\n 420: new #183 // class java/util/ArrayList\n 423: dup\n 424: aload 5\n 426: bipush 10\n 428: invokestatic #259 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 431: invokespecial #187 // Method java/util/ArrayList.\"<init>\":(I)V\n 434: checkcast #189 // class java/util/Collection\n 437: astore 8\n 439: iconst_0\n 440: istore 9\n 442: aload 7\n 444: invokeinterface #252, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 449: astore 10\n 451: aload 10\n 453: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 458: ifeq 505\n 461: aload 10\n 463: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 468: astore 11\n 470: aload 8\n 472: aload 11\n 474: checkcast #62 // class java/lang/String\n 477: astore 12\n 479: astore 14\n 481: iconst_0\n 482: istore 13\n 484: aload 12\n 486: invokestatic #96 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 489: nop\n 490: invokestatic #128 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 493: aload 14\n 495: swap\n 496: invokeinterface #203, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 501: pop\n 502: goto 451\n 505: aload 8\n 507: checkcast #38 // class java/util/List\n 510: nop\n 511: astore 4\n 513: aload_3\n 514: checkcast #28 // class java/lang/Iterable\n 517: aload 4\n 519: checkcast #28 // class java/lang/Iterable\n 522: invokestatic #263 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 525: checkcast #28 // class java/lang/Iterable\n 528: invokestatic #267 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 531: astore 5\n 533: aload 5\n 535: areturn\n}\n", "javap_err": "" }, { "class_path": "daincredibleholg__AdventOfCode2023__4aa7c68/io/steinh/aoc/day04/ScratchcardKt.class", "javap": "Compiled from \"Scratchcard.kt\"\npublic final class io.steinh.aoc.day04.ScratchcardKt {\n public static final void main();\n Code:\n 0: invokedynamic #25, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function0;\n 5: invokevirtual #29 // Method java/lang/Object.getClass:()Ljava/lang/Class;\n 8: invokevirtual #35 // Method java/lang/Class.getClassLoader:()Ljava/lang/ClassLoader;\n 11: dup\n 12: ifnull 58\n 15: ldc #37 // String day04/input.txt\n 17: invokevirtual #43 // Method java/lang/ClassLoader.getResource:(Ljava/lang/String;)Ljava/net/URL;\n 20: dup\n 21: ifnull 58\n 24: astore 4\n 26: getstatic #49 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 29: astore 5\n 31: aload 4\n 33: invokestatic #55 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B\n 36: astore 6\n 38: new #57 // class java/lang/String\n 41: dup\n 42: aload 6\n 44: aload 5\n 46: invokespecial #61 // Method java/lang/String.\"<init>\":([BLjava/nio/charset/Charset;)V\n 49: checkcast #63 // class java/lang/CharSequence\n 52: invokestatic #69 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 55: goto 60\n 58: pop\n 59: aconst_null\n 60: dup\n 61: invokestatic #75 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 64: astore_0\n 65: new #77 // class io/steinh/aoc/day04/Scratchcard\n 68: dup\n 69: invokespecial #79 // Method io/steinh/aoc/day04/Scratchcard.\"<init>\":()V\n 72: astore_1\n 73: aload_1\n 74: aload_0\n 75: invokevirtual #83 // Method io/steinh/aoc/day04/Scratchcard.calculatePoints:(Ljava/util/List;)I\n 78: istore_2\n 79: aload_1\n 80: aload_0\n 81: invokevirtual #86 // Method io/steinh/aoc/day04/Scratchcard.calculateNumberOfCardsWon:(Ljava/util/List;)I\n 84: istore_3\n 85: new #88 // class java/lang/StringBuilder\n 88: dup\n 89: invokespecial #89 // Method java/lang/StringBuilder.\"<init>\":()V\n 92: ldc #91 // String Result day 04, part I:\n 94: invokevirtual #95 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 97: iload_2\n 98: invokevirtual #98 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 101: invokevirtual #102 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 104: getstatic #108 // Field java/lang/System.out:Ljava/io/PrintStream;\n 107: swap\n 108: invokevirtual #113 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 111: new #88 // class java/lang/StringBuilder\n 114: dup\n 115: invokespecial #89 // Method java/lang/StringBuilder.\"<init>\":()V\n 118: ldc #115 // String Result day 04, part II:\n 120: invokevirtual #95 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 123: iload_3\n 124: invokevirtual #98 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 127: invokevirtual #102 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 130: getstatic #108 // Field java/lang/System.out:Ljava/io/PrintStream;\n 133: swap\n 134: invokevirtual #113 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 137: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #126 // Method main:()V\n 3: return\n\n private static final kotlin.Unit main$lambda$0();\n Code:\n 0: getstatic #134 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 3: areturn\n}\n", "javap_err": "" } ]
daincredibleholg__AdventOfCode2023__4aa7c68/src/main/kotlin/io/steinh/aoc/day03/GearRatios.kt
package io.steinh.aoc.day03 class GearRatios { fun addUpPartNumbers(lines: List<String>): Int { var result = 0 for (lineIndex in lines.indices) { val line = lines[lineIndex] val numberMatches = "(\\d+)".toRegex().findAll(line) for (numberMatch in numberMatches) { var startPos = numberMatch.groups[0]!!.range.first() if (startPos > 0) { startPos -= 1 } val endPos = numberMatch.groups[0]!!.range.last() + 1 val startLineId = if (lineIndex > 0) lineIndex - 1 else 0 val endLineId = if (lineIndex < lines.lastIndex) lineIndex + 1 else lineIndex if (hasAdjacentSymbol(lines, startLineId, endLineId, startPos, endPos)) { result += numberMatch.groups[0]!!.value.toInt() } } } return result } fun calculateGearRatioSum(lines: List<String>): Int { var result = 0 for (lineIndex in lines.indices) { val line = lines[lineIndex] val asteriskMatches = "([*])".toRegex().findAll(line) for (match in asteriskMatches) { result += searchAndCalculate(lines, lineIndex, match.groups[0]!!.range) } } return result } private fun searchAndCalculate(lines: List<String>, lineIndex: Int, range: IntRange): Int { val minLineId = if (lineIndex > 0) lineIndex - 1 else 0 val maxLineId = if (lineIndex < lines.lastIndex) lineIndex + 1 else lineIndex val foundNumbers = mutableListOf<Int>() for (i in minLineId..maxLineId) { val line = lines[i] val numberMatches = "(\\d+)".toRegex().findAll(line) for (match in numberMatches) { val matchRange = match.groups[0]!!.range val startAt = if (matchRange.first() > 0) matchRange.first() - 1 else 0 val endAt = matchRange.last() + 1 if ((startAt..endAt).contains(range.first())) { foundNumbers.add(match.groups[0]!!.value.toInt()) } } } if (foundNumbers.size == 2) { return foundNumbers.first() * foundNumbers.last() } return 0 } private fun hasAdjacentSymbol( lines: List<String>, startLineId: Int, endLineId: Int, startPos: Int, endPos: Int ): Boolean { var result = false for (i in startLineId..endLineId) { val max = if (endPos >= lines[i].length) lines[i].length - 1 else endPos val subString = lines[i].substring(startPos..max) result = result || subString.any { it != '.' && !it.isDigit() } } return result } } fun main() { val gearRatios = GearRatios() val lines = {}.javaClass.classLoader?.getResource("day03/input.txt")?.readText()?.lines()!! val resultPart1 = gearRatios.addUpPartNumbers(lines) val resultPart2 = gearRatios.calculateGearRatioSum(lines) print ("Result Day 3, Part I: $resultPart1\n") print ("Result Day 3, Part II: $resultPart2\n") }
[ { "class_path": "daincredibleholg__AdventOfCode2023__4aa7c68/io/steinh/aoc/day03/GearRatiosKt.class", "javap": "Compiled from \"GearRatios.kt\"\npublic final class io.steinh.aoc.day03.GearRatiosKt {\n public static final void main();\n Code:\n 0: new #8 // class io/steinh/aoc/day03/GearRatios\n 3: dup\n 4: invokespecial #11 // Method io/steinh/aoc/day03/GearRatios.\"<init>\":()V\n 7: astore_0\n 8: invokedynamic #30, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function0;\n 13: invokevirtual #34 // Method java/lang/Object.getClass:()Ljava/lang/Class;\n 16: invokevirtual #40 // Method java/lang/Class.getClassLoader:()Ljava/lang/ClassLoader;\n 19: dup\n 20: ifnull 66\n 23: ldc #42 // String day03/input.txt\n 25: invokevirtual #48 // Method java/lang/ClassLoader.getResource:(Ljava/lang/String;)Ljava/net/URL;\n 28: dup\n 29: ifnull 66\n 32: astore 4\n 34: getstatic #54 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 37: astore 5\n 39: aload 4\n 41: invokestatic #60 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B\n 44: astore 6\n 46: new #62 // class java/lang/String\n 49: dup\n 50: aload 6\n 52: aload 5\n 54: invokespecial #65 // Method java/lang/String.\"<init>\":([BLjava/nio/charset/Charset;)V\n 57: checkcast #67 // class java/lang/CharSequence\n 60: invokestatic #73 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 63: goto 68\n 66: pop\n 67: aconst_null\n 68: dup\n 69: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 72: astore_1\n 73: aload_0\n 74: aload_1\n 75: invokevirtual #83 // Method io/steinh/aoc/day03/GearRatios.addUpPartNumbers:(Ljava/util/List;)I\n 78: istore_2\n 79: aload_0\n 80: aload_1\n 81: invokevirtual #86 // Method io/steinh/aoc/day03/GearRatios.calculateGearRatioSum:(Ljava/util/List;)I\n 84: istore_3\n 85: new #88 // class java/lang/StringBuilder\n 88: dup\n 89: invokespecial #89 // Method java/lang/StringBuilder.\"<init>\":()V\n 92: ldc #91 // String Result Day 3, Part I:\n 94: invokevirtual #95 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 97: iload_2\n 98: invokevirtual #98 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 101: bipush 10\n 103: invokevirtual #101 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 106: invokevirtual #105 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 109: getstatic #111 // Field java/lang/System.out:Ljava/io/PrintStream;\n 112: swap\n 113: invokevirtual #116 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 116: new #88 // class java/lang/StringBuilder\n 119: dup\n 120: invokespecial #89 // Method java/lang/StringBuilder.\"<init>\":()V\n 123: ldc #118 // String Result Day 3, Part II:\n 125: invokevirtual #95 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 128: iload_3\n 129: invokevirtual #98 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 132: bipush 10\n 134: invokevirtual #101 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 137: invokevirtual #105 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 140: getstatic #111 // Field java/lang/System.out:Ljava/io/PrintStream;\n 143: swap\n 144: invokevirtual #116 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 147: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #129 // Method main:()V\n 3: return\n\n private static final kotlin.Unit main$lambda$0();\n Code:\n 0: getstatic #137 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 3: areturn\n}\n", "javap_err": "" }, { "class_path": "daincredibleholg__AdventOfCode2023__4aa7c68/io/steinh/aoc/day03/GearRatios.class", "javap": "Compiled from \"GearRatios.kt\"\npublic final class io.steinh.aoc.day03.GearRatios {\n public io.steinh.aoc.day03.GearRatios();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int addUpPartNumbers(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String lines\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_2\n 8: iconst_0\n 9: istore_3\n 10: aload_1\n 11: checkcast #24 // class java/util/Collection\n 14: invokeinterface #28, 1 // InterfaceMethod java/util/Collection.size:()I\n 19: istore 4\n 21: iload_3\n 22: iload 4\n 24: if_icmpge 239\n 27: aload_1\n 28: iload_3\n 29: invokeinterface #34, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 34: checkcast #36 // class java/lang/String\n 37: astore 5\n 39: new #38 // class kotlin/text/Regex\n 42: dup\n 43: ldc #40 // String (\\\\d+)\n 45: invokespecial #43 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 48: aload 5\n 50: checkcast #45 // class java/lang/CharSequence\n 53: iconst_0\n 54: iconst_2\n 55: aconst_null\n 56: invokestatic #49 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 59: astore 6\n 61: aload 6\n 63: invokeinterface #55, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 68: astore 7\n 70: aload 7\n 72: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 77: ifeq 233\n 80: aload 7\n 82: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 87: checkcast #67 // class kotlin/text/MatchResult\n 90: astore 8\n 92: aload 8\n 94: invokeinterface #71, 1 // InterfaceMethod kotlin/text/MatchResult.getGroups:()Lkotlin/text/MatchGroupCollection;\n 99: iconst_0\n 100: invokeinterface #76, 2 // InterfaceMethod kotlin/text/MatchGroupCollection.get:(I)Lkotlin/text/MatchGroup;\n 105: dup\n 106: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 109: invokevirtual #86 // Method kotlin/text/MatchGroup.getRange:()Lkotlin/ranges/IntRange;\n 112: checkcast #88 // class kotlin/ranges/IntProgression\n 115: invokestatic #94 // Method kotlin/ranges/RangesKt.first:(Lkotlin/ranges/IntProgression;)I\n 118: istore 9\n 120: iload 9\n 122: ifle 128\n 125: iinc 9, -1\n 128: aload 8\n 130: invokeinterface #71, 1 // InterfaceMethod kotlin/text/MatchResult.getGroups:()Lkotlin/text/MatchGroupCollection;\n 135: iconst_0\n 136: invokeinterface #76, 2 // InterfaceMethod kotlin/text/MatchGroupCollection.get:(I)Lkotlin/text/MatchGroup;\n 141: dup\n 142: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 145: invokevirtual #86 // Method kotlin/text/MatchGroup.getRange:()Lkotlin/ranges/IntRange;\n 148: checkcast #88 // class kotlin/ranges/IntProgression\n 151: invokestatic #97 // Method kotlin/ranges/RangesKt.last:(Lkotlin/ranges/IntProgression;)I\n 154: iconst_1\n 155: iadd\n 156: istore 10\n 158: iload_3\n 159: ifle 168\n 162: iload_3\n 163: iconst_1\n 164: isub\n 165: goto 169\n 168: iconst_0\n 169: istore 11\n 171: iload_3\n 172: aload_1\n 173: invokestatic #102 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 176: if_icmpge 185\n 179: iload_3\n 180: iconst_1\n 181: iadd\n 182: goto 186\n 185: iload_3\n 186: istore 12\n 188: aload_0\n 189: aload_1\n 190: iload 11\n 192: iload 12\n 194: iload 9\n 196: iload 10\n 198: invokespecial #106 // Method hasAdjacentSymbol:(Ljava/util/List;IIII)Z\n 201: ifeq 70\n 204: iload_2\n 205: aload 8\n 207: invokeinterface #71, 1 // InterfaceMethod kotlin/text/MatchResult.getGroups:()Lkotlin/text/MatchGroupCollection;\n 212: iconst_0\n 213: invokeinterface #76, 2 // InterfaceMethod kotlin/text/MatchGroupCollection.get:(I)Lkotlin/text/MatchGroup;\n 218: dup\n 219: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 222: invokevirtual #110 // Method kotlin/text/MatchGroup.getValue:()Ljava/lang/String;\n 225: invokestatic #116 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 228: iadd\n 229: istore_2\n 230: goto 70\n 233: iinc 3, 1\n 236: goto 21\n 239: iload_2\n 240: ireturn\n\n public final int calculateGearRatioSum(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String lines\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_2\n 8: iconst_0\n 9: istore_3\n 10: aload_1\n 11: checkcast #24 // class java/util/Collection\n 14: invokeinterface #28, 1 // InterfaceMethod java/util/Collection.size:()I\n 19: istore 4\n 21: iload_3\n 22: iload 4\n 24: if_icmpge 130\n 27: aload_1\n 28: iload_3\n 29: invokeinterface #34, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 34: checkcast #36 // class java/lang/String\n 37: astore 5\n 39: new #38 // class kotlin/text/Regex\n 42: dup\n 43: ldc #133 // String ([*])\n 45: invokespecial #43 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 48: aload 5\n 50: checkcast #45 // class java/lang/CharSequence\n 53: iconst_0\n 54: iconst_2\n 55: aconst_null\n 56: invokestatic #49 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 59: astore 6\n 61: aload 6\n 63: invokeinterface #55, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 68: astore 7\n 70: aload 7\n 72: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 77: ifeq 124\n 80: aload 7\n 82: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 87: checkcast #67 // class kotlin/text/MatchResult\n 90: astore 8\n 92: iload_2\n 93: aload_0\n 94: aload_1\n 95: iload_3\n 96: aload 8\n 98: invokeinterface #71, 1 // InterfaceMethod kotlin/text/MatchResult.getGroups:()Lkotlin/text/MatchGroupCollection;\n 103: iconst_0\n 104: invokeinterface #76, 2 // InterfaceMethod kotlin/text/MatchGroupCollection.get:(I)Lkotlin/text/MatchGroup;\n 109: dup\n 110: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 113: invokevirtual #86 // Method kotlin/text/MatchGroup.getRange:()Lkotlin/ranges/IntRange;\n 116: invokespecial #137 // Method searchAndCalculate:(Ljava/util/List;ILkotlin/ranges/IntRange;)I\n 119: iadd\n 120: istore_2\n 121: goto 70\n 124: iinc 3, 1\n 127: goto 21\n 130: iload_2\n 131: ireturn\n\n private final int searchAndCalculate(java.util.List<java.lang.String>, int, kotlin.ranges.IntRange);\n Code:\n 0: iload_2\n 1: ifle 10\n 4: iload_2\n 5: iconst_1\n 6: isub\n 7: goto 11\n 10: iconst_0\n 11: istore 4\n 13: iload_2\n 14: aload_1\n 15: invokestatic #102 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 18: if_icmpge 27\n 21: iload_2\n 22: iconst_1\n 23: iadd\n 24: goto 28\n 27: iload_2\n 28: istore 5\n 30: new #142 // class java/util/ArrayList\n 33: dup\n 34: invokespecial #143 // Method java/util/ArrayList.\"<init>\":()V\n 37: checkcast #30 // class java/util/List\n 40: astore 6\n 42: iload 4\n 44: istore 7\n 46: iload 7\n 48: iload 5\n 50: if_icmpgt 254\n 53: aload_1\n 54: iload 7\n 56: invokeinterface #34, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 61: checkcast #36 // class java/lang/String\n 64: astore 8\n 66: new #38 // class kotlin/text/Regex\n 69: dup\n 70: ldc #40 // String (\\\\d+)\n 72: invokespecial #43 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 75: aload 8\n 77: checkcast #45 // class java/lang/CharSequence\n 80: iconst_0\n 81: iconst_2\n 82: aconst_null\n 83: invokestatic #49 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 86: astore 9\n 88: aload 9\n 90: invokeinterface #55, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 95: astore 10\n 97: aload 10\n 99: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 104: ifeq 241\n 107: aload 10\n 109: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 114: checkcast #67 // class kotlin/text/MatchResult\n 117: astore 11\n 119: aload 11\n 121: invokeinterface #71, 1 // InterfaceMethod kotlin/text/MatchResult.getGroups:()Lkotlin/text/MatchGroupCollection;\n 126: iconst_0\n 127: invokeinterface #76, 2 // InterfaceMethod kotlin/text/MatchGroupCollection.get:(I)Lkotlin/text/MatchGroup;\n 132: dup\n 133: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 136: invokevirtual #86 // Method kotlin/text/MatchGroup.getRange:()Lkotlin/ranges/IntRange;\n 139: astore 12\n 141: aload 12\n 143: checkcast #88 // class kotlin/ranges/IntProgression\n 146: invokestatic #94 // Method kotlin/ranges/RangesKt.first:(Lkotlin/ranges/IntProgression;)I\n 149: ifle 165\n 152: aload 12\n 154: checkcast #88 // class kotlin/ranges/IntProgression\n 157: invokestatic #94 // Method kotlin/ranges/RangesKt.first:(Lkotlin/ranges/IntProgression;)I\n 160: iconst_1\n 161: isub\n 162: goto 166\n 165: iconst_0\n 166: istore 13\n 168: aload 12\n 170: checkcast #88 // class kotlin/ranges/IntProgression\n 173: invokestatic #97 // Method kotlin/ranges/RangesKt.last:(Lkotlin/ranges/IntProgression;)I\n 176: iconst_1\n 177: iadd\n 178: istore 14\n 180: new #145 // class kotlin/ranges/IntRange\n 183: dup\n 184: iload 13\n 186: iload 14\n 188: invokespecial #148 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 191: aload_3\n 192: checkcast #88 // class kotlin/ranges/IntProgression\n 195: invokestatic #94 // Method kotlin/ranges/RangesKt.first:(Lkotlin/ranges/IntProgression;)I\n 198: invokevirtual #152 // Method kotlin/ranges/IntRange.contains:(I)Z\n 201: ifeq 97\n 204: aload 6\n 206: aload 11\n 208: invokeinterface #71, 1 // InterfaceMethod kotlin/text/MatchResult.getGroups:()Lkotlin/text/MatchGroupCollection;\n 213: iconst_0\n 214: invokeinterface #76, 2 // InterfaceMethod kotlin/text/MatchGroupCollection.get:(I)Lkotlin/text/MatchGroup;\n 219: dup\n 220: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 223: invokevirtual #110 // Method kotlin/text/MatchGroup.getValue:()Ljava/lang/String;\n 226: invokestatic #116 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 229: invokestatic #156 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 232: invokeinterface #160, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 237: pop\n 238: goto 97\n 241: iload 7\n 243: iload 5\n 245: if_icmpeq 254\n 248: iinc 7, 1\n 251: goto 53\n 254: aload 6\n 256: invokeinterface #161, 1 // InterfaceMethod java/util/List.size:()I\n 261: iconst_2\n 262: if_icmpne 289\n 265: aload 6\n 267: invokestatic #164 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 270: checkcast #166 // class java/lang/Number\n 273: invokevirtual #169 // Method java/lang/Number.intValue:()I\n 276: aload 6\n 278: invokestatic #171 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 281: checkcast #166 // class java/lang/Number\n 284: invokevirtual #169 // Method java/lang/Number.intValue:()I\n 287: imul\n 288: ireturn\n 289: iconst_0\n 290: ireturn\n\n private final boolean hasAdjacentSymbol(java.util.List<java.lang.String>, int, int, int, int);\n Code:\n 0: iconst_0\n 1: istore 6\n 3: iload_2\n 4: istore 7\n 6: iload 7\n 8: iload_3\n 9: if_icmpgt 185\n 12: iload 5\n 14: aload_1\n 15: iload 7\n 17: invokeinterface #34, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 22: checkcast #36 // class java/lang/String\n 25: invokevirtual #184 // Method java/lang/String.length:()I\n 28: if_icmplt 50\n 31: aload_1\n 32: iload 7\n 34: invokeinterface #34, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 39: checkcast #36 // class java/lang/String\n 42: invokevirtual #184 // Method java/lang/String.length:()I\n 45: iconst_1\n 46: isub\n 47: goto 52\n 50: iload 5\n 52: istore 8\n 54: aload_1\n 55: iload 7\n 57: invokeinterface #34, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 62: checkcast #36 // class java/lang/String\n 65: new #145 // class kotlin/ranges/IntRange\n 68: dup\n 69: iload 4\n 71: iload 8\n 73: invokespecial #148 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 76: invokestatic #190 // Method kotlin/text/StringsKt.substring:(Ljava/lang/String;Lkotlin/ranges/IntRange;)Ljava/lang/String;\n 79: astore 9\n 81: iload 6\n 83: ifne 166\n 86: aload 9\n 88: checkcast #45 // class java/lang/CharSequence\n 91: astore 10\n 93: iconst_0\n 94: istore 11\n 96: iconst_0\n 97: istore 12\n 99: iload 12\n 101: aload 10\n 103: invokeinterface #191, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 108: if_icmpge 162\n 111: aload 10\n 113: iload 12\n 115: invokeinterface #195, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 120: istore 13\n 122: iload 13\n 124: istore 14\n 126: iconst_0\n 127: istore 15\n 129: iload 14\n 131: bipush 46\n 133: if_icmpeq 148\n 136: iload 14\n 138: invokestatic #201 // Method java/lang/Character.isDigit:(C)Z\n 141: ifne 148\n 144: iconst_1\n 145: goto 149\n 148: iconst_0\n 149: ifeq 156\n 152: iconst_1\n 153: goto 163\n 156: iinc 12, 1\n 159: goto 99\n 162: iconst_0\n 163: ifeq 170\n 166: iconst_1\n 167: goto 171\n 170: iconst_0\n 171: istore 6\n 173: iload 7\n 175: iload_3\n 176: if_icmpeq 185\n 179: iinc 7, 1\n 182: goto 12\n 185: iload 6\n 187: ireturn\n}\n", "javap_err": "" } ]
daincredibleholg__AdventOfCode2023__4aa7c68/src/main/kotlin/io/steinh/aoc/day02/CubeConundrum.kt
package io.steinh.aoc.day02 class CubeConundrum { fun sumIds(lines: List<String>, bagLimits: List<CubeCount>): Int { val processed = analyze(lines) var sum = 0 for (game in processed) { var match = true for (entry in game.value) { for (limit in bagLimits) { match = match && entry.any { it.color == limit.color && it.count <= limit.count } } } if (match) { print("Game ${game.key} is possible\n") sum += game.key } } return sum } fun powerOfTheFewest(lines: List<String>): Int { val processed = analyze(lines) val fewest = getFewest(processed) var result = 0 for (game in fewest) { val value = game.value.map { it.count }.reduce { acc, i -> acc * i } result += value } return result } private fun getFewest(processed: Map<Int, List<List<CubeCount>>>): Map<Int, List<CubeCount>> { val result = mutableMapOf<Int, List<CubeCount>>() for (game in processed) { var red = 0 var green = 0 var blue = 0 for (set in game.value) { for (entry in set) { when (entry.color) { "red" -> red = if (red < entry.count) entry.count else red "green" -> green = if (green < entry.count) entry.count else green "blue" -> blue = if (blue < entry.count) entry.count else blue } } } result[game.key] = listOf( CubeCount(red, "red"), CubeCount(green, "green"), CubeCount(blue, "blue") ) } return result } private fun analyze(lines: List<String>): Map<Int, List<List<CubeCount>>> { val result: MutableMap<Int, List<List<CubeCount>>> = mutableMapOf() for (line in lines) { val gameId = "Game (\\d+)".toRegex().find(line)!!.groupValues[1].toInt() val drawnSets = line.split(": ").last().split(";") val sets = buildList { for (set in drawnSets) { add( buildList { var redCubes = 0 var greenCubes = 0 var blueCubes = 0 for (matches in "(\\d+) (red|green|blue)".toRegex().findAll(set)) { val cnt = matches.groups[1]!!.value.toInt() when (matches.groups[2]!!.value) { "red" -> redCubes += cnt "green" -> greenCubes += cnt "blue" -> blueCubes += cnt } } add(CubeCount(redCubes, "red")) add(CubeCount(blueCubes, "blue")) add(CubeCount(greenCubes, "green")) }) } } result.put(gameId, sets) } return result } } data class CubeCount( val count: Int, val color: String, ) fun main() { val input = {}.javaClass.classLoader?.getResource("day02/input.txt")?.readText()?.lines()!! val bagLimits = listOf( CubeCount(12, "red"), CubeCount(13, "green"), CubeCount(14, "blue") ) val cubeConundrum = CubeConundrum() val result = cubeConundrum.sumIds(input, bagLimits) val resultPart2 = cubeConundrum.powerOfTheFewest(input) print("Solution for Day 2, Part I: $result\n") print("Solution for Day 2, Part II: $resultPart2\n") }
[ { "class_path": "daincredibleholg__AdventOfCode2023__4aa7c68/io/steinh/aoc/day02/CubeConundrumKt.class", "javap": "Compiled from \"CubeConundrum.kt\"\npublic final class io.steinh.aoc.day02.CubeConundrumKt {\n public static final void main();\n Code:\n 0: invokedynamic #25, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function0;\n 5: invokevirtual #29 // Method java/lang/Object.getClass:()Ljava/lang/Class;\n 8: invokevirtual #35 // Method java/lang/Class.getClassLoader:()Ljava/lang/ClassLoader;\n 11: dup\n 12: ifnull 58\n 15: ldc #37 // String day02/input.txt\n 17: invokevirtual #43 // Method java/lang/ClassLoader.getResource:(Ljava/lang/String;)Ljava/net/URL;\n 20: dup\n 21: ifnull 58\n 24: astore 4\n 26: getstatic #49 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 29: astore 5\n 31: aload 4\n 33: invokestatic #55 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B\n 36: astore 6\n 38: new #57 // class java/lang/String\n 41: dup\n 42: aload 6\n 44: aload 5\n 46: invokespecial #61 // Method java/lang/String.\"<init>\":([BLjava/nio/charset/Charset;)V\n 49: checkcast #63 // class java/lang/CharSequence\n 52: invokestatic #69 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 55: goto 60\n 58: pop\n 59: aconst_null\n 60: dup\n 61: invokestatic #75 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 64: astore_0\n 65: iconst_3\n 66: anewarray #77 // class io/steinh/aoc/day02/CubeCount\n 69: astore_2\n 70: aload_2\n 71: iconst_0\n 72: new #77 // class io/steinh/aoc/day02/CubeCount\n 75: dup\n 76: bipush 12\n 78: ldc #79 // String red\n 80: invokespecial #82 // Method io/steinh/aoc/day02/CubeCount.\"<init>\":(ILjava/lang/String;)V\n 83: aastore\n 84: aload_2\n 85: iconst_1\n 86: new #77 // class io/steinh/aoc/day02/CubeCount\n 89: dup\n 90: bipush 13\n 92: ldc #84 // String green\n 94: invokespecial #82 // Method io/steinh/aoc/day02/CubeCount.\"<init>\":(ILjava/lang/String;)V\n 97: aastore\n 98: aload_2\n 99: iconst_2\n 100: new #77 // class io/steinh/aoc/day02/CubeCount\n 103: dup\n 104: bipush 14\n 106: ldc #86 // String blue\n 108: invokespecial #82 // Method io/steinh/aoc/day02/CubeCount.\"<init>\":(ILjava/lang/String;)V\n 111: aastore\n 112: aload_2\n 113: invokestatic #92 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 116: astore_1\n 117: new #94 // class io/steinh/aoc/day02/CubeConundrum\n 120: dup\n 121: invokespecial #96 // Method io/steinh/aoc/day02/CubeConundrum.\"<init>\":()V\n 124: astore_2\n 125: aload_2\n 126: aload_0\n 127: aload_1\n 128: invokevirtual #100 // Method io/steinh/aoc/day02/CubeConundrum.sumIds:(Ljava/util/List;Ljava/util/List;)I\n 131: istore_3\n 132: aload_2\n 133: aload_0\n 134: invokevirtual #104 // Method io/steinh/aoc/day02/CubeConundrum.powerOfTheFewest:(Ljava/util/List;)I\n 137: istore 4\n 139: new #106 // class java/lang/StringBuilder\n 142: dup\n 143: invokespecial #107 // Method java/lang/StringBuilder.\"<init>\":()V\n 146: ldc #109 // String Solution for Day 2, Part I:\n 148: invokevirtual #113 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 151: iload_3\n 152: invokevirtual #116 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 155: bipush 10\n 157: invokevirtual #119 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 160: invokevirtual #123 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 163: getstatic #129 // Field java/lang/System.out:Ljava/io/PrintStream;\n 166: swap\n 167: invokevirtual #134 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 170: new #106 // class java/lang/StringBuilder\n 173: dup\n 174: invokespecial #107 // Method java/lang/StringBuilder.\"<init>\":()V\n 177: ldc #136 // String Solution for Day 2, Part II:\n 179: invokevirtual #113 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 182: iload 4\n 184: invokevirtual #116 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 187: bipush 10\n 189: invokevirtual #119 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 192: invokevirtual #123 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 195: getstatic #129 // Field java/lang/System.out:Ljava/io/PrintStream;\n 198: swap\n 199: invokevirtual #134 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 202: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #149 // Method main:()V\n 3: return\n\n private static final kotlin.Unit main$lambda$0();\n Code:\n 0: getstatic #157 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 3: areturn\n}\n", "javap_err": "" }, { "class_path": "daincredibleholg__AdventOfCode2023__4aa7c68/io/steinh/aoc/day02/CubeConundrum.class", "javap": "Compiled from \"CubeConundrum.kt\"\npublic final class io.steinh.aoc.day02.CubeConundrum {\n public io.steinh.aoc.day02.CubeConundrum();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int sumIds(java.util.List<java.lang.String>, java.util.List<io.steinh.aoc.day02.CubeCount>);\n Code:\n 0: aload_1\n 1: ldc #16 // String lines\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #24 // String bagLimits\n 9: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_1\n 14: invokespecial #28 // Method analyze:(Ljava/util/List;)Ljava/util/Map;\n 17: astore_3\n 18: iconst_0\n 19: istore 4\n 21: aload_3\n 22: invokeinterface #34, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 27: invokeinterface #40, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 32: astore 5\n 34: aload 5\n 36: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 330\n 44: aload 5\n 46: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: checkcast #52 // class java/util/Map$Entry\n 54: astore 6\n 56: iconst_1\n 57: istore 7\n 59: aload 6\n 61: invokeinterface #55, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 66: checkcast #57 // class java/util/List\n 69: invokeinterface #58, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 74: astore 8\n 76: aload 8\n 78: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 83: ifeq 261\n 86: aload 8\n 88: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 93: checkcast #57 // class java/util/List\n 96: astore 9\n 98: aload_2\n 99: invokeinterface #58, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 104: astore 10\n 106: aload 10\n 108: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 113: ifeq 76\n 116: aload 10\n 118: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 123: checkcast #60 // class io/steinh/aoc/day02/CubeCount\n 126: astore 11\n 128: iload 7\n 130: ifeq 255\n 133: aload 9\n 135: checkcast #62 // class java/lang/Iterable\n 138: astore 12\n 140: iconst_0\n 141: istore 13\n 143: aload 12\n 145: instanceof #64 // class java/util/Collection\n 148: ifeq 168\n 151: aload 12\n 153: checkcast #64 // class java/util/Collection\n 156: invokeinterface #67, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 161: ifeq 168\n 164: iconst_0\n 165: goto 248\n 168: aload 12\n 170: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 175: astore 14\n 177: aload 14\n 179: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 184: ifeq 247\n 187: aload 14\n 189: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 194: astore 15\n 196: aload 15\n 198: checkcast #60 // class io/steinh/aoc/day02/CubeCount\n 201: astore 16\n 203: iconst_0\n 204: istore 17\n 206: aload 16\n 208: invokevirtual #72 // Method io/steinh/aoc/day02/CubeCount.getColor:()Ljava/lang/String;\n 211: aload 11\n 213: invokevirtual #72 // Method io/steinh/aoc/day02/CubeCount.getColor:()Ljava/lang/String;\n 216: invokestatic #76 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 219: ifeq 239\n 222: aload 16\n 224: invokevirtual #80 // Method io/steinh/aoc/day02/CubeCount.getCount:()I\n 227: aload 11\n 229: invokevirtual #80 // Method io/steinh/aoc/day02/CubeCount.getCount:()I\n 232: if_icmpgt 239\n 235: iconst_1\n 236: goto 240\n 239: iconst_0\n 240: ifeq 177\n 243: iconst_1\n 244: goto 248\n 247: iconst_0\n 248: ifeq 255\n 251: iconst_1\n 252: goto 256\n 255: iconst_0\n 256: istore 7\n 258: goto 106\n 261: iload 7\n 263: ifeq 34\n 266: new #82 // class java/lang/StringBuilder\n 269: dup\n 270: invokespecial #83 // Method java/lang/StringBuilder.\"<init>\":()V\n 273: ldc #85 // String Game\n 275: invokevirtual #89 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 278: aload 6\n 280: invokeinterface #92, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 285: checkcast #94 // class java/lang/Number\n 288: invokevirtual #97 // Method java/lang/Number.intValue:()I\n 291: invokevirtual #100 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 294: ldc #102 // String is possible\\n\n 296: invokevirtual #89 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 299: invokevirtual #105 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 302: getstatic #111 // Field java/lang/System.out:Ljava/io/PrintStream;\n 305: swap\n 306: invokevirtual #117 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 309: iload 4\n 311: aload 6\n 313: invokeinterface #92, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 318: checkcast #94 // class java/lang/Number\n 321: invokevirtual #97 // Method java/lang/Number.intValue:()I\n 324: iadd\n 325: istore 4\n 327: goto 34\n 330: iload 4\n 332: ireturn\n\n public final int powerOfTheFewest(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String lines\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokespecial #28 // Method analyze:(Ljava/util/List;)Ljava/util/Map;\n 11: astore_2\n 12: aload_0\n 13: aload_2\n 14: invokespecial #143 // Method getFewest:(Ljava/util/Map;)Ljava/util/Map;\n 17: astore_3\n 18: iconst_0\n 19: istore 4\n 21: aload_3\n 22: invokeinterface #34, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 27: invokeinterface #40, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 32: astore 5\n 34: aload 5\n 36: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 283\n 44: aload 5\n 46: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: checkcast #52 // class java/util/Map$Entry\n 54: astore 6\n 56: aload 6\n 58: invokeinterface #55, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 63: checkcast #62 // class java/lang/Iterable\n 66: astore 8\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: astore 10\n 75: new #145 // class java/util/ArrayList\n 78: dup\n 79: aload 8\n 81: bipush 10\n 83: invokestatic #151 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 86: invokespecial #154 // Method java/util/ArrayList.\"<init>\":(I)V\n 89: checkcast #64 // class java/util/Collection\n 92: astore 11\n 94: iconst_0\n 95: istore 12\n 97: aload 10\n 99: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 104: astore 13\n 106: aload 13\n 108: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 113: ifeq 159\n 116: aload 13\n 118: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 123: astore 14\n 125: aload 11\n 127: aload 14\n 129: checkcast #60 // class io/steinh/aoc/day02/CubeCount\n 132: astore 15\n 134: astore 17\n 136: iconst_0\n 137: istore 16\n 139: aload 15\n 141: invokevirtual #80 // Method io/steinh/aoc/day02/CubeCount.getCount:()I\n 144: invokestatic #160 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 147: aload 17\n 149: swap\n 150: invokeinterface #164, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 155: pop\n 156: goto 106\n 159: aload 11\n 161: checkcast #57 // class java/util/List\n 164: nop\n 165: checkcast #62 // class java/lang/Iterable\n 168: astore 8\n 170: nop\n 171: iconst_0\n 172: istore 9\n 174: aload 8\n 176: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 181: astore 10\n 183: aload 10\n 185: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 190: ifne 203\n 193: new #166 // class java/lang/UnsupportedOperationException\n 196: dup\n 197: ldc #168 // String Empty collection can\\'t be reduced.\n 199: invokespecial #171 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 202: athrow\n 203: aload 10\n 205: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 210: astore 11\n 212: aload 10\n 214: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 219: ifeq 263\n 222: aload 11\n 224: aload 10\n 226: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 231: checkcast #94 // class java/lang/Number\n 234: invokevirtual #97 // Method java/lang/Number.intValue:()I\n 237: istore 12\n 239: checkcast #94 // class java/lang/Number\n 242: invokevirtual #97 // Method java/lang/Number.intValue:()I\n 245: istore 13\n 247: iconst_0\n 248: istore 14\n 250: iload 13\n 252: iload 12\n 254: imul\n 255: invokestatic #160 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 258: astore 11\n 260: goto 212\n 263: aload 11\n 265: checkcast #94 // class java/lang/Number\n 268: invokevirtual #97 // Method java/lang/Number.intValue:()I\n 271: istore 7\n 273: iload 4\n 275: iload 7\n 277: iadd\n 278: istore 4\n 280: goto 34\n 283: iload 4\n 285: ireturn\n\n private final java.util.Map<java.lang.Integer, java.util.List<io.steinh.aoc.day02.CubeCount>> getFewest(java.util.Map<java.lang.Integer, ? extends java.util.List<? extends java.util.List<io.steinh.aoc.day02.CubeCount>>>);\n Code:\n 0: new #193 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #194 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #30 // class java/util/Map\n 10: astore_2\n 11: aload_1\n 12: invokeinterface #34, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 17: invokeinterface #40, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 22: astore_3\n 23: aload_3\n 24: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifeq 367\n 32: aload_3\n 33: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 38: checkcast #52 // class java/util/Map$Entry\n 41: astore 4\n 43: iconst_0\n 44: istore 5\n 46: iconst_0\n 47: istore 6\n 49: iconst_0\n 50: istore 7\n 52: aload 4\n 54: invokeinterface #55, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 59: checkcast #57 // class java/util/List\n 62: invokeinterface #58, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 67: astore 8\n 69: aload 8\n 71: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 76: ifeq 282\n 79: aload 8\n 81: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: checkcast #57 // class java/util/List\n 89: astore 9\n 91: aload 9\n 93: invokeinterface #58, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 98: astore 10\n 100: aload 10\n 102: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 107: ifeq 69\n 110: aload 10\n 112: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 117: checkcast #60 // class io/steinh/aoc/day02/CubeCount\n 120: astore 11\n 122: aload 11\n 124: invokevirtual #72 // Method io/steinh/aoc/day02/CubeCount.getColor:()Ljava/lang/String;\n 127: astore 12\n 129: aload 12\n 131: invokevirtual #199 // Method java/lang/String.hashCode:()I\n 134: lookupswitch { // 3\n 112785: 168\n 3027034: 194\n 98619139: 181\n default: 279\n }\n 168: aload 12\n 170: ldc #201 // String red\n 172: invokevirtual #204 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 175: ifne 207\n 178: goto 100\n 181: aload 12\n 183: ldc #206 // String green\n 185: invokevirtual #204 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 188: ifne 232\n 191: goto 100\n 194: aload 12\n 196: ldc #208 // String blue\n 198: invokevirtual #204 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 201: ifne 257\n 204: goto 100\n 207: iload 5\n 209: aload 11\n 211: invokevirtual #80 // Method io/steinh/aoc/day02/CubeCount.getCount:()I\n 214: if_icmpge 225\n 217: aload 11\n 219: invokevirtual #80 // Method io/steinh/aoc/day02/CubeCount.getCount:()I\n 222: goto 227\n 225: iload 5\n 227: istore 5\n 229: goto 100\n 232: iload 6\n 234: aload 11\n 236: invokevirtual #80 // Method io/steinh/aoc/day02/CubeCount.getCount:()I\n 239: if_icmpge 250\n 242: aload 11\n 244: invokevirtual #80 // Method io/steinh/aoc/day02/CubeCount.getCount:()I\n 247: goto 252\n 250: iload 6\n 252: istore 6\n 254: goto 100\n 257: iload 7\n 259: aload 11\n 261: invokevirtual #80 // Method io/steinh/aoc/day02/CubeCount.getCount:()I\n 264: if_icmpge 275\n 267: aload 11\n 269: invokevirtual #80 // Method io/steinh/aoc/day02/CubeCount.getCount:()I\n 272: goto 277\n 275: iload 7\n 277: istore 7\n 279: goto 100\n 282: aload_2\n 283: astore 8\n 285: aload 4\n 287: invokeinterface #92, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 292: astore 9\n 294: iconst_3\n 295: anewarray #60 // class io/steinh/aoc/day02/CubeCount\n 298: astore 10\n 300: aload 10\n 302: iconst_0\n 303: new #60 // class io/steinh/aoc/day02/CubeCount\n 306: dup\n 307: iload 5\n 309: ldc #201 // String red\n 311: invokespecial #211 // Method io/steinh/aoc/day02/CubeCount.\"<init>\":(ILjava/lang/String;)V\n 314: aastore\n 315: aload 10\n 317: iconst_1\n 318: new #60 // class io/steinh/aoc/day02/CubeCount\n 321: dup\n 322: iload 6\n 324: ldc #206 // String green\n 326: invokespecial #211 // Method io/steinh/aoc/day02/CubeCount.\"<init>\":(ILjava/lang/String;)V\n 329: aastore\n 330: aload 10\n 332: iconst_2\n 333: new #60 // class io/steinh/aoc/day02/CubeCount\n 336: dup\n 337: iload 7\n 339: ldc #208 // String blue\n 341: invokespecial #211 // Method io/steinh/aoc/day02/CubeCount.\"<init>\":(ILjava/lang/String;)V\n 344: aastore\n 345: aload 10\n 347: invokestatic #215 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 350: astore 10\n 352: aload 8\n 354: aload 9\n 356: aload 10\n 358: invokeinterface #219, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 363: pop\n 364: goto 23\n 367: aload_2\n 368: areturn\n\n private final java.util.Map<java.lang.Integer, java.util.List<java.util.List<io.steinh.aoc.day02.CubeCount>>> analyze(java.util.List<java.lang.String>);\n Code:\n 0: new #193 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #194 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #30 // class java/util/Map\n 10: astore_2\n 11: aload_1\n 12: invokeinterface #58, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 17: astore_3\n 18: aload_3\n 19: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 24: ifeq 512\n 27: aload_3\n 28: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 33: checkcast #196 // class java/lang/String\n 36: astore 4\n 38: new #223 // class kotlin/text/Regex\n 41: dup\n 42: ldc #225 // String Game (\\\\d+)\n 44: invokespecial #226 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 47: aload 4\n 49: checkcast #228 // class java/lang/CharSequence\n 52: iconst_0\n 53: iconst_2\n 54: aconst_null\n 55: invokestatic #232 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 58: dup\n 59: invokestatic #235 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 62: invokeinterface #241, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 67: iconst_1\n 68: invokeinterface #245, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 73: checkcast #196 // class java/lang/String\n 76: invokestatic #249 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 79: istore 5\n 81: aload 4\n 83: checkcast #228 // class java/lang/CharSequence\n 86: iconst_1\n 87: anewarray #196 // class java/lang/String\n 90: astore 7\n 92: aload 7\n 94: iconst_0\n 95: ldc #251 // String :\n 97: aastore\n 98: aload 7\n 100: iconst_0\n 101: iconst_0\n 102: bipush 6\n 104: aconst_null\n 105: invokestatic #257 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 108: invokestatic #261 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 111: checkcast #228 // class java/lang/CharSequence\n 114: iconst_1\n 115: anewarray #196 // class java/lang/String\n 118: astore 7\n 120: aload 7\n 122: iconst_0\n 123: ldc_w #263 // String ;\n 126: aastore\n 127: aload 7\n 129: iconst_0\n 130: iconst_0\n 131: bipush 6\n 133: aconst_null\n 134: invokestatic #257 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 137: astore 6\n 139: invokestatic #266 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 142: astore 8\n 144: aload 8\n 146: astore 9\n 148: iconst_0\n 149: istore 10\n 151: aload 6\n 153: invokeinterface #58, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 158: astore 11\n 160: aload 11\n 162: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 167: ifeq 487\n 170: aload 11\n 172: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 177: checkcast #196 // class java/lang/String\n 180: astore 12\n 182: aload 9\n 184: invokestatic #266 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 187: astore 13\n 189: aload 13\n 191: astore 14\n 193: astore 15\n 195: iconst_0\n 196: istore 16\n 198: iconst_0\n 199: istore 17\n 201: iconst_0\n 202: istore 18\n 204: iconst_0\n 205: istore 19\n 207: new #223 // class kotlin/text/Regex\n 210: dup\n 211: ldc_w #268 // String (\\\\d+) (red|green|blue)\n 214: invokespecial #226 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 217: aload 12\n 219: checkcast #228 // class java/lang/CharSequence\n 222: iconst_0\n 223: iconst_2\n 224: aconst_null\n 225: invokestatic #272 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 228: invokeinterface #275, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 233: astore 20\n 235: aload 20\n 237: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 242: ifeq 413\n 245: aload 20\n 247: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 252: checkcast #237 // class kotlin/text/MatchResult\n 255: astore 21\n 257: aload 21\n 259: invokeinterface #279, 1 // InterfaceMethod kotlin/text/MatchResult.getGroups:()Lkotlin/text/MatchGroupCollection;\n 264: iconst_1\n 265: invokeinterface #284, 2 // InterfaceMethod kotlin/text/MatchGroupCollection.get:(I)Lkotlin/text/MatchGroup;\n 270: dup\n 271: invokestatic #235 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 274: invokevirtual #288 // Method kotlin/text/MatchGroup.getValue:()Ljava/lang/String;\n 277: invokestatic #249 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 280: istore 22\n 282: aload 21\n 284: invokeinterface #279, 1 // InterfaceMethod kotlin/text/MatchResult.getGroups:()Lkotlin/text/MatchGroupCollection;\n 289: iconst_2\n 290: invokeinterface #284, 2 // InterfaceMethod kotlin/text/MatchGroupCollection.get:(I)Lkotlin/text/MatchGroup;\n 295: dup\n 296: invokestatic #235 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 299: invokevirtual #288 // Method kotlin/text/MatchGroup.getValue:()Ljava/lang/String;\n 302: astore 23\n 304: aload 23\n 306: invokevirtual #199 // Method java/lang/String.hashCode:()I\n 309: lookupswitch { // 3\n 112785: 344\n 3027034: 370\n 98619139: 357\n default: 410\n }\n 344: aload 23\n 346: ldc #201 // String red\n 348: invokevirtual #204 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 351: ifne 383\n 354: goto 235\n 357: aload 23\n 359: ldc #206 // String green\n 361: invokevirtual #204 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 364: ifne 393\n 367: goto 235\n 370: aload 23\n 372: ldc #208 // String blue\n 374: invokevirtual #204 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 377: ifne 403\n 380: goto 235\n 383: iload 17\n 385: iload 22\n 387: iadd\n 388: istore 17\n 390: goto 235\n 393: iload 18\n 395: iload 22\n 397: iadd\n 398: istore 18\n 400: goto 235\n 403: iload 19\n 405: iload 22\n 407: iadd\n 408: istore 19\n 410: goto 235\n 413: aload 14\n 415: new #60 // class io/steinh/aoc/day02/CubeCount\n 418: dup\n 419: iload 17\n 421: ldc #201 // String red\n 423: invokespecial #211 // Method io/steinh/aoc/day02/CubeCount.\"<init>\":(ILjava/lang/String;)V\n 426: invokeinterface #289, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 431: pop\n 432: aload 14\n 434: new #60 // class io/steinh/aoc/day02/CubeCount\n 437: dup\n 438: iload 19\n 440: ldc #208 // String blue\n 442: invokespecial #211 // Method io/steinh/aoc/day02/CubeCount.\"<init>\":(ILjava/lang/String;)V\n 445: invokeinterface #289, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 450: pop\n 451: aload 14\n 453: new #60 // class io/steinh/aoc/day02/CubeCount\n 456: dup\n 457: iload 18\n 459: ldc #206 // String green\n 461: invokespecial #211 // Method io/steinh/aoc/day02/CubeCount.\"<init>\":(ILjava/lang/String;)V\n 464: invokeinterface #289, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 469: pop\n 470: nop\n 471: aload 15\n 473: aload 13\n 475: invokestatic #293 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 478: invokeinterface #289, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 483: pop\n 484: goto 160\n 487: nop\n 488: aload 8\n 490: invokestatic #293 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 493: astore 7\n 495: aload_2\n 496: iload 5\n 498: invokestatic #160 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 501: aload 7\n 503: invokeinterface #219, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 508: pop\n 509: goto 18\n 512: aload_2\n 513: areturn\n}\n", "javap_err": "" } ]
daincredibleholg__AdventOfCode2023__4aa7c68/src/main/kotlin/io/steinh/aoc/day05/Almanac.kt
package io.steinh.aoc.day05 class Almanac(private val sourceData: Input) { fun lowestLocation(): Long { val list = mutableListOf<Long>() sourceData.seeds.forEach { val soil = getSoilForSeed(it) val fertilizer = getFertilizerForSoil(soil) val water = getWaterForFertilizer(fertilizer) val light = getLightForWater(water) val temperature = getTemperatureForLight(light) val humidity = getHumidityForTemperature(temperature) list.add(getLocationForHumidity(humidity)) } list.sort() return list.first() } fun lowestLocationForSeedRanges(): Long { var lowestLocationFound = 0L sourceData.seeds.chunked(2).forEach { seedRange -> for(it in seedRange.first()..(seedRange.first() + seedRange.last())) { val soil = getSoilForSeed(it) val fertilizer = getFertilizerForSoil(soil) val water = getWaterForFertilizer(fertilizer) val light = getLightForWater(water) val temperature = getTemperatureForLight(light) val humidity = getHumidityForTemperature(temperature) val location = getLocationForHumidity(humidity) lowestLocationFound = if (lowestLocationFound == 0L || location < lowestLocationFound) location else lowestLocationFound } } return lowestLocationFound } private fun getSoilForSeed(seed: Long) = filterFromMapping(seed, sourceData.seedToSoilMappings) private fun getFertilizerForSoil(soil: Long) = filterFromMapping(soil, sourceData.soilToFertilizerMappings) private fun getWaterForFertilizer(fertilizer: Long) = filterFromMapping(fertilizer, sourceData.fertilizerToWaterMappings) private fun getLightForWater(water: Long) = filterFromMapping(water, sourceData.waterToLightMappings) private fun getTemperatureForLight(light: Long) = filterFromMapping(light, sourceData.lightToTemperatureMappings) private fun getHumidityForTemperature(temperature: Long) = filterFromMapping(temperature, sourceData.temperatureToHumidityMappings) private fun getLocationForHumidity(humidity: Long) = filterFromMapping(humidity, sourceData.humidityToLocationMappings) private fun filterFromMapping(id: Long, mappings: List<Mapping>): Long = mappings .filter { it.sourceRangeStart.contains(id) }.map { it.destinationRangeStart.first + (id - it.sourceRangeStart.first) }.ifEmpty { listOf(id) }.first() } fun main() { val rawInput = {}.javaClass.classLoader?.getResource("day05/input.txt")?.readText()!! val inputProcessor = AlmanacInputProcessor() val input = inputProcessor.transform(rawInput) val instance = Almanac(input) val resultOne = instance.lowestLocation() println("Result for day 05, part I: $resultOne") val resultTwo = instance.lowestLocationForSeedRanges() println("Result for day 05, part II: $resultTwo") }
[ { "class_path": "daincredibleholg__AdventOfCode2023__4aa7c68/io/steinh/aoc/day05/AlmanacKt.class", "javap": "Compiled from \"Almanac.kt\"\npublic final class io.steinh.aoc.day05.AlmanacKt {\n public static final void main();\n Code:\n 0: invokedynamic #25, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function0;\n 5: invokevirtual #29 // Method java/lang/Object.getClass:()Ljava/lang/Class;\n 8: invokevirtual #35 // Method java/lang/Class.getClassLoader:()Ljava/lang/ClassLoader;\n 11: dup\n 12: ifnull 50\n 15: ldc #37 // String day05/input.txt\n 17: invokevirtual #43 // Method java/lang/ClassLoader.getResource:(Ljava/lang/String;)Ljava/net/URL;\n 20: dup\n 21: ifnull 50\n 24: astore_3\n 25: getstatic #49 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 28: astore 4\n 30: aload_3\n 31: invokestatic #55 // Method kotlin/io/TextStreamsKt.readBytes:(Ljava/net/URL;)[B\n 34: astore 5\n 36: new #57 // class java/lang/String\n 39: dup\n 40: aload 5\n 42: aload 4\n 44: invokespecial #61 // Method java/lang/String.\"<init>\":([BLjava/nio/charset/Charset;)V\n 47: goto 52\n 50: pop\n 51: aconst_null\n 52: dup\n 53: invokestatic #67 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 56: astore_0\n 57: new #69 // class io/steinh/aoc/day05/AlmanacInputProcessor\n 60: dup\n 61: invokespecial #71 // Method io/steinh/aoc/day05/AlmanacInputProcessor.\"<init>\":()V\n 64: astore_1\n 65: aload_1\n 66: aload_0\n 67: invokevirtual #75 // Method io/steinh/aoc/day05/AlmanacInputProcessor.transform:(Ljava/lang/String;)Lio/steinh/aoc/day05/Input;\n 70: astore_2\n 71: new #77 // class io/steinh/aoc/day05/Almanac\n 74: dup\n 75: aload_2\n 76: invokespecial #80 // Method io/steinh/aoc/day05/Almanac.\"<init>\":(Lio/steinh/aoc/day05/Input;)V\n 79: astore_3\n 80: aload_3\n 81: invokevirtual #84 // Method io/steinh/aoc/day05/Almanac.lowestLocation:()J\n 84: lstore 4\n 86: new #86 // class java/lang/StringBuilder\n 89: dup\n 90: invokespecial #87 // Method java/lang/StringBuilder.\"<init>\":()V\n 93: ldc #89 // String Result for day 05, part I:\n 95: invokevirtual #93 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 98: lload 4\n 100: invokevirtual #96 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 103: invokevirtual #100 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 106: getstatic #106 // Field java/lang/System.out:Ljava/io/PrintStream;\n 109: swap\n 110: invokevirtual #111 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 113: aload_3\n 114: invokevirtual #114 // Method io/steinh/aoc/day05/Almanac.lowestLocationForSeedRanges:()J\n 117: lstore 6\n 119: new #86 // class java/lang/StringBuilder\n 122: dup\n 123: invokespecial #87 // Method java/lang/StringBuilder.\"<init>\":()V\n 126: ldc #116 // String Result for day 05, part II:\n 128: invokevirtual #93 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 131: lload 6\n 133: invokevirtual #96 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 136: invokevirtual #100 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 139: getstatic #106 // Field java/lang/System.out:Ljava/io/PrintStream;\n 142: swap\n 143: invokevirtual #111 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 146: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #130 // Method main:()V\n 3: return\n\n private static final kotlin.Unit main$lambda$0();\n Code:\n 0: getstatic #138 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 3: areturn\n}\n", "javap_err": "" }, { "class_path": "daincredibleholg__AdventOfCode2023__4aa7c68/io/steinh/aoc/day05/Almanac.class", "javap": "Compiled from \"Almanac.kt\"\npublic final class io.steinh.aoc.day05.Almanac {\n private final io.steinh.aoc.day05.Input sourceData;\n\n public io.steinh.aoc.day05.Almanac(io.steinh.aoc.day05.Input);\n Code:\n 0: aload_1\n 1: ldc #9 // String sourceData\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #18 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #21 // Field sourceData:Lio/steinh/aoc/day05/Input;\n 15: return\n\n public final long lowestLocation();\n Code:\n 0: new #27 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #28 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #30 // class java/util/List\n 10: astore_1\n 11: aload_0\n 12: getfield #21 // Field sourceData:Lio/steinh/aoc/day05/Input;\n 15: invokevirtual #36 // Method io/steinh/aoc/day05/Input.getSeeds:()Ljava/util/List;\n 18: checkcast #38 // class java/lang/Iterable\n 21: astore_2\n 22: iconst_0\n 23: istore_3\n 24: aload_2\n 25: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 30: astore 4\n 32: aload 4\n 34: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 39: ifeq 133\n 42: aload 4\n 44: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 49: astore 5\n 51: aload 5\n 53: checkcast #54 // class java/lang/Number\n 56: invokevirtual #57 // Method java/lang/Number.longValue:()J\n 59: lstore 6\n 61: iconst_0\n 62: istore 8\n 64: aload_0\n 65: lload 6\n 67: invokespecial #61 // Method getSoilForSeed:(J)J\n 70: lstore 9\n 72: aload_0\n 73: lload 9\n 75: invokespecial #64 // Method getFertilizerForSoil:(J)J\n 78: lstore 11\n 80: aload_0\n 81: lload 11\n 83: invokespecial #67 // Method getWaterForFertilizer:(J)J\n 86: lstore 13\n 88: aload_0\n 89: lload 13\n 91: invokespecial #70 // Method getLightForWater:(J)J\n 94: lstore 15\n 96: aload_0\n 97: lload 15\n 99: invokespecial #73 // Method getTemperatureForLight:(J)J\n 102: lstore 17\n 104: aload_0\n 105: lload 17\n 107: invokespecial #76 // Method getHumidityForTemperature:(J)J\n 110: lstore 19\n 112: aload_1\n 113: aload_0\n 114: lload 19\n 116: invokespecial #79 // Method getLocationForHumidity:(J)J\n 119: invokestatic #85 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 122: invokeinterface #89, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 127: pop\n 128: nop\n 129: nop\n 130: goto 32\n 133: nop\n 134: aload_1\n 135: invokestatic #95 // Method kotlin/collections/CollectionsKt.sort:(Ljava/util/List;)V\n 138: aload_1\n 139: invokestatic #99 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 142: checkcast #54 // class java/lang/Number\n 145: invokevirtual #57 // Method java/lang/Number.longValue:()J\n 148: lreturn\n\n public final long lowestLocationForSeedRanges();\n Code:\n 0: lconst_0\n 1: lstore 25\n 3: aload_0\n 4: getfield #21 // Field sourceData:Lio/steinh/aoc/day05/Input;\n 7: invokevirtual #36 // Method io/steinh/aoc/day05/Input.getSeeds:()Ljava/util/List;\n 10: checkcast #38 // class java/lang/Iterable\n 13: iconst_2\n 14: invokestatic #121 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 17: checkcast #38 // class java/lang/Iterable\n 20: astore_1\n 21: iconst_0\n 22: istore_2\n 23: aload_1\n 24: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 29: astore_3\n 30: aload_3\n 31: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 36: ifeq 206\n 39: aload_3\n 40: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 45: astore 4\n 47: aload 4\n 49: checkcast #30 // class java/util/List\n 52: astore 5\n 54: iconst_0\n 55: istore 6\n 57: aload 5\n 59: invokestatic #99 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 62: checkcast #54 // class java/lang/Number\n 65: invokevirtual #57 // Method java/lang/Number.longValue:()J\n 68: lstore 7\n 70: aload 5\n 72: invokestatic #99 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 75: checkcast #54 // class java/lang/Number\n 78: invokevirtual #57 // Method java/lang/Number.longValue:()J\n 81: aload 5\n 83: invokestatic #124 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 86: checkcast #54 // class java/lang/Number\n 89: invokevirtual #57 // Method java/lang/Number.longValue:()J\n 92: ladd\n 93: lstore 9\n 95: lload 7\n 97: lload 9\n 99: lcmp\n 100: ifgt 201\n 103: aload_0\n 104: lload 7\n 106: invokespecial #61 // Method getSoilForSeed:(J)J\n 109: lstore 11\n 111: aload_0\n 112: lload 11\n 114: invokespecial #64 // Method getFertilizerForSoil:(J)J\n 117: lstore 13\n 119: aload_0\n 120: lload 13\n 122: invokespecial #67 // Method getWaterForFertilizer:(J)J\n 125: lstore 15\n 127: aload_0\n 128: lload 15\n 130: invokespecial #70 // Method getLightForWater:(J)J\n 133: lstore 17\n 135: aload_0\n 136: lload 17\n 138: invokespecial #73 // Method getTemperatureForLight:(J)J\n 141: lstore 19\n 143: aload_0\n 144: lload 19\n 146: invokespecial #76 // Method getHumidityForTemperature:(J)J\n 149: lstore 21\n 151: aload_0\n 152: lload 21\n 154: invokespecial #79 // Method getLocationForHumidity:(J)J\n 157: lstore 23\n 159: nop\n 160: lload 25\n 162: lconst_0\n 163: lcmp\n 164: ifeq 175\n 167: lload 23\n 169: lload 25\n 171: lcmp\n 172: ifge 180\n 175: lload 23\n 177: goto 182\n 180: lload 25\n 182: lstore 25\n 184: lload 7\n 186: lload 9\n 188: lcmp\n 189: ifeq 201\n 192: lload 7\n 194: lconst_1\n 195: ladd\n 196: lstore 7\n 198: goto 103\n 201: nop\n 202: nop\n 203: goto 30\n 206: nop\n 207: lload 25\n 209: lreturn\n\n private final long getSoilForSeed(long);\n Code:\n 0: aload_0\n 1: lload_1\n 2: aload_0\n 3: getfield #21 // Field sourceData:Lio/steinh/aoc/day05/Input;\n 6: invokevirtual #131 // Method io/steinh/aoc/day05/Input.getSeedToSoilMappings:()Ljava/util/List;\n 9: invokespecial #135 // Method filterFromMapping:(JLjava/util/List;)J\n 12: lreturn\n\n private final long getFertilizerForSoil(long);\n Code:\n 0: aload_0\n 1: lload_1\n 2: aload_0\n 3: getfield #21 // Field sourceData:Lio/steinh/aoc/day05/Input;\n 6: invokevirtual #139 // Method io/steinh/aoc/day05/Input.getSoilToFertilizerMappings:()Ljava/util/List;\n 9: invokespecial #135 // Method filterFromMapping:(JLjava/util/List;)J\n 12: lreturn\n\n private final long getWaterForFertilizer(long);\n Code:\n 0: aload_0\n 1: lload_1\n 2: aload_0\n 3: getfield #21 // Field sourceData:Lio/steinh/aoc/day05/Input;\n 6: invokevirtual #142 // Method io/steinh/aoc/day05/Input.getFertilizerToWaterMappings:()Ljava/util/List;\n 9: invokespecial #135 // Method filterFromMapping:(JLjava/util/List;)J\n 12: lreturn\n\n private final long getLightForWater(long);\n Code:\n 0: aload_0\n 1: lload_1\n 2: aload_0\n 3: getfield #21 // Field sourceData:Lio/steinh/aoc/day05/Input;\n 6: invokevirtual #145 // Method io/steinh/aoc/day05/Input.getWaterToLightMappings:()Ljava/util/List;\n 9: invokespecial #135 // Method filterFromMapping:(JLjava/util/List;)J\n 12: lreturn\n\n private final long getTemperatureForLight(long);\n Code:\n 0: aload_0\n 1: lload_1\n 2: aload_0\n 3: getfield #21 // Field sourceData:Lio/steinh/aoc/day05/Input;\n 6: invokevirtual #148 // Method io/steinh/aoc/day05/Input.getLightToTemperatureMappings:()Ljava/util/List;\n 9: invokespecial #135 // Method filterFromMapping:(JLjava/util/List;)J\n 12: lreturn\n\n private final long getHumidityForTemperature(long);\n Code:\n 0: aload_0\n 1: lload_1\n 2: aload_0\n 3: getfield #21 // Field sourceData:Lio/steinh/aoc/day05/Input;\n 6: invokevirtual #151 // Method io/steinh/aoc/day05/Input.getTemperatureToHumidityMappings:()Ljava/util/List;\n 9: invokespecial #135 // Method filterFromMapping:(JLjava/util/List;)J\n 12: lreturn\n\n private final long getLocationForHumidity(long);\n Code:\n 0: aload_0\n 1: lload_1\n 2: aload_0\n 3: getfield #21 // Field sourceData:Lio/steinh/aoc/day05/Input;\n 6: invokevirtual #154 // Method io/steinh/aoc/day05/Input.getHumidityToLocationMappings:()Ljava/util/List;\n 9: invokespecial #135 // Method filterFromMapping:(JLjava/util/List;)J\n 12: lreturn\n\n private final long filterFromMapping(long, java.util.List<io.steinh.aoc.day05.Mapping>);\n Code:\n 0: aload_3\n 1: checkcast #38 // class java/lang/Iterable\n 4: astore 4\n 6: nop\n 7: iconst_0\n 8: istore 5\n 10: aload 4\n 12: astore 6\n 14: new #27 // class java/util/ArrayList\n 17: dup\n 18: invokespecial #28 // Method java/util/ArrayList.\"<init>\":()V\n 21: checkcast #157 // class java/util/Collection\n 24: astore 7\n 26: iconst_0\n 27: istore 8\n 29: aload 6\n 31: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 9\n 38: aload 9\n 40: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 92\n 48: aload 9\n 50: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 10\n 57: aload 10\n 59: checkcast #159 // class io/steinh/aoc/day05/Mapping\n 62: astore 11\n 64: iconst_0\n 65: istore 12\n 67: aload 11\n 69: invokevirtual #163 // Method io/steinh/aoc/day05/Mapping.getSourceRangeStart:()Lkotlin/ranges/LongRange;\n 72: lload_1\n 73: invokevirtual #169 // Method kotlin/ranges/LongRange.contains:(J)Z\n 76: ifeq 38\n 79: aload 7\n 81: aload 10\n 83: invokeinterface #170, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 88: pop\n 89: goto 38\n 92: aload 7\n 94: checkcast #30 // class java/util/List\n 97: nop\n 98: checkcast #38 // class java/lang/Iterable\n 101: astore 4\n 103: nop\n 104: iconst_0\n 105: istore 5\n 107: aload 4\n 109: astore 6\n 111: new #27 // class java/util/ArrayList\n 114: dup\n 115: aload 4\n 117: bipush 10\n 119: invokestatic #174 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 122: invokespecial #177 // Method java/util/ArrayList.\"<init>\":(I)V\n 125: checkcast #157 // class java/util/Collection\n 128: astore 7\n 130: iconst_0\n 131: istore 8\n 133: aload 6\n 135: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 140: astore 9\n 142: aload 9\n 144: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 149: ifeq 209\n 152: aload 9\n 154: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 159: astore 10\n 161: aload 7\n 163: aload 10\n 165: checkcast #159 // class io/steinh/aoc/day05/Mapping\n 168: astore 11\n 170: astore 13\n 172: iconst_0\n 173: istore 12\n 175: aload 11\n 177: invokevirtual #180 // Method io/steinh/aoc/day05/Mapping.getDestinationRangeStart:()Lkotlin/ranges/LongRange;\n 180: invokevirtual #183 // Method kotlin/ranges/LongRange.getFirst:()J\n 183: lload_1\n 184: aload 11\n 186: invokevirtual #163 // Method io/steinh/aoc/day05/Mapping.getSourceRangeStart:()Lkotlin/ranges/LongRange;\n 189: invokevirtual #183 // Method kotlin/ranges/LongRange.getFirst:()J\n 192: lsub\n 193: ladd\n 194: invokestatic #85 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 197: aload 13\n 199: swap\n 200: invokeinterface #170, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 205: pop\n 206: goto 142\n 209: aload 7\n 211: checkcast #30 // class java/util/List\n 214: nop\n 215: checkcast #157 // class java/util/Collection\n 218: astore 4\n 220: aload 4\n 222: invokeinterface #186, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 227: ifeq 243\n 230: iconst_0\n 231: istore 5\n 233: lload_1\n 234: invokestatic #85 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 237: invokestatic #190 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 240: goto 245\n 243: aload 4\n 245: checkcast #30 // class java/util/List\n 248: invokestatic #99 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 251: checkcast #54 // class java/lang/Number\n 254: invokevirtual #57 // Method java/lang/Number.longValue:()J\n 257: lreturn\n}\n", "javap_err": "" } ]
daincredibleholg__AdventOfCode2023__4aa7c68/src/main/kotlin/io/steinh/aoc/day05/AlmanacInputProcessor.kt
package io.steinh.aoc.day05 class AlmanacInputProcessor { companion object { const val LENGTH_POSITION = 3 } fun transform(input: String): Input { return Input( extractSeeds(input), extractBlockFor("seed-to-soil", input), extractBlockFor("soil-to-fertilizer", input), extractBlockFor("fertilizer-to-water", input), extractBlockFor("water-to-light", input), extractBlockFor("light-to-temperature", input), extractBlockFor("temperature-to-humidity", input), extractBlockFor("humidity-to-location", input) ) } private fun extractSeeds(input: String): List<Long> { val spaceSeperatedSeeds = "^seeds: ([\\d ]+)\n".toRegex().find(input) ?: return emptyList() return spaceSeperatedSeeds.groupValues[1].split(" ").map { it.toLong() } } private fun extractBlockFor(prefix: String, input: String): List<Mapping> { val rawMappings = "$prefix map:.*([\\d \\n]+)".toRegex().findAll(input) return rawMappings.flatMap { "(\\d+) (\\d+) (\\d+)\\n?".toRegex().findAll(it.groupValues[1]) .map { mappings -> extractMapping(mappings) } }.toList() } private fun extractMapping(matchResult: MatchResult): Mapping { var length = matchResult.groupValues[LENGTH_POSITION].toLong() if (length > 0) { length -= 1 } val destinationRangeStart = matchResult.groupValues[1].toLong() val sourceRangeStart = matchResult.groupValues[2].toLong() return Mapping(destinationRangeStart..(destinationRangeStart+length), sourceRangeStart..(sourceRangeStart+length)) } } data class Mapping( val destinationRangeStart: LongRange, val sourceRangeStart: LongRange, ) data class Input( val seeds: List<Long>, val seedToSoilMappings: List<Mapping>, val soilToFertilizerMappings: List<Mapping>, val fertilizerToWaterMappings: List<Mapping>, val waterToLightMappings: List<Mapping>, val lightToTemperatureMappings: List<Mapping>, val temperatureToHumidityMappings: List<Mapping>, val humidityToLocationMappings: List<Mapping>, )
[ { "class_path": "daincredibleholg__AdventOfCode2023__4aa7c68/io/steinh/aoc/day05/AlmanacInputProcessor$Companion.class", "javap": "Compiled from \"AlmanacInputProcessor.kt\"\npublic final class io.steinh.aoc.day05.AlmanacInputProcessor$Companion {\n private io.steinh.aoc.day05.AlmanacInputProcessor$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public io.steinh.aoc.day05.AlmanacInputProcessor$Companion(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #12 // Method \"<init>\":()V\n 4: return\n}\n", "javap_err": "" }, { "class_path": "daincredibleholg__AdventOfCode2023__4aa7c68/io/steinh/aoc/day05/AlmanacInputProcessor.class", "javap": "Compiled from \"AlmanacInputProcessor.kt\"\npublic final class io.steinh.aoc.day05.AlmanacInputProcessor {\n public static final io.steinh.aoc.day05.AlmanacInputProcessor$Companion Companion;\n\n public static final int LENGTH_POSITION;\n\n public io.steinh.aoc.day05.AlmanacInputProcessor();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final io.steinh.aoc.day05.Input transform(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String input\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #23 // class io/steinh/aoc/day05/Input\n 9: dup\n 10: aload_0\n 11: aload_1\n 12: invokespecial #27 // Method extractSeeds:(Ljava/lang/String;)Ljava/util/List;\n 15: aload_0\n 16: ldc #29 // String seed-to-soil\n 18: aload_1\n 19: invokespecial #33 // Method extractBlockFor:(Ljava/lang/String;Ljava/lang/String;)Ljava/util/List;\n 22: aload_0\n 23: ldc #35 // String soil-to-fertilizer\n 25: aload_1\n 26: invokespecial #33 // Method extractBlockFor:(Ljava/lang/String;Ljava/lang/String;)Ljava/util/List;\n 29: aload_0\n 30: ldc #37 // String fertilizer-to-water\n 32: aload_1\n 33: invokespecial #33 // Method extractBlockFor:(Ljava/lang/String;Ljava/lang/String;)Ljava/util/List;\n 36: aload_0\n 37: ldc #39 // String water-to-light\n 39: aload_1\n 40: invokespecial #33 // Method extractBlockFor:(Ljava/lang/String;Ljava/lang/String;)Ljava/util/List;\n 43: aload_0\n 44: ldc #41 // String light-to-temperature\n 46: aload_1\n 47: invokespecial #33 // Method extractBlockFor:(Ljava/lang/String;Ljava/lang/String;)Ljava/util/List;\n 50: aload_0\n 51: ldc #43 // String temperature-to-humidity\n 53: aload_1\n 54: invokespecial #33 // Method extractBlockFor:(Ljava/lang/String;Ljava/lang/String;)Ljava/util/List;\n 57: aload_0\n 58: ldc #45 // String humidity-to-location\n 60: aload_1\n 61: invokespecial #33 // Method extractBlockFor:(Ljava/lang/String;Ljava/lang/String;)Ljava/util/List;\n 64: invokespecial #48 // Method io/steinh/aoc/day05/Input.\"<init>\":(Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;Ljava/util/List;)V\n 67: areturn\n\n private final java.util.List<java.lang.Long> extractSeeds(java.lang.String);\n Code:\n 0: new #52 // class kotlin/text/Regex\n 3: dup\n 4: ldc #54 // String ^seeds: ([\\\\d ]+)\\n\n 6: invokespecial #57 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: aload_1\n 10: checkcast #59 // class java/lang/CharSequence\n 13: iconst_0\n 14: iconst_2\n 15: aconst_null\n 16: invokestatic #63 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 19: dup\n 20: ifnonnull 28\n 23: pop\n 24: invokestatic #69 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 27: areturn\n 28: astore_2\n 29: aload_2\n 30: invokeinterface #74, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 35: iconst_1\n 36: invokeinterface #80, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 41: checkcast #59 // class java/lang/CharSequence\n 44: iconst_1\n 45: anewarray #82 // class java/lang/String\n 48: astore_3\n 49: aload_3\n 50: iconst_0\n 51: ldc #84 // String\n 53: aastore\n 54: aload_3\n 55: iconst_0\n 56: iconst_0\n 57: bipush 6\n 59: aconst_null\n 60: invokestatic #90 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 63: checkcast #92 // class java/lang/Iterable\n 66: astore_3\n 67: iconst_0\n 68: istore 4\n 70: aload_3\n 71: astore 5\n 73: new #94 // class java/util/ArrayList\n 76: dup\n 77: aload_3\n 78: bipush 10\n 80: invokestatic #98 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 83: invokespecial #101 // Method java/util/ArrayList.\"<init>\":(I)V\n 86: checkcast #103 // class java/util/Collection\n 89: astore 6\n 91: iconst_0\n 92: istore 7\n 94: aload 5\n 96: invokeinterface #107, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 101: astore 8\n 103: aload 8\n 105: invokeinterface #113, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 110: ifeq 157\n 113: aload 8\n 115: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 120: astore 9\n 122: aload 6\n 124: aload 9\n 126: checkcast #82 // class java/lang/String\n 129: astore 10\n 131: astore 12\n 133: iconst_0\n 134: istore 11\n 136: aload 10\n 138: invokestatic #123 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 141: nop\n 142: invokestatic #127 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 145: aload 12\n 147: swap\n 148: invokeinterface #131, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 153: pop\n 154: goto 103\n 157: aload 6\n 159: checkcast #76 // class java/util/List\n 162: nop\n 163: areturn\n\n private final java.util.List<io.steinh.aoc.day05.Mapping> extractBlockFor(java.lang.String, java.lang.String);\n Code:\n 0: new #52 // class kotlin/text/Regex\n 3: dup\n 4: new #148 // class java/lang/StringBuilder\n 7: dup\n 8: invokespecial #149 // Method java/lang/StringBuilder.\"<init>\":()V\n 11: aload_1\n 12: invokevirtual #153 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 15: ldc #155 // String map:.*([\\\\d \\\\n]+)\n 17: invokevirtual #153 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: invokevirtual #159 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 23: invokespecial #57 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 26: aload_2\n 27: checkcast #59 // class java/lang/CharSequence\n 30: iconst_0\n 31: iconst_2\n 32: aconst_null\n 33: invokestatic #163 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 36: astore_3\n 37: aload_3\n 38: aload_0\n 39: invokedynamic #183, 0 // InvokeDynamic #0:invoke:(Lio/steinh/aoc/day05/AlmanacInputProcessor;)Lkotlin/jvm/functions/Function1;\n 44: invokestatic #189 // Method kotlin/sequences/SequencesKt.flatMap:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 47: invokestatic #193 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 50: areturn\n\n private final io.steinh.aoc.day05.Mapping extractMapping(kotlin.text.MatchResult);\n Code:\n 0: aload_1\n 1: invokeinterface #74, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 6: iconst_3\n 7: invokeinterface #80, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 12: checkcast #82 // class java/lang/String\n 15: invokestatic #123 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 18: lstore_2\n 19: lload_2\n 20: lconst_0\n 21: lcmp\n 22: ifle 29\n 25: lload_2\n 26: lconst_1\n 27: lsub\n 28: lstore_2\n 29: aload_1\n 30: invokeinterface #74, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 35: iconst_1\n 36: invokeinterface #80, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 41: checkcast #82 // class java/lang/String\n 44: invokestatic #123 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 47: lstore 4\n 49: aload_1\n 50: invokeinterface #74, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 55: iconst_2\n 56: invokeinterface #80, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 61: checkcast #82 // class java/lang/String\n 64: invokestatic #123 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 67: lstore 6\n 69: new #200 // class io/steinh/aoc/day05/Mapping\n 72: dup\n 73: new #202 // class kotlin/ranges/LongRange\n 76: dup\n 77: lload 4\n 79: lload 4\n 81: lload_2\n 82: ladd\n 83: invokespecial #205 // Method kotlin/ranges/LongRange.\"<init>\":(JJ)V\n 86: new #202 // class kotlin/ranges/LongRange\n 89: dup\n 90: lload 6\n 92: lload 6\n 94: lload_2\n 95: ladd\n 96: invokespecial #205 // Method kotlin/ranges/LongRange.\"<init>\":(JJ)V\n 99: invokespecial #208 // Method io/steinh/aoc/day05/Mapping.\"<init>\":(Lkotlin/ranges/LongRange;Lkotlin/ranges/LongRange;)V\n 102: areturn\n\n private static final io.steinh.aoc.day05.Mapping extractBlockFor$lambda$2$lambda$1(io.steinh.aoc.day05.AlmanacInputProcessor, kotlin.text.MatchResult);\n Code:\n 0: aload_1\n 1: ldc #217 // String mappings\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokespecial #219 // Method extractMapping:(Lkotlin/text/MatchResult;)Lio/steinh/aoc/day05/Mapping;\n 11: areturn\n\n private static final kotlin.sequences.Sequence extractBlockFor$lambda$2(io.steinh.aoc.day05.AlmanacInputProcessor, kotlin.text.MatchResult);\n Code:\n 0: aload_1\n 1: ldc #221 // String it\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #52 // class kotlin/text/Regex\n 9: dup\n 10: ldc #223 // String (\\\\d+) (\\\\d+) (\\\\d+)\\\\n?\n 12: invokespecial #57 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 15: aload_1\n 16: invokeinterface #74, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 21: iconst_1\n 22: invokeinterface #80, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 27: checkcast #59 // class java/lang/CharSequence\n 30: iconst_0\n 31: iconst_2\n 32: aconst_null\n 33: invokestatic #163 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 36: aload_0\n 37: invokedynamic #228, 0 // InvokeDynamic #1:invoke:(Lio/steinh/aoc/day05/AlmanacInputProcessor;)Lkotlin/jvm/functions/Function1;\n 42: invokestatic #231 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 45: areturn\n\n static {};\n Code:\n 0: new #234 // class io/steinh/aoc/day05/AlmanacInputProcessor$Companion\n 3: dup\n 4: aconst_null\n 5: invokespecial #237 // Method io/steinh/aoc/day05/AlmanacInputProcessor$Companion.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 8: putstatic #241 // Field Companion:Lio/steinh/aoc/day05/AlmanacInputProcessor$Companion;\n 11: return\n}\n", "javap_err": "" } ]
kirvader__AutomatedSoccerRecordingWithAndroid__9dfbebf/movement/src/main/java/com/hawkeye/movement/utils/AngleMeasure.kt
package com.hawkeye.movement.utils import kotlin.math.PI fun cos(angle: AngleMeasure): Float = kotlin.math.cos(angle.radian()) fun sin(angle: AngleMeasure): Float = kotlin.math.sin(angle.radian()) fun abs(angle: AngleMeasure): AngleMeasure = Degree(kotlin.math.abs(angle.degree())) fun sign(angle: AngleMeasure): Float { return if (angle > Degree(0f)) { 1f } else if (angle < Degree(0f)) { -1f } else { 0f } } fun min(a: AngleMeasure, b: AngleMeasure): AngleMeasure = Degree(kotlin.math.min(a.degree(), b.degree())) fun max(a: AngleMeasure, b: AngleMeasure): AngleMeasure = Degree(kotlin.math.max(a.degree(), b.degree())) interface AngleMeasure : Comparable<AngleMeasure> { fun degree(): Float { return this.radian() * 180.0f / PI.toFloat() } fun radian(): Float { return this.degree() * PI.toFloat() / 180.0f } override operator fun compareTo(angle: AngleMeasure): Int { val deltaAngle = this.degree() - angle.degree() if (deltaAngle < -eps) { return -1 } if (deltaAngle > eps) { return 1 } return 0 } operator fun plus(angle: AngleMeasure): AngleMeasure { return Degree(this.degree() + angle.degree()) } operator fun minus(angle: AngleMeasure): AngleMeasure { return Degree(this.degree() - angle.degree()) } operator fun times(factor: Float): AngleMeasure { return Degree(this.degree() * factor) } operator fun div(factor: Float): AngleMeasure { return Degree(this.degree() / factor) } companion object { private const val eps = 0.00001f } } class Radian(private val angle: Float) : AngleMeasure { override fun degree(): Float = angle * 180.0f / PI.toFloat() override fun radian(): Float = angle } class Degree(private val angle: Float) : AngleMeasure { override fun degree(): Float = angle override fun radian(): Float = angle * PI.toFloat() / 180.0f }
[ { "class_path": "kirvader__AutomatedSoccerRecordingWithAndroid__9dfbebf/com/hawkeye/movement/utils/AngleMeasure$DefaultImpls.class", "javap": "Compiled from \"AngleMeasure.kt\"\npublic final class com.hawkeye.movement.utils.AngleMeasure$DefaultImpls {\n public static float degree(com.hawkeye.movement.utils.AngleMeasure);\n Code:\n 0: aload_0\n 1: invokeinterface #13, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.radian:()F\n 6: ldc #14 // float 180.0f\n 8: fmul\n 9: ldc #15 // float 3.1415927f\n 11: fdiv\n 12: freturn\n\n public static float radian(com.hawkeye.movement.utils.AngleMeasure);\n Code:\n 0: aload_0\n 1: invokeinterface #19, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.degree:()F\n 6: ldc #15 // float 3.1415927f\n 8: fmul\n 9: ldc #14 // float 180.0f\n 11: fdiv\n 12: freturn\n\n public static int compareTo(com.hawkeye.movement.utils.AngleMeasure, com.hawkeye.movement.utils.AngleMeasure);\n Code:\n 0: aload_1\n 1: ldc #23 // String angle\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #19, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.degree:()F\n 12: aload_1\n 13: invokeinterface #19, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.degree:()F\n 18: fsub\n 19: fstore_2\n 20: fload_2\n 21: ldc #30 // float -1.0E-5f\n 23: fcmpg\n 24: ifge 29\n 27: iconst_m1\n 28: ireturn\n 29: fload_2\n 30: ldc #31 // float 1.0E-5f\n 32: fcmpl\n 33: ifle 38\n 36: iconst_1\n 37: ireturn\n 38: iconst_0\n 39: ireturn\n\n public static com.hawkeye.movement.utils.AngleMeasure plus(com.hawkeye.movement.utils.AngleMeasure, com.hawkeye.movement.utils.AngleMeasure);\n Code:\n 0: aload_1\n 1: ldc #23 // String angle\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #37 // class com/hawkeye/movement/utils/Degree\n 9: dup\n 10: aload_0\n 11: invokeinterface #19, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.degree:()F\n 16: aload_1\n 17: invokeinterface #19, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.degree:()F\n 22: fadd\n 23: invokespecial #41 // Method com/hawkeye/movement/utils/Degree.\"<init>\":(F)V\n 26: checkcast #9 // class com/hawkeye/movement/utils/AngleMeasure\n 29: areturn\n\n public static com.hawkeye.movement.utils.AngleMeasure minus(com.hawkeye.movement.utils.AngleMeasure, com.hawkeye.movement.utils.AngleMeasure);\n Code:\n 0: aload_1\n 1: ldc #23 // String angle\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #37 // class com/hawkeye/movement/utils/Degree\n 9: dup\n 10: aload_0\n 11: invokeinterface #19, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.degree:()F\n 16: aload_1\n 17: invokeinterface #19, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.degree:()F\n 22: fsub\n 23: invokespecial #41 // Method com/hawkeye/movement/utils/Degree.\"<init>\":(F)V\n 26: checkcast #9 // class com/hawkeye/movement/utils/AngleMeasure\n 29: areturn\n\n public static com.hawkeye.movement.utils.AngleMeasure times(com.hawkeye.movement.utils.AngleMeasure, float);\n Code:\n 0: new #37 // class com/hawkeye/movement/utils/Degree\n 3: dup\n 4: aload_0\n 5: invokeinterface #19, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.degree:()F\n 10: fload_1\n 11: fmul\n 12: invokespecial #41 // Method com/hawkeye/movement/utils/Degree.\"<init>\":(F)V\n 15: checkcast #9 // class com/hawkeye/movement/utils/AngleMeasure\n 18: areturn\n\n public static com.hawkeye.movement.utils.AngleMeasure div(com.hawkeye.movement.utils.AngleMeasure, float);\n Code:\n 0: new #37 // class com/hawkeye/movement/utils/Degree\n 3: dup\n 4: aload_0\n 5: invokeinterface #19, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.degree:()F\n 10: fload_1\n 11: fdiv\n 12: invokespecial #41 // Method com/hawkeye/movement/utils/Degree.\"<init>\":(F)V\n 15: checkcast #9 // class com/hawkeye/movement/utils/AngleMeasure\n 18: areturn\n}\n", "javap_err": "" }, { "class_path": "kirvader__AutomatedSoccerRecordingWithAndroid__9dfbebf/com/hawkeye/movement/utils/AngleMeasure.class", "javap": "Compiled from \"AngleMeasure.kt\"\npublic interface com.hawkeye.movement.utils.AngleMeasure extends java.lang.Comparable<com.hawkeye.movement.utils.AngleMeasure> {\n public static final com.hawkeye.movement.utils.AngleMeasure$Companion Companion;\n\n public abstract float degree();\n\n public abstract float radian();\n\n public abstract int compareTo(com.hawkeye.movement.utils.AngleMeasure);\n\n public abstract com.hawkeye.movement.utils.AngleMeasure plus(com.hawkeye.movement.utils.AngleMeasure);\n\n public abstract com.hawkeye.movement.utils.AngleMeasure minus(com.hawkeye.movement.utils.AngleMeasure);\n\n public abstract com.hawkeye.movement.utils.AngleMeasure times(float);\n\n public abstract com.hawkeye.movement.utils.AngleMeasure div(float);\n\n static {};\n Code:\n 0: getstatic #27 // Field com/hawkeye/movement/utils/AngleMeasure$Companion.$$INSTANCE:Lcom/hawkeye/movement/utils/AngleMeasure$Companion;\n 3: putstatic #30 // Field Companion:Lcom/hawkeye/movement/utils/AngleMeasure$Companion;\n 6: return\n}\n", "javap_err": "" }, { "class_path": "kirvader__AutomatedSoccerRecordingWithAndroid__9dfbebf/com/hawkeye/movement/utils/AngleMeasureKt.class", "javap": "Compiled from \"AngleMeasure.kt\"\npublic final class com.hawkeye.movement.utils.AngleMeasureKt {\n public static final float cos(com.hawkeye.movement.utils.AngleMeasure);\n Code:\n 0: aload_0\n 1: ldc #9 // String angle\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #21, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.radian:()F\n 12: f2d\n 13: invokestatic #26 // Method java/lang/Math.cos:(D)D\n 16: d2f\n 17: freturn\n\n public static final float sin(com.hawkeye.movement.utils.AngleMeasure);\n Code:\n 0: aload_0\n 1: ldc #9 // String angle\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #21, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.radian:()F\n 12: f2d\n 13: invokestatic #30 // Method java/lang/Math.sin:(D)D\n 16: d2f\n 17: freturn\n\n public static final com.hawkeye.movement.utils.AngleMeasure abs(com.hawkeye.movement.utils.AngleMeasure);\n Code:\n 0: aload_0\n 1: ldc #9 // String angle\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #34 // class com/hawkeye/movement/utils/Degree\n 9: dup\n 10: aload_0\n 11: invokeinterface #37, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.degree:()F\n 16: invokestatic #40 // Method java/lang/Math.abs:(F)F\n 19: invokespecial #44 // Method com/hawkeye/movement/utils/Degree.\"<init>\":(F)V\n 22: checkcast #17 // class com/hawkeye/movement/utils/AngleMeasure\n 25: areturn\n\n public static final float sign(com.hawkeye.movement.utils.AngleMeasure);\n Code:\n 0: aload_0\n 1: ldc #9 // String angle\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: new #34 // class com/hawkeye/movement/utils/Degree\n 10: dup\n 11: fconst_0\n 12: invokespecial #44 // Method com/hawkeye/movement/utils/Degree.\"<init>\":(F)V\n 15: checkcast #17 // class com/hawkeye/movement/utils/AngleMeasure\n 18: invokeinterface #49, 2 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.compareTo:(Lcom/hawkeye/movement/utils/AngleMeasure;)I\n 23: ifle 30\n 26: fconst_1\n 27: goto 56\n 30: aload_0\n 31: new #34 // class com/hawkeye/movement/utils/Degree\n 34: dup\n 35: fconst_0\n 36: invokespecial #44 // Method com/hawkeye/movement/utils/Degree.\"<init>\":(F)V\n 39: checkcast #17 // class com/hawkeye/movement/utils/AngleMeasure\n 42: invokeinterface #49, 2 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.compareTo:(Lcom/hawkeye/movement/utils/AngleMeasure;)I\n 47: ifge 55\n 50: ldc #50 // float -1.0f\n 52: goto 56\n 55: fconst_0\n 56: freturn\n\n public static final com.hawkeye.movement.utils.AngleMeasure min(com.hawkeye.movement.utils.AngleMeasure, com.hawkeye.movement.utils.AngleMeasure);\n Code:\n 0: aload_0\n 1: ldc #54 // String a\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #56 // String b\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #34 // class com/hawkeye/movement/utils/Degree\n 15: dup\n 16: aload_0\n 17: invokeinterface #37, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.degree:()F\n 22: aload_1\n 23: invokeinterface #37, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.degree:()F\n 28: invokestatic #59 // Method java/lang/Math.min:(FF)F\n 31: invokespecial #44 // Method com/hawkeye/movement/utils/Degree.\"<init>\":(F)V\n 34: checkcast #17 // class com/hawkeye/movement/utils/AngleMeasure\n 37: areturn\n\n public static final com.hawkeye.movement.utils.AngleMeasure max(com.hawkeye.movement.utils.AngleMeasure, com.hawkeye.movement.utils.AngleMeasure);\n Code:\n 0: aload_0\n 1: ldc #54 // String a\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #56 // String b\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #34 // class com/hawkeye/movement/utils/Degree\n 15: dup\n 16: aload_0\n 17: invokeinterface #37, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.degree:()F\n 22: aload_1\n 23: invokeinterface #37, 1 // InterfaceMethod com/hawkeye/movement/utils/AngleMeasure.degree:()F\n 28: invokestatic #62 // Method java/lang/Math.max:(FF)F\n 31: invokespecial #44 // Method com/hawkeye/movement/utils/Degree.\"<init>\":(F)V\n 34: checkcast #17 // class com/hawkeye/movement/utils/AngleMeasure\n 37: areturn\n}\n", "javap_err": "" }, { "class_path": "kirvader__AutomatedSoccerRecordingWithAndroid__9dfbebf/com/hawkeye/movement/utils/AngleMeasure$Companion.class", "javap": "Compiled from \"AngleMeasure.kt\"\npublic final class com.hawkeye.movement.utils.AngleMeasure$Companion {\n static final com.hawkeye.movement.utils.AngleMeasure$Companion $$INSTANCE;\n\n private static final float eps;\n\n private com.hawkeye.movement.utils.AngleMeasure$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #2 // class com/hawkeye/movement/utils/AngleMeasure$Companion\n 3: dup\n 4: invokespecial #12 // Method \"<init>\":()V\n 7: putstatic #15 // Field $$INSTANCE:Lcom/hawkeye/movement/utils/AngleMeasure$Companion;\n 10: return\n}\n", "javap_err": "" } ]
clechasseur__adventofcode2020__f3e8840/src/main/kotlin/org/clechasseur/adventofcode2020/math/Math.kt
package org.clechasseur.adventofcode2017.math import kotlin.math.abs fun <T> permutations(elements: List<T>): Sequence<List<T>> { if (elements.size == 1) { return sequenceOf(listOf(elements.first())) } return elements.asSequence().flatMap { elem -> val subIt = permutations(elements - elem).iterator() generateSequence { when (subIt.hasNext()) { true -> listOf(elem) + subIt.next() false -> null } } } } fun generatePairSequence(firstRange: IntRange, secondRange: IntRange): Sequence<Pair<Int, Int>> { return generateSequence(firstRange.first to secondRange.first) { when (it.second) { secondRange.last -> when (it.first) { firstRange.last -> null else -> it.first + 1 to secondRange.first } else -> it.first to it.second + 1 } } } fun factors(n: Long): List<Long> { return generateSequence(1L) { when { it < n -> it + 1L else -> null } }.filter { n % it == 0L }.toList() } fun greatestCommonDenominator(a: Long, b: Long): Long { // https://en.wikipedia.org/wiki/Euclidean_algorithm require(a > 0L && b > 0L) { "Can only find GCD for positive numbers" } var rm = b var r = a % rm while (r != 0L) { val rm2 = rm rm = r r = rm2 % rm } return rm } fun leastCommonMultiple(a: Long, b: Long): Long { // https://en.wikipedia.org/wiki/Least_common_multiple require(a > 0L && b > 0L) { "Can only find LCM for positive numbers" } return a / greatestCommonDenominator(a, b) * b } fun reduceFraction(numerator: Long, denominator: Long): Pair<Long, Long> { require(denominator != 0L) { "Divide by zero error" } return when (numerator) { 0L -> 0L to 1L else -> { val gcd = greatestCommonDenominator(abs(numerator), abs(denominator)) (numerator / gcd) to (denominator / gcd) } } }
[ { "class_path": "clechasseur__adventofcode2020__f3e8840/org/clechasseur/adventofcode2017/math/MathKt.class", "javap": "Compiled from \"Math.kt\"\npublic final class org.clechasseur.adventofcode2017.math.MathKt {\n public static final <T> kotlin.sequences.Sequence<java.util.List<T>> permutations(java.util.List<? extends T>);\n Code:\n 0: aload_0\n 1: ldc #10 // String elements\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #22, 1 // InterfaceMethod java/util/List.size:()I\n 12: iconst_1\n 13: if_icmpne 36\n 16: iconst_1\n 17: anewarray #18 // class java/util/List\n 20: astore_1\n 21: aload_1\n 22: iconst_0\n 23: aload_0\n 24: invokestatic #28 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 27: invokestatic #32 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 30: aastore\n 31: aload_1\n 32: invokestatic #38 // Method kotlin/sequences/SequencesKt.sequenceOf:([Ljava/lang/Object;)Lkotlin/sequences/Sequence;\n 35: areturn\n 36: aload_0\n 37: checkcast #40 // class java/lang/Iterable\n 40: invokestatic #44 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 43: aload_0\n 44: invokedynamic #64, 0 // InvokeDynamic #0:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 49: invokestatic #68 // Method kotlin/sequences/SequencesKt.flatMap:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 52: areturn\n\n public static final kotlin.sequences.Sequence<kotlin.Pair<java.lang.Integer, java.lang.Integer>> generatePairSequence(kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_0\n 1: ldc #74 // String firstRange\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #76 // String secondRange\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokevirtual #81 // Method kotlin/ranges/IntRange.getFirst:()I\n 16: invokestatic #87 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 19: aload_1\n 20: invokevirtual #81 // Method kotlin/ranges/IntRange.getFirst:()I\n 23: invokestatic #87 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 26: invokestatic #93 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 29: aload_1\n 30: aload_0\n 31: invokedynamic #103, 0 // InvokeDynamic #1:invoke:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Lkotlin/jvm/functions/Function1;\n 36: invokestatic #107 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 39: areturn\n\n public static final java.util.List<java.lang.Long> factors(long);\n Code:\n 0: lconst_1\n 1: invokestatic #116 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 4: lload_0\n 5: invokedynamic #126, 0 // InvokeDynamic #2:invoke:(J)Lkotlin/jvm/functions/Function1;\n 10: invokestatic #107 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 13: lload_0\n 14: invokedynamic #134, 0 // InvokeDynamic #3:invoke:(J)Lkotlin/jvm/functions/Function1;\n 19: invokestatic #137 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 22: invokestatic #141 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 25: areturn\n\n public static final long greatestCommonDenominator(long, long);\n Code:\n 0: lload_0\n 1: lconst_0\n 2: lcmp\n 3: ifle 16\n 6: lload_2\n 7: lconst_0\n 8: lcmp\n 9: ifle 16\n 12: iconst_1\n 13: goto 17\n 16: iconst_0\n 17: ifne 40\n 20: iconst_0\n 21: istore 5\n 23: ldc #147 // String Can only find GCD for positive numbers\n 25: astore 5\n 27: new #149 // class java/lang/IllegalArgumentException\n 30: dup\n 31: aload 5\n 33: invokevirtual #153 // Method java/lang/Object.toString:()Ljava/lang/String;\n 36: invokespecial #157 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 39: athrow\n 40: lload_2\n 41: lstore 4\n 43: lload_0\n 44: lload 4\n 46: lrem\n 47: lstore 6\n 49: lload 6\n 51: lconst_0\n 52: lcmp\n 53: ifeq 74\n 56: lload 4\n 58: lstore 8\n 60: lload 6\n 62: lstore 4\n 64: lload 8\n 66: lload 4\n 68: lrem\n 69: lstore 6\n 71: goto 49\n 74: lload 4\n 76: lreturn\n\n public static final long leastCommonMultiple(long, long);\n Code:\n 0: lload_0\n 1: lconst_0\n 2: lcmp\n 3: ifle 16\n 6: lload_2\n 7: lconst_0\n 8: lcmp\n 9: ifle 16\n 12: iconst_1\n 13: goto 17\n 16: iconst_0\n 17: ifne 40\n 20: iconst_0\n 21: istore 4\n 23: ldc #167 // String Can only find LCM for positive numbers\n 25: astore 4\n 27: new #149 // class java/lang/IllegalArgumentException\n 30: dup\n 31: aload 4\n 33: invokevirtual #153 // Method java/lang/Object.toString:()Ljava/lang/String;\n 36: invokespecial #157 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 39: athrow\n 40: lload_0\n 41: lload_0\n 42: lload_2\n 43: invokestatic #169 // Method greatestCommonDenominator:(JJ)J\n 46: ldiv\n 47: lload_2\n 48: lmul\n 49: lreturn\n\n public static final kotlin.Pair<java.lang.Long, java.lang.Long> reduceFraction(long, long);\n Code:\n 0: lload_2\n 1: lconst_0\n 2: lcmp\n 3: ifeq 10\n 6: iconst_1\n 7: goto 11\n 10: iconst_0\n 11: ifne 34\n 14: iconst_0\n 15: istore 4\n 17: ldc #175 // String Divide by zero error\n 19: astore 4\n 21: new #149 // class java/lang/IllegalArgumentException\n 24: dup\n 25: aload 4\n 27: invokevirtual #153 // Method java/lang/Object.toString:()Ljava/lang/String;\n 30: invokespecial #157 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 33: athrow\n 34: lload_0\n 35: lconst_0\n 36: lcmp\n 37: ifne 54\n 40: lconst_0\n 41: invokestatic #116 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 44: lconst_1\n 45: invokestatic #116 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 48: invokestatic #93 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 51: goto 84\n 54: lload_0\n 55: invokestatic #181 // Method java/lang/Math.abs:(J)J\n 58: lload_2\n 59: invokestatic #181 // Method java/lang/Math.abs:(J)J\n 62: invokestatic #169 // Method greatestCommonDenominator:(JJ)J\n 65: lstore 5\n 67: lload_0\n 68: lload 5\n 70: ldiv\n 71: invokestatic #116 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 74: lload_2\n 75: lload 5\n 77: ldiv\n 78: invokestatic #116 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 81: invokestatic #93 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 84: areturn\n\n private static final java.util.List permutations$lambda$1$lambda$0(java.util.Iterator, java.lang.Object);\n Code:\n 0: aload_0\n 1: invokeinterface #195, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 6: istore_2\n 7: iload_2\n 8: iconst_1\n 9: if_icmpne 34\n 12: aload_1\n 13: invokestatic #32 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 16: checkcast #197 // class java/util/Collection\n 19: aload_0\n 20: invokeinterface #201, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 25: checkcast #40 // class java/lang/Iterable\n 28: invokestatic #205 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 31: goto 50\n 34: iload_2\n 35: ifne 42\n 38: aconst_null\n 39: goto 50\n 42: new #207 // class kotlin/NoWhenBranchMatchedException\n 45: dup\n 46: invokespecial #210 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 49: athrow\n 50: areturn\n\n private static final kotlin.sequences.Sequence permutations$lambda$1(java.util.List, java.lang.Object);\n Code:\n 0: aload_0\n 1: checkcast #40 // class java/lang/Iterable\n 4: aload_1\n 5: invokestatic #218 // Method kotlin/collections/CollectionsKt.minus:(Ljava/lang/Iterable;Ljava/lang/Object;)Ljava/util/List;\n 8: invokestatic #220 // Method permutations:(Ljava/util/List;)Lkotlin/sequences/Sequence;\n 11: invokeinterface #226, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 16: astore_2\n 17: aload_2\n 18: aload_1\n 19: invokedynamic #235, 0 // InvokeDynamic #4:invoke:(Ljava/util/Iterator;Ljava/lang/Object;)Lkotlin/jvm/functions/Function0;\n 24: invokestatic #238 // Method kotlin/sequences/SequencesKt.generateSequence:(Lkotlin/jvm/functions/Function0;)Lkotlin/sequences/Sequence;\n 27: areturn\n\n private static final kotlin.Pair generatePairSequence$lambda$2(kotlin.ranges.IntRange, kotlin.ranges.IntRange, kotlin.Pair);\n Code:\n 0: aload_2\n 1: ldc #243 // String it\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: invokevirtual #246 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 10: checkcast #248 // class java/lang/Number\n 13: invokevirtual #251 // Method java/lang/Number.intValue:()I\n 16: aload_0\n 17: invokevirtual #254 // Method kotlin/ranges/IntRange.getLast:()I\n 20: if_icmpne 72\n 23: aload_2\n 24: invokevirtual #256 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 27: checkcast #248 // class java/lang/Number\n 30: invokevirtual #251 // Method java/lang/Number.intValue:()I\n 33: aload_1\n 34: invokevirtual #254 // Method kotlin/ranges/IntRange.getLast:()I\n 37: if_icmpne 44\n 40: aconst_null\n 41: goto 94\n 44: aload_2\n 45: invokevirtual #256 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 48: checkcast #248 // class java/lang/Number\n 51: invokevirtual #251 // Method java/lang/Number.intValue:()I\n 54: iconst_1\n 55: iadd\n 56: invokestatic #87 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 59: aload_0\n 60: invokevirtual #81 // Method kotlin/ranges/IntRange.getFirst:()I\n 63: invokestatic #87 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 66: invokestatic #93 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 69: goto 94\n 72: aload_2\n 73: invokevirtual #256 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 76: aload_2\n 77: invokevirtual #246 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 80: checkcast #248 // class java/lang/Number\n 83: invokevirtual #251 // Method java/lang/Number.intValue:()I\n 86: iconst_1\n 87: iadd\n 88: invokestatic #87 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 91: invokestatic #93 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 94: areturn\n\n private static final java.lang.Long factors$lambda$3(long, long);\n Code:\n 0: nop\n 1: lload_2\n 2: lload_0\n 3: lcmp\n 4: ifge 16\n 7: lload_2\n 8: lconst_1\n 9: ladd\n 10: invokestatic #116 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 13: goto 17\n 16: aconst_null\n 17: areturn\n\n private static final boolean factors$lambda$4(long, long);\n Code:\n 0: lload_0\n 1: lload_2\n 2: lrem\n 3: lconst_0\n 4: lcmp\n 5: ifne 12\n 8: iconst_1\n 9: goto 13\n 12: iconst_0\n 13: ireturn\n}\n", "javap_err": "" } ]
mdenburger__aoc-2020__b965f46/src/main/kotlin/day09/Day09.kt
package day09 import java.io.File fun main() { val numbers = File("src/main/kotlin/day09/day09-input.txt").readLines().map { it.toLong() }.toLongArray() val window = 25 val invalidNumber = answer1(numbers, window) println("Answer 1: $invalidNumber") println("Answer 2: " + answer2(numbers, invalidNumber)) } private fun answer1(numbers: LongArray, window: Int): Long { for (start in 0 until numbers.size - window) { val next = numbers[start + window] if (!numbers.containsSum(start, start + window, next)) { return next } } error("No answer found") } private fun LongArray.containsSum(start: Int, end: Int, sum: Long): Boolean { for (i in start until end) { val first = get(i) for (j in i + 1 until end) { val second = get(j) if (first != second && first + second == sum) { return true } } } return false } private fun answer2(numbers: LongArray, sum: Long): Long { for (start in numbers.indices) { numbers.findRangeSumsTo(start, sum)?.let { return it.minOrNull()!! + it.maxOrNull()!! } } error("No answer found") } private fun LongArray.findRangeSumsTo(start: Int, sum: Long): List<Long>? { val range = mutableListOf<Long>() var rangeSum = 0L for (i in start until size) { range += get(i) rangeSum += get(i) if (rangeSum == sum) { return range } if (rangeSum > sum) { return null } } return null }
[ { "class_path": "mdenburger__aoc-2020__b965f46/day09/Day09Kt.class", "javap": "Compiled from \"Day09.kt\"\npublic final class day09.Day09Kt {\n public static final void main();\n Code:\n 0: new #8 // class java/io/File\n 3: dup\n 4: ldc #10 // String src/main/kotlin/day09/day09-input.txt\n 6: invokespecial #14 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #20 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 15: checkcast #22 // class java/lang/Iterable\n 18: astore_1\n 19: iconst_0\n 20: istore_2\n 21: aload_1\n 22: astore_3\n 23: new #24 // class java/util/ArrayList\n 26: dup\n 27: aload_1\n 28: bipush 10\n 30: invokestatic #30 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 33: invokespecial #33 // Method java/util/ArrayList.\"<init>\":(I)V\n 36: checkcast #35 // class java/util/Collection\n 39: astore 4\n 41: iconst_0\n 42: istore 5\n 44: aload_3\n 45: invokeinterface #39, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 6\n 52: aload 6\n 54: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 106\n 62: aload 6\n 64: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 7\n 71: aload 4\n 73: aload 7\n 75: checkcast #51 // class java/lang/String\n 78: astore 8\n 80: astore 10\n 82: iconst_0\n 83: istore 9\n 85: aload 8\n 87: invokestatic #57 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 90: nop\n 91: invokestatic #61 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 94: aload 10\n 96: swap\n 97: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 102: pop\n 103: goto 52\n 106: aload 4\n 108: checkcast #67 // class java/util/List\n 111: nop\n 112: checkcast #35 // class java/util/Collection\n 115: invokestatic #71 // Method kotlin/collections/CollectionsKt.toLongArray:(Ljava/util/Collection;)[J\n 118: astore_0\n 119: bipush 25\n 121: istore_1\n 122: aload_0\n 123: iload_1\n 124: invokestatic #75 // Method answer1:([JI)J\n 127: lstore_2\n 128: new #77 // class java/lang/StringBuilder\n 131: dup\n 132: invokespecial #79 // Method java/lang/StringBuilder.\"<init>\":()V\n 135: ldc #81 // String Answer 1:\n 137: invokevirtual #85 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 140: lload_2\n 141: invokevirtual #88 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 144: invokevirtual #92 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 147: getstatic #98 // Field java/lang/System.out:Ljava/io/PrintStream;\n 150: swap\n 151: invokevirtual #104 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 154: new #77 // class java/lang/StringBuilder\n 157: dup\n 158: invokespecial #79 // Method java/lang/StringBuilder.\"<init>\":()V\n 161: ldc #106 // String Answer 2:\n 163: invokevirtual #85 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 166: aload_0\n 167: lload_2\n 168: invokestatic #110 // Method answer2:([JJ)J\n 171: invokevirtual #88 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 174: invokevirtual #92 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 177: getstatic #98 // Field java/lang/System.out:Ljava/io/PrintStream;\n 180: swap\n 181: invokevirtual #104 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 184: return\n\n private static final long answer1(long[], int);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: aload_0\n 3: arraylength\n 4: iload_1\n 5: isub\n 6: istore_3\n 7: iload_2\n 8: iload_3\n 9: if_icmpge 41\n 12: aload_0\n 13: iload_2\n 14: iload_1\n 15: iadd\n 16: laload\n 17: lstore 4\n 19: aload_0\n 20: iload_2\n 21: iload_2\n 22: iload_1\n 23: iadd\n 24: lload 4\n 26: invokestatic #132 // Method containsSum:([JIIJ)Z\n 29: ifne 35\n 32: lload 4\n 34: lreturn\n 35: iinc 2, 1\n 38: goto 7\n 41: new #134 // class java/lang/IllegalStateException\n 44: dup\n 45: ldc #136 // String No answer found\n 47: invokevirtual #137 // Method java/lang/Object.toString:()Ljava/lang/String;\n 50: invokespecial #138 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 53: athrow\n\n private static final boolean containsSum(long[], int, int, long);\n Code:\n 0: iload_1\n 1: istore 5\n 3: iload 5\n 5: iload_2\n 6: if_icmpge 65\n 9: aload_0\n 10: iload 5\n 12: laload\n 13: lstore 6\n 15: iload 5\n 17: iconst_1\n 18: iadd\n 19: istore 8\n 21: iload 8\n 23: iload_2\n 24: if_icmpge 59\n 27: aload_0\n 28: iload 8\n 30: laload\n 31: lstore 9\n 33: lload 6\n 35: lload 9\n 37: lcmp\n 38: ifeq 53\n 41: lload 6\n 43: lload 9\n 45: ladd\n 46: lload_3\n 47: lcmp\n 48: ifne 53\n 51: iconst_1\n 52: ireturn\n 53: iinc 8, 1\n 56: goto 21\n 59: iinc 5, 1\n 62: goto 3\n 65: iconst_0\n 66: ireturn\n\n private static final long answer2(long[], long);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: aload_0\n 3: arraylength\n 4: istore 4\n 6: iload_3\n 7: iload 4\n 9: if_icmpge 76\n 12: aload_0\n 13: iload_3\n 14: lload_1\n 15: invokestatic #150 // Method findRangeSumsTo:([JIJ)Ljava/util/List;\n 18: astore 5\n 20: aload 5\n 22: ifnull 70\n 25: aload 5\n 27: astore 6\n 29: iconst_0\n 30: istore 7\n 32: aload 6\n 34: checkcast #22 // class java/lang/Iterable\n 37: invokestatic #154 // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 40: dup\n 41: invokestatic #159 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 44: checkcast #161 // class java/lang/Number\n 47: invokevirtual #165 // Method java/lang/Number.longValue:()J\n 50: aload 6\n 52: checkcast #22 // class java/lang/Iterable\n 55: invokestatic #168 // Method kotlin/collections/CollectionsKt.maxOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 58: dup\n 59: invokestatic #159 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 62: checkcast #161 // class java/lang/Number\n 65: invokevirtual #165 // Method java/lang/Number.longValue:()J\n 68: ladd\n 69: lreturn\n 70: iinc 3, 1\n 73: goto 6\n 76: new #134 // class java/lang/IllegalStateException\n 79: dup\n 80: ldc #136 // String No answer found\n 82: invokevirtual #137 // Method java/lang/Object.toString:()Ljava/lang/String;\n 85: invokespecial #138 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 88: athrow\n\n private static final java.util.List<java.lang.Long> findRangeSumsTo(long[], int, long);\n Code:\n 0: new #24 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #172 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #67 // class java/util/List\n 10: astore 4\n 12: lconst_0\n 13: lstore 5\n 15: iload_1\n 16: istore 7\n 18: aload_0\n 19: arraylength\n 20: istore 8\n 22: iload 7\n 24: iload 8\n 26: if_icmpge 81\n 29: aload 4\n 31: checkcast #35 // class java/util/Collection\n 34: aload_0\n 35: iload 7\n 37: laload\n 38: invokestatic #61 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 41: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 46: pop\n 47: lload 5\n 49: aload_0\n 50: iload 7\n 52: laload\n 53: ladd\n 54: lstore 5\n 56: lload 5\n 58: lload_2\n 59: lcmp\n 60: ifne 66\n 63: aload 4\n 65: areturn\n 66: lload 5\n 68: lload_2\n 69: lcmp\n 70: ifle 75\n 73: aconst_null\n 74: areturn\n 75: iinc 7, 1\n 78: goto 22\n 81: aconst_null\n 82: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #179 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
mdenburger__aoc-2020__b965f46/src/main/kotlin/day08/Day08.kt
package day08 import java.io.File data class Operation(val name: String, val argument: Int) class Program(private val operations: List<Operation>) { private var instruction = 0 private var accumulator = 0 private val visited = BooleanArray(operations.size) fun run(): Int { while (instruction < operations.size && !visited[instruction]) { visited[instruction] = true val operation = operations[instruction] when (operation.name) { "nop" -> instruction += 1 "acc" -> { accumulator += operation.argument instruction += 1 } "jmp" -> instruction += operation.argument else -> error("unknown operation: ${operation.name}") } } return accumulator } fun terminated() = instruction >= operations.size } fun main() { val operations = File("src/main/kotlin/day08/day08-input.txt").readLines().map { val (operationName, argument) = it.split(" ") Operation(operationName, argument.toInt()) } println("Answer 1: " + operations.run()) println("Answer 2: " + operations.modifyAndRun()) } fun List<Operation>.run() = Program(this).run() fun List<Operation>.modifyAndRun(): Int? { forEachIndexed { index, operation -> when (operation.name) { "jmp", "nop" -> { val modifiedOperations = toMutableList() val modifiedOperationName = when (operation.name) { "jmp" -> "nop" "nop" -> "jmp" else -> operation.name } modifiedOperations[index] = Operation(modifiedOperationName, operation.argument) val program = Program(modifiedOperations) val result = program.run() if (program.terminated()) { return result } } } } return null }
[ { "class_path": "mdenburger__aoc-2020__b965f46/day08/Day08Kt.class", "javap": "Compiled from \"Day08.kt\"\npublic final class day08.Day08Kt {\n public static final void main();\n Code:\n 0: new #8 // class java/io/File\n 3: dup\n 4: ldc #10 // String src/main/kotlin/day08/day08-input.txt\n 6: invokespecial #14 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #20 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 15: checkcast #22 // class java/lang/Iterable\n 18: astore_1\n 19: iconst_0\n 20: istore_2\n 21: aload_1\n 22: astore_3\n 23: new #24 // class java/util/ArrayList\n 26: dup\n 27: aload_1\n 28: bipush 10\n 30: invokestatic #30 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 33: invokespecial #33 // Method java/util/ArrayList.\"<init>\":(I)V\n 36: checkcast #35 // class java/util/Collection\n 39: astore 4\n 41: iconst_0\n 42: istore 5\n 44: aload_3\n 45: invokeinterface #39, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 6\n 52: aload 6\n 54: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 166\n 62: aload 6\n 64: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 7\n 71: aload 4\n 73: aload 7\n 75: checkcast #51 // class java/lang/String\n 78: astore 8\n 80: astore 13\n 82: iconst_0\n 83: istore 9\n 85: aload 8\n 87: checkcast #53 // class java/lang/CharSequence\n 90: iconst_1\n 91: anewarray #51 // class java/lang/String\n 94: astore 10\n 96: aload 10\n 98: iconst_0\n 99: ldc #55 // String\n 101: aastore\n 102: aload 10\n 104: iconst_0\n 105: iconst_0\n 106: bipush 6\n 108: aconst_null\n 109: invokestatic #61 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 112: astore 11\n 114: aload 11\n 116: iconst_0\n 117: invokeinterface #67, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 122: checkcast #51 // class java/lang/String\n 125: astore 10\n 127: aload 11\n 129: iconst_1\n 130: invokeinterface #67, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 135: checkcast #51 // class java/lang/String\n 138: astore 12\n 140: new #69 // class day08/Operation\n 143: dup\n 144: aload 10\n 146: aload 12\n 148: invokestatic #75 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 151: invokespecial #78 // Method day08/Operation.\"<init>\":(Ljava/lang/String;I)V\n 154: aload 13\n 156: swap\n 157: invokeinterface #82, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 162: pop\n 163: goto 52\n 166: aload 4\n 168: checkcast #63 // class java/util/List\n 171: nop\n 172: astore_0\n 173: new #84 // class java/lang/StringBuilder\n 176: dup\n 177: invokespecial #86 // Method java/lang/StringBuilder.\"<init>\":()V\n 180: ldc #88 // String Answer 1:\n 182: invokevirtual #92 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 185: aload_0\n 186: invokestatic #96 // Method run:(Ljava/util/List;)I\n 189: invokevirtual #99 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 192: invokevirtual #103 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 195: getstatic #109 // Field java/lang/System.out:Ljava/io/PrintStream;\n 198: swap\n 199: invokevirtual #115 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 202: new #84 // class java/lang/StringBuilder\n 205: dup\n 206: invokespecial #86 // Method java/lang/StringBuilder.\"<init>\":()V\n 209: ldc #117 // String Answer 2:\n 211: invokevirtual #92 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 214: aload_0\n 215: invokestatic #121 // Method modifyAndRun:(Ljava/util/List;)Ljava/lang/Integer;\n 218: invokevirtual #124 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 221: invokevirtual #103 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 224: getstatic #109 // Field java/lang/System.out:Ljava/io/PrintStream;\n 227: swap\n 228: invokevirtual #115 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 231: return\n\n public static final int run(java.util.List<day08.Operation>);\n Code:\n 0: aload_0\n 1: ldc #145 // String <this>\n 3: invokestatic #151 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #153 // class day08/Program\n 9: dup\n 10: aload_0\n 11: invokespecial #156 // Method day08/Program.\"<init>\":(Ljava/util/List;)V\n 14: invokevirtual #159 // Method day08/Program.run:()I\n 17: ireturn\n\n public static final java.lang.Integer modifyAndRun(java.util.List<day08.Operation>);\n Code:\n 0: aload_0\n 1: ldc #145 // String <this>\n 3: invokestatic #151 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #22 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: iconst_0\n 14: istore_3\n 15: aload_1\n 16: invokeinterface #39, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 21: astore 4\n 23: aload 4\n 25: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 30: ifeq 211\n 33: aload 4\n 35: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 40: astore 5\n 42: iload_3\n 43: iinc 3, 1\n 46: istore 6\n 48: iload 6\n 50: ifge 56\n 53: invokestatic #165 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 56: iload 6\n 58: aload 5\n 60: checkcast #69 // class day08/Operation\n 63: astore 7\n 65: istore 8\n 67: iconst_0\n 68: istore 9\n 70: aload 7\n 72: invokevirtual #168 // Method day08/Operation.getName:()Ljava/lang/String;\n 75: astore 10\n 77: aload 10\n 79: ldc #170 // String jmp\n 81: invokestatic #174 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 84: ifne 97\n 87: aload 10\n 89: ldc #176 // String nop\n 91: invokestatic #174 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 94: ifeq 206\n 97: aload_0\n 98: checkcast #35 // class java/util/Collection\n 101: invokestatic #180 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 104: astore 11\n 106: aload 7\n 108: invokevirtual #168 // Method day08/Operation.getName:()Ljava/lang/String;\n 111: astore 12\n 113: aload 12\n 115: ldc #170 // String jmp\n 117: invokestatic #174 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 120: ifeq 128\n 123: ldc #176 // String nop\n 125: goto 148\n 128: aload 12\n 130: ldc #176 // String nop\n 132: invokestatic #174 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 135: ifeq 143\n 138: ldc #170 // String jmp\n 140: goto 148\n 143: aload 7\n 145: invokevirtual #168 // Method day08/Operation.getName:()Ljava/lang/String;\n 148: astore 13\n 150: aload 11\n 152: iload 8\n 154: new #69 // class day08/Operation\n 157: dup\n 158: aload 13\n 160: aload 7\n 162: invokevirtual #183 // Method day08/Operation.getArgument:()I\n 165: invokespecial #78 // Method day08/Operation.\"<init>\":(Ljava/lang/String;I)V\n 168: invokeinterface #187, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 173: pop\n 174: new #153 // class day08/Program\n 177: dup\n 178: aload 11\n 180: invokespecial #156 // Method day08/Program.\"<init>\":(Ljava/util/List;)V\n 183: astore 12\n 185: aload 12\n 187: invokevirtual #159 // Method day08/Program.run:()I\n 190: istore 14\n 192: aload 12\n 194: invokevirtual #190 // Method day08/Program.terminated:()Z\n 197: ifeq 206\n 200: iload 14\n 202: invokestatic #194 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 205: areturn\n 206: nop\n 207: nop\n 208: goto 23\n 211: nop\n 212: aconst_null\n 213: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #211 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
mdenburger__aoc-2020__b965f46/src/main/kotlin/day10/Day10Second.kt
package day10 import java.io.File import kotlin.math.pow fun main() { val differences = File("src/main/kotlin/day10/day10-input.txt") .readLines() .map { it.toInt() } .sorted() .let { listOf(0) + it + listOf(it.last() + 3) } .windowed(2) .map { it[1] - it[0] } val permutationsOfOnes = listOf(0, 1, 2, 4, 7) val sublistCount = longArrayOf(0, 0, 0, 0, 0) var numberOfOnes = 0 differences.forEach { diff -> if (diff == 1) { numberOfOnes++ } else { sublistCount[numberOfOnes]++ numberOfOnes = 0 } } var answer = 1L for (i in 2 until sublistCount.size) { val permutations = permutationsOfOnes[i].pow(sublistCount[i]) if (permutations > 0) { answer *= permutations } } println(answer) } fun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()
[ { "class_path": "mdenburger__aoc-2020__b965f46/day10/Day10SecondKt.class", "javap": "Compiled from \"Day10Second.kt\"\npublic final class day10.Day10SecondKt {\n public static final void main();\n Code:\n 0: new #8 // class java/io/File\n 3: dup\n 4: ldc #10 // String src/main/kotlin/day10/day10-input.txt\n 6: invokespecial #14 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #20 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 15: checkcast #22 // class java/lang/Iterable\n 18: astore_1\n 19: nop\n 20: iconst_0\n 21: istore_2\n 22: aload_1\n 23: astore_3\n 24: new #24 // class java/util/ArrayList\n 27: dup\n 28: aload_1\n 29: bipush 10\n 31: invokestatic #30 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 34: invokespecial #33 // Method java/util/ArrayList.\"<init>\":(I)V\n 37: checkcast #35 // class java/util/Collection\n 40: astore 4\n 42: iconst_0\n 43: istore 5\n 45: aload_3\n 46: invokeinterface #39, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 51: astore 6\n 53: aload 6\n 55: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 60: ifeq 107\n 63: aload 6\n 65: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 70: astore 7\n 72: aload 4\n 74: aload 7\n 76: checkcast #51 // class java/lang/String\n 79: astore 8\n 81: astore 13\n 83: iconst_0\n 84: istore 9\n 86: aload 8\n 88: invokestatic #57 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 91: nop\n 92: invokestatic #61 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 95: aload 13\n 97: swap\n 98: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 103: pop\n 104: goto 53\n 107: aload 4\n 109: checkcast #67 // class java/util/List\n 112: nop\n 113: checkcast #22 // class java/lang/Iterable\n 116: invokestatic #71 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 119: astore_2\n 120: iconst_0\n 121: istore_3\n 122: iconst_0\n 123: invokestatic #61 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 126: invokestatic #75 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 129: checkcast #35 // class java/util/Collection\n 132: aload_2\n 133: checkcast #22 // class java/lang/Iterable\n 136: invokestatic #79 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 139: checkcast #35 // class java/util/Collection\n 142: aload_2\n 143: invokestatic #83 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 146: checkcast #85 // class java/lang/Number\n 149: invokevirtual #89 // Method java/lang/Number.intValue:()I\n 152: iconst_3\n 153: iadd\n 154: invokestatic #61 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 157: invokestatic #75 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 160: checkcast #22 // class java/lang/Iterable\n 163: invokestatic #79 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 166: checkcast #22 // class java/lang/Iterable\n 169: iconst_2\n 170: iconst_0\n 171: iconst_0\n 172: bipush 6\n 174: aconst_null\n 175: invokestatic #93 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;\n 178: checkcast #22 // class java/lang/Iterable\n 181: astore_1\n 182: nop\n 183: iconst_0\n 184: istore_2\n 185: aload_1\n 186: astore_3\n 187: new #24 // class java/util/ArrayList\n 190: dup\n 191: aload_1\n 192: bipush 10\n 194: invokestatic #30 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 197: invokespecial #33 // Method java/util/ArrayList.\"<init>\":(I)V\n 200: checkcast #35 // class java/util/Collection\n 203: astore 4\n 205: iconst_0\n 206: istore 5\n 208: aload_3\n 209: invokeinterface #39, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 214: astore 6\n 216: aload 6\n 218: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 223: ifeq 293\n 226: aload 6\n 228: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 233: astore 7\n 235: aload 4\n 237: aload 7\n 239: checkcast #67 // class java/util/List\n 242: astore 8\n 244: astore 13\n 246: iconst_0\n 247: istore 9\n 249: aload 8\n 251: iconst_1\n 252: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 257: checkcast #85 // class java/lang/Number\n 260: invokevirtual #89 // Method java/lang/Number.intValue:()I\n 263: aload 8\n 265: iconst_0\n 266: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 271: checkcast #85 // class java/lang/Number\n 274: invokevirtual #89 // Method java/lang/Number.intValue:()I\n 277: isub\n 278: invokestatic #61 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 281: aload 13\n 283: swap\n 284: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 289: pop\n 290: goto 216\n 293: aload 4\n 295: checkcast #67 // class java/util/List\n 298: nop\n 299: astore_0\n 300: iconst_5\n 301: anewarray #53 // class java/lang/Integer\n 304: astore_2\n 305: aload_2\n 306: iconst_0\n 307: iconst_0\n 308: invokestatic #61 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 311: aastore\n 312: aload_2\n 313: iconst_1\n 314: iconst_1\n 315: invokestatic #61 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 318: aastore\n 319: aload_2\n 320: iconst_2\n 321: iconst_2\n 322: invokestatic #61 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 325: aastore\n 326: aload_2\n 327: iconst_3\n 328: iconst_4\n 329: invokestatic #61 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 332: aastore\n 333: aload_2\n 334: iconst_4\n 335: bipush 7\n 337: invokestatic #61 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 340: aastore\n 341: aload_2\n 342: invokestatic #100 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 345: astore_1\n 346: iconst_5\n 347: newarray long\n 349: astore_3\n 350: aload_3\n 351: iconst_0\n 352: lconst_0\n 353: lastore\n 354: aload_3\n 355: iconst_1\n 356: lconst_0\n 357: lastore\n 358: aload_3\n 359: iconst_2\n 360: lconst_0\n 361: lastore\n 362: aload_3\n 363: iconst_3\n 364: lconst_0\n 365: lastore\n 366: aload_3\n 367: iconst_4\n 368: lconst_0\n 369: lastore\n 370: aload_3\n 371: astore_2\n 372: iconst_0\n 373: istore_3\n 374: aload_0\n 375: checkcast #22 // class java/lang/Iterable\n 378: astore 4\n 380: iconst_0\n 381: istore 5\n 383: aload 4\n 385: invokeinterface #39, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 390: astore 6\n 392: aload 6\n 394: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 399: ifeq 468\n 402: aload 6\n 404: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 409: astore 7\n 411: aload 7\n 413: checkcast #85 // class java/lang/Number\n 416: invokevirtual #89 // Method java/lang/Number.intValue:()I\n 419: istore 8\n 421: iconst_0\n 422: istore 9\n 424: iload 8\n 426: iconst_1\n 427: if_icmpne 444\n 430: iload_3\n 431: istore 10\n 433: iload 10\n 435: iconst_1\n 436: iadd\n 437: istore_3\n 438: iload 10\n 440: pop\n 441: goto 463\n 444: iload_3\n 445: istore 10\n 447: aload_2\n 448: iload 10\n 450: laload\n 451: lstore 11\n 453: aload_2\n 454: iload 10\n 456: lload 11\n 458: lconst_1\n 459: ladd\n 460: lastore\n 461: iconst_0\n 462: istore_3\n 463: nop\n 464: nop\n 465: goto 392\n 468: nop\n 469: lconst_1\n 470: lstore 4\n 472: iconst_2\n 473: istore 6\n 475: aload_2\n 476: arraylength\n 477: istore 7\n 479: iload 6\n 481: iload 7\n 483: if_icmpge 529\n 486: aload_1\n 487: iload 6\n 489: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 494: checkcast #85 // class java/lang/Number\n 497: invokevirtual #89 // Method java/lang/Number.intValue:()I\n 500: aload_2\n 501: iload 6\n 503: laload\n 504: invokestatic #104 // Method pow:(IJ)J\n 507: lstore 8\n 509: lload 8\n 511: lconst_0\n 512: lcmp\n 513: ifle 523\n 516: lload 4\n 518: lload 8\n 520: lmul\n 521: lstore 4\n 523: iinc 6, 1\n 526: goto 479\n 529: getstatic #110 // Field java/lang/System.out:Ljava/io/PrintStream;\n 532: lload 4\n 534: invokevirtual #116 // Method java/io/PrintStream.println:(J)V\n 537: return\n\n public static final long pow(int, long);\n Code:\n 0: iload_0\n 1: i2d\n 2: lload_1\n 3: l2d\n 4: invokestatic #152 // Method java/lang/Math.pow:(DD)D\n 7: d2l\n 8: lreturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #157 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
PeteShepley__advent-of-code__f9679c1/2019/DEC02/src/main/kotlin/day2/App.kt
package day2 class Computer(val program: Array<Int>) { private var pointer: Int = 0 fun execute() { while (pointer < program.size) { when (program[pointer]) { 1 -> { add() pointer += 4 } 2 -> { mult() pointer += 4 } 99 -> pointer = program.size } } } override fun toString(): String { return program.joinToString(" ") } private fun add() { val op1 = program[program[pointer + 1]] val op2 = program[program[pointer + 2]] val loc = program[pointer + 3] program[loc] = op1 + op2 } private fun mult() { val op1 = program[program[pointer + 1]] val op2 = program[program[pointer + 2]] val loc = program[pointer + 3] program[loc] = op1 * op2 } } fun copyOfProgram(): Array<Int> { return arrayOf(1, 0, 0, 3, 1, 1, 2, 3, 1, 3, 4, 3, 1, 5, 0, 3, 2, 1, 10, 19, 1, 6, 19, 23, 2, 23, 6, 27, 2, 6, 27, 31, 2, 13, 31, 35, 1, 10, 35, 39, 2, 39, 13, 43, 1, 43, 13, 47, 1, 6, 47, 51, 1, 10, 51, 55, 2, 55, 6, 59, 1, 5, 59, 63, 2, 9, 63, 67, 1, 6, 67, 71, 2, 9, 71, 75, 1, 6, 75, 79, 2, 79, 13, 83, 1, 83, 10, 87, 1, 13, 87, 91, 1, 91, 10, 95, 2, 9, 95, 99, 1, 5, 99, 103, 2, 10, 103, 107, 1, 107, 2, 111, 1, 111, 5, 0, 99, 2, 14, 0, 0) } fun main(args: Array<String>) { for (noun in 0..99) { print('*') for (verb in 0..99) { print('.') val testProgram = copyOfProgram() testProgram[1] = noun testProgram[2] = verb val comp = Computer(testProgram) comp.execute() if (comp.program[0] == 19690720) { println("Noun: $noun Verb: $verb") } } } }
[ { "class_path": "PeteShepley__advent-of-code__f9679c1/day2/AppKt.class", "javap": "Compiled from \"App.kt\"\npublic final class day2.AppKt {\n public static final java.lang.Integer[] copyOfProgram();\n Code:\n 0: bipush 121\n 2: anewarray #9 // class java/lang/Integer\n 5: astore_0\n 6: aload_0\n 7: iconst_0\n 8: iconst_1\n 9: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 12: aastore\n 13: aload_0\n 14: iconst_1\n 15: iconst_0\n 16: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 19: aastore\n 20: aload_0\n 21: iconst_2\n 22: iconst_0\n 23: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 26: aastore\n 27: aload_0\n 28: iconst_3\n 29: iconst_3\n 30: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 33: aastore\n 34: aload_0\n 35: iconst_4\n 36: iconst_1\n 37: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 40: aastore\n 41: aload_0\n 42: iconst_5\n 43: iconst_1\n 44: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 47: aastore\n 48: aload_0\n 49: bipush 6\n 51: iconst_2\n 52: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 55: aastore\n 56: aload_0\n 57: bipush 7\n 59: iconst_3\n 60: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 63: aastore\n 64: aload_0\n 65: bipush 8\n 67: iconst_1\n 68: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 71: aastore\n 72: aload_0\n 73: bipush 9\n 75: iconst_3\n 76: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 79: aastore\n 80: aload_0\n 81: bipush 10\n 83: iconst_4\n 84: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 87: aastore\n 88: aload_0\n 89: bipush 11\n 91: iconst_3\n 92: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 95: aastore\n 96: aload_0\n 97: bipush 12\n 99: iconst_1\n 100: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 103: aastore\n 104: aload_0\n 105: bipush 13\n 107: iconst_5\n 108: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 111: aastore\n 112: aload_0\n 113: bipush 14\n 115: iconst_0\n 116: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 119: aastore\n 120: aload_0\n 121: bipush 15\n 123: iconst_3\n 124: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 127: aastore\n 128: aload_0\n 129: bipush 16\n 131: iconst_2\n 132: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 135: aastore\n 136: aload_0\n 137: bipush 17\n 139: iconst_1\n 140: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 143: aastore\n 144: aload_0\n 145: bipush 18\n 147: bipush 10\n 149: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 152: aastore\n 153: aload_0\n 154: bipush 19\n 156: bipush 19\n 158: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 161: aastore\n 162: aload_0\n 163: bipush 20\n 165: iconst_1\n 166: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 169: aastore\n 170: aload_0\n 171: bipush 21\n 173: bipush 6\n 175: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 178: aastore\n 179: aload_0\n 180: bipush 22\n 182: bipush 19\n 184: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 187: aastore\n 188: aload_0\n 189: bipush 23\n 191: bipush 23\n 193: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 196: aastore\n 197: aload_0\n 198: bipush 24\n 200: iconst_2\n 201: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 204: aastore\n 205: aload_0\n 206: bipush 25\n 208: bipush 23\n 210: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 213: aastore\n 214: aload_0\n 215: bipush 26\n 217: bipush 6\n 219: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 222: aastore\n 223: aload_0\n 224: bipush 27\n 226: bipush 27\n 228: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 231: aastore\n 232: aload_0\n 233: bipush 28\n 235: iconst_2\n 236: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 239: aastore\n 240: aload_0\n 241: bipush 29\n 243: bipush 6\n 245: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 248: aastore\n 249: aload_0\n 250: bipush 30\n 252: bipush 27\n 254: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 257: aastore\n 258: aload_0\n 259: bipush 31\n 261: bipush 31\n 263: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 266: aastore\n 267: aload_0\n 268: bipush 32\n 270: iconst_2\n 271: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 274: aastore\n 275: aload_0\n 276: bipush 33\n 278: bipush 13\n 280: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 283: aastore\n 284: aload_0\n 285: bipush 34\n 287: bipush 31\n 289: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 292: aastore\n 293: aload_0\n 294: bipush 35\n 296: bipush 35\n 298: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 301: aastore\n 302: aload_0\n 303: bipush 36\n 305: iconst_1\n 306: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 309: aastore\n 310: aload_0\n 311: bipush 37\n 313: bipush 10\n 315: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 318: aastore\n 319: aload_0\n 320: bipush 38\n 322: bipush 35\n 324: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 327: aastore\n 328: aload_0\n 329: bipush 39\n 331: bipush 39\n 333: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 336: aastore\n 337: aload_0\n 338: bipush 40\n 340: iconst_2\n 341: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 344: aastore\n 345: aload_0\n 346: bipush 41\n 348: bipush 39\n 350: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 353: aastore\n 354: aload_0\n 355: bipush 42\n 357: bipush 13\n 359: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 362: aastore\n 363: aload_0\n 364: bipush 43\n 366: bipush 43\n 368: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 371: aastore\n 372: aload_0\n 373: bipush 44\n 375: iconst_1\n 376: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 379: aastore\n 380: aload_0\n 381: bipush 45\n 383: bipush 43\n 385: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 388: aastore\n 389: aload_0\n 390: bipush 46\n 392: bipush 13\n 394: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 397: aastore\n 398: aload_0\n 399: bipush 47\n 401: bipush 47\n 403: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 406: aastore\n 407: aload_0\n 408: bipush 48\n 410: iconst_1\n 411: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 414: aastore\n 415: aload_0\n 416: bipush 49\n 418: bipush 6\n 420: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 423: aastore\n 424: aload_0\n 425: bipush 50\n 427: bipush 47\n 429: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 432: aastore\n 433: aload_0\n 434: bipush 51\n 436: bipush 51\n 438: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 441: aastore\n 442: aload_0\n 443: bipush 52\n 445: iconst_1\n 446: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 449: aastore\n 450: aload_0\n 451: bipush 53\n 453: bipush 10\n 455: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 458: aastore\n 459: aload_0\n 460: bipush 54\n 462: bipush 51\n 464: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 467: aastore\n 468: aload_0\n 469: bipush 55\n 471: bipush 55\n 473: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 476: aastore\n 477: aload_0\n 478: bipush 56\n 480: iconst_2\n 481: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 484: aastore\n 485: aload_0\n 486: bipush 57\n 488: bipush 55\n 490: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 493: aastore\n 494: aload_0\n 495: bipush 58\n 497: bipush 6\n 499: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 502: aastore\n 503: aload_0\n 504: bipush 59\n 506: bipush 59\n 508: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 511: aastore\n 512: aload_0\n 513: bipush 60\n 515: iconst_1\n 516: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 519: aastore\n 520: aload_0\n 521: bipush 61\n 523: iconst_5\n 524: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 527: aastore\n 528: aload_0\n 529: bipush 62\n 531: bipush 59\n 533: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 536: aastore\n 537: aload_0\n 538: bipush 63\n 540: bipush 63\n 542: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 545: aastore\n 546: aload_0\n 547: bipush 64\n 549: iconst_2\n 550: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 553: aastore\n 554: aload_0\n 555: bipush 65\n 557: bipush 9\n 559: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 562: aastore\n 563: aload_0\n 564: bipush 66\n 566: bipush 63\n 568: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 571: aastore\n 572: aload_0\n 573: bipush 67\n 575: bipush 67\n 577: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 580: aastore\n 581: aload_0\n 582: bipush 68\n 584: iconst_1\n 585: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 588: aastore\n 589: aload_0\n 590: bipush 69\n 592: bipush 6\n 594: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 597: aastore\n 598: aload_0\n 599: bipush 70\n 601: bipush 67\n 603: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 606: aastore\n 607: aload_0\n 608: bipush 71\n 610: bipush 71\n 612: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 615: aastore\n 616: aload_0\n 617: bipush 72\n 619: iconst_2\n 620: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 623: aastore\n 624: aload_0\n 625: bipush 73\n 627: bipush 9\n 629: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 632: aastore\n 633: aload_0\n 634: bipush 74\n 636: bipush 71\n 638: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 641: aastore\n 642: aload_0\n 643: bipush 75\n 645: bipush 75\n 647: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 650: aastore\n 651: aload_0\n 652: bipush 76\n 654: iconst_1\n 655: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 658: aastore\n 659: aload_0\n 660: bipush 77\n 662: bipush 6\n 664: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 667: aastore\n 668: aload_0\n 669: bipush 78\n 671: bipush 75\n 673: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 676: aastore\n 677: aload_0\n 678: bipush 79\n 680: bipush 79\n 682: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 685: aastore\n 686: aload_0\n 687: bipush 80\n 689: iconst_2\n 690: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 693: aastore\n 694: aload_0\n 695: bipush 81\n 697: bipush 79\n 699: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 702: aastore\n 703: aload_0\n 704: bipush 82\n 706: bipush 13\n 708: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 711: aastore\n 712: aload_0\n 713: bipush 83\n 715: bipush 83\n 717: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 720: aastore\n 721: aload_0\n 722: bipush 84\n 724: iconst_1\n 725: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 728: aastore\n 729: aload_0\n 730: bipush 85\n 732: bipush 83\n 734: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 737: aastore\n 738: aload_0\n 739: bipush 86\n 741: bipush 10\n 743: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 746: aastore\n 747: aload_0\n 748: bipush 87\n 750: bipush 87\n 752: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 755: aastore\n 756: aload_0\n 757: bipush 88\n 759: iconst_1\n 760: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 763: aastore\n 764: aload_0\n 765: bipush 89\n 767: bipush 13\n 769: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 772: aastore\n 773: aload_0\n 774: bipush 90\n 776: bipush 87\n 778: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 781: aastore\n 782: aload_0\n 783: bipush 91\n 785: bipush 91\n 787: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 790: aastore\n 791: aload_0\n 792: bipush 92\n 794: iconst_1\n 795: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 798: aastore\n 799: aload_0\n 800: bipush 93\n 802: bipush 91\n 804: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 807: aastore\n 808: aload_0\n 809: bipush 94\n 811: bipush 10\n 813: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 816: aastore\n 817: aload_0\n 818: bipush 95\n 820: bipush 95\n 822: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 825: aastore\n 826: aload_0\n 827: bipush 96\n 829: iconst_2\n 830: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 833: aastore\n 834: aload_0\n 835: bipush 97\n 837: bipush 9\n 839: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 842: aastore\n 843: aload_0\n 844: bipush 98\n 846: bipush 95\n 848: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 851: aastore\n 852: aload_0\n 853: bipush 99\n 855: bipush 99\n 857: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 860: aastore\n 861: aload_0\n 862: bipush 100\n 864: iconst_1\n 865: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 868: aastore\n 869: aload_0\n 870: bipush 101\n 872: iconst_5\n 873: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 876: aastore\n 877: aload_0\n 878: bipush 102\n 880: bipush 99\n 882: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 885: aastore\n 886: aload_0\n 887: bipush 103\n 889: bipush 103\n 891: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 894: aastore\n 895: aload_0\n 896: bipush 104\n 898: iconst_2\n 899: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 902: aastore\n 903: aload_0\n 904: bipush 105\n 906: bipush 10\n 908: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 911: aastore\n 912: aload_0\n 913: bipush 106\n 915: bipush 103\n 917: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 920: aastore\n 921: aload_0\n 922: bipush 107\n 924: bipush 107\n 926: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 929: aastore\n 930: aload_0\n 931: bipush 108\n 933: iconst_1\n 934: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 937: aastore\n 938: aload_0\n 939: bipush 109\n 941: bipush 107\n 943: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 946: aastore\n 947: aload_0\n 948: bipush 110\n 950: iconst_2\n 951: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 954: aastore\n 955: aload_0\n 956: bipush 111\n 958: bipush 111\n 960: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 963: aastore\n 964: aload_0\n 965: bipush 112\n 967: iconst_1\n 968: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 971: aastore\n 972: aload_0\n 973: bipush 113\n 975: bipush 111\n 977: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 980: aastore\n 981: aload_0\n 982: bipush 114\n 984: iconst_5\n 985: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 988: aastore\n 989: aload_0\n 990: bipush 115\n 992: iconst_0\n 993: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 996: aastore\n 997: aload_0\n 998: bipush 116\n 1000: bipush 99\n 1002: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1005: aastore\n 1006: aload_0\n 1007: bipush 117\n 1009: iconst_2\n 1010: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1013: aastore\n 1014: aload_0\n 1015: bipush 118\n 1017: bipush 14\n 1019: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1022: aastore\n 1023: aload_0\n 1024: bipush 119\n 1026: iconst_0\n 1027: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1030: aastore\n 1031: aload_0\n 1032: bipush 120\n 1034: iconst_0\n 1035: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1038: aastore\n 1039: aload_0\n 1040: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #17 // String args\n 3: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_1\n 8: iload_1\n 9: bipush 100\n 11: if_icmpge 137\n 14: bipush 42\n 16: istore_2\n 17: getstatic #29 // Field java/lang/System.out:Ljava/io/PrintStream;\n 20: iload_2\n 21: invokevirtual #35 // Method java/io/PrintStream.print:(C)V\n 24: iconst_0\n 25: istore_2\n 26: iload_2\n 27: bipush 100\n 29: if_icmpge 131\n 32: bipush 46\n 34: istore_3\n 35: getstatic #29 // Field java/lang/System.out:Ljava/io/PrintStream;\n 38: iload_3\n 39: invokevirtual #35 // Method java/io/PrintStream.print:(C)V\n 42: invokestatic #37 // Method copyOfProgram:()[Ljava/lang/Integer;\n 45: astore_3\n 46: aload_3\n 47: iconst_1\n 48: iload_1\n 49: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 52: aastore\n 53: aload_3\n 54: iconst_2\n 55: iload_2\n 56: invokestatic #13 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 59: aastore\n 60: new #39 // class day2/Computer\n 63: dup\n 64: aload_3\n 65: invokespecial #43 // Method day2/Computer.\"<init>\":([Ljava/lang/Integer;)V\n 68: astore 4\n 70: aload 4\n 72: invokevirtual #47 // Method day2/Computer.execute:()V\n 75: aload 4\n 77: invokevirtual #50 // Method day2/Computer.getProgram:()[Ljava/lang/Integer;\n 80: iconst_0\n 81: aaload\n 82: invokevirtual #54 // Method java/lang/Integer.intValue:()I\n 85: ldc #55 // int 19690720\n 87: if_icmpne 125\n 90: new #57 // class java/lang/StringBuilder\n 93: dup\n 94: invokespecial #59 // Method java/lang/StringBuilder.\"<init>\":()V\n 97: ldc #61 // String Noun:\n 99: invokevirtual #65 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 102: iload_1\n 103: invokevirtual #68 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 106: ldc #70 // String Verb:\n 108: invokevirtual #65 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 111: iload_2\n 112: invokevirtual #68 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 115: invokevirtual #74 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 118: getstatic #29 // Field java/lang/System.out:Ljava/io/PrintStream;\n 121: swap\n 122: invokevirtual #78 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 125: iinc 2, 1\n 128: goto 26\n 131: iinc 1, 1\n 134: goto 8\n 137: return\n}\n", "javap_err": "" } ]
LukasHavemann__microservice-transformer__8638fe7/src/main/kotlin/de/havemann/transformer/domain/sortkey/SortKey.kt
package de.havemann.transformer.domain.sortkey import java.util.* import java.util.Comparator.comparing import kotlin.reflect.KProperty1 /** * Sorting is determined through the use of the ‘sort’ query string parameter. The value of this parameter is a * comma-separated list of sort keys. Sort directions can optionally be appended to each sort key, separated by the ‘:’ * character. * * The supported sort directions are either ‘asc’ for ascending or ‘desc’ for descending. * * The caller may (but is not required to) specify a sort direction for each key. If a sort direction is not specified * for a key, then a default is set by the server. */ data class SortKey(val key: String, val ordering: Ordering) { companion object { /** * Transforms a list of {@link SortKey} to a {@link Comparator} */ fun <Entity, Value : Comparable<Value>> toComparator( sortKeys: List<SortKey>, sortKeyToProperty: Map<String, KProperty1<Entity, Value?>> ): Comparator<Entity> { return sortKeys .stream() .filter { sortKeyToProperty[it.key] != null } .map { sortKey -> val property = sortKeyToProperty[sortKey.key] val sortingFunction: (t: Entity) -> Value = { property?.call(it)!! } sortKey.ordering.adjust(comparing(sortingFunction)) } .reduce { a, b -> a.thenComparing(b) } .orElseThrow { IllegalArgumentException("list shouldn't be empty") } } } } enum class Ordering(val key: String) { ASCENDING("asc"), DESCENDING("desc"); /** * reverses the given comparator if ordering is descending */ fun <T> adjust(comparator: Comparator<T>): Comparator<T> { return if (this == DESCENDING) comparator.reversed() else comparator } companion object { /** * determines Ordering form given string */ fun detect(token: String): Ordering { return values().asSequence() .filter { it.key == token } .firstOrNull() ?: throw IllegalArgumentException(token) } } }
[ { "class_path": "LukasHavemann__microservice-transformer__8638fe7/de/havemann/transformer/domain/sortkey/SortKey$Companion.class", "javap": "Compiled from \"SortKey.kt\"\npublic final class de.havemann.transformer.domain.sortkey.SortKey$Companion {\n private de.havemann.transformer.domain.sortkey.SortKey$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final <Entity, Value extends java.lang.Comparable<? super Value>> java.util.Comparator<Entity> toComparator(java.util.List<de.havemann.transformer.domain.sortkey.SortKey>, java.util.Map<java.lang.String, ? extends kotlin.reflect.KProperty1<Entity, ? extends Value>>);\n Code:\n 0: aload_1\n 1: ldc #16 // String sortKeys\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #24 // String sortKeyToProperty\n 9: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: invokeinterface #30, 1 // InterfaceMethod java/util/List.stream:()Ljava/util/stream/Stream;\n 18: aload_2\n 19: invokedynamic #50, 0 // InvokeDynamic #0:invoke:(Ljava/util/Map;)Lkotlin/jvm/functions/Function1;\n 24: invokedynamic #61, 0 // InvokeDynamic #1:test:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Predicate;\n 29: invokeinterface #67, 2 // InterfaceMethod java/util/stream/Stream.filter:(Ljava/util/function/Predicate;)Ljava/util/stream/Stream;\n 34: aload_2\n 35: invokedynamic #75, 0 // InvokeDynamic #2:invoke:(Ljava/util/Map;)Lkotlin/jvm/functions/Function1;\n 40: invokedynamic #86, 0 // InvokeDynamic #3:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;\n 45: invokeinterface #90, 2 // InterfaceMethod java/util/stream/Stream.map:(Ljava/util/function/Function;)Ljava/util/stream/Stream;\n 50: invokedynamic #101, 0 // InvokeDynamic #4:apply:()Ljava/util/function/BinaryOperator;\n 55: invokeinterface #105, 2 // InterfaceMethod java/util/stream/Stream.reduce:(Ljava/util/function/BinaryOperator;)Ljava/util/Optional;\n 60: invokedynamic #117, 0 // InvokeDynamic #5:get:()Ljava/util/function/Supplier;\n 65: invokevirtual #123 // Method java/util/Optional.orElseThrow:(Ljava/util/function/Supplier;)Ljava/lang/Object;\n 68: astore_3\n 69: aload_3\n 70: ldc #125 // String orElseThrow(...)\n 72: invokestatic #128 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 75: aload_3\n 76: checkcast #130 // class java/util/Comparator\n 79: areturn\n\n private static final boolean toComparator$lambda$0(java.util.Map, de.havemann.transformer.domain.sortkey.SortKey);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokevirtual #138 // Method de/havemann/transformer/domain/sortkey/SortKey.getKey:()Ljava/lang/String;\n 5: invokeinterface #142, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 10: ifnull 17\n 13: iconst_1\n 14: goto 18\n 17: iconst_0\n 18: ireturn\n\n private static final boolean toComparator$lambda$1(kotlin.jvm.functions.Function1, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #149, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #151 // class java/lang/Boolean\n 10: invokevirtual #155 // Method java/lang/Boolean.booleanValue:()Z\n 13: ireturn\n\n private static final java.lang.Comparable toComparator$lambda$4$lambda$2(kotlin.reflect.KProperty1, java.lang.Object);\n Code:\n 0: aload_0\n 1: dup\n 2: ifnull 26\n 5: iconst_1\n 6: anewarray #4 // class java/lang/Object\n 9: astore_2\n 10: aload_2\n 11: iconst_0\n 12: aload_1\n 13: aastore\n 14: aload_2\n 15: invokeinterface #167, 2 // InterfaceMethod kotlin/reflect/KProperty1.call:([Ljava/lang/Object;)Ljava/lang/Object;\n 20: checkcast #169 // class java/lang/Comparable\n 23: goto 28\n 26: pop\n 27: aconst_null\n 28: dup\n 29: invokestatic #173 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 32: areturn\n\n private static final java.lang.Comparable toComparator$lambda$4$lambda$3(kotlin.jvm.functions.Function1, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #149, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #169 // class java/lang/Comparable\n 10: areturn\n\n private static final java.util.Comparator toComparator$lambda$4(java.util.Map, de.havemann.transformer.domain.sortkey.SortKey);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokevirtual #138 // Method de/havemann/transformer/domain/sortkey/SortKey.getKey:()Ljava/lang/String;\n 5: invokeinterface #142, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 10: checkcast #163 // class kotlin/reflect/KProperty1\n 13: astore_2\n 14: aload_2\n 15: invokedynamic #185, 0 // InvokeDynamic #6:invoke:(Lkotlin/reflect/KProperty1;)Lkotlin/jvm/functions/Function1;\n 20: astore_3\n 21: aload_1\n 22: invokevirtual #189 // Method de/havemann/transformer/domain/sortkey/SortKey.getOrdering:()Lde/havemann/transformer/domain/sortkey/Ordering;\n 25: aload_3\n 26: invokedynamic #193, 0 // InvokeDynamic #7:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;\n 31: invokestatic #197 // InterfaceMethod java/util/Comparator.comparing:(Ljava/util/function/Function;)Ljava/util/Comparator;\n 34: dup\n 35: ldc #199 // String comparing(...)\n 37: invokestatic #128 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 40: invokevirtual #205 // Method de/havemann/transformer/domain/sortkey/Ordering.adjust:(Ljava/util/Comparator;)Ljava/util/Comparator;\n 43: areturn\n\n private static final java.util.Comparator toComparator$lambda$5(kotlin.jvm.functions.Function1, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #149, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #130 // class java/util/Comparator\n 10: areturn\n\n private static final java.util.Comparator toComparator$lambda$6(java.util.Comparator, java.util.Comparator);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #211, 2 // InterfaceMethod java/util/Comparator.thenComparing:(Ljava/util/Comparator;)Ljava/util/Comparator;\n 7: areturn\n\n private static final java.lang.IllegalArgumentException toComparator$lambda$7();\n Code:\n 0: new #216 // class java/lang/IllegalArgumentException\n 3: dup\n 4: ldc #218 // String list shouldn\\'t be empty\n 6: invokespecial #221 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 9: areturn\n\n public de.havemann.transformer.domain.sortkey.SortKey$Companion(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #223 // Method \"<init>\":()V\n 4: return\n}\n", "javap_err": "" }, { "class_path": "LukasHavemann__microservice-transformer__8638fe7/de/havemann/transformer/domain/sortkey/SortKey.class", "javap": "Compiled from \"SortKey.kt\"\npublic final class de.havemann.transformer.domain.sortkey.SortKey {\n public static final de.havemann.transformer.domain.sortkey.SortKey$Companion Companion;\n\n private final java.lang.String key;\n\n private final de.havemann.transformer.domain.sortkey.Ordering ordering;\n\n public de.havemann.transformer.domain.sortkey.SortKey(java.lang.String, de.havemann.transformer.domain.sortkey.Ordering);\n Code:\n 0: aload_1\n 1: ldc #9 // String key\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #17 // String ordering\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokespecial #20 // Method java/lang/Object.\"<init>\":()V\n 16: aload_0\n 17: aload_1\n 18: putfield #23 // Field key:Ljava/lang/String;\n 21: aload_0\n 22: aload_2\n 23: putfield #26 // Field ordering:Lde/havemann/transformer/domain/sortkey/Ordering;\n 26: return\n\n public final java.lang.String getKey();\n Code:\n 0: aload_0\n 1: getfield #23 // Field key:Ljava/lang/String;\n 4: areturn\n\n public final de.havemann.transformer.domain.sortkey.Ordering getOrdering();\n Code:\n 0: aload_0\n 1: getfield #26 // Field ordering:Lde/havemann/transformer/domain/sortkey/Ordering;\n 4: areturn\n\n public final java.lang.String component1();\n Code:\n 0: aload_0\n 1: getfield #23 // Field key:Ljava/lang/String;\n 4: areturn\n\n public final de.havemann.transformer.domain.sortkey.Ordering component2();\n Code:\n 0: aload_0\n 1: getfield #26 // Field ordering:Lde/havemann/transformer/domain/sortkey/Ordering;\n 4: areturn\n\n public final de.havemann.transformer.domain.sortkey.SortKey copy(java.lang.String, de.havemann.transformer.domain.sortkey.Ordering);\n Code:\n 0: aload_1\n 1: ldc #9 // String key\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #17 // String ordering\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class de/havemann/transformer/domain/sortkey/SortKey\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: invokespecial #38 // Method \"<init>\":(Ljava/lang/String;Lde/havemann/transformer/domain/sortkey/Ordering;)V\n 21: areturn\n\n public static de.havemann.transformer.domain.sortkey.SortKey copy$default(de.havemann.transformer.domain.sortkey.SortKey, java.lang.String, de.havemann.transformer.domain.sortkey.Ordering, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #23 // Field key:Ljava/lang/String;\n 10: astore_1\n 11: iload_3\n 12: iconst_2\n 13: iand\n 14: ifeq 22\n 17: aload_0\n 18: getfield #26 // Field ordering:Lde/havemann/transformer/domain/sortkey/Ordering;\n 21: astore_2\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokevirtual #42 // Method copy:(Ljava/lang/String;Lde/havemann/transformer/domain/sortkey/Ordering;)Lde/havemann/transformer/domain/sortkey/SortKey;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #45 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #46 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #48 // String SortKey(key=\n 9: invokevirtual #52 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #23 // Field key:Ljava/lang/String;\n 16: invokevirtual #52 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 19: ldc #54 // String , ordering=\n 21: invokevirtual #52 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #26 // Field ordering:Lde/havemann/transformer/domain/sortkey/Ordering;\n 28: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #60 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #62 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 39: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #23 // Field key:Ljava/lang/String;\n 4: invokevirtual #68 // Method java/lang/String.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #26 // Field ordering:Lde/havemann/transformer/domain/sortkey/Ordering;\n 16: invokevirtual #71 // Method de/havemann/transformer/domain/sortkey/Ordering.hashCode:()I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: ireturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_1\n 8: instanceof #2 // class de/havemann/transformer/domain/sortkey/SortKey\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class de/havemann/transformer/domain/sortkey/SortKey\n 20: astore_2\n 21: aload_0\n 22: getfield #23 // Field key:Ljava/lang/String;\n 25: aload_2\n 26: getfield #23 // Field key:Ljava/lang/String;\n 29: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifne 37\n 35: iconst_0\n 36: ireturn\n 37: aload_0\n 38: getfield #26 // Field ordering:Lde/havemann/transformer/domain/sortkey/Ordering;\n 41: aload_2\n 42: getfield #26 // Field ordering:Lde/havemann/transformer/domain/sortkey/Ordering;\n 45: if_acmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: iconst_1\n 51: ireturn\n\n static {};\n Code:\n 0: new #85 // class de/havemann/transformer/domain/sortkey/SortKey$Companion\n 3: dup\n 4: aconst_null\n 5: invokespecial #88 // Method de/havemann/transformer/domain/sortkey/SortKey$Companion.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 8: putstatic #92 // Field Companion:Lde/havemann/transformer/domain/sortkey/SortKey$Companion;\n 11: return\n}\n", "javap_err": "" } ]
Mindera__skeletoid__881de79/base/src/main/java/com/mindera/skeletoid/utils/versioning/Versioning.kt
package com.mindera.skeletoid.utils.versioning import kotlin.math.sign object Versioning { /** * Compares two version strings. * Credits to: https://gist.github.com/antalindisguise/d9d462f2defcfd7ae1d4 * * Use this instead of String.compareTo() for a non-lexicographical * comparison that works for version strings. e.g. "1.10".compareTo("1.6"). * * @note It does not work if "1.10" is supposed to be equal to "1.10.0". * * @param str1 a string of ordinal numbers separated by decimal points. * @param str2 a string of ordinal numbers separated by decimal points. * @return The result is a negative integer if str1 is _numerically_ less than str2. * The result is a positive integer if str1 is _numerically_ greater than str2. * The result is zero if the strings are _numerically_ equal. */ fun compareVersions(str1: String, str2: String): Int { if (str1.isBlank() || str2.isBlank()) { throw IllegalArgumentException("Invalid Version") } val vals1 = str1.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() val vals2 = str2.split("\\.".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() var i = 0 // set index to first non-equal ordinal or length of shortest version string while (i < vals1.size && i < vals2.size && vals1[i] == vals2[i]) { i++ } // compare first non-equal ordinal number return run { // compare first non-equal ordinal number if (i < vals1.size && i < vals2.size) { vals1[i].toInt().compareTo(vals2[i].toInt()) } else { // the strings are equal or one string is a substring of the other // e.g. "1.2.3" = "1.2.3" or "1.2.3" < "1.2.3.4" vals1.size - vals2.size } }.sign } }
[ { "class_path": "Mindera__skeletoid__881de79/com/mindera/skeletoid/utils/versioning/Versioning.class", "javap": "Compiled from \"Versioning.kt\"\npublic final class com.mindera.skeletoid.utils.versioning.Versioning {\n public static final com.mindera.skeletoid.utils.versioning.Versioning INSTANCE;\n\n private com.mindera.skeletoid.utils.versioning.Versioning();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compareVersions(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String str1\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #23 // String str2\n 9: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: checkcast #25 // class java/lang/CharSequence\n 16: invokestatic #31 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 19: ifne 32\n 22: aload_2\n 23: checkcast #25 // class java/lang/CharSequence\n 26: invokestatic #31 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 29: ifeq 42\n 32: new #33 // class java/lang/IllegalArgumentException\n 35: dup\n 36: ldc #35 // String Invalid Version\n 38: invokespecial #38 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 41: athrow\n 42: aload_1\n 43: checkcast #25 // class java/lang/CharSequence\n 46: astore 4\n 48: new #40 // class kotlin/text/Regex\n 51: dup\n 52: ldc #42 // String \\\\.\n 54: invokespecial #43 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 57: astore 5\n 59: iconst_0\n 60: istore 6\n 62: aload 5\n 64: aload 4\n 66: iload 6\n 68: invokevirtual #47 // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 71: astore 4\n 73: nop\n 74: iconst_0\n 75: istore 5\n 77: aload 4\n 79: invokeinterface #53, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 84: ifne 170\n 87: aload 4\n 89: aload 4\n 91: invokeinterface #57, 1 // InterfaceMethod java/util/List.size:()I\n 96: invokeinterface #61, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 101: astore 6\n 103: aload 6\n 105: invokeinterface #66, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 110: ifeq 170\n 113: aload 6\n 115: invokeinterface #70, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 120: checkcast #72 // class java/lang/String\n 123: astore 7\n 125: iconst_0\n 126: istore 8\n 128: aload 7\n 130: checkcast #25 // class java/lang/CharSequence\n 133: invokeinterface #75, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 138: ifne 145\n 141: iconst_1\n 142: goto 146\n 145: iconst_0\n 146: nop\n 147: ifne 103\n 150: aload 4\n 152: checkcast #77 // class java/lang/Iterable\n 155: aload 6\n 157: invokeinterface #80, 1 // InterfaceMethod java/util/ListIterator.nextIndex:()I\n 162: iconst_1\n 163: iadd\n 164: invokestatic #86 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 167: goto 173\n 170: invokestatic #90 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 173: checkcast #92 // class java/util/Collection\n 176: astore 4\n 178: nop\n 179: iconst_0\n 180: istore 5\n 182: aload 4\n 184: astore 6\n 186: aload 6\n 188: iconst_0\n 189: anewarray #72 // class java/lang/String\n 192: invokeinterface #96, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 197: checkcast #98 // class \"[Ljava/lang/String;\"\n 200: astore_3\n 201: aload_2\n 202: checkcast #25 // class java/lang/CharSequence\n 205: astore 5\n 207: new #40 // class kotlin/text/Regex\n 210: dup\n 211: ldc #42 // String \\\\.\n 213: invokespecial #43 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 216: astore 6\n 218: iconst_0\n 219: istore 7\n 221: aload 6\n 223: aload 5\n 225: iload 7\n 227: invokevirtual #47 // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 230: astore 5\n 232: nop\n 233: iconst_0\n 234: istore 6\n 236: aload 5\n 238: invokeinterface #53, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 243: ifne 329\n 246: aload 5\n 248: aload 5\n 250: invokeinterface #57, 1 // InterfaceMethod java/util/List.size:()I\n 255: invokeinterface #61, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 260: astore 7\n 262: aload 7\n 264: invokeinterface #66, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 269: ifeq 329\n 272: aload 7\n 274: invokeinterface #70, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 279: checkcast #72 // class java/lang/String\n 282: astore 8\n 284: iconst_0\n 285: istore 9\n 287: aload 8\n 289: checkcast #25 // class java/lang/CharSequence\n 292: invokeinterface #75, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 297: ifne 304\n 300: iconst_1\n 301: goto 305\n 304: iconst_0\n 305: nop\n 306: ifne 262\n 309: aload 5\n 311: checkcast #77 // class java/lang/Iterable\n 314: aload 7\n 316: invokeinterface #80, 1 // InterfaceMethod java/util/ListIterator.nextIndex:()I\n 321: iconst_1\n 322: iadd\n 323: invokestatic #86 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 326: goto 332\n 329: invokestatic #90 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 332: checkcast #92 // class java/util/Collection\n 335: astore 5\n 337: nop\n 338: iconst_0\n 339: istore 6\n 341: aload 5\n 343: astore 7\n 345: aload 7\n 347: iconst_0\n 348: anewarray #72 // class java/lang/String\n 351: invokeinterface #96, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 356: checkcast #98 // class \"[Ljava/lang/String;\"\n 359: astore 4\n 361: iconst_0\n 362: istore 5\n 364: iload 5\n 366: aload_3\n 367: arraylength\n 368: if_icmpge 407\n 371: iload 5\n 373: aload 4\n 375: arraylength\n 376: if_icmpge 407\n 379: aload_3\n 380: iload 5\n 382: aaload\n 383: aload 4\n 385: iload 5\n 387: aaload\n 388: invokestatic #102 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 391: ifeq 407\n 394: iload 5\n 396: istore 6\n 398: iload 6\n 400: iconst_1\n 401: iadd\n 402: istore 5\n 404: goto 364\n 407: aload_0\n 408: checkcast #2 // class com/mindera/skeletoid/utils/versioning/Versioning\n 411: astore 7\n 413: iconst_0\n 414: istore 8\n 416: iload 5\n 418: aload_3\n 419: arraylength\n 420: if_icmpge 452\n 423: iload 5\n 425: aload 4\n 427: arraylength\n 428: if_icmpge 452\n 431: aload_3\n 432: iload 5\n 434: aaload\n 435: invokestatic #108 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 438: aload 4\n 440: iload 5\n 442: aaload\n 443: invokestatic #108 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 446: invokestatic #112 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 449: goto 458\n 452: aload_3\n 453: arraylength\n 454: aload 4\n 456: arraylength\n 457: isub\n 458: nop\n 459: nop\n 460: invokestatic #118 // Method kotlin/math/MathKt.getSign:(I)I\n 463: ireturn\n\n static {};\n Code:\n 0: new #2 // class com/mindera/skeletoid/utils/versioning/Versioning\n 3: dup\n 4: invokespecial #139 // Method \"<init>\":()V\n 7: putstatic #142 // Field INSTANCE:Lcom/mindera/skeletoid/utils/versioning/Versioning;\n 10: return\n}\n", "javap_err": "" } ]
AhmedTawfiqM__ProblemSolving__a569265/src/palindrome_int/PalindRomeInt.kt
package palindrome_int //https://leetcode.com/problems/palindrome-number object PalindRomeInt { private fun isPalindrome(input: Int): Boolean { if (input < 0 || input >= Int.MAX_VALUE) return false if (input in 0..9) return true var original = input var reversed = 0 while (original != 0) { reversed = (reversed * 10) + original % 10 original /= 10 } return input == reversed } @JvmStatic fun main(args: Array<String>) { println(isPalindrome(121)) println(isPalindrome(-121)) println(isPalindrome(10)) } } /** * Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is a palindrome while 123 is not. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Example 2: Input: x = -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. Example 3: Input: x = 10 Output: false Explanation: Reads 01 from right to left. Therefore it is not a palindrome. Constraints: -231 <= x <= 231 - 1 Follow up: Could you solve it without converting the integer to a string? **/
[ { "class_path": "AhmedTawfiqM__ProblemSolving__a569265/palindrome_int/PalindRomeInt.class", "javap": "Compiled from \"PalindRomeInt.kt\"\npublic final class palindrome_int.PalindRomeInt {\n public static final palindrome_int.PalindRomeInt INSTANCE;\n\n private palindrome_int.PalindRomeInt();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final boolean isPalindrome(int);\n Code:\n 0: iload_1\n 1: iflt 10\n 4: iload_1\n 5: ldc #13 // int 2147483647\n 7: if_icmplt 12\n 10: iconst_0\n 11: ireturn\n 12: iconst_0\n 13: iload_1\n 14: if_icmpgt 31\n 17: iload_1\n 18: bipush 10\n 20: if_icmpge 27\n 23: iconst_1\n 24: goto 32\n 27: iconst_0\n 28: goto 32\n 31: iconst_0\n 32: ifeq 37\n 35: iconst_1\n 36: ireturn\n 37: iload_1\n 38: istore_2\n 39: iconst_0\n 40: istore_3\n 41: iload_2\n 42: ifeq 63\n 45: iload_3\n 46: bipush 10\n 48: imul\n 49: iload_2\n 50: bipush 10\n 52: irem\n 53: iadd\n 54: istore_3\n 55: iload_2\n 56: bipush 10\n 58: idiv\n 59: istore_2\n 60: goto 41\n 63: iload_1\n 64: iload_3\n 65: if_icmpne 72\n 68: iconst_1\n 69: goto 73\n 72: iconst_0\n 73: ireturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #23 // String args\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #32 // Field INSTANCE:Lpalindrome_int/PalindRomeInt;\n 9: bipush 121\n 11: invokespecial #34 // Method isPalindrome:(I)Z\n 14: istore_1\n 15: getstatic #40 // Field java/lang/System.out:Ljava/io/PrintStream;\n 18: iload_1\n 19: invokevirtual #46 // Method java/io/PrintStream.println:(Z)V\n 22: getstatic #32 // Field INSTANCE:Lpalindrome_int/PalindRomeInt;\n 25: bipush -121\n 27: invokespecial #34 // Method isPalindrome:(I)Z\n 30: istore_1\n 31: getstatic #40 // Field java/lang/System.out:Ljava/io/PrintStream;\n 34: iload_1\n 35: invokevirtual #46 // Method java/io/PrintStream.println:(Z)V\n 38: getstatic #32 // Field INSTANCE:Lpalindrome_int/PalindRomeInt;\n 41: bipush 10\n 43: invokespecial #34 // Method isPalindrome:(I)Z\n 46: istore_1\n 47: getstatic #40 // Field java/lang/System.out:Ljava/io/PrintStream;\n 50: iload_1\n 51: invokevirtual #46 // Method java/io/PrintStream.println:(Z)V\n 54: return\n\n static {};\n Code:\n 0: new #2 // class palindrome_int/PalindRomeInt\n 3: dup\n 4: invokespecial #49 // Method \"<init>\":()V\n 7: putstatic #32 // Field INSTANCE:Lpalindrome_int/PalindRomeInt;\n 10: return\n}\n", "javap_err": "" } ]
AhmedTawfiqM__ProblemSolving__a569265/src/palindrome_int/PalindRomeString.kt
package palindrome_int //https://leetcode.com/problems/palindrome-number object PalindRomeString { private fun isPalindrome(input: Int): Boolean { if (input < 0 || input >= Int.MAX_VALUE) return false if (input in 0..9) return true val original = input.toString() original.forEachIndexed { index, num -> if (num != original[original.length - (index+1)]) return false } return true } @JvmStatic fun main(args: Array<String>) { println(isPalindrome(121)) println(isPalindrome(-121)) println(isPalindrome(10)) } } /** * Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is a palindrome while 123 is not. Example 1: Input: x = 121 Output: true Explanation: 121 reads as 121 from left to right and from right to left. Example 2: Input: x = -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. Example 3: Input: x = 10 Output: false Explanation: Reads 01 from right to left. Therefore it is not a palindrome. Constraints: -231 <= x <= 231 - 1 Follow up: Could you solve it without converting the integer to a string? **/
[ { "class_path": "AhmedTawfiqM__ProblemSolving__a569265/palindrome_int/PalindRomeString.class", "javap": "Compiled from \"PalindRomeString.kt\"\npublic final class palindrome_int.PalindRomeString {\n public static final palindrome_int.PalindRomeString INSTANCE;\n\n private palindrome_int.PalindRomeString();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final boolean isPalindrome(int);\n Code:\n 0: iload_1\n 1: iflt 10\n 4: iload_1\n 5: ldc #13 // int 2147483647\n 7: if_icmplt 12\n 10: iconst_0\n 11: ireturn\n 12: iconst_0\n 13: iload_1\n 14: if_icmpgt 31\n 17: iload_1\n 18: bipush 10\n 20: if_icmpge 27\n 23: iconst_1\n 24: goto 32\n 27: iconst_0\n 28: goto 32\n 31: iconst_0\n 32: ifeq 37\n 35: iconst_1\n 36: ireturn\n 37: iload_1\n 38: invokestatic #19 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 41: astore_2\n 42: aload_2\n 43: checkcast #21 // class java/lang/CharSequence\n 46: astore_3\n 47: iconst_0\n 48: istore 4\n 50: iconst_0\n 51: istore 5\n 53: iconst_0\n 54: istore 6\n 56: iload 6\n 58: aload_3\n 59: invokeinterface #25, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 64: if_icmpge 119\n 67: aload_3\n 68: iload 6\n 70: invokeinterface #29, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 75: istore 7\n 77: iload 5\n 79: iinc 5, 1\n 82: iload 7\n 84: istore 8\n 86: istore 9\n 88: iconst_0\n 89: istore 10\n 91: iload 8\n 93: aload_2\n 94: aload_2\n 95: invokevirtual #30 // Method java/lang/String.length:()I\n 98: iload 9\n 100: iconst_1\n 101: iadd\n 102: isub\n 103: invokevirtual #31 // Method java/lang/String.charAt:(I)C\n 106: if_icmpeq 111\n 109: iconst_0\n 110: ireturn\n 111: nop\n 112: nop\n 113: iinc 6, 1\n 116: goto 56\n 119: nop\n 120: iconst_1\n 121: ireturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #50 // String args\n 3: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #59 // Field INSTANCE:Lpalindrome_int/PalindRomeString;\n 9: bipush 121\n 11: invokespecial #61 // Method isPalindrome:(I)Z\n 14: istore_1\n 15: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 18: iload_1\n 19: invokevirtual #73 // Method java/io/PrintStream.println:(Z)V\n 22: getstatic #59 // Field INSTANCE:Lpalindrome_int/PalindRomeString;\n 25: bipush -121\n 27: invokespecial #61 // Method isPalindrome:(I)Z\n 30: istore_1\n 31: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 34: iload_1\n 35: invokevirtual #73 // Method java/io/PrintStream.println:(Z)V\n 38: getstatic #59 // Field INSTANCE:Lpalindrome_int/PalindRomeString;\n 41: bipush 10\n 43: invokespecial #61 // Method isPalindrome:(I)Z\n 46: istore_1\n 47: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 50: iload_1\n 51: invokevirtual #73 // Method java/io/PrintStream.println:(Z)V\n 54: return\n\n static {};\n Code:\n 0: new #2 // class palindrome_int/PalindRomeString\n 3: dup\n 4: invokespecial #76 // Method \"<init>\":()V\n 7: putstatic #59 // Field INSTANCE:Lpalindrome_int/PalindRomeString;\n 10: return\n}\n", "javap_err": "" } ]
AhmedTawfiqM__ProblemSolving__a569265/src/common_prefix/CommonPrefix.kt
package common_prefix //https://leetcode.com/problems/longest-common-prefix/ object CommonPrefix { private fun longestCommonPrefix(list: Array<String>): String { if (list.isEmpty()) return "" var prefix = list[0] list.forEach { while (it.indexOf(prefix) != 0) { prefix = prefix.substring(0, prefix.length - 1) } } return prefix } @JvmStatic fun main(args: Array<String>) { println(longestCommonPrefix(arrayOf("flower", "flow", "flight"))) println(longestCommonPrefix(arrayOf("dog", "racecar", "car"))) println(longestCommonPrefix(arrayOf("ahmed", "sahm", "wassbah"))) } } /* * Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: strs = ["flower","flow","flight"] Output: "fl" Example 2: Input: strs = ["dog","racecar","car"] Output: "" Explanation: There is no common prefix among the input strings. Constraints: 1 <= strs.length <= 200 0 <= strs[i].length <= 200 strs[i] consists of only lower-case English letters. **/
[ { "class_path": "AhmedTawfiqM__ProblemSolving__a569265/common_prefix/CommonPrefix.class", "javap": "Compiled from \"CommonPrefix.kt\"\npublic final class common_prefix.CommonPrefix {\n public static final common_prefix.CommonPrefix INSTANCE;\n\n private common_prefix.CommonPrefix();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final java.lang.String longestCommonPrefix(java.lang.String[]);\n Code:\n 0: aload_1\n 1: arraylength\n 2: ifne 9\n 5: iconst_1\n 6: goto 10\n 9: iconst_0\n 10: ifeq 16\n 13: ldc #14 // String\n 15: areturn\n 16: aconst_null\n 17: astore_2\n 18: aload_1\n 19: iconst_0\n 20: aaload\n 21: astore_2\n 22: aload_1\n 23: astore_3\n 24: iconst_0\n 25: istore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: arraylength\n 32: istore 6\n 34: iload 5\n 36: iload 6\n 38: if_icmpge 100\n 41: aload_3\n 42: iload 5\n 44: aaload\n 45: astore 7\n 47: aload 7\n 49: astore 8\n 51: iconst_0\n 52: istore 9\n 54: aload 8\n 56: checkcast #16 // class java/lang/CharSequence\n 59: aload_2\n 60: iconst_0\n 61: iconst_0\n 62: bipush 6\n 64: aconst_null\n 65: invokestatic #22 // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;Ljava/lang/String;IZILjava/lang/Object;)I\n 68: ifeq 92\n 71: aload_2\n 72: iconst_0\n 73: aload_2\n 74: invokevirtual #28 // Method java/lang/String.length:()I\n 77: iconst_1\n 78: isub\n 79: invokevirtual #32 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 82: dup\n 83: ldc #34 // String substring(...)\n 85: invokestatic #40 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 88: astore_2\n 89: goto 54\n 92: nop\n 93: nop\n 94: iinc 5, 1\n 97: goto 34\n 100: nop\n 101: aload_2\n 102: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #59 // String args\n 3: invokestatic #62 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #65 // Field INSTANCE:Lcommon_prefix/CommonPrefix;\n 9: iconst_3\n 10: anewarray #24 // class java/lang/String\n 13: astore_1\n 14: aload_1\n 15: iconst_0\n 16: ldc #67 // String flower\n 18: aastore\n 19: aload_1\n 20: iconst_1\n 21: ldc #69 // String flow\n 23: aastore\n 24: aload_1\n 25: iconst_2\n 26: ldc #71 // String flight\n 28: aastore\n 29: aload_1\n 30: invokespecial #73 // Method longestCommonPrefix:([Ljava/lang/String;)Ljava/lang/String;\n 33: getstatic #79 // Field java/lang/System.out:Ljava/io/PrintStream;\n 36: swap\n 37: invokevirtual #85 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 40: getstatic #65 // Field INSTANCE:Lcommon_prefix/CommonPrefix;\n 43: iconst_3\n 44: anewarray #24 // class java/lang/String\n 47: astore_1\n 48: aload_1\n 49: iconst_0\n 50: ldc #87 // String dog\n 52: aastore\n 53: aload_1\n 54: iconst_1\n 55: ldc #89 // String racecar\n 57: aastore\n 58: aload_1\n 59: iconst_2\n 60: ldc #91 // String car\n 62: aastore\n 63: aload_1\n 64: invokespecial #73 // Method longestCommonPrefix:([Ljava/lang/String;)Ljava/lang/String;\n 67: getstatic #79 // Field java/lang/System.out:Ljava/io/PrintStream;\n 70: swap\n 71: invokevirtual #85 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 74: getstatic #65 // Field INSTANCE:Lcommon_prefix/CommonPrefix;\n 77: iconst_3\n 78: anewarray #24 // class java/lang/String\n 81: astore_1\n 82: aload_1\n 83: iconst_0\n 84: ldc #93 // String ahmed\n 86: aastore\n 87: aload_1\n 88: iconst_1\n 89: ldc #95 // String sahm\n 91: aastore\n 92: aload_1\n 93: iconst_2\n 94: ldc #97 // String wassbah\n 96: aastore\n 97: aload_1\n 98: invokespecial #73 // Method longestCommonPrefix:([Ljava/lang/String;)Ljava/lang/String;\n 101: getstatic #79 // Field java/lang/System.out:Ljava/io/PrintStream;\n 104: swap\n 105: invokevirtual #85 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 108: return\n\n static {};\n Code:\n 0: new #2 // class common_prefix/CommonPrefix\n 3: dup\n 4: invokespecial #99 // Method \"<init>\":()V\n 7: putstatic #65 // Field INSTANCE:Lcommon_prefix/CommonPrefix;\n 10: return\n}\n", "javap_err": "" } ]
jack-bolles__GildedRose-Refactoring-Kata-Kotlin__2036281/src/main/kotlin/com/gildedrose/Item.kt
package com.gildedrose data class Item(val name: String, val sellIn: Int, val quality: Int) { override fun toString(): String { return this.name + ", " + this.sellIn + ", " + this.quality } } fun Item.ageBy(days: Int): Item { return copy( sellIn = remainingSellInAfter(days), quality = qualityIn(days) ) } private fun Item.remainingSellInAfter(days: Int): Int { return when (name) { "Sulfuras, Hand of Ragnaros" -> sellIn else -> sellIn - days } } private fun Item.qualityIn(days: Int): Int { return when { name == "Backstage passes to a TAFKAL80ETC concert" -> boundedQuality(quality + this.incrementQualityFor(days)) name == "Sulfuras, Hand of Ragnaros" -> quality name == "Aged Brie" -> boundedQuality(quality + days) name.startsWith("Conjured") -> boundedQuality(quality + -2 * days) else -> boundedQuality(quality + -1 * days) } } private fun boundedQuality(rawQuality: Int): Int { return Integer.min(50, Integer.max(0, rawQuality)) } private fun Item.incrementQualityFor(days: Int): Int { val daysToSell = sellIn return (1 until days + 1) .fold(0) { total, e -> total + accelerateQualityWhenExpiring(daysToSell - e, quality) } } private fun accelerateQualityWhenExpiring(sellIn: Int, startingQuality: Int): Int { return when { sellIn < 0 -> -startingQuality sellIn <= 5 -> 3 sellIn <= 10 -> 2 else -> 1 } }
[ { "class_path": "jack-bolles__GildedRose-Refactoring-Kata-Kotlin__2036281/com/gildedrose/Item.class", "javap": "Compiled from \"Item.kt\"\npublic final class com.gildedrose.Item {\n private final java.lang.String name;\n\n private final int sellIn;\n\n private final int quality;\n\n public com.gildedrose.Item(java.lang.String, int, int);\n Code:\n 0: aload_1\n 1: ldc #9 // String name\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #18 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #21 // Field name:Ljava/lang/String;\n 15: aload_0\n 16: iload_2\n 17: putfield #25 // Field sellIn:I\n 20: aload_0\n 21: iload_3\n 22: putfield #28 // Field quality:I\n 25: return\n\n public final java.lang.String getName();\n Code:\n 0: aload_0\n 1: getfield #21 // Field name:Ljava/lang/String;\n 4: areturn\n\n public final int getSellIn();\n Code:\n 0: aload_0\n 1: getfield #25 // Field sellIn:I\n 4: ireturn\n\n public final int getQuality();\n Code:\n 0: aload_0\n 1: getfield #28 // Field quality:I\n 4: ireturn\n\n public java.lang.String toString();\n Code:\n 0: new #38 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #39 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: aload_0\n 8: getfield #21 // Field name:Ljava/lang/String;\n 11: invokevirtual #43 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 14: ldc #45 // String ,\n 16: invokevirtual #43 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 19: aload_0\n 20: getfield #25 // Field sellIn:I\n 23: invokevirtual #48 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 26: ldc #45 // String ,\n 28: invokevirtual #43 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 31: aload_0\n 32: getfield #28 // Field quality:I\n 35: invokevirtual #48 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 38: invokevirtual #50 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 41: areturn\n\n public final java.lang.String component1();\n Code:\n 0: aload_0\n 1: getfield #21 // Field name:Ljava/lang/String;\n 4: areturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field sellIn:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #28 // Field quality:I\n 4: ireturn\n\n public final com.gildedrose.Item copy(java.lang.String, int, int);\n Code:\n 0: aload_1\n 1: ldc #9 // String name\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class com/gildedrose/Item\n 9: dup\n 10: aload_1\n 11: iload_2\n 12: iload_3\n 13: invokespecial #57 // Method \"<init>\":(Ljava/lang/String;II)V\n 16: areturn\n\n public static com.gildedrose.Item copy$default(com.gildedrose.Item, java.lang.String, int, int, int, java.lang.Object);\n Code:\n 0: iload 4\n 2: iconst_1\n 3: iand\n 4: ifeq 12\n 7: aload_0\n 8: getfield #21 // Field name:Ljava/lang/String;\n 11: astore_1\n 12: iload 4\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #25 // Field sellIn:I\n 23: istore_2\n 24: iload 4\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #28 // Field quality:I\n 35: istore_3\n 36: aload_0\n 37: aload_1\n 38: iload_2\n 39: iload_3\n 40: invokevirtual #61 // Method copy:(Ljava/lang/String;II)Lcom/gildedrose/Item;\n 43: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #21 // Field name:Ljava/lang/String;\n 4: invokevirtual #66 // Method java/lang/String.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #25 // Field sellIn:I\n 16: invokestatic #71 // Method java/lang/Integer.hashCode:(I)I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: bipush 31\n 24: imul\n 25: aload_0\n 26: getfield #28 // Field quality:I\n 29: invokestatic #71 // Method java/lang/Integer.hashCode:(I)I\n 32: iadd\n 33: istore_1\n 34: iload_1\n 35: ireturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_1\n 8: instanceof #2 // class com/gildedrose/Item\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class com/gildedrose/Item\n 20: astore_2\n 21: aload_0\n 22: getfield #21 // Field name:Ljava/lang/String;\n 25: aload_2\n 26: getfield #21 // Field name:Ljava/lang/String;\n 29: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifne 37\n 35: iconst_0\n 36: ireturn\n 37: aload_0\n 38: getfield #25 // Field sellIn:I\n 41: aload_2\n 42: getfield #25 // Field sellIn:I\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: aload_0\n 51: getfield #28 // Field quality:I\n 54: aload_2\n 55: getfield #28 // Field quality:I\n 58: if_icmpeq 63\n 61: iconst_0\n 62: ireturn\n 63: iconst_1\n 64: ireturn\n}\n", "javap_err": "" }, { "class_path": "jack-bolles__GildedRose-Refactoring-Kata-Kotlin__2036281/com/gildedrose/ItemKt.class", "javap": "Compiled from \"Item.kt\"\npublic final class com.gildedrose.ItemKt {\n public static final com.gildedrose.Item ageBy(com.gildedrose.Item, int);\n Code:\n 0: aload_0\n 1: ldc #9 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aconst_null\n 8: aload_0\n 9: iload_1\n 10: invokestatic #19 // Method remainingSellInAfter:(Lcom/gildedrose/Item;I)I\n 13: aload_0\n 14: iload_1\n 15: invokestatic #22 // Method qualityIn:(Lcom/gildedrose/Item;I)I\n 18: iconst_1\n 19: aconst_null\n 20: invokestatic #28 // Method com/gildedrose/Item.copy$default:(Lcom/gildedrose/Item;Ljava/lang/String;IIILjava/lang/Object;)Lcom/gildedrose/Item;\n 23: areturn\n\n private static final int remainingSellInAfter(com.gildedrose.Item, int);\n Code:\n 0: aload_0\n 1: invokevirtual #36 // Method com/gildedrose/Item.getName:()Ljava/lang/String;\n 4: ldc #38 // String Sulfuras, Hand of Ragnaros\n 6: invokestatic #42 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 9: ifeq 19\n 12: aload_0\n 13: invokevirtual #46 // Method com/gildedrose/Item.getSellIn:()I\n 16: goto 25\n 19: aload_0\n 20: invokevirtual #46 // Method com/gildedrose/Item.getSellIn:()I\n 23: iload_1\n 24: isub\n 25: ireturn\n\n private static final int qualityIn(com.gildedrose.Item, int);\n Code:\n 0: nop\n 1: aload_0\n 2: invokevirtual #36 // Method com/gildedrose/Item.getName:()Ljava/lang/String;\n 5: ldc #49 // String Backstage passes to a TAFKAL80ETC concert\n 7: invokestatic #42 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 10: ifeq 29\n 13: aload_0\n 14: invokevirtual #52 // Method com/gildedrose/Item.getQuality:()I\n 17: aload_0\n 18: iload_1\n 19: invokestatic #55 // Method incrementQualityFor:(Lcom/gildedrose/Item;I)I\n 22: iadd\n 23: invokestatic #59 // Method boundedQuality:(I)I\n 26: goto 113\n 29: aload_0\n 30: invokevirtual #36 // Method com/gildedrose/Item.getName:()Ljava/lang/String;\n 33: ldc #38 // String Sulfuras, Hand of Ragnaros\n 35: invokestatic #42 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 38: ifeq 48\n 41: aload_0\n 42: invokevirtual #52 // Method com/gildedrose/Item.getQuality:()I\n 45: goto 113\n 48: aload_0\n 49: invokevirtual #36 // Method com/gildedrose/Item.getName:()Ljava/lang/String;\n 52: ldc #61 // String Aged Brie\n 54: invokestatic #42 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 57: ifeq 72\n 60: aload_0\n 61: invokevirtual #52 // Method com/gildedrose/Item.getQuality:()I\n 64: iload_1\n 65: iadd\n 66: invokestatic #59 // Method boundedQuality:(I)I\n 69: goto 113\n 72: aload_0\n 73: invokevirtual #36 // Method com/gildedrose/Item.getName:()Ljava/lang/String;\n 76: ldc #63 // String Conjured\n 78: iconst_0\n 79: iconst_2\n 80: aconst_null\n 81: invokestatic #69 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 84: ifeq 102\n 87: aload_0\n 88: invokevirtual #52 // Method com/gildedrose/Item.getQuality:()I\n 91: bipush -2\n 93: iload_1\n 94: imul\n 95: iadd\n 96: invokestatic #59 // Method boundedQuality:(I)I\n 99: goto 113\n 102: aload_0\n 103: invokevirtual #52 // Method com/gildedrose/Item.getQuality:()I\n 106: iconst_m1\n 107: iload_1\n 108: imul\n 109: iadd\n 110: invokestatic #59 // Method boundedQuality:(I)I\n 113: ireturn\n\n private static final int boundedQuality(int);\n Code:\n 0: bipush 50\n 2: iconst_0\n 3: iload_0\n 4: invokestatic #76 // Method java/lang/Integer.max:(II)I\n 7: invokestatic #79 // Method java/lang/Integer.min:(II)I\n 10: ireturn\n\n private static final int incrementQualityFor(com.gildedrose.Item, int);\n Code:\n 0: aload_0\n 1: invokevirtual #46 // Method com/gildedrose/Item.getSellIn:()I\n 4: istore_2\n 5: iconst_1\n 6: iload_1\n 7: iconst_1\n 8: iadd\n 9: invokestatic #86 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 12: checkcast #88 // class java/lang/Iterable\n 15: astore_3\n 16: iconst_0\n 17: istore 4\n 19: iconst_0\n 20: istore 5\n 22: iload 4\n 24: istore 6\n 26: aload_3\n 27: invokeinterface #92, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 7\n 34: aload 7\n 36: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 84\n 44: aload 7\n 46: checkcast #100 // class kotlin/collections/IntIterator\n 49: invokevirtual #103 // Method kotlin/collections/IntIterator.nextInt:()I\n 52: istore 8\n 54: iload 6\n 56: iload 8\n 58: istore 9\n 60: istore 10\n 62: iconst_0\n 63: istore 11\n 65: iload 10\n 67: iload_2\n 68: iload 9\n 70: isub\n 71: aload_0\n 72: invokevirtual #52 // Method com/gildedrose/Item.getQuality:()I\n 75: invokestatic #106 // Method accelerateQualityWhenExpiring:(II)I\n 78: iadd\n 79: istore 6\n 81: goto 34\n 84: iload 6\n 86: ireturn\n\n private static final int accelerateQualityWhenExpiring(int, int);\n Code:\n 0: nop\n 1: iload_0\n 2: ifge 10\n 5: iload_1\n 6: ineg\n 7: goto 30\n 10: iload_0\n 11: iconst_5\n 12: if_icmpgt 19\n 15: iconst_3\n 16: goto 30\n 19: iload_0\n 20: bipush 10\n 22: if_icmpgt 29\n 25: iconst_2\n 26: goto 30\n 29: iconst_1\n 30: ireturn\n}\n", "javap_err": "" } ]
Kraktun__java_web_frameworks_cmp__28c5739/code/supportLib/src/main/java/it/unipd/stage/sl/lib/rsa/RsaUtils.kt
package it.unipd.stage.sl.lib.rsa import java.math.BigInteger /* The following functions come from https://en.wikipedia.org/wiki/RSA_(cryptosystem)#Key_generation */ /** * @return true is a big integer is probably prime with certainty 15 */ fun BigInteger.isPrime(): Boolean { // not 100% correct, but error is very low and for this type of application it's good enough return this.isProbablePrime(15) } /** * @param n1 a non null positive big integer * @param n2 a non null positive big integer * @return true if n1 and n2 are coprime */ fun areCoprime(n1: BigInteger, n2: BigInteger): Boolean { return gcd(n1, n2) == BigInteger.ONE } /** * from https://www.geeksforgeeks.org/euclidean-algorithms-basic-and-extended/ * @param a a non null positive big integer * @param b a non null positive big integer * @return greatest common divisor between a and b */ fun gcd(a: BigInteger, b: BigInteger): BigInteger { return if (a == BigInteger.ZERO) b else gcd(b % a, a) } /** * @param n1 a non null positive big integer * @param n2 a non null positive big integer * @return least common multiple between n1 and n2 */ fun lcm(n1: BigInteger, n2: BigInteger): BigInteger { return n1.multiply(n2).divide(gcd(n1, n2)) } /** * Returns modulo inverse of 'a' with respect to 'm' using extended Euclid * Algorithm Assumption: 'a' and 'm' are coprimes * from https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/ * * @param a non null positive big integer * @param m non null positive big integer */ fun modInverse(a: BigInteger, m: BigInteger): BigInteger { // note: mapping to rsa: a = e, m= y, result = d var a1 = a var m1 = m val m0 = m1 var y = BigInteger.ZERO var x = BigInteger.ONE if (m1 == BigInteger.ONE) return BigInteger.ZERO while (a1 > BigInteger.ONE) { // q is the quotient val q = a1 / m1 var t = m1 // m is the remainder now, process same as Euclid's algo m1 = a1 % m1 a1 = t t = y // Update x and y y = x - q * y x = t } // Make x positive if (x < BigInteger.ZERO) x += m0 return x } /** * Naive approach to factorize a number. * Note that this does not always return all factors, but a set such that * each element of the set may be a factor multiple times * and/or the last factor is obtained from the set as n/prod(set) * * @param n non null positive big integer * @return set of factors */ fun factorize(n: BigInteger): Set<BigInteger> { val set = mutableSetOf<BigInteger>() // first test 2 and 3 if (n % BigInteger("2") == BigInteger.ZERO) set.add(BigInteger("2")) // for some reason BigInteger.TWO does not work with shadowjar if (n % BigInteger("3") == BigInteger.ZERO) set.add(BigInteger("3")) // use 6k+1 rule var i = BigInteger("5") while (i*i <= n) { if (n%i == BigInteger.ZERO) { set.add(i) } if (n%(i+ BigInteger("2")) == BigInteger.ZERO) { set.add(i+ BigInteger("2")) } i += BigInteger("6") } return set } /** * Return a list of all the prime factors of n * * @param n non null positive big integer * @return list of prime factors (may be repated) */ fun factorizeFull(n: BigInteger): List<BigInteger> { val list = mutableListOf<BigInteger>() val set = factorize(n) list.addAll(set) val prod = set.reduce { acc, bigInteger -> acc*bigInteger } var residual = n / prod while (residual > BigInteger.ONE) { set.forEach{ while (residual % it == BigInteger.ZERO) { list.add(it) residual /= it } } if (residual.isPrime()) { list.add(residual) break } } return list }
[ { "class_path": "Kraktun__java_web_frameworks_cmp__28c5739/it/unipd/stage/sl/lib/rsa/RsaUtilsKt.class", "javap": "Compiled from \"RsaUtils.kt\"\npublic final class it.unipd.stage.sl.lib.rsa.RsaUtilsKt {\n public static final boolean isPrime(java.math.BigInteger);\n Code:\n 0: aload_0\n 1: ldc #9 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: bipush 15\n 9: invokevirtual #21 // Method java/math/BigInteger.isProbablePrime:(I)Z\n 12: ireturn\n\n public static final boolean areCoprime(java.math.BigInteger, java.math.BigInteger);\n Code:\n 0: aload_0\n 1: ldc #27 // String n1\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #29 // String n2\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_1\n 14: invokestatic #33 // Method gcd:(Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 17: getstatic #36 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;\n 20: invokestatic #40 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 23: ireturn\n\n public static final java.math.BigInteger gcd(java.math.BigInteger, java.math.BigInteger);\n Code:\n 0: aload_0\n 1: ldc #42 // String a\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #44 // String b\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: getstatic #47 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 16: invokestatic #40 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 19: ifeq 26\n 22: aload_1\n 23: goto 41\n 26: aload_1\n 27: aload_0\n 28: invokevirtual #51 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 31: dup\n 32: ldc #53 // String remainder(...)\n 34: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 37: aload_0\n 38: invokestatic #33 // Method gcd:(Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 41: areturn\n\n public static final java.math.BigInteger lcm(java.math.BigInteger, java.math.BigInteger);\n Code:\n 0: aload_0\n 1: ldc #27 // String n1\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #29 // String n2\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_1\n 14: invokevirtual #60 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 17: aload_0\n 18: aload_1\n 19: invokestatic #33 // Method gcd:(Ljava/math/BigInteger;Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 22: invokevirtual #63 // Method java/math/BigInteger.divide:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 25: dup\n 26: ldc #65 // String divide(...)\n 28: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 31: areturn\n\n public static final java.math.BigInteger modInverse(java.math.BigInteger, java.math.BigInteger);\n Code:\n 0: aload_0\n 1: ldc #42 // String a\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #68 // String m\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: astore_2\n 14: aload_1\n 15: astore_3\n 16: aload_3\n 17: astore 4\n 19: getstatic #47 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 22: astore 5\n 24: getstatic #36 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;\n 27: astore 6\n 29: aload_3\n 30: getstatic #36 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;\n 33: invokestatic #40 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 36: ifeq 49\n 39: getstatic #47 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 42: dup\n 43: ldc #69 // String ZERO\n 45: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 48: areturn\n 49: aload_2\n 50: getstatic #36 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;\n 53: invokevirtual #73 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I\n 56: ifle 166\n 59: aload_2\n 60: aload_3\n 61: invokevirtual #63 // Method java/math/BigInteger.divide:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 64: dup\n 65: ldc #65 // String divide(...)\n 67: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 70: astore 7\n 72: aload_3\n 73: astore 8\n 75: aload_2\n 76: aload_3\n 77: invokevirtual #51 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 80: dup\n 81: ldc #53 // String remainder(...)\n 83: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 86: astore_3\n 87: aload 8\n 89: astore_2\n 90: aload 5\n 92: astore 9\n 94: aload 9\n 96: invokestatic #77 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 99: aload 9\n 101: astore 8\n 103: aload 6\n 105: astore 9\n 107: aload 9\n 109: invokestatic #77 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 112: aload 9\n 114: astore 9\n 116: aload 7\n 118: astore 10\n 120: aload 5\n 122: astore 11\n 124: aload 11\n 126: invokestatic #77 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 129: aload 10\n 131: aload 11\n 133: invokevirtual #60 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 136: dup\n 137: ldc #79 // String multiply(...)\n 139: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 142: astore 10\n 144: aload 9\n 146: aload 10\n 148: invokevirtual #82 // Method java/math/BigInteger.subtract:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 151: dup\n 152: ldc #84 // String subtract(...)\n 154: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 157: astore 5\n 159: aload 8\n 161: astore 6\n 163: goto 49\n 166: aload 6\n 168: getstatic #47 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 171: invokevirtual #73 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I\n 174: ifge 201\n 177: aload 6\n 179: astore 7\n 181: aload 7\n 183: invokestatic #77 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 186: aload 7\n 188: aload 4\n 190: invokevirtual #87 // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 193: dup\n 194: ldc #89 // String add(...)\n 196: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 199: astore 6\n 201: aload 6\n 203: astore 7\n 205: aload 7\n 207: invokestatic #77 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 210: aload 7\n 212: areturn\n\n public static final java.util.Set<java.math.BigInteger> factorize(java.math.BigInteger);\n Code:\n 0: aload_0\n 1: ldc #101 // String n\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #103 // class java/util/LinkedHashSet\n 9: dup\n 10: invokespecial #107 // Method java/util/LinkedHashSet.\"<init>\":()V\n 13: checkcast #109 // class java/util/Set\n 16: astore_1\n 17: aload_0\n 18: new #17 // class java/math/BigInteger\n 21: dup\n 22: ldc #111 // String 2\n 24: invokespecial #114 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 27: invokevirtual #51 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 30: dup\n 31: ldc #53 // String remainder(...)\n 33: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 36: getstatic #47 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 39: invokestatic #40 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 42: ifeq 61\n 45: aload_1\n 46: new #17 // class java/math/BigInteger\n 49: dup\n 50: ldc #111 // String 2\n 52: invokespecial #114 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 55: invokeinterface #117, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 60: pop\n 61: aload_0\n 62: new #17 // class java/math/BigInteger\n 65: dup\n 66: ldc #119 // String 3\n 68: invokespecial #114 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 71: invokevirtual #51 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 74: dup\n 75: ldc #53 // String remainder(...)\n 77: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 80: getstatic #47 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 83: invokestatic #40 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 86: ifeq 105\n 89: aload_1\n 90: new #17 // class java/math/BigInteger\n 93: dup\n 94: ldc #119 // String 3\n 96: invokespecial #114 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 99: invokeinterface #117, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 104: pop\n 105: new #17 // class java/math/BigInteger\n 108: dup\n 109: ldc #121 // String 5\n 111: invokespecial #114 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 114: astore_2\n 115: aload_2\n 116: aload_2\n 117: invokevirtual #60 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 120: dup\n 121: ldc #79 // String multiply(...)\n 123: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 126: aload_0\n 127: invokevirtual #73 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I\n 130: ifgt 248\n 133: aload_0\n 134: aload_2\n 135: invokevirtual #51 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 138: dup\n 139: ldc #53 // String remainder(...)\n 141: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 144: getstatic #47 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 147: invokestatic #40 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 150: ifeq 161\n 153: aload_1\n 154: aload_2\n 155: invokeinterface #117, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 160: pop\n 161: aload_0\n 162: aload_2\n 163: new #17 // class java/math/BigInteger\n 166: dup\n 167: ldc #111 // String 2\n 169: invokespecial #114 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 172: invokevirtual #87 // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 175: dup\n 176: ldc #89 // String add(...)\n 178: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 181: invokevirtual #51 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 184: dup\n 185: ldc #53 // String remainder(...)\n 187: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 190: getstatic #47 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 193: invokestatic #40 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 196: ifeq 225\n 199: aload_1\n 200: aload_2\n 201: new #17 // class java/math/BigInteger\n 204: dup\n 205: ldc #111 // String 2\n 207: invokespecial #114 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 210: invokevirtual #87 // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 213: dup\n 214: ldc #89 // String add(...)\n 216: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 219: invokeinterface #117, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 224: pop\n 225: aload_2\n 226: new #17 // class java/math/BigInteger\n 229: dup\n 230: ldc #123 // String 6\n 232: invokespecial #114 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 235: invokevirtual #87 // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 238: dup\n 239: ldc #89 // String add(...)\n 241: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 244: astore_2\n 245: goto 115\n 248: aload_1\n 249: areturn\n\n public static final java.util.List<java.math.BigInteger> factorizeFull(java.math.BigInteger);\n Code:\n 0: aload_0\n 1: ldc #101 // String n\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #131 // class java/util/ArrayList\n 9: dup\n 10: invokespecial #132 // Method java/util/ArrayList.\"<init>\":()V\n 13: checkcast #134 // class java/util/List\n 16: astore_1\n 17: aload_0\n 18: invokestatic #136 // Method factorize:(Ljava/math/BigInteger;)Ljava/util/Set;\n 21: astore_2\n 22: aload_1\n 23: aload_2\n 24: checkcast #138 // class java/util/Collection\n 27: invokeinterface #142, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 32: pop\n 33: aload_2\n 34: checkcast #144 // class java/lang/Iterable\n 37: astore 4\n 39: iconst_0\n 40: istore 5\n 42: aload 4\n 44: invokeinterface #148, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 49: astore 6\n 51: aload 6\n 53: invokeinterface #154, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 58: ifne 71\n 61: new #156 // class java/lang/UnsupportedOperationException\n 64: dup\n 65: ldc #158 // String Empty collection can\\'t be reduced.\n 67: invokespecial #159 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 70: athrow\n 71: aload 6\n 73: invokeinterface #163, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 78: astore 7\n 80: aload 6\n 82: invokeinterface #154, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 87: ifeq 131\n 90: aload 7\n 92: aload 6\n 94: invokeinterface #163, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 99: checkcast #17 // class java/math/BigInteger\n 102: astore 8\n 104: checkcast #17 // class java/math/BigInteger\n 107: astore 9\n 109: iconst_0\n 110: istore 10\n 112: aload 9\n 114: aload 8\n 116: invokevirtual #60 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 119: dup\n 120: ldc #79 // String multiply(...)\n 122: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 125: nop\n 126: astore 7\n 128: goto 80\n 131: aload 7\n 133: checkcast #17 // class java/math/BigInteger\n 136: astore_3\n 137: aconst_null\n 138: astore 4\n 140: aload_0\n 141: aload_3\n 142: invokevirtual #63 // Method java/math/BigInteger.divide:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 145: dup\n 146: ldc #65 // String divide(...)\n 148: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 151: astore 4\n 153: aload 4\n 155: getstatic #36 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;\n 158: invokevirtual #73 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I\n 161: ifle 286\n 164: aload_2\n 165: checkcast #144 // class java/lang/Iterable\n 168: astore 5\n 170: iconst_0\n 171: istore 6\n 173: aload 5\n 175: invokeinterface #148, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 180: astore 7\n 182: aload 7\n 184: invokeinterface #154, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 189: ifeq 265\n 192: aload 7\n 194: invokeinterface #163, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 199: astore 8\n 201: aload 8\n 203: checkcast #17 // class java/math/BigInteger\n 206: astore 9\n 208: iconst_0\n 209: istore 10\n 211: aload 4\n 213: aload 9\n 215: invokevirtual #51 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 218: dup\n 219: ldc #53 // String remainder(...)\n 221: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 224: getstatic #47 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 227: invokestatic #40 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 230: ifeq 260\n 233: aload_1\n 234: aload 9\n 236: invokeinterface #164, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 241: pop\n 242: aload 4\n 244: aload 9\n 246: invokevirtual #63 // Method java/math/BigInteger.divide:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 249: dup\n 250: ldc #65 // String divide(...)\n 252: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 255: astore 4\n 257: goto 211\n 260: nop\n 261: nop\n 262: goto 182\n 265: nop\n 266: aload 4\n 268: invokestatic #166 // Method isPrime:(Ljava/math/BigInteger;)Z\n 271: ifeq 153\n 274: aload_1\n 275: aload 4\n 277: invokeinterface #164, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 282: pop\n 283: goto 286\n 286: aload_1\n 287: areturn\n}\n", "javap_err": "" } ]
coil-kt__coil__75ed843/internal/test-utils/src/commonMain/kotlin/coil3/test/utils/maths.kt
package coil3.test.utils import kotlin.math.pow import kotlin.math.roundToInt import kotlin.math.sqrt /** * Returns the cross correlation between two arrays. * * https://en.wikipedia.org/wiki/Cross-correlation */ fun crossCorrelation(x: IntArray, y: IntArray): Double { require(x.count() == y.count()) { "Input arrays must be of equal size." } val xVar = x.variance() val yVar = y.variance() val squaredVariance = sqrt(xVar * yVar) val xAvg = x.average() val yAvg = y.average() val count = x.count() var sum = 0.0 for (index in 0 until count) { sum += (x[index] - xAvg) * (y[index] - yAvg) } return sum / count / squaredVariance } /** * Returns the cross correlation between two arrays. * * https://en.wikipedia.org/wiki/Cross-correlation */ fun crossCorrelation(x: ByteArray, y: ByteArray): Double { require(x.count() == y.count()) { "Input arrays must be of equal size." } val xVar = x.variance() val yVar = y.variance() val squaredVariance = sqrt(xVar * yVar) val xAvg = x.average() val yAvg = y.average() val count = x.count() var sum = 0.0 for (index in 0 until count) { sum += (x[index] - xAvg) * (y[index] - yAvg) } return sum / count / squaredVariance } /** * Returns an average value of elements in the array. */ fun IntArray.variance(): Double { if (isEmpty()) return Double.NaN val average = average() return sumOf { (it - average).pow(2) } / count() } /** * Returns an average value of elements in the array. */ fun ByteArray.variance(): Double { if (isEmpty()) return Double.NaN val average = average() return sumOf { (it - average).pow(2) } / count() } /** * Round the given value to the nearest [Double] with [precision] number of decimal places. */ fun Double.round(precision: Int): Double { val multiplier = 10.0.pow(precision) return (this * multiplier).roundToInt() / multiplier }
[ { "class_path": "coil-kt__coil__75ed843/coil3/test/utils/MathsKt.class", "javap": "Compiled from \"maths.kt\"\npublic final class coil3.test.utils.MathsKt {\n public static final double crossCorrelation(int[], int[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String x\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #17 // String y\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: arraylength\n 14: aload_1\n 15: arraylength\n 16: if_icmpne 23\n 19: iconst_1\n 20: goto 24\n 23: iconst_0\n 24: ifne 44\n 27: iconst_0\n 28: istore_3\n 29: ldc #19 // String Input arrays must be of equal size.\n 31: astore_3\n 32: new #21 // class java/lang/IllegalArgumentException\n 35: dup\n 36: aload_3\n 37: invokevirtual #25 // Method java/lang/Object.toString:()Ljava/lang/String;\n 40: invokespecial #29 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 43: athrow\n 44: aload_0\n 45: invokestatic #33 // Method variance:([I)D\n 48: dstore_2\n 49: aload_1\n 50: invokestatic #33 // Method variance:([I)D\n 53: dstore 4\n 55: dload_2\n 56: dload 4\n 58: dmul\n 59: invokestatic #39 // Method java/lang/Math.sqrt:(D)D\n 62: dstore 6\n 64: aload_0\n 65: invokestatic #44 // Method kotlin/collections/ArraysKt.average:([I)D\n 68: dstore 8\n 70: aload_1\n 71: invokestatic #44 // Method kotlin/collections/ArraysKt.average:([I)D\n 74: dstore 10\n 76: aload_0\n 77: arraylength\n 78: istore 12\n 80: dconst_0\n 81: dstore 13\n 83: iconst_0\n 84: istore 15\n 86: iload 15\n 88: iload 12\n 90: if_icmpge 121\n 93: dload 13\n 95: aload_0\n 96: iload 15\n 98: iaload\n 99: i2d\n 100: dload 8\n 102: dsub\n 103: aload_1\n 104: iload 15\n 106: iaload\n 107: i2d\n 108: dload 10\n 110: dsub\n 111: dmul\n 112: dadd\n 113: dstore 13\n 115: iinc 15, 1\n 118: goto 86\n 121: dload 13\n 123: iload 12\n 125: i2d\n 126: ddiv\n 127: dload 6\n 129: ddiv\n 130: dreturn\n\n public static final double crossCorrelation(byte[], byte[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String x\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #17 // String y\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: arraylength\n 14: aload_1\n 15: arraylength\n 16: if_icmpne 23\n 19: iconst_1\n 20: goto 24\n 23: iconst_0\n 24: ifne 44\n 27: iconst_0\n 28: istore_3\n 29: ldc #19 // String Input arrays must be of equal size.\n 31: astore_3\n 32: new #21 // class java/lang/IllegalArgumentException\n 35: dup\n 36: aload_3\n 37: invokevirtual #25 // Method java/lang/Object.toString:()Ljava/lang/String;\n 40: invokespecial #29 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 43: athrow\n 44: aload_0\n 45: invokestatic #61 // Method variance:([B)D\n 48: dstore_2\n 49: aload_1\n 50: invokestatic #61 // Method variance:([B)D\n 53: dstore 4\n 55: dload_2\n 56: dload 4\n 58: dmul\n 59: invokestatic #39 // Method java/lang/Math.sqrt:(D)D\n 62: dstore 6\n 64: aload_0\n 65: invokestatic #63 // Method kotlin/collections/ArraysKt.average:([B)D\n 68: dstore 8\n 70: aload_1\n 71: invokestatic #63 // Method kotlin/collections/ArraysKt.average:([B)D\n 74: dstore 10\n 76: aload_0\n 77: arraylength\n 78: istore 12\n 80: dconst_0\n 81: dstore 13\n 83: iconst_0\n 84: istore 15\n 86: iload 15\n 88: iload 12\n 90: if_icmpge 121\n 93: dload 13\n 95: aload_0\n 96: iload 15\n 98: baload\n 99: i2d\n 100: dload 8\n 102: dsub\n 103: aload_1\n 104: iload 15\n 106: baload\n 107: i2d\n 108: dload 10\n 110: dsub\n 111: dmul\n 112: dadd\n 113: dstore 13\n 115: iinc 15, 1\n 118: goto 86\n 121: dload 13\n 123: iload 12\n 125: i2d\n 126: ddiv\n 127: dload 6\n 129: ddiv\n 130: dreturn\n\n public static final double variance(int[]);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: arraylength\n 8: ifne 15\n 11: iconst_1\n 12: goto 16\n 15: iconst_0\n 16: ifeq 23\n 19: ldc2_w #69 // double NaNd\n 22: dreturn\n 23: aload_0\n 24: invokestatic #44 // Method kotlin/collections/ArraysKt.average:([I)D\n 27: dstore_1\n 28: aload_0\n 29: astore_3\n 30: dconst_0\n 31: dstore 4\n 33: iconst_0\n 34: istore 6\n 36: aload_3\n 37: arraylength\n 38: istore 7\n 40: iload 6\n 42: iload 7\n 44: if_icmpge 90\n 47: aload_3\n 48: iload 6\n 50: iaload\n 51: istore 8\n 53: dload 4\n 55: iload 8\n 57: istore 9\n 59: dstore 11\n 61: iconst_0\n 62: istore 10\n 64: iload 9\n 66: i2d\n 67: dload_1\n 68: dsub\n 69: iconst_2\n 70: i2d\n 71: invokestatic #74 // Method java/lang/Math.pow:(DD)D\n 74: nop\n 75: dstore 13\n 77: dload 11\n 79: dload 13\n 81: dadd\n 82: dstore 4\n 84: iinc 6, 1\n 87: goto 40\n 90: dload 4\n 92: aload_0\n 93: arraylength\n 94: i2d\n 95: ddiv\n 96: dreturn\n\n public static final double variance(byte[]);\n Code:\n 0: aload_0\n 1: ldc #68 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: arraylength\n 8: ifne 15\n 11: iconst_1\n 12: goto 16\n 15: iconst_0\n 16: ifeq 23\n 19: ldc2_w #69 // double NaNd\n 22: dreturn\n 23: aload_0\n 24: invokestatic #63 // Method kotlin/collections/ArraysKt.average:([B)D\n 27: dstore_1\n 28: aload_0\n 29: astore_3\n 30: dconst_0\n 31: dstore 4\n 33: iconst_0\n 34: istore 6\n 36: aload_3\n 37: arraylength\n 38: istore 7\n 40: iload 6\n 42: iload 7\n 44: if_icmpge 90\n 47: aload_3\n 48: iload 6\n 50: baload\n 51: istore 8\n 53: dload 4\n 55: iload 8\n 57: istore 9\n 59: dstore 11\n 61: iconst_0\n 62: istore 10\n 64: iload 9\n 66: i2d\n 67: dload_1\n 68: dsub\n 69: iconst_2\n 70: i2d\n 71: invokestatic #74 // Method java/lang/Math.pow:(DD)D\n 74: nop\n 75: dstore 13\n 77: dload 11\n 79: dload 13\n 81: dadd\n 82: dstore 4\n 84: iinc 6, 1\n 87: goto 40\n 90: dload 4\n 92: aload_0\n 93: arraylength\n 94: i2d\n 95: ddiv\n 96: dreturn\n\n public static final double round(double, int);\n Code:\n 0: ldc2_w #82 // double 10.0d\n 3: iload_2\n 4: i2d\n 5: invokestatic #74 // Method java/lang/Math.pow:(DD)D\n 8: dstore_3\n 9: dload_0\n 10: dload_3\n 11: dmul\n 12: invokestatic #89 // Method kotlin/math/MathKt.roundToInt:(D)I\n 15: i2d\n 16: dload_3\n 17: ddiv\n 18: dreturn\n}\n", "javap_err": "" } ]
JIghtuse__simple-search-engine-hyperskill__4634a62/src/search/Main.kt
package search import java.io.File import java.lang.IllegalArgumentException typealias Dataset = List<String> typealias InvertedIndex = Map<String, List<Int>> fun toLowercaseWords(s: String) = s.split(" ").map(String::lowercase) fun ask(prompt: String): String { println(prompt) return readln() } fun scanInputFile(filePath: String): Pair<Dataset, InvertedIndex> { val lines = mutableListOf<String>() val invertedIndex = mutableMapOf<String, MutableList<Int>>() var lineIndex = 0 val file = File(filePath) file.forEachLine { lines.add(it) for (word in toLowercaseWords(it).filter(String::isNotEmpty)) { val positions = invertedIndex.getOrDefault(word, mutableListOf()) positions.add(lineIndex) invertedIndex[word] = positions } lineIndex += 1 } return lines to invertedIndex } fun printPeople(dataset: Dataset) { println("=== List of people ===") dataset.forEach(::println) } fun reportResult(matchedItems: Dataset) { if (matchedItems.isNotEmpty()) { println("${matchedItems.size} persons found:") printPeople(matchedItems) } else { println("No matching people found.") } } enum class MatchOption { ALL, ANY, NONE, } fun toMatchOption(s: String): MatchOption { return MatchOption.valueOf(s.uppercase()) } class Searcher(private val dataset: Dataset, private val invertedIndex: InvertedIndex) { fun search(query: String, matchOption: MatchOption): Dataset { return when (matchOption) { MatchOption.ALL -> ::searchAll MatchOption.ANY -> ::searchAny MatchOption.NONE -> ::searchNone }(toLowercaseWords(query)) } private fun searchAny(queryWords: List<String>): Dataset { return queryWords.flatMap { word -> invertedIndex .getOrDefault(word, mutableListOf()) .map { dataset[it] } } } private fun searchAll(queryWords: List<String>): Dataset { if (queryWords.isEmpty()) return listOf() return queryWords .map { word -> invertedIndex .getOrDefault(word, mutableListOf()) .toSet() } .reduce { acc, indices -> acc.intersect(indices) } .map { dataset[it] } } private fun searchNone(queryWords: List<String>): Dataset { if (queryWords.isEmpty()) return dataset val allIndices = (0..dataset.lastIndex) val anyIndices = queryWords .flatMap { word -> invertedIndex .getOrDefault(word, mutableListOf()) } .toSet() return allIndices .subtract(anyIndices) .map { dataset[it] } } } fun createSearcherAndDataset(dataFilePath: String): Pair<Searcher, Dataset> { val (dataset, invertedIndex) = scanInputFile(dataFilePath) return Searcher(dataset, invertedIndex) to dataset } fun matchOptionToQueryPrompt(matchOption: MatchOption): String { return when (matchOption) { MatchOption.NONE -> "Enter a name or email to search none matching people." MatchOption.ANY -> "Enter a name or email to search any matching people." MatchOption.ALL -> "Enter a name or email to search all matching people." } } fun searchAndReportResult(searcher: Searcher) { val matchOption = toMatchOption(ask("Select a matching strategy: ALL, ANY, NONE")) val query = ask(matchOptionToQueryPrompt(matchOption)) val matchedItems = searcher.search(query, matchOption) reportResult(matchedItems) } data class MenuItem(val name: String, val action: () -> Unit) class Menu(exitItemNumber: Int, private val items: Map<Int, MenuItem>) { private val exitItem = exitItemNumber.toString() init { require(!items.containsKey(exitItemNumber)) } val prompt = buildString { append("=== Menu ===") append("\n") items .entries .forEach { command -> append("${command.key}. ${command.value.name}") append("\n") } append("$exitItem. Exit") append("\n") } fun run(userChoice: String): Boolean { if (userChoice == exitItem) { return false } try { val menuIndex = userChoice.toInt() require(items.containsKey(menuIndex)) items[menuIndex]!!.action() } catch (e: IllegalArgumentException) { println("Incorrect option! Try again.") } return true } } fun main(args: Array<String>) { require(args.size == 2) require(args[0] == "--data") val (searcher, dataset) = createSearcherAndDataset(args[1]) val menu = Menu( 0, mapOf( 1 to MenuItem("Find a person") { searchAndReportResult(searcher) }, 2 to MenuItem("Print all people") { printPeople(dataset) }) ) while (true) { val moreToRun = menu.run(ask(menu.prompt)) if (!moreToRun) break } println("Bye!") }
[ { "class_path": "JIghtuse__simple-search-engine-hyperskill__4634a62/search/MainKt$WhenMappings.class", "javap": "Compiled from \"Main.kt\"\npublic final class search.MainKt$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method search/MatchOption.values:()[Lsearch/MatchOption;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field search/MatchOption.NONE:Lsearch/MatchOption;\n 12: invokevirtual #22 // Method search/MatchOption.ordinal:()I\n 15: iconst_1\n 16: iastore\n 17: goto 21\n 20: astore_1\n 21: nop\n 22: aload_0\n 23: getstatic #25 // Field search/MatchOption.ANY:Lsearch/MatchOption;\n 26: invokevirtual #22 // Method search/MatchOption.ordinal:()I\n 29: iconst_2\n 30: iastore\n 31: goto 35\n 34: astore_1\n 35: nop\n 36: aload_0\n 37: getstatic #28 // Field search/MatchOption.ALL:Lsearch/MatchOption;\n 40: invokevirtual #22 // Method search/MatchOption.ordinal:()I\n 43: iconst_3\n 44: iastore\n 45: goto 49\n 48: astore_1\n 49: aload_0\n 50: putstatic #32 // Field $EnumSwitchMapping$0:[I\n 53: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n 21 31 34 Class java/lang/NoSuchFieldError\n 35 45 48 Class java/lang/NoSuchFieldError\n}\n", "javap_err": "" }, { "class_path": "JIghtuse__simple-search-engine-hyperskill__4634a62/search/MainKt.class", "javap": "Compiled from \"Main.kt\"\npublic final class search.MainKt {\n public static final java.util.List<java.lang.String> toLowercaseWords(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #10 // String s\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #18 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #20 // class java/lang/String\n 14: astore_1\n 15: aload_1\n 16: iconst_0\n 17: ldc #22 // String\n 19: aastore\n 20: aload_1\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #28 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: checkcast #30 // class java/lang/Iterable\n 32: astore_1\n 33: iconst_0\n 34: istore_2\n 35: aload_1\n 36: astore_3\n 37: new #32 // class java/util/ArrayList\n 40: dup\n 41: aload_1\n 42: bipush 10\n 44: invokestatic #38 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 47: invokespecial #42 // Method java/util/ArrayList.\"<init>\":(I)V\n 50: checkcast #44 // class java/util/Collection\n 53: astore 4\n 55: iconst_0\n 56: istore 5\n 58: aload_3\n 59: invokeinterface #48, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 64: astore 6\n 66: aload 6\n 68: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 73: ifeq 126\n 76: aload 6\n 78: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 83: astore 7\n 85: aload 4\n 87: aload 7\n 89: checkcast #20 // class java/lang/String\n 92: astore 8\n 94: astore 10\n 96: iconst_0\n 97: istore 9\n 99: aload 8\n 101: getstatic #64 // Field java/util/Locale.ROOT:Ljava/util/Locale;\n 104: invokevirtual #68 // Method java/lang/String.toLowerCase:(Ljava/util/Locale;)Ljava/lang/String;\n 107: dup\n 108: ldc #70 // String toLowerCase(...)\n 110: invokestatic #73 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 113: nop\n 114: aload 10\n 116: swap\n 117: invokeinterface #77, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 122: pop\n 123: goto 66\n 126: aload 4\n 128: checkcast #79 // class java/util/List\n 131: nop\n 132: areturn\n\n public static final java.lang.String ask(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #96 // String prompt\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #102 // Field java/lang/System.out:Ljava/io/PrintStream;\n 9: aload_0\n 10: invokevirtual #108 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 13: invokestatic #114 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;\n 16: areturn\n\n public static final kotlin.Pair<java.util.List<java.lang.String>, java.util.Map<java.lang.String, java.util.List<java.lang.Integer>>> scanInputFile(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #119 // String filePath\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #32 // class java/util/ArrayList\n 9: dup\n 10: invokespecial #122 // Method java/util/ArrayList.\"<init>\":()V\n 13: checkcast #79 // class java/util/List\n 16: astore_1\n 17: new #124 // class java/util/LinkedHashMap\n 20: dup\n 21: invokespecial #125 // Method java/util/LinkedHashMap.\"<init>\":()V\n 24: checkcast #127 // class java/util/Map\n 27: astore_2\n 28: new #129 // class kotlin/jvm/internal/Ref$IntRef\n 31: dup\n 32: invokespecial #130 // Method kotlin/jvm/internal/Ref$IntRef.\"<init>\":()V\n 35: astore_3\n 36: new #132 // class java/io/File\n 39: dup\n 40: aload_0\n 41: invokespecial #135 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 44: astore 4\n 46: aload 4\n 48: aconst_null\n 49: aload_1\n 50: aload_2\n 51: aload_3\n 52: invokedynamic #155, 0 // InvokeDynamic #0:invoke:(Ljava/util/List;Ljava/util/Map;Lkotlin/jvm/internal/Ref$IntRef;)Lkotlin/jvm/functions/Function1;\n 57: iconst_1\n 58: aconst_null\n 59: invokestatic #161 // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V\n 62: aload_1\n 63: aload_2\n 64: invokestatic #167 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 67: areturn\n\n public static final void printPeople(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #180 // String dataset\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #182 // String === List of people ===\n 8: getstatic #102 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: swap\n 12: invokevirtual #108 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 15: aload_0\n 16: checkcast #30 // class java/lang/Iterable\n 19: astore_1\n 20: iconst_0\n 21: istore_2\n 22: aload_1\n 23: invokeinterface #48, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 28: astore_3\n 29: aload_3\n 30: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 35: ifeq 66\n 38: aload_3\n 39: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 44: astore 4\n 46: aload 4\n 48: astore 5\n 50: iconst_0\n 51: istore 6\n 53: getstatic #102 // Field java/lang/System.out:Ljava/io/PrintStream;\n 56: aload 5\n 58: invokevirtual #108 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 61: nop\n 62: nop\n 63: goto 29\n 66: nop\n 67: return\n\n public static final void reportResult(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #189 // String matchedItems\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #44 // class java/util/Collection\n 10: invokeinterface #192, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 15: ifne 22\n 18: iconst_1\n 19: goto 23\n 22: iconst_0\n 23: ifeq 64\n 26: new #194 // class java/lang/StringBuilder\n 29: dup\n 30: invokespecial #195 // Method java/lang/StringBuilder.\"<init>\":()V\n 33: aload_0\n 34: invokeinterface #199, 1 // InterfaceMethod java/util/List.size:()I\n 39: invokevirtual #203 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 42: ldc #205 // String persons found:\n 44: invokevirtual #208 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 47: invokevirtual #211 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 50: getstatic #102 // Field java/lang/System.out:Ljava/io/PrintStream;\n 53: swap\n 54: invokevirtual #108 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 57: aload_0\n 58: invokestatic #213 // Method printPeople:(Ljava/util/List;)V\n 61: goto 73\n 64: ldc #215 // String No matching people found.\n 66: getstatic #102 // Field java/lang/System.out:Ljava/io/PrintStream;\n 69: swap\n 70: invokevirtual #108 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 73: return\n\n public static final search.MatchOption toMatchOption(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #10 // String s\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getstatic #64 // Field java/util/Locale.ROOT:Ljava/util/Locale;\n 10: invokevirtual #220 // Method java/lang/String.toUpperCase:(Ljava/util/Locale;)Ljava/lang/String;\n 13: dup\n 14: ldc #222 // String toUpperCase(...)\n 16: invokestatic #73 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 19: invokestatic #227 // Method search/MatchOption.valueOf:(Ljava/lang/String;)Lsearch/MatchOption;\n 22: areturn\n\n public static final kotlin.Pair<search.Searcher, java.util.List<java.lang.String>> createSearcherAndDataset(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #231 // String dataFilePath\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #233 // Method scanInputFile:(Ljava/lang/String;)Lkotlin/Pair;\n 10: astore_1\n 11: aload_1\n 12: invokevirtual #238 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 15: checkcast #79 // class java/util/List\n 18: astore_2\n 19: aload_1\n 20: invokevirtual #241 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 23: checkcast #127 // class java/util/Map\n 26: astore_3\n 27: new #243 // class search/Searcher\n 30: dup\n 31: aload_2\n 32: aload_3\n 33: invokespecial #246 // Method search/Searcher.\"<init>\":(Ljava/util/List;Ljava/util/Map;)V\n 36: aload_2\n 37: invokestatic #167 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 40: areturn\n\n public static final java.lang.String matchOptionToQueryPrompt(search.MatchOption);\n Code:\n 0: aload_0\n 1: ldc #250 // String matchOption\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getstatic #256 // Field search/MainKt$WhenMappings.$EnumSwitchMapping$0:[I\n 10: swap\n 11: invokevirtual #259 // Method search/MatchOption.ordinal:()I\n 14: iaload\n 15: tableswitch { // 1 to 3\n 1: 40\n 2: 46\n 3: 52\n default: 58\n }\n 40: ldc_w #261 // String Enter a name or email to search none matching people.\n 43: goto 66\n 46: ldc_w #263 // String Enter a name or email to search any matching people.\n 49: goto 66\n 52: ldc_w #265 // String Enter a name or email to search all matching people.\n 55: goto 66\n 58: new #267 // class kotlin/NoWhenBranchMatchedException\n 61: dup\n 62: invokespecial #268 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 65: athrow\n 66: areturn\n\n public static final void searchAndReportResult(search.Searcher);\n Code:\n 0: aload_0\n 1: ldc_w #273 // String searcher\n 4: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: ldc_w #275 // String Select a matching strategy: ALL, ANY, NONE\n 10: invokestatic #277 // Method ask:(Ljava/lang/String;)Ljava/lang/String;\n 13: invokestatic #279 // Method toMatchOption:(Ljava/lang/String;)Lsearch/MatchOption;\n 16: astore_1\n 17: aload_1\n 18: invokestatic #281 // Method matchOptionToQueryPrompt:(Lsearch/MatchOption;)Ljava/lang/String;\n 21: invokestatic #277 // Method ask:(Ljava/lang/String;)Ljava/lang/String;\n 24: astore_2\n 25: aload_0\n 26: aload_2\n 27: aload_1\n 28: invokevirtual #285 // Method search/Searcher.search:(Ljava/lang/String;Lsearch/MatchOption;)Ljava/util/List;\n 31: astore_3\n 32: aload_3\n 33: invokestatic #287 // Method reportResult:(Ljava/util/List;)V\n 36: return\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc_w #293 // String args\n 4: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: arraylength\n 9: iconst_2\n 10: if_icmpne 17\n 13: iconst_1\n 14: goto 18\n 17: iconst_0\n 18: ifne 37\n 21: ldc_w #295 // String Failed requirement.\n 24: astore_2\n 25: new #297 // class java/lang/IllegalArgumentException\n 28: dup\n 29: aload_2\n 30: invokevirtual #298 // Method java/lang/Object.toString:()Ljava/lang/String;\n 33: invokespecial #299 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 36: athrow\n 37: aload_0\n 38: iconst_0\n 39: aaload\n 40: ldc_w #301 // String --data\n 43: invokestatic #305 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 46: ifne 65\n 49: ldc_w #295 // String Failed requirement.\n 52: astore_2\n 53: new #297 // class java/lang/IllegalArgumentException\n 56: dup\n 57: aload_2\n 58: invokevirtual #298 // Method java/lang/Object.toString:()Ljava/lang/String;\n 61: invokespecial #299 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 64: athrow\n 65: aload_0\n 66: iconst_1\n 67: aaload\n 68: invokestatic #307 // Method createSearcherAndDataset:(Ljava/lang/String;)Lkotlin/Pair;\n 71: astore_1\n 72: aload_1\n 73: invokevirtual #238 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 76: checkcast #243 // class search/Searcher\n 79: astore_2\n 80: aload_1\n 81: invokevirtual #241 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 84: checkcast #79 // class java/util/List\n 87: astore_3\n 88: new #309 // class search/Menu\n 91: dup\n 92: iconst_0\n 93: iconst_2\n 94: anewarray #235 // class kotlin/Pair\n 97: astore 5\n 99: aload 5\n 101: iconst_0\n 102: iconst_1\n 103: invokestatic #314 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 106: new #316 // class search/MenuItem\n 109: dup\n 110: ldc_w #318 // String Find a person\n 113: aload_2\n 114: invokedynamic #329, 0 // InvokeDynamic #1:invoke:(Lsearch/Searcher;)Lkotlin/jvm/functions/Function0;\n 119: invokespecial #332 // Method search/MenuItem.\"<init>\":(Ljava/lang/String;Lkotlin/jvm/functions/Function0;)V\n 122: invokestatic #167 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 125: aastore\n 126: aload 5\n 128: iconst_1\n 129: iconst_2\n 130: invokestatic #314 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 133: new #316 // class search/MenuItem\n 136: dup\n 137: ldc_w #334 // String Print all people\n 140: aload_3\n 141: invokedynamic #342, 0 // InvokeDynamic #2:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function0;\n 146: invokespecial #332 // Method search/MenuItem.\"<init>\":(Ljava/lang/String;Lkotlin/jvm/functions/Function0;)V\n 149: invokestatic #167 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 152: aastore\n 153: aload 5\n 155: invokestatic #348 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 158: invokespecial #351 // Method search/Menu.\"<init>\":(ILjava/util/Map;)V\n 161: astore 4\n 163: nop\n 164: aload 4\n 166: aload 4\n 168: invokevirtual #354 // Method search/Menu.getPrompt:()Ljava/lang/String;\n 171: invokestatic #277 // Method ask:(Ljava/lang/String;)Ljava/lang/String;\n 174: invokevirtual #358 // Method search/Menu.run:(Ljava/lang/String;)Z\n 177: istore 5\n 179: iload 5\n 181: ifne 163\n 184: goto 187\n 187: ldc_w #360 // String Bye!\n 190: getstatic #102 // Field java/lang/System.out:Ljava/io/PrintStream;\n 193: swap\n 194: invokevirtual #108 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 197: return\n\n private static final kotlin.Unit scanInputFile$lambda$1(java.util.List, java.util.Map, kotlin.jvm.internal.Ref$IntRef, java.lang.String);\n Code:\n 0: aload_3\n 1: ldc_w #368 // String it\n 4: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: aload_3\n 9: invokeinterface #369, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 14: pop\n 15: aload_3\n 16: invokestatic #371 // Method toLowercaseWords:(Ljava/lang/String;)Ljava/util/List;\n 19: checkcast #30 // class java/lang/Iterable\n 22: astore 5\n 24: iconst_0\n 25: istore 6\n 27: aload 5\n 29: astore 7\n 31: new #32 // class java/util/ArrayList\n 34: dup\n 35: invokespecial #122 // Method java/util/ArrayList.\"<init>\":()V\n 38: checkcast #44 // class java/util/Collection\n 41: astore 8\n 43: iconst_0\n 44: istore 9\n 46: aload 7\n 48: invokeinterface #48, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 53: astore 10\n 55: aload 10\n 57: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 62: ifeq 119\n 65: aload 10\n 67: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 72: astore 11\n 74: aload 11\n 76: checkcast #20 // class java/lang/String\n 79: astore 12\n 81: iconst_0\n 82: istore 13\n 84: aload 12\n 86: checkcast #18 // class java/lang/CharSequence\n 89: invokeinterface #374, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 94: ifle 101\n 97: iconst_1\n 98: goto 102\n 101: iconst_0\n 102: nop\n 103: ifeq 55\n 106: aload 8\n 108: aload 11\n 110: invokeinterface #77, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 115: pop\n 116: goto 55\n 119: aload 8\n 121: checkcast #79 // class java/util/List\n 124: nop\n 125: invokeinterface #375, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 130: astore 4\n 132: aload 4\n 134: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 139: ifeq 206\n 142: aload 4\n 144: invokeinterface #58, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 149: checkcast #20 // class java/lang/String\n 152: astore 5\n 154: aload_1\n 155: aload 5\n 157: new #32 // class java/util/ArrayList\n 160: dup\n 161: invokespecial #122 // Method java/util/ArrayList.\"<init>\":()V\n 164: checkcast #79 // class java/util/List\n 167: invokeinterface #379, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 172: checkcast #79 // class java/util/List\n 175: astore 6\n 177: aload 6\n 179: aload_2\n 180: getfield #382 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 183: invokestatic #314 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 186: invokeinterface #369, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 191: pop\n 192: aload_1\n 193: aload 5\n 195: aload 6\n 197: invokeinterface #385, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 202: pop\n 203: goto 132\n 206: aload_2\n 207: aload_2\n 208: getfield #382 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 211: iconst_1\n 212: iadd\n 213: putfield #382 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 216: getstatic #391 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 219: areturn\n\n private static final kotlin.Unit main$lambda$3(search.Searcher);\n Code:\n 0: aload_0\n 1: invokestatic #404 // Method searchAndReportResult:(Lsearch/Searcher;)V\n 4: getstatic #391 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 7: areturn\n\n private static final kotlin.Unit main$lambda$4(java.util.List);\n Code:\n 0: aload_0\n 1: invokestatic #213 // Method printPeople:(Ljava/util/List;)V\n 4: getstatic #391 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 7: areturn\n}\n", "javap_err": "" } ]
kevinvanleer__cyclotrack__c936057/app/src/main/java/com/kvl/cyclotrack/Statistics.kt
package com.kvl.cyclotrack import kotlin.math.pow fun List<Double>.average(): Double = this.reduce { acc, d -> acc + d } / this.size fun average(newValue: Double, sampleSize: Int, lastAverage: Double): Double = (lastAverage * (sampleSize - 1) + newValue) / sampleSize fun List<Double>.sampleVariance(): Double { val avg = this.average() return this.fold(0.0, { acc, d -> acc + (d - avg).pow(2.0) }) / (this.size - 1) } fun sampleVariance( newValue: Double, oldVariance: Double, sampleSize: Int, oldAverage: Double, ): Double { return (oldVariance * (sampleSize - 2) / (sampleSize - 1)) + ((newValue - oldAverage).pow( 2.0) / sampleSize) } fun List<Double>.populationVariance(): Double { val avg = this.average() return this.fold(0.0, { acc, d -> acc + (d - avg).pow(2.0) }) / this.size } fun exponentialSmoothing(alpha: Double, current: Double, last: Double) = (alpha * current) + ((1 - alpha) * last) fun doubleExponentialSmoothing( alpha: Double, current: Double, smoothLast: Double, trendLast: Double, ) = alpha * current + ((1 - alpha) * (smoothLast + trendLast)) fun doubleExponentialSmoothingTrend( beta: Double, smooth: Double, smoothLast: Double, trendLast: Double, ) = beta * (smooth - smoothLast) + (1 - beta) * trendLast fun smooth(alpha: Double, data: Array<Pair<Double, Double>>): List<Pair<Double, Double>> { var smoothedFirst = data[0].first var smoothedSecond = data[0].second return data.map { datum -> smoothedFirst = exponentialSmoothing(alpha, datum.first, smoothedFirst) smoothedSecond = exponentialSmoothing(alpha, datum.second, smoothedSecond) Pair(smoothedFirst, smoothedSecond) } } fun doubleSmooth(alpha: Double, beta: Double, data: Array<Double>): List<Double> { var smoothed: Double = data[0] var trend: Double = data[1] - data[0] var smoothedLast = smoothed return data.map { datum -> smoothed = doubleExponentialSmoothing(alpha, datum, smoothedLast, trend) trend = doubleExponentialSmoothingTrend(beta, smoothed, smoothedLast, trend) smoothedLast = smoothed smoothed } } fun isRangeGreaterThan(left: Pair<Double, Double>, right: Double): Boolean { val leftRange = Pair(left.first - left.second, left.first + left.second) return leftRange.first > right } fun isRangeLessThan(left: Pair<Double, Double>, right: Double): Boolean { val leftRange = Pair(left.first - left.second, left.first + left.second) return leftRange.second < right } fun isRangeGreaterThan(left: Pair<Double, Double>, right: Pair<Double, Double>): Boolean { val leftRange = Pair(left.first - left.second, left.first + left.second) val rightRange = Pair(right.first - right.second, right.first + right.second) return leftRange.first > rightRange.second } fun isRangeLessThan(left: Pair<Double, Double>, right: Pair<Double, Double>): Boolean { val leftRange = Pair(left.first - left.second, left.first + left.second) val rightRange = Pair(right.first - right.second, right.first + right.second) return leftRange.second < rightRange.first } fun leastSquaresFitSlope(data: List<Pair<Double, Double>>): Double { //https://stats.libretexts.org/Bookshelves/Introductory_Statistics/Book%3A_Introductory_Statistics_(Shafer_and_Zhang)/10%3A_Correlation_and_Regression/10.04%3A_The_Least_Squares_Regression_Line var sumx = 0.0 var sumy = 0.0 var sumxsq = 0.0 var sumxy = 0.0 data.forEach { sumx += it.first sumy += it.second sumxsq += it.first * it.first sumxy += it.first * it.second } val ssxy = sumxy - ((1.0 / data.size) * sumx * sumy) val ssxx = sumxsq - ((1.0 / data.size) * sumx * sumx) return ssxy / ssxx } fun accumulateAscentDescent(elevationData: List<Pair<Double, Double>>): Pair<Double, Double> { var totalAscent = 0.0 var totalDescent = 0.0 var altitudeCursor = elevationData[0] elevationData.forEach { sample -> if (isRangeGreaterThan(sample, altitudeCursor)) { totalAscent += sample.first - altitudeCursor.first altitudeCursor = sample } if (isRangeLessThan(sample, altitudeCursor)) { totalDescent += sample.first - altitudeCursor.first altitudeCursor = sample } } return Pair(totalAscent, totalDescent) }
[ { "class_path": "kevinvanleer__cyclotrack__c936057/com/kvl/cyclotrack/StatisticsKt.class", "javap": "Compiled from \"Statistics.kt\"\npublic final class com.kvl.cyclotrack.StatisticsKt {\n public static final double average(java.util.List<java.lang.Double>);\n Code:\n 0: aload_0\n 1: ldc #10 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #18 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: invokeinterface #22, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 19: astore_3\n 20: aload_3\n 21: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 26: ifne 39\n 29: new #30 // class java/lang/UnsupportedOperationException\n 32: dup\n 33: ldc #32 // String Empty collection can\\'t be reduced.\n 35: invokespecial #36 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 38: athrow\n 39: aload_3\n 40: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 45: astore 4\n 47: aload_3\n 48: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 96\n 56: aload 4\n 58: aload_3\n 59: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: checkcast #42 // class java/lang/Number\n 67: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 70: dstore 5\n 72: checkcast #42 // class java/lang/Number\n 75: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 78: dstore 7\n 80: iconst_0\n 81: istore 9\n 83: dload 7\n 85: dload 5\n 87: dadd\n 88: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 91: astore 4\n 93: goto 47\n 96: aload 4\n 98: checkcast #42 // class java/lang/Number\n 101: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 104: aload_0\n 105: invokeinterface #58, 1 // InterfaceMethod java/util/List.size:()I\n 110: i2d\n 111: ddiv\n 112: dreturn\n\n public static final double average(double, int, double);\n Code:\n 0: dload_3\n 1: iload_2\n 2: iconst_1\n 3: isub\n 4: i2d\n 5: dmul\n 6: dload_0\n 7: dadd\n 8: iload_2\n 9: i2d\n 10: ddiv\n 11: dreturn\n\n public static final double sampleVariance(java.util.List<java.lang.Double>);\n Code:\n 0: aload_0\n 1: ldc #10 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #79 // Method average:(Ljava/util/List;)D\n 10: dstore_1\n 11: aload_0\n 12: checkcast #18 // class java/lang/Iterable\n 15: astore_3\n 16: dconst_0\n 17: dstore 4\n 19: iconst_0\n 20: istore 6\n 22: dload 4\n 24: dstore 7\n 26: aload_3\n 27: invokeinterface #22, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 9\n 34: aload 9\n 36: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 88\n 44: aload 9\n 46: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: astore 10\n 53: dload 7\n 55: aload 10\n 57: checkcast #42 // class java/lang/Number\n 60: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 63: dstore 11\n 65: dstore 13\n 67: iconst_0\n 68: istore 15\n 70: dload 13\n 72: dload 11\n 74: dload_1\n 75: dsub\n 76: ldc2_w #80 // double 2.0d\n 79: invokestatic #87 // Method java/lang/Math.pow:(DD)D\n 82: dadd\n 83: dstore 7\n 85: goto 34\n 88: dload 7\n 90: aload_0\n 91: invokeinterface #58, 1 // InterfaceMethod java/util/List.size:()I\n 96: iconst_1\n 97: isub\n 98: i2d\n 99: ddiv\n 100: dreturn\n\n public static final double sampleVariance(double, double, int, double);\n Code:\n 0: dload_2\n 1: iload 4\n 3: iconst_2\n 4: isub\n 5: i2d\n 6: dmul\n 7: iload 4\n 9: iconst_1\n 10: isub\n 11: i2d\n 12: ddiv\n 13: dload_0\n 14: dload 5\n 16: dsub\n 17: ldc2_w #80 // double 2.0d\n 20: invokestatic #87 // Method java/lang/Math.pow:(DD)D\n 23: iload 4\n 25: i2d\n 26: ddiv\n 27: dadd\n 28: dreturn\n\n public static final double populationVariance(java.util.List<java.lang.Double>);\n Code:\n 0: aload_0\n 1: ldc #10 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #79 // Method average:(Ljava/util/List;)D\n 10: dstore_1\n 11: aload_0\n 12: checkcast #18 // class java/lang/Iterable\n 15: astore_3\n 16: dconst_0\n 17: dstore 4\n 19: iconst_0\n 20: istore 6\n 22: dload 4\n 24: dstore 7\n 26: aload_3\n 27: invokeinterface #22, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 9\n 34: aload 9\n 36: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 88\n 44: aload 9\n 46: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: astore 10\n 53: dload 7\n 55: aload 10\n 57: checkcast #42 // class java/lang/Number\n 60: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 63: dstore 11\n 65: dstore 13\n 67: iconst_0\n 68: istore 15\n 70: dload 13\n 72: dload 11\n 74: dload_1\n 75: dsub\n 76: ldc2_w #80 // double 2.0d\n 79: invokestatic #87 // Method java/lang/Math.pow:(DD)D\n 82: dadd\n 83: dstore 7\n 85: goto 34\n 88: dload 7\n 90: aload_0\n 91: invokeinterface #58, 1 // InterfaceMethod java/util/List.size:()I\n 96: i2d\n 97: ddiv\n 98: dreturn\n\n public static final double exponentialSmoothing(double, double, double);\n Code:\n 0: dload_0\n 1: dload_2\n 2: dmul\n 3: iconst_1\n 4: i2d\n 5: dload_0\n 6: dsub\n 7: dload 4\n 9: dmul\n 10: dadd\n 11: dreturn\n\n public static final double doubleExponentialSmoothing(double, double, double, double);\n Code:\n 0: dload_0\n 1: dload_2\n 2: dmul\n 3: iconst_1\n 4: i2d\n 5: dload_0\n 6: dsub\n 7: dload 4\n 9: dload 6\n 11: dadd\n 12: dmul\n 13: dadd\n 14: dreturn\n\n public static final double doubleExponentialSmoothingTrend(double, double, double, double);\n Code:\n 0: dload_0\n 1: dload_2\n 2: dload 4\n 4: dsub\n 5: dmul\n 6: iconst_1\n 7: i2d\n 8: dload_0\n 9: dsub\n 10: dload 6\n 12: dmul\n 13: dadd\n 14: dreturn\n\n public static final java.util.List<kotlin.Pair<java.lang.Double, java.lang.Double>> smooth(double, kotlin.Pair<java.lang.Double, java.lang.Double>[]);\n Code:\n 0: aload_2\n 1: ldc #116 // String data\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: dconst_0\n 7: dstore 14\n 9: aload_2\n 10: iconst_0\n 11: aaload\n 12: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 15: checkcast #42 // class java/lang/Number\n 18: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 21: dstore 14\n 23: dconst_0\n 24: dstore 16\n 26: aload_2\n 27: iconst_0\n 28: aaload\n 29: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 32: checkcast #42 // class java/lang/Number\n 35: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 38: dstore 16\n 40: aload_2\n 41: astore_3\n 42: iconst_0\n 43: istore 4\n 45: aload_3\n 46: astore 5\n 48: new #126 // class java/util/ArrayList\n 51: dup\n 52: aload_3\n 53: arraylength\n 54: invokespecial #129 // Method java/util/ArrayList.\"<init>\":(I)V\n 57: checkcast #131 // class java/util/Collection\n 60: astore 6\n 62: iconst_0\n 63: istore 7\n 65: iconst_0\n 66: istore 8\n 68: aload 5\n 70: arraylength\n 71: istore 9\n 73: iload 8\n 75: iload 9\n 77: if_icmpge 168\n 80: aload 5\n 82: iload 8\n 84: aaload\n 85: astore 10\n 87: aload 6\n 89: aload 10\n 91: astore 11\n 93: astore 13\n 95: iconst_0\n 96: istore 12\n 98: dload_0\n 99: aload 11\n 101: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 104: checkcast #42 // class java/lang/Number\n 107: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 110: dload 14\n 112: invokestatic #133 // Method exponentialSmoothing:(DDD)D\n 115: dstore 14\n 117: dload_0\n 118: aload 11\n 120: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 123: checkcast #42 // class java/lang/Number\n 126: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 129: dload 16\n 131: invokestatic #133 // Method exponentialSmoothing:(DDD)D\n 134: dstore 16\n 136: new #118 // class kotlin/Pair\n 139: dup\n 140: dload 14\n 142: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 145: dload 16\n 147: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 150: invokespecial #136 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 153: aload 13\n 155: swap\n 156: invokeinterface #140, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 161: pop\n 162: iinc 8, 1\n 165: goto 73\n 168: aload 6\n 170: checkcast #54 // class java/util/List\n 173: nop\n 174: areturn\n\n public static final java.util.List<java.lang.Double> doubleSmooth(double, double, java.lang.Double[]);\n Code:\n 0: aload 4\n 2: ldc #116 // String data\n 4: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: dconst_0\n 8: dstore 17\n 10: aload 4\n 12: iconst_0\n 13: aaload\n 14: invokevirtual #159 // Method java/lang/Double.doubleValue:()D\n 17: dstore 17\n 19: dconst_0\n 20: dstore 19\n 22: aload 4\n 24: iconst_1\n 25: aaload\n 26: invokevirtual #159 // Method java/lang/Double.doubleValue:()D\n 29: aload 4\n 31: iconst_0\n 32: aaload\n 33: invokevirtual #159 // Method java/lang/Double.doubleValue:()D\n 36: dsub\n 37: dstore 19\n 39: dconst_0\n 40: dstore 21\n 42: dload 17\n 44: dstore 21\n 46: aload 4\n 48: astore 5\n 50: iconst_0\n 51: istore 6\n 53: aload 5\n 55: astore 7\n 57: new #126 // class java/util/ArrayList\n 60: dup\n 61: aload 5\n 63: arraylength\n 64: invokespecial #129 // Method java/util/ArrayList.\"<init>\":(I)V\n 67: checkcast #131 // class java/util/Collection\n 70: astore 8\n 72: iconst_0\n 73: istore 9\n 75: iconst_0\n 76: istore 10\n 78: aload 7\n 80: arraylength\n 81: istore 11\n 83: iload 10\n 85: iload 11\n 87: if_icmpge 162\n 90: aload 7\n 92: iload 10\n 94: aaload\n 95: astore 12\n 97: aload 8\n 99: aload 12\n 101: checkcast #42 // class java/lang/Number\n 104: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 107: dstore 13\n 109: astore 16\n 111: iconst_0\n 112: istore 15\n 114: dload_0\n 115: dload 13\n 117: dload 21\n 119: dload 19\n 121: invokestatic #161 // Method doubleExponentialSmoothing:(DDDD)D\n 124: dstore 17\n 126: dload_2\n 127: dload 17\n 129: dload 21\n 131: dload 19\n 133: invokestatic #163 // Method doubleExponentialSmoothingTrend:(DDDD)D\n 136: dstore 19\n 138: dload 17\n 140: dstore 21\n 142: dload 17\n 144: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 147: aload 16\n 149: swap\n 150: invokeinterface #140, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 155: pop\n 156: iinc 10, 1\n 159: goto 83\n 162: aload 8\n 164: checkcast #54 // class java/util/List\n 167: nop\n 168: areturn\n\n public static final boolean isRangeGreaterThan(kotlin.Pair<java.lang.Double, java.lang.Double>, double);\n Code:\n 0: aload_0\n 1: ldc #174 // String left\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #118 // class kotlin/Pair\n 9: dup\n 10: aload_0\n 11: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 14: checkcast #42 // class java/lang/Number\n 17: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 20: aload_0\n 21: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 24: checkcast #42 // class java/lang/Number\n 27: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 30: dsub\n 31: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 34: aload_0\n 35: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 38: checkcast #42 // class java/lang/Number\n 41: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 44: aload_0\n 45: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 48: checkcast #42 // class java/lang/Number\n 51: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 54: dadd\n 55: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 58: invokespecial #136 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 61: astore_3\n 62: aload_3\n 63: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 66: checkcast #42 // class java/lang/Number\n 69: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 72: dload_1\n 73: dcmpl\n 74: ifle 81\n 77: iconst_1\n 78: goto 82\n 81: iconst_0\n 82: ireturn\n\n public static final boolean isRangeLessThan(kotlin.Pair<java.lang.Double, java.lang.Double>, double);\n Code:\n 0: aload_0\n 1: ldc #174 // String left\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #118 // class kotlin/Pair\n 9: dup\n 10: aload_0\n 11: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 14: checkcast #42 // class java/lang/Number\n 17: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 20: aload_0\n 21: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 24: checkcast #42 // class java/lang/Number\n 27: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 30: dsub\n 31: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 34: aload_0\n 35: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 38: checkcast #42 // class java/lang/Number\n 41: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 44: aload_0\n 45: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 48: checkcast #42 // class java/lang/Number\n 51: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 54: dadd\n 55: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 58: invokespecial #136 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 61: astore_3\n 62: aload_3\n 63: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 66: checkcast #42 // class java/lang/Number\n 69: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 72: dload_1\n 73: dcmpg\n 74: ifge 81\n 77: iconst_1\n 78: goto 82\n 81: iconst_0\n 82: ireturn\n\n public static final boolean isRangeGreaterThan(kotlin.Pair<java.lang.Double, java.lang.Double>, kotlin.Pair<java.lang.Double, java.lang.Double>);\n Code:\n 0: aload_0\n 1: ldc #174 // String left\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #180 // String right\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #118 // class kotlin/Pair\n 15: dup\n 16: aload_0\n 17: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 20: checkcast #42 // class java/lang/Number\n 23: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 26: aload_0\n 27: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 30: checkcast #42 // class java/lang/Number\n 33: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 36: dsub\n 37: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 40: aload_0\n 41: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 44: checkcast #42 // class java/lang/Number\n 47: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 50: aload_0\n 51: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 54: checkcast #42 // class java/lang/Number\n 57: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 60: dadd\n 61: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 64: invokespecial #136 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 67: astore_2\n 68: new #118 // class kotlin/Pair\n 71: dup\n 72: aload_1\n 73: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 76: checkcast #42 // class java/lang/Number\n 79: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 82: aload_1\n 83: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 86: checkcast #42 // class java/lang/Number\n 89: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 92: dsub\n 93: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 96: aload_1\n 97: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 100: checkcast #42 // class java/lang/Number\n 103: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 106: aload_1\n 107: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 110: checkcast #42 // class java/lang/Number\n 113: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 116: dadd\n 117: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 120: invokespecial #136 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 123: astore_3\n 124: aload_2\n 125: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 128: checkcast #42 // class java/lang/Number\n 131: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 134: aload_3\n 135: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 138: checkcast #42 // class java/lang/Number\n 141: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 144: dcmpl\n 145: ifle 152\n 148: iconst_1\n 149: goto 153\n 152: iconst_0\n 153: ireturn\n\n public static final boolean isRangeLessThan(kotlin.Pair<java.lang.Double, java.lang.Double>, kotlin.Pair<java.lang.Double, java.lang.Double>);\n Code:\n 0: aload_0\n 1: ldc #174 // String left\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #180 // String right\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #118 // class kotlin/Pair\n 15: dup\n 16: aload_0\n 17: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 20: checkcast #42 // class java/lang/Number\n 23: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 26: aload_0\n 27: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 30: checkcast #42 // class java/lang/Number\n 33: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 36: dsub\n 37: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 40: aload_0\n 41: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 44: checkcast #42 // class java/lang/Number\n 47: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 50: aload_0\n 51: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 54: checkcast #42 // class java/lang/Number\n 57: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 60: dadd\n 61: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 64: invokespecial #136 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 67: astore_2\n 68: new #118 // class kotlin/Pair\n 71: dup\n 72: aload_1\n 73: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 76: checkcast #42 // class java/lang/Number\n 79: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 82: aload_1\n 83: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 86: checkcast #42 // class java/lang/Number\n 89: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 92: dsub\n 93: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 96: aload_1\n 97: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 100: checkcast #42 // class java/lang/Number\n 103: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 106: aload_1\n 107: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 110: checkcast #42 // class java/lang/Number\n 113: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 116: dadd\n 117: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 120: invokespecial #136 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 123: astore_3\n 124: aload_2\n 125: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 128: checkcast #42 // class java/lang/Number\n 131: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 134: aload_3\n 135: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 138: checkcast #42 // class java/lang/Number\n 141: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 144: dcmpg\n 145: ifge 152\n 148: iconst_1\n 149: goto 153\n 152: iconst_0\n 153: ireturn\n\n public static final double leastSquaresFitSlope(java.util.List<kotlin.Pair<java.lang.Double, java.lang.Double>>);\n Code:\n 0: aload_0\n 1: ldc #116 // String data\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: dconst_0\n 7: dstore 7\n 9: dconst_0\n 10: dstore 9\n 12: dconst_0\n 13: dstore 11\n 15: dconst_0\n 16: dstore 13\n 18: aload_0\n 19: checkcast #18 // class java/lang/Iterable\n 22: astore_1\n 23: iconst_0\n 24: istore_2\n 25: aload_1\n 26: invokeinterface #22, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 31: astore_3\n 32: aload_3\n 33: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 38: ifeq 152\n 41: aload_3\n 42: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 47: astore 4\n 49: aload 4\n 51: checkcast #118 // class kotlin/Pair\n 54: astore 5\n 56: iconst_0\n 57: istore 6\n 59: dload 7\n 61: aload 5\n 63: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 66: checkcast #42 // class java/lang/Number\n 69: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 72: dadd\n 73: dstore 7\n 75: dload 9\n 77: aload 5\n 79: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 82: checkcast #42 // class java/lang/Number\n 85: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 88: dadd\n 89: dstore 9\n 91: dload 11\n 93: aload 5\n 95: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 98: checkcast #42 // class java/lang/Number\n 101: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 104: aload 5\n 106: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 109: checkcast #42 // class java/lang/Number\n 112: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 115: dmul\n 116: dadd\n 117: dstore 11\n 119: dload 13\n 121: aload 5\n 123: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 126: checkcast #42 // class java/lang/Number\n 129: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 132: aload 5\n 134: invokevirtual #124 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 137: checkcast #42 // class java/lang/Number\n 140: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 143: dmul\n 144: dadd\n 145: dstore 13\n 147: nop\n 148: nop\n 149: goto 32\n 152: nop\n 153: dload 13\n 155: dconst_1\n 156: aload_0\n 157: invokeinterface #58, 1 // InterfaceMethod java/util/List.size:()I\n 162: i2d\n 163: ddiv\n 164: dload 7\n 166: dmul\n 167: dload 9\n 169: dmul\n 170: dsub\n 171: dstore_1\n 172: dload 11\n 174: dconst_1\n 175: aload_0\n 176: invokeinterface #58, 1 // InterfaceMethod java/util/List.size:()I\n 181: i2d\n 182: ddiv\n 183: dload 7\n 185: dmul\n 186: dload 7\n 188: dmul\n 189: dsub\n 190: dstore_3\n 191: dload_1\n 192: dload_3\n 193: ddiv\n 194: dreturn\n\n public static final kotlin.Pair<java.lang.Double, java.lang.Double> accumulateAscentDescent(java.util.List<kotlin.Pair<java.lang.Double, java.lang.Double>>);\n Code:\n 0: aload_0\n 1: ldc #198 // String elevationData\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: dconst_0\n 7: dstore 8\n 9: dconst_0\n 10: dstore 10\n 12: aconst_null\n 13: astore_1\n 14: aload_0\n 15: iconst_0\n 16: invokeinterface #202, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 21: astore_1\n 22: aload_0\n 23: checkcast #18 // class java/lang/Iterable\n 26: astore_2\n 27: iconst_0\n 28: istore_3\n 29: aload_2\n 30: invokeinterface #22, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 35: astore 4\n 37: aload 4\n 39: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 44: ifeq 161\n 47: aload 4\n 49: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 54: astore 5\n 56: aload 5\n 58: checkcast #118 // class kotlin/Pair\n 61: astore 6\n 63: iconst_0\n 64: istore 7\n 66: aload 6\n 68: aload_1\n 69: checkcast #118 // class kotlin/Pair\n 72: invokestatic #204 // Method isRangeGreaterThan:(Lkotlin/Pair;Lkotlin/Pair;)Z\n 75: ifeq 111\n 78: dload 8\n 80: aload 6\n 82: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 85: checkcast #42 // class java/lang/Number\n 88: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 91: aload_1\n 92: checkcast #118 // class kotlin/Pair\n 95: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 98: checkcast #42 // class java/lang/Number\n 101: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 104: dsub\n 105: dadd\n 106: dstore 8\n 108: aload 6\n 110: astore_1\n 111: aload 6\n 113: aload_1\n 114: checkcast #118 // class kotlin/Pair\n 117: invokestatic #206 // Method isRangeLessThan:(Lkotlin/Pair;Lkotlin/Pair;)Z\n 120: ifeq 156\n 123: dload 10\n 125: aload 6\n 127: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 130: checkcast #42 // class java/lang/Number\n 133: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 136: aload_1\n 137: checkcast #118 // class kotlin/Pair\n 140: invokevirtual #121 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 143: checkcast #42 // class java/lang/Number\n 146: invokevirtual #46 // Method java/lang/Number.doubleValue:()D\n 149: dsub\n 150: dadd\n 151: dstore 10\n 153: aload 6\n 155: astore_1\n 156: nop\n 157: nop\n 158: goto 37\n 161: nop\n 162: new #118 // class kotlin/Pair\n 165: dup\n 166: dload 8\n 168: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 171: dload 10\n 173: invokestatic #52 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 176: invokespecial #136 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 179: areturn\n}\n", "javap_err": "" } ]
wdfHPY__kotlinStudy__d879b02/协程/collection/CollectionComparable.kt
package com.lonbon.kotlin.collection /** * 排序 Comparable. * 1. 存在自然排序。针对一个类需要自然排序的话,那么需要实现的Comparable接口。并且实现Comparable接口。 * 2. */ class CollectionComparable { } fun main() { /* val v1 = Version(1, 2) val v2 = Version(2, 1) println(v1 > v2)*/ collectionPolymerization() } /** * 定义自然排序的话 -> 正值表示大 * 负值表示小 * 0 代表两个对象相等 */ data class Version( val majorVersion: Int, val subVersion: Int ) : Comparable<Version> { /** * 实现Comparable来定义自然顺序。 */ override fun compareTo(other: Version): Int { if (this.majorVersion != other.majorVersion) { return this.majorVersion - this.majorVersion } else if (this.subVersion != other.subVersion) { return this.subVersion - other.subVersion } else { return 0 } } } /* * 定义非自然顺序。 * 当不可以为类来定义自然顺序的时候,此时需要定义一个非自然的顺序。 * */ fun notNatureComparable() { /** * 定义一个比较器。Comparator()并且实现compareTo()方法。 */ val comparator = Comparator<String> { t, t2 -> t.length - t2.length } val list = listOf("aaa", "bb", "c") //可以调用kotlin的sortedWith方法。传入了一个Comparator即可。 println(list.sortedWith(comparator).joinToString()) //如果想快速定义一个的Comparator对象的话,可以使用 compareBy方法。该方法可以快速的定义出一个Comparator对象。 //定义comparator对象时,需要标注其类型。 val comparator2 = compareBy<String> { it.length } } fun collectionSort() { val list = listOf(1, 2, 3, 4, 5) val listVersion = listOf( Version(1, 1), Version(1, 2), Version(2, 3), Version(2, 1) ) println(list.sorted()) println(list.sortedDescending()) println(listVersion.sortedDescending()) println(listVersion.sortedDescending()) /** * sorted()和sortedDescending() 两个函数。可以针对存在自然排序的集合进行排序。 * sorted() 是自然排序的正序。sortedDescending()是自然排序的倒序。 */ /** * 自定义排序规则。通常存在两个函数sortedBy() */ val listNumber = listOf("one", "two", "three", "four", "five") //sortedBy的底层还是调用sortedWith(comparableBy{}) println(listNumber.sortedBy { it.length }.joinToString()) println(listNumber.sortedByDescending { it.length }.joinToString()) //sortWith可以使用自己的提供的Comparator } /** * 集合的倒序。kotlin * 1. reversed() 创建一个集合的副本,其中的元素的是接受者排序的逆序。 * 2. asReversed() * 3. reverse() 将集合逆转。 */ fun collectionReversed() { val list = mutableListOf(1, 2, 3, 4, 5, 6) val reverse = list.reversed() val reverse2 = list.asReversed() list.add(7) println(reverse) //由于是创建的副本的,所以那么原Collection的更改不会影响到新的倒序的Collection println(reverse2) //asRevered和reversed不相同。这个函数是针对引用来。原Collection的变化可以导致新的Collection变化。 println(list.joinToString()) } /** * shuffled洗牌算法。 */ fun collectionShuffled() { val list = listOf(1, 2, 3, 4, 5) //list.shuffled()同样是创建集合的副本然后执行洗牌 println(list.shuffled()) } /* * 集合的聚合操作: 按照某一种规则将集合聚合成一个值。 * */ fun collectionPolymerization() { val list = listOf(1, 543, 6, 89) val min = list.min() //最小值 val max = list.max() val average = list.average() val sum = list.sum() println(min) println(max) println(average) println(sum) //更高级的sum求和函数sumBy() .在集合的基础上调用上it函数 println(list.sumBy { it * 2 }) println(list.sumByDouble { it.toDouble() / 2 }) val numbers = listOf<Int>(1, 2, 3, 4) val sum2 = numbers.reduce { sum, element -> sum + element } // s = 5 T = 2、10、4 -> 5 + 2 -> 7 + 10 -> 17 + 4 = 21 val sum3 = numbers.fold(0) { sum, ele -> sum + ele * 2 // 0 + 5 + 2 + 10 + 4 -> } /** * reduce的初始值是第一个元素。在第一个元素的基础上,一直向后进行迭代调用值来调用相对应的方法。 * 在对元素进行reduce的时候,此时如果集合为空的集合,那么此时会产生异常。 * 而 fold的初始化的不是第一个元素,而是另外提供的一个初始化值。包括第一个值内一次和初始化做一定的操作。 * 当list为空的时候,此时不会产生异常,会返回初始值。 */ println(sum2) println(sum3) //fold 和 reduce 默认都是从集合的 left -> right。如何需要从集合的右侧开始进行规约。 foldRight() 或者 reduceRight() //通过查看源码发现。参数的顺序产生变化。第二个参数变成累加值。 val sum4 = numbers.foldRight(0) { sum, ele -> ele + sum * 2 // 0 + 5 + 2 + 10 + 4 -> } //如果需要加上针对Index的判断的话,那么也存在函数 val sum5 = numbers.foldIndexed(0) { index, sum, ele -> if (index % 2 == 0) sum + ele else sum + ele * 2 //0 + 1 + 4 + 3 + 8 } println(sum4) println(sum5) }
[ { "class_path": "wdfHPY__kotlinStudy__d879b02/com/lonbon/kotlin/collection/CollectionComparable.class", "javap": "Compiled from \"CollectionComparable.kt\"\npublic final class com.lonbon.kotlin.collection.CollectionComparable {\n public com.lonbon.kotlin.collection.CollectionComparable();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n}\n", "javap_err": "" }, { "class_path": "wdfHPY__kotlinStudy__d879b02/com/lonbon/kotlin/collection/CollectionComparableKt$collectionSort$$inlined$sortedBy$1.class", "javap": "Compiled from \"Comparisons.kt\"\npublic final class com.lonbon.kotlin.collection.CollectionComparableKt$collectionSort$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public com.lonbon.kotlin.collection.CollectionComparableKt$collectionSort$$inlined$sortedBy$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_1\n 1: checkcast #23 // class java/lang/String\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method java/lang/String.length:()I\n 12: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 15: checkcast #35 // class java/lang/Comparable\n 18: aload_2\n 19: checkcast #23 // class java/lang/String\n 22: astore_3\n 23: astore 5\n 25: iconst_0\n 26: istore 4\n 28: aload_3\n 29: invokevirtual #27 // Method java/lang/String.length:()I\n 32: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: aload 5\n 37: swap\n 38: checkcast #35 // class java/lang/Comparable\n 41: invokestatic #41 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 44: ireturn\n}\n", "javap_err": "" }, { "class_path": "wdfHPY__kotlinStudy__d879b02/com/lonbon/kotlin/collection/CollectionComparableKt.class", "javap": "Compiled from \"CollectionComparable.kt\"\npublic final class com.lonbon.kotlin.collection.CollectionComparableKt {\n public static final void main();\n Code:\n 0: invokestatic #9 // Method collectionPolymerization:()V\n 3: return\n\n public static final void notNatureComparable();\n Code:\n 0: invokedynamic #29, 0 // InvokeDynamic #0:compare:()Ljava/util/Comparator;\n 5: astore_0\n 6: iconst_3\n 7: anewarray #31 // class java/lang/String\n 10: astore_2\n 11: aload_2\n 12: iconst_0\n 13: ldc #33 // String aaa\n 15: aastore\n 16: aload_2\n 17: iconst_1\n 18: ldc #35 // String bb\n 20: aastore\n 21: aload_2\n 22: iconst_2\n 23: ldc #37 // String c\n 25: aastore\n 26: aload_2\n 27: invokestatic #43 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 30: astore_1\n 31: aload_1\n 32: checkcast #45 // class java/lang/Iterable\n 35: aload_0\n 36: invokestatic #49 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 39: checkcast #45 // class java/lang/Iterable\n 42: aconst_null\n 43: aconst_null\n 44: aconst_null\n 45: iconst_0\n 46: aconst_null\n 47: aconst_null\n 48: bipush 63\n 50: aconst_null\n 51: invokestatic #53 // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;\n 54: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 57: swap\n 58: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 61: new #67 // class com/lonbon/kotlin/collection/CollectionComparableKt$notNatureComparable$$inlined$compareBy$1\n 64: dup\n 65: invokespecial #70 // Method com/lonbon/kotlin/collection/CollectionComparableKt$notNatureComparable$$inlined$compareBy$1.\"<init>\":()V\n 68: checkcast #72 // class java/util/Comparator\n 71: astore_2\n 72: return\n\n public static final void collectionSort();\n Code:\n 0: iconst_5\n 1: anewarray #80 // class java/lang/Integer\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: iconst_1\n 8: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 11: aastore\n 12: aload_1\n 13: iconst_1\n 14: iconst_2\n 15: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: aastore\n 19: aload_1\n 20: iconst_2\n 21: iconst_3\n 22: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 25: aastore\n 26: aload_1\n 27: iconst_3\n 28: iconst_4\n 29: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 32: aastore\n 33: aload_1\n 34: iconst_4\n 35: iconst_5\n 36: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 39: aastore\n 40: aload_1\n 41: invokestatic #43 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 44: astore_0\n 45: iconst_4\n 46: anewarray #86 // class com/lonbon/kotlin/collection/Version\n 49: astore_2\n 50: aload_2\n 51: iconst_0\n 52: new #86 // class com/lonbon/kotlin/collection/Version\n 55: dup\n 56: iconst_1\n 57: iconst_1\n 58: invokespecial #89 // Method com/lonbon/kotlin/collection/Version.\"<init>\":(II)V\n 61: aastore\n 62: aload_2\n 63: iconst_1\n 64: new #86 // class com/lonbon/kotlin/collection/Version\n 67: dup\n 68: iconst_1\n 69: iconst_2\n 70: invokespecial #89 // Method com/lonbon/kotlin/collection/Version.\"<init>\":(II)V\n 73: aastore\n 74: aload_2\n 75: iconst_2\n 76: new #86 // class com/lonbon/kotlin/collection/Version\n 79: dup\n 80: iconst_2\n 81: iconst_3\n 82: invokespecial #89 // Method com/lonbon/kotlin/collection/Version.\"<init>\":(II)V\n 85: aastore\n 86: aload_2\n 87: iconst_3\n 88: new #86 // class com/lonbon/kotlin/collection/Version\n 91: dup\n 92: iconst_2\n 93: iconst_1\n 94: invokespecial #89 // Method com/lonbon/kotlin/collection/Version.\"<init>\":(II)V\n 97: aastore\n 98: aload_2\n 99: invokestatic #43 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 102: astore_1\n 103: aload_0\n 104: checkcast #45 // class java/lang/Iterable\n 107: invokestatic #93 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 110: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 113: swap\n 114: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 117: aload_0\n 118: checkcast #45 // class java/lang/Iterable\n 121: invokestatic #96 // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;\n 124: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 127: swap\n 128: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 131: aload_1\n 132: checkcast #45 // class java/lang/Iterable\n 135: invokestatic #96 // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;\n 138: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 141: swap\n 142: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 145: aload_1\n 146: checkcast #45 // class java/lang/Iterable\n 149: invokestatic #96 // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;\n 152: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 155: swap\n 156: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 159: iconst_5\n 160: anewarray #31 // class java/lang/String\n 163: astore_3\n 164: aload_3\n 165: iconst_0\n 166: ldc #98 // String one\n 168: aastore\n 169: aload_3\n 170: iconst_1\n 171: ldc #100 // String two\n 173: aastore\n 174: aload_3\n 175: iconst_2\n 176: ldc #102 // String three\n 178: aastore\n 179: aload_3\n 180: iconst_3\n 181: ldc #104 // String four\n 183: aastore\n 184: aload_3\n 185: iconst_4\n 186: ldc #106 // String five\n 188: aastore\n 189: aload_3\n 190: invokestatic #43 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 193: astore_2\n 194: aload_2\n 195: checkcast #45 // class java/lang/Iterable\n 198: astore_3\n 199: iconst_0\n 200: istore 4\n 202: aload_3\n 203: new #108 // class com/lonbon/kotlin/collection/CollectionComparableKt$collectionSort$$inlined$sortedBy$1\n 206: dup\n 207: invokespecial #109 // Method com/lonbon/kotlin/collection/CollectionComparableKt$collectionSort$$inlined$sortedBy$1.\"<init>\":()V\n 210: checkcast #72 // class java/util/Comparator\n 213: invokestatic #49 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 216: checkcast #45 // class java/lang/Iterable\n 219: aconst_null\n 220: aconst_null\n 221: aconst_null\n 222: iconst_0\n 223: aconst_null\n 224: aconst_null\n 225: bipush 63\n 227: aconst_null\n 228: invokestatic #53 // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;\n 231: astore_3\n 232: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 235: aload_3\n 236: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 239: aload_2\n 240: checkcast #45 // class java/lang/Iterable\n 243: astore_3\n 244: iconst_0\n 245: istore 4\n 247: aload_3\n 248: new #111 // class com/lonbon/kotlin/collection/CollectionComparableKt$collectionSort$$inlined$sortedByDescending$1\n 251: dup\n 252: invokespecial #112 // Method com/lonbon/kotlin/collection/CollectionComparableKt$collectionSort$$inlined$sortedByDescending$1.\"<init>\":()V\n 255: checkcast #72 // class java/util/Comparator\n 258: invokestatic #49 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 261: checkcast #45 // class java/lang/Iterable\n 264: aconst_null\n 265: aconst_null\n 266: aconst_null\n 267: iconst_0\n 268: aconst_null\n 269: aconst_null\n 270: bipush 63\n 272: aconst_null\n 273: invokestatic #53 // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;\n 276: astore_3\n 277: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 280: aload_3\n 281: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 284: return\n\n public static final void collectionReversed();\n Code:\n 0: bipush 6\n 2: anewarray #80 // class java/lang/Integer\n 5: astore_1\n 6: aload_1\n 7: iconst_0\n 8: iconst_1\n 9: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 12: aastore\n 13: aload_1\n 14: iconst_1\n 15: iconst_2\n 16: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 19: aastore\n 20: aload_1\n 21: iconst_2\n 22: iconst_3\n 23: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 26: aastore\n 27: aload_1\n 28: iconst_3\n 29: iconst_4\n 30: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 33: aastore\n 34: aload_1\n 35: iconst_4\n 36: iconst_5\n 37: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 40: aastore\n 41: aload_1\n 42: iconst_5\n 43: bipush 6\n 45: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 48: aastore\n 49: aload_1\n 50: invokestatic #124 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 53: astore_0\n 54: aload_0\n 55: checkcast #45 // class java/lang/Iterable\n 58: invokestatic #127 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 61: astore_1\n 62: aload_0\n 63: invokestatic #131 // Method kotlin/collections/CollectionsKt.asReversedMutable:(Ljava/util/List;)Ljava/util/List;\n 66: astore_2\n 67: aload_0\n 68: bipush 7\n 70: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 73: invokeinterface #137, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 78: pop\n 79: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 82: aload_1\n 83: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 86: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 89: aload_2\n 90: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 93: aload_0\n 94: checkcast #45 // class java/lang/Iterable\n 97: aconst_null\n 98: aconst_null\n 99: aconst_null\n 100: iconst_0\n 101: aconst_null\n 102: aconst_null\n 103: bipush 63\n 105: aconst_null\n 106: invokestatic #53 // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;\n 109: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 112: swap\n 113: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 116: return\n\n public static final void collectionShuffled();\n Code:\n 0: iconst_5\n 1: anewarray #80 // class java/lang/Integer\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: iconst_1\n 8: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 11: aastore\n 12: aload_1\n 13: iconst_1\n 14: iconst_2\n 15: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: aastore\n 19: aload_1\n 20: iconst_2\n 21: iconst_3\n 22: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 25: aastore\n 26: aload_1\n 27: iconst_3\n 28: iconst_4\n 29: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 32: aastore\n 33: aload_1\n 34: iconst_4\n 35: iconst_5\n 36: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 39: aastore\n 40: aload_1\n 41: invokestatic #43 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 44: astore_0\n 45: aload_0\n 46: checkcast #45 // class java/lang/Iterable\n 49: invokestatic #143 // Method kotlin/collections/CollectionsKt.shuffled:(Ljava/lang/Iterable;)Ljava/util/List;\n 52: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 55: swap\n 56: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 59: return\n\n public static final void collectionPolymerization();\n Code:\n 0: iconst_4\n 1: anewarray #80 // class java/lang/Integer\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: iconst_1\n 8: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 11: aastore\n 12: aload_1\n 13: iconst_1\n 14: sipush 543\n 17: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 20: aastore\n 21: aload_1\n 22: iconst_2\n 23: bipush 6\n 25: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 28: aastore\n 29: aload_1\n 30: iconst_3\n 31: bipush 89\n 33: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 36: aastore\n 37: aload_1\n 38: invokestatic #43 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 41: astore_0\n 42: aload_0\n 43: checkcast #45 // class java/lang/Iterable\n 46: invokestatic #147 // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 49: checkcast #149 // class java/lang/Number\n 52: invokevirtual #153 // Method java/lang/Number.intValue:()I\n 55: istore_1\n 56: aload_0\n 57: checkcast #45 // class java/lang/Iterable\n 60: invokestatic #156 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 63: checkcast #149 // class java/lang/Number\n 66: invokevirtual #153 // Method java/lang/Number.intValue:()I\n 69: istore_2\n 70: aload_0\n 71: checkcast #45 // class java/lang/Iterable\n 74: invokestatic #160 // Method kotlin/collections/CollectionsKt.averageOfInt:(Ljava/lang/Iterable;)D\n 77: dstore_3\n 78: aload_0\n 79: checkcast #45 // class java/lang/Iterable\n 82: invokestatic #164 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 85: istore 5\n 87: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 90: iload_1\n 91: invokevirtual #167 // Method java/io/PrintStream.println:(I)V\n 94: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 97: iload_2\n 98: invokevirtual #167 // Method java/io/PrintStream.println:(I)V\n 101: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 104: dload_3\n 105: invokevirtual #170 // Method java/io/PrintStream.println:(D)V\n 108: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 111: iload 5\n 113: invokevirtual #167 // Method java/io/PrintStream.println:(I)V\n 116: aload_0\n 117: checkcast #45 // class java/lang/Iterable\n 120: astore 6\n 122: iconst_0\n 123: istore 7\n 125: iconst_0\n 126: istore 8\n 128: aload 6\n 130: invokeinterface #174, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 135: astore 9\n 137: aload 9\n 139: invokeinterface #180, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 144: ifeq 189\n 147: aload 9\n 149: invokeinterface #184, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 154: astore 10\n 156: iload 8\n 158: aload 10\n 160: checkcast #149 // class java/lang/Number\n 163: invokevirtual #153 // Method java/lang/Number.intValue:()I\n 166: istore 11\n 168: istore 23\n 170: iconst_0\n 171: istore 12\n 173: iload 11\n 175: iconst_2\n 176: imul\n 177: istore 24\n 179: iload 23\n 181: iload 24\n 183: iadd\n 184: istore 8\n 186: goto 137\n 189: iload 8\n 191: istore 6\n 193: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 196: iload 6\n 198: invokevirtual #167 // Method java/io/PrintStream.println:(I)V\n 201: aload_0\n 202: checkcast #45 // class java/lang/Iterable\n 205: astore 6\n 207: iconst_0\n 208: istore 7\n 210: dconst_0\n 211: dstore 8\n 213: aload 6\n 215: invokeinterface #174, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 220: astore 10\n 222: aload 10\n 224: invokeinterface #180, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 229: ifeq 276\n 232: aload 10\n 234: invokeinterface #184, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 239: astore 11\n 241: dload 8\n 243: aload 11\n 245: checkcast #149 // class java/lang/Number\n 248: invokevirtual #153 // Method java/lang/Number.intValue:()I\n 251: istore 12\n 253: dstore 23\n 255: iconst_0\n 256: istore 13\n 258: iload 12\n 260: i2d\n 261: iconst_2\n 262: i2d\n 263: ddiv\n 264: dstore 25\n 266: dload 23\n 268: dload 25\n 270: dadd\n 271: dstore 8\n 273: goto 222\n 276: dload 8\n 278: dstore 6\n 280: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 283: dload 6\n 285: invokevirtual #170 // Method java/io/PrintStream.println:(D)V\n 288: iconst_4\n 289: anewarray #80 // class java/lang/Integer\n 292: astore 7\n 294: aload 7\n 296: iconst_0\n 297: iconst_1\n 298: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 301: aastore\n 302: aload 7\n 304: iconst_1\n 305: iconst_2\n 306: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 309: aastore\n 310: aload 7\n 312: iconst_2\n 313: iconst_3\n 314: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 317: aastore\n 318: aload 7\n 320: iconst_3\n 321: iconst_4\n 322: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 325: aastore\n 326: aload 7\n 328: invokestatic #43 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 331: astore 6\n 333: aload 6\n 335: checkcast #45 // class java/lang/Iterable\n 338: astore 8\n 340: iconst_0\n 341: istore 9\n 343: aload 8\n 345: invokeinterface #174, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 350: astore 10\n 352: aload 10\n 354: invokeinterface #180, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 359: ifne 372\n 362: new #186 // class java/lang/UnsupportedOperationException\n 365: dup\n 366: ldc #188 // String Empty collection can\\'t be reduced.\n 368: invokespecial #191 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 371: athrow\n 372: aload 10\n 374: invokeinterface #184, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 379: astore 11\n 381: aload 10\n 383: invokeinterface #180, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 388: ifeq 432\n 391: aload 11\n 393: aload 10\n 395: invokeinterface #184, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 400: checkcast #149 // class java/lang/Number\n 403: invokevirtual #153 // Method java/lang/Number.intValue:()I\n 406: istore 12\n 408: checkcast #149 // class java/lang/Number\n 411: invokevirtual #153 // Method java/lang/Number.intValue:()I\n 414: istore 13\n 416: iconst_0\n 417: istore 14\n 419: iload 13\n 421: iload 12\n 423: iadd\n 424: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 427: astore 11\n 429: goto 381\n 432: aload 11\n 434: checkcast #149 // class java/lang/Number\n 437: invokevirtual #153 // Method java/lang/Number.intValue:()I\n 440: istore 7\n 442: aload 6\n 444: checkcast #45 // class java/lang/Iterable\n 447: astore 9\n 449: iconst_0\n 450: istore 10\n 452: iconst_0\n 453: istore 11\n 455: iload 10\n 457: istore 12\n 459: aload 9\n 461: invokeinterface #174, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 466: astore 13\n 468: aload 13\n 470: invokeinterface #180, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 475: ifeq 516\n 478: aload 13\n 480: invokeinterface #184, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 485: astore 14\n 487: iload 12\n 489: aload 14\n 491: checkcast #149 // class java/lang/Number\n 494: invokevirtual #153 // Method java/lang/Number.intValue:()I\n 497: istore 15\n 499: istore 16\n 501: iconst_0\n 502: istore 17\n 504: iload 16\n 506: iload 15\n 508: iconst_2\n 509: imul\n 510: iadd\n 511: istore 12\n 513: goto 468\n 516: iload 12\n 518: istore 8\n 520: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 523: iload 7\n 525: invokevirtual #167 // Method java/io/PrintStream.println:(I)V\n 528: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 531: iload 8\n 533: invokevirtual #167 // Method java/io/PrintStream.println:(I)V\n 536: aload 6\n 538: astore 10\n 540: iconst_0\n 541: istore 11\n 543: iconst_0\n 544: istore 12\n 546: iload 11\n 548: istore 13\n 550: aload 10\n 552: invokeinterface #194, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 557: ifne 620\n 560: aload 10\n 562: aload 10\n 564: invokeinterface #197, 1 // InterfaceMethod java/util/List.size:()I\n 569: invokeinterface #201, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 574: astore 14\n 576: aload 14\n 578: invokeinterface #206, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 583: ifeq 620\n 586: aload 14\n 588: invokeinterface #209, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 593: iload 13\n 595: istore 15\n 597: checkcast #149 // class java/lang/Number\n 600: invokevirtual #153 // Method java/lang/Number.intValue:()I\n 603: istore 16\n 605: iconst_0\n 606: istore 17\n 608: iload 15\n 610: iload 16\n 612: iconst_2\n 613: imul\n 614: iadd\n 615: istore 13\n 617: goto 576\n 620: iload 13\n 622: istore 9\n 624: aload 6\n 626: checkcast #45 // class java/lang/Iterable\n 629: astore 11\n 631: iconst_0\n 632: istore 12\n 634: iconst_0\n 635: istore 13\n 637: iconst_0\n 638: istore 14\n 640: iload 12\n 642: istore 15\n 644: aload 11\n 646: invokeinterface #174, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 651: astore 16\n 653: aload 16\n 655: invokeinterface #180, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 660: ifeq 735\n 663: aload 16\n 665: invokeinterface #184, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 670: astore 17\n 672: iload 14\n 674: iinc 14, 1\n 677: istore 18\n 679: iload 18\n 681: ifge 687\n 684: invokestatic #212 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 687: iload 18\n 689: iload 15\n 691: aload 17\n 693: checkcast #149 // class java/lang/Number\n 696: invokevirtual #153 // Method java/lang/Number.intValue:()I\n 699: istore 19\n 701: istore 20\n 703: istore 21\n 705: iconst_0\n 706: istore 22\n 708: iload 21\n 710: iconst_2\n 711: irem\n 712: ifne 723\n 715: iload 20\n 717: iload 19\n 719: iadd\n 720: goto 730\n 723: iload 20\n 725: iload 19\n 727: iconst_2\n 728: imul\n 729: iadd\n 730: istore 15\n 732: goto 653\n 735: iload 15\n 737: istore 10\n 739: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 742: iload 9\n 744: invokevirtual #167 // Method java/io/PrintStream.println:(I)V\n 747: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 750: iload 10\n 752: invokevirtual #167 // Method java/io/PrintStream.println:(I)V\n 755: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #258 // Method main:()V\n 3: return\n\n private static final int notNatureComparable$lambda$0(java.lang.String, java.lang.String);\n Code:\n 0: aload_0\n 1: invokevirtual #263 // Method java/lang/String.length:()I\n 4: aload_1\n 5: invokevirtual #263 // Method java/lang/String.length:()I\n 8: isub\n 9: ireturn\n}\n", "javap_err": "" }, { "class_path": "wdfHPY__kotlinStudy__d879b02/com/lonbon/kotlin/collection/CollectionComparableKt$notNatureComparable$$inlined$compareBy$1.class", "javap": "Compiled from \"Comparisons.kt\"\npublic final class com.lonbon.kotlin.collection.CollectionComparableKt$notNatureComparable$$inlined$compareBy$1<T> implements java.util.Comparator {\n public com.lonbon.kotlin.collection.CollectionComparableKt$notNatureComparable$$inlined$compareBy$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_1\n 1: checkcast #23 // class java/lang/String\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method java/lang/String.length:()I\n 12: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 15: checkcast #35 // class java/lang/Comparable\n 18: aload_2\n 19: checkcast #23 // class java/lang/String\n 22: astore_3\n 23: astore 5\n 25: iconst_0\n 26: istore 4\n 28: aload_3\n 29: invokevirtual #27 // Method java/lang/String.length:()I\n 32: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: checkcast #35 // class java/lang/Comparable\n 38: aload 5\n 40: swap\n 41: invokestatic #41 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 44: ireturn\n}\n", "javap_err": "" }, { "class_path": "wdfHPY__kotlinStudy__d879b02/com/lonbon/kotlin/collection/CollectionComparableKt$collectionSort$$inlined$sortedByDescending$1.class", "javap": "Compiled from \"Comparisons.kt\"\npublic final class com.lonbon.kotlin.collection.CollectionComparableKt$collectionSort$$inlined$sortedByDescending$1<T> implements java.util.Comparator {\n public com.lonbon.kotlin.collection.CollectionComparableKt$collectionSort$$inlined$sortedByDescending$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_2\n 1: checkcast #23 // class java/lang/String\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method java/lang/String.length:()I\n 12: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 15: checkcast #35 // class java/lang/Comparable\n 18: aload_1\n 19: checkcast #23 // class java/lang/String\n 22: astore_3\n 23: astore 5\n 25: iconst_0\n 26: istore 4\n 28: aload_3\n 29: invokevirtual #27 // Method java/lang/String.length:()I\n 32: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: aload 5\n 37: swap\n 38: checkcast #35 // class java/lang/Comparable\n 41: invokestatic #41 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 44: ireturn\n}\n", "javap_err": "" } ]
daf276__AdventOfCode__d397cfe/2021/src/main/kotlin/aoc/day2.kt
package aoc.day2 sealed class Instruction { data class FORWARD(val value: Int) : Instruction() data class DOWN(val value: Int) : Instruction() data class UP(val value: Int) : Instruction() } fun parseInstructions(input: List<String>): List<Instruction> = input.map { it.split(" ") }.map { (instruction, value) -> when (instruction) { "forward" -> Instruction.FORWARD(value.toInt()) "down" -> Instruction.DOWN(value.toInt()) "up" -> Instruction.UP(value.toInt()) else -> throw Exception("This when is exhaustive") } } fun part1(input: List<Instruction>): Int { val (pos, depth) = input.fold(Pair(0, 0)) { sum, add -> when (add) { is Instruction.FORWARD -> sum.copy(first = sum.first + add.value) is Instruction.DOWN -> sum.copy(second = sum.second + add.value) is Instruction.UP -> sum.copy(second = sum.second - add.value) } } return pos * depth } fun part2(input: List<Instruction>): Int { val (pos, depth, aim) = input.fold(Triple(0, 0, 0)) { sum, add -> when (add) { is Instruction.FORWARD -> sum.copy( first = sum.first + add.value, second = sum.second + sum.third * add.value ) is Instruction.DOWN -> sum.copy(third = sum.third + add.value) is Instruction.UP -> sum.copy(third = sum.third - add.value) } } return pos * depth }
[ { "class_path": "daf276__AdventOfCode__d397cfe/aoc/day2/Day2Kt.class", "javap": "Compiled from \"day2.kt\"\npublic final class aoc.day2.Day2Kt {\n public static final java.util.List<aoc.day2.Instruction> parseInstructions(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #18 // class java/lang/Iterable\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_1\n 14: astore_3\n 15: new #20 // class java/util/ArrayList\n 18: dup\n 19: aload_1\n 20: bipush 10\n 22: invokestatic #26 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 25: invokespecial #30 // Method java/util/ArrayList.\"<init>\":(I)V\n 28: checkcast #32 // class java/util/Collection\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: aload_3\n 37: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 6\n 44: aload 6\n 46: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 116\n 54: aload 6\n 56: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 7\n 63: aload 4\n 65: aload 7\n 67: checkcast #48 // class java/lang/String\n 70: astore 8\n 72: astore 13\n 74: iconst_0\n 75: istore 9\n 77: aload 8\n 79: checkcast #50 // class java/lang/CharSequence\n 82: iconst_1\n 83: anewarray #48 // class java/lang/String\n 86: astore 10\n 88: aload 10\n 90: iconst_0\n 91: ldc #52 // String\n 93: aastore\n 94: aload 10\n 96: iconst_0\n 97: iconst_0\n 98: bipush 6\n 100: aconst_null\n 101: invokestatic #58 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 104: aload 13\n 106: swap\n 107: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 112: pop\n 113: goto 44\n 116: aload 4\n 118: checkcast #64 // class java/util/List\n 121: nop\n 122: checkcast #18 // class java/lang/Iterable\n 125: astore_1\n 126: nop\n 127: iconst_0\n 128: istore_2\n 129: aload_1\n 130: astore_3\n 131: new #20 // class java/util/ArrayList\n 134: dup\n 135: aload_1\n 136: bipush 10\n 138: invokestatic #26 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 141: invokespecial #30 // Method java/util/ArrayList.\"<init>\":(I)V\n 144: checkcast #32 // class java/util/Collection\n 147: astore 4\n 149: iconst_0\n 150: istore 5\n 152: aload_3\n 153: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 158: astore 6\n 160: aload 6\n 162: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 167: ifeq 380\n 170: aload 6\n 172: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 177: astore 7\n 179: aload 4\n 181: aload 7\n 183: checkcast #64 // class java/util/List\n 186: astore 8\n 188: astore 13\n 190: iconst_0\n 191: istore 9\n 193: aload 8\n 195: iconst_0\n 196: invokeinterface #68, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 201: checkcast #48 // class java/lang/String\n 204: astore 10\n 206: aload 8\n 208: iconst_1\n 209: invokeinterface #68, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 214: checkcast #48 // class java/lang/String\n 217: astore 11\n 219: aload 10\n 221: astore 12\n 223: aload 12\n 225: invokevirtual #72 // Method java/lang/String.hashCode:()I\n 228: lookupswitch { // 3\n -677145915: 264\n 3739: 277\n 3089570: 290\n default: 357\n }\n 264: aload 12\n 266: ldc #74 // String forward\n 268: invokevirtual #77 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 271: ifne 303\n 274: goto 357\n 277: aload 12\n 279: ldc #79 // String up\n 281: invokevirtual #77 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 284: ifne 339\n 287: goto 357\n 290: aload 12\n 292: ldc #81 // String down\n 294: invokevirtual #77 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 297: ifne 321\n 300: goto 357\n 303: new #83 // class aoc/day2/Instruction$FORWARD\n 306: dup\n 307: aload 11\n 309: invokestatic #89 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 312: invokespecial #90 // Method aoc/day2/Instruction$FORWARD.\"<init>\":(I)V\n 315: checkcast #92 // class aoc/day2/Instruction\n 318: goto 367\n 321: new #94 // class aoc/day2/Instruction$DOWN\n 324: dup\n 325: aload 11\n 327: invokestatic #89 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 330: invokespecial #95 // Method aoc/day2/Instruction$DOWN.\"<init>\":(I)V\n 333: checkcast #92 // class aoc/day2/Instruction\n 336: goto 367\n 339: new #97 // class aoc/day2/Instruction$UP\n 342: dup\n 343: aload 11\n 345: invokestatic #89 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 348: invokespecial #98 // Method aoc/day2/Instruction$UP.\"<init>\":(I)V\n 351: checkcast #92 // class aoc/day2/Instruction\n 354: goto 367\n 357: new #100 // class java/lang/Exception\n 360: dup\n 361: ldc #102 // String This when is exhaustive\n 363: invokespecial #105 // Method java/lang/Exception.\"<init>\":(Ljava/lang/String;)V\n 366: athrow\n 367: nop\n 368: aload 13\n 370: swap\n 371: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 376: pop\n 377: goto 160\n 380: aload 4\n 382: checkcast #64 // class java/util/List\n 385: nop\n 386: areturn\n\n public static final int part1(java.util.List<? extends aoc.day2.Instruction>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #18 // class java/lang/Iterable\n 10: astore_2\n 11: new #127 // class kotlin/Pair\n 14: dup\n 15: iconst_0\n 16: invokestatic #131 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 19: iconst_0\n 20: invokestatic #131 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 23: invokespecial #134 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 26: astore_3\n 27: iconst_0\n 28: istore 4\n 30: aload_3\n 31: astore 5\n 33: aload_2\n 34: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 6\n 41: aload 6\n 43: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 218\n 51: aload 6\n 53: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 7\n 60: aload 5\n 62: aload 7\n 64: checkcast #92 // class aoc/day2/Instruction\n 67: astore 8\n 69: astore 9\n 71: iconst_0\n 72: istore 10\n 74: aload 8\n 76: astore 11\n 78: aload 11\n 80: instanceof #83 // class aoc/day2/Instruction$FORWARD\n 83: ifeq 120\n 86: aload 9\n 88: aload 9\n 90: invokevirtual #137 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 93: checkcast #139 // class java/lang/Number\n 96: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 99: aload 8\n 101: checkcast #83 // class aoc/day2/Instruction$FORWARD\n 104: invokevirtual #145 // Method aoc/day2/Instruction$FORWARD.getValue:()I\n 107: iadd\n 108: invokestatic #131 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 111: aconst_null\n 112: iconst_2\n 113: aconst_null\n 114: invokestatic #149 // Method kotlin/Pair.copy$default:(Lkotlin/Pair;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Lkotlin/Pair;\n 117: goto 212\n 120: aload 11\n 122: instanceof #94 // class aoc/day2/Instruction$DOWN\n 125: ifeq 162\n 128: aload 9\n 130: aconst_null\n 131: aload 9\n 133: invokevirtual #152 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 136: checkcast #139 // class java/lang/Number\n 139: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 142: aload 8\n 144: checkcast #94 // class aoc/day2/Instruction$DOWN\n 147: invokevirtual #153 // Method aoc/day2/Instruction$DOWN.getValue:()I\n 150: iadd\n 151: invokestatic #131 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 154: iconst_1\n 155: aconst_null\n 156: invokestatic #149 // Method kotlin/Pair.copy$default:(Lkotlin/Pair;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Lkotlin/Pair;\n 159: goto 212\n 162: aload 11\n 164: instanceof #97 // class aoc/day2/Instruction$UP\n 167: ifeq 204\n 170: aload 9\n 172: aconst_null\n 173: aload 9\n 175: invokevirtual #152 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 178: checkcast #139 // class java/lang/Number\n 181: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 184: aload 8\n 186: checkcast #97 // class aoc/day2/Instruction$UP\n 189: invokevirtual #154 // Method aoc/day2/Instruction$UP.getValue:()I\n 192: isub\n 193: invokestatic #131 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 196: iconst_1\n 197: aconst_null\n 198: invokestatic #149 // Method kotlin/Pair.copy$default:(Lkotlin/Pair;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Lkotlin/Pair;\n 201: goto 212\n 204: new #156 // class kotlin/NoWhenBranchMatchedException\n 207: dup\n 208: invokespecial #159 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 211: athrow\n 212: nop\n 213: astore 5\n 215: goto 41\n 218: aload 5\n 220: astore_1\n 221: aload_1\n 222: invokevirtual #162 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 225: checkcast #139 // class java/lang/Number\n 228: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 231: istore_2\n 232: aload_1\n 233: invokevirtual #165 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 236: checkcast #139 // class java/lang/Number\n 239: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 242: istore_3\n 243: iload_2\n 244: iload_3\n 245: imul\n 246: ireturn\n\n public static final int part2(java.util.List<? extends aoc.day2.Instruction>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #18 // class java/lang/Iterable\n 10: astore_2\n 11: new #179 // class kotlin/Triple\n 14: dup\n 15: iconst_0\n 16: invokestatic #131 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 19: iconst_0\n 20: invokestatic #131 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 23: iconst_0\n 24: invokestatic #131 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 27: invokespecial #182 // Method kotlin/Triple.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V\n 30: astore_3\n 31: iconst_0\n 32: istore 4\n 34: aload_3\n 35: astore 5\n 37: aload_2\n 38: invokeinterface #36, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 43: astore 6\n 45: aload 6\n 47: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 52: ifeq 259\n 55: aload 6\n 57: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 62: astore 7\n 64: aload 5\n 66: aload 7\n 68: checkcast #92 // class aoc/day2/Instruction\n 71: astore 8\n 73: astore 9\n 75: iconst_0\n 76: istore 10\n 78: aload 8\n 80: astore 11\n 82: aload 11\n 84: instanceof #83 // class aoc/day2/Instruction$FORWARD\n 87: ifeq 159\n 90: aload 9\n 92: aload 9\n 94: invokevirtual #183 // Method kotlin/Triple.getFirst:()Ljava/lang/Object;\n 97: checkcast #139 // class java/lang/Number\n 100: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 103: aload 8\n 105: checkcast #83 // class aoc/day2/Instruction$FORWARD\n 108: invokevirtual #145 // Method aoc/day2/Instruction$FORWARD.getValue:()I\n 111: iadd\n 112: invokestatic #131 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 115: aload 9\n 117: invokevirtual #184 // Method kotlin/Triple.getSecond:()Ljava/lang/Object;\n 120: checkcast #139 // class java/lang/Number\n 123: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 126: aload 9\n 128: invokevirtual #187 // Method kotlin/Triple.getThird:()Ljava/lang/Object;\n 131: checkcast #139 // class java/lang/Number\n 134: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 137: aload 8\n 139: checkcast #83 // class aoc/day2/Instruction$FORWARD\n 142: invokevirtual #145 // Method aoc/day2/Instruction$FORWARD.getValue:()I\n 145: imul\n 146: iadd\n 147: invokestatic #131 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 150: aconst_null\n 151: iconst_4\n 152: aconst_null\n 153: invokestatic #190 // Method kotlin/Triple.copy$default:(Lkotlin/Triple;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Lkotlin/Triple;\n 156: goto 253\n 159: aload 11\n 161: instanceof #94 // class aoc/day2/Instruction$DOWN\n 164: ifeq 202\n 167: aload 9\n 169: aconst_null\n 170: aconst_null\n 171: aload 9\n 173: invokevirtual #187 // Method kotlin/Triple.getThird:()Ljava/lang/Object;\n 176: checkcast #139 // class java/lang/Number\n 179: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 182: aload 8\n 184: checkcast #94 // class aoc/day2/Instruction$DOWN\n 187: invokevirtual #153 // Method aoc/day2/Instruction$DOWN.getValue:()I\n 190: iadd\n 191: invokestatic #131 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 194: iconst_3\n 195: aconst_null\n 196: invokestatic #190 // Method kotlin/Triple.copy$default:(Lkotlin/Triple;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Lkotlin/Triple;\n 199: goto 253\n 202: aload 11\n 204: instanceof #97 // class aoc/day2/Instruction$UP\n 207: ifeq 245\n 210: aload 9\n 212: aconst_null\n 213: aconst_null\n 214: aload 9\n 216: invokevirtual #187 // Method kotlin/Triple.getThird:()Ljava/lang/Object;\n 219: checkcast #139 // class java/lang/Number\n 222: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 225: aload 8\n 227: checkcast #97 // class aoc/day2/Instruction$UP\n 230: invokevirtual #154 // Method aoc/day2/Instruction$UP.getValue:()I\n 233: isub\n 234: invokestatic #131 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 237: iconst_3\n 238: aconst_null\n 239: invokestatic #190 // Method kotlin/Triple.copy$default:(Lkotlin/Triple;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;ILjava/lang/Object;)Lkotlin/Triple;\n 242: goto 253\n 245: new #156 // class kotlin/NoWhenBranchMatchedException\n 248: dup\n 249: invokespecial #159 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 252: athrow\n 253: nop\n 254: astore 5\n 256: goto 45\n 259: aload 5\n 261: astore_1\n 262: aload_1\n 263: invokevirtual #191 // Method kotlin/Triple.component1:()Ljava/lang/Object;\n 266: checkcast #139 // class java/lang/Number\n 269: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 272: istore_2\n 273: aload_1\n 274: invokevirtual #192 // Method kotlin/Triple.component2:()Ljava/lang/Object;\n 277: checkcast #139 // class java/lang/Number\n 280: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 283: istore_3\n 284: aload_1\n 285: invokevirtual #195 // Method kotlin/Triple.component3:()Ljava/lang/Object;\n 288: checkcast #139 // class java/lang/Number\n 291: invokevirtual #142 // Method java/lang/Number.intValue:()I\n 294: istore 4\n 296: iload_2\n 297: iload_3\n 298: imul\n 299: ireturn\n}\n", "javap_err": "" } ]
swstack__algo-expert-solutions__3ddad97/src/main/kotlin/algo/expert/solutions/medium/MinCoinsForChange.kt
package algo.expert.solutions.medium import java.lang.Integer.min // Solution: Dynamic programming fun minNumberOfCoinsForChange(n: Int, denoms: List<Int>): Int { val coins = IntArray(n + 1) { -1 } coins[0] = 0 for (d in denoms.sorted()) { for (i in 1 until coins.size) { if (d <= i) { val remaining = i - d val remainingCoins = coins[remaining] if (remainingCoins != -1) { if (coins[i] == -1) { coins[i] = 1 + remainingCoins } else { coins[i] = min(coins[i], 1 + remainingCoins) } } } } } return coins[n] } // Solution: Build a tree of all possible combinations -- very inefficient class TreeNode(var value: Int) { var children: MutableList<TreeNode> = mutableListOf() } fun minNumberOfCoinsForChangeTreeNaive(n: Int, denoms: List<Int>): Int { val root = buildTree(TreeNode(n), denoms) val shortest = findShortestBranchEqualToZero(root, 0) return shortest } fun buildTree(node: TreeNode, denoms: List<Int>): TreeNode { for (d in denoms) { if (node.value - d >= 0) { node.children.add(TreeNode(node.value - d)) } } for (c in node.children) { buildTree(c, denoms) } return node } fun findShortestBranchEqualToZero(node: TreeNode, depth: Int): Int { if (node.value == 0) { return depth } if (node.children.isEmpty()) { return Integer.MAX_VALUE } val lengths = mutableListOf<Int>() for (c in node.children) { lengths.add(findShortestBranchEqualToZero(c, depth + 1)) } return lengths.min()!! } // Solution: Build optimized tree (without using actual tree data structure) // - Build out the tree breadth-first // - Stop on the first branch to equal 0 instead of building out the entire tree // - Stop building branches < 0 fun minNumberOfCoinsForChangeTreeOptimized(n: Int, denoms: List<Int>): Int { return treeOptimizedHelper(listOf(n), denoms, 1) } fun treeOptimizedHelper(row: List<Int>, denoms: List<Int>, depth: Int): Int { if (row.isEmpty()) { return Integer.MAX_VALUE } val nextRow = mutableListOf<Int>() for (node in row) { for (d in denoms) { if (node - d == 0) { return depth } if (node - d > 0) { nextRow.add(node - d) } } } return treeOptimizedHelper(nextRow, denoms, depth + 1) }
[ { "class_path": "swstack__algo-expert-solutions__3ddad97/algo/expert/solutions/medium/MinCoinsForChangeKt.class", "javap": "Compiled from \"MinCoinsForChange.kt\"\npublic final class algo.expert.solutions.medium.MinCoinsForChangeKt {\n public static final int minNumberOfCoinsForChange(int, java.util.List<java.lang.Integer>);\n Code:\n 0: aload_1\n 1: ldc #10 // String denoms\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_3\n 8: iload_0\n 9: iconst_1\n 10: iadd\n 11: istore 4\n 13: iload 4\n 15: newarray int\n 17: astore 5\n 19: iload_3\n 20: iload 4\n 22: if_icmpge 40\n 25: iload_3\n 26: istore 6\n 28: aload 5\n 30: iload 6\n 32: iconst_m1\n 33: iastore\n 34: iinc 3, 1\n 37: goto 19\n 40: aload 5\n 42: astore_2\n 43: aload_2\n 44: iconst_0\n 45: iconst_0\n 46: iastore\n 47: aload_1\n 48: checkcast #18 // class java/lang/Iterable\n 51: invokestatic #24 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 54: invokeinterface #30, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 59: astore_3\n 60: aload_3\n 61: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 66: ifeq 163\n 69: aload_3\n 70: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 75: checkcast #42 // class java/lang/Number\n 78: invokevirtual #46 // Method java/lang/Number.intValue:()I\n 81: istore 4\n 83: iconst_1\n 84: istore 5\n 86: aload_2\n 87: arraylength\n 88: istore 6\n 90: iload 5\n 92: iload 6\n 94: if_icmpge 60\n 97: iload 4\n 99: iload 5\n 101: if_icmpgt 157\n 104: iload 5\n 106: iload 4\n 108: isub\n 109: istore 7\n 111: aload_2\n 112: iload 7\n 114: iaload\n 115: istore 8\n 117: iload 8\n 119: iconst_m1\n 120: if_icmpeq 157\n 123: aload_2\n 124: iload 5\n 126: iaload\n 127: iconst_m1\n 128: if_icmpne 142\n 131: aload_2\n 132: iload 5\n 134: iconst_1\n 135: iload 8\n 137: iadd\n 138: iastore\n 139: goto 157\n 142: aload_2\n 143: iload 5\n 145: aload_2\n 146: iload 5\n 148: iaload\n 149: iconst_1\n 150: iload 8\n 152: iadd\n 153: invokestatic #52 // Method java/lang/Integer.min:(II)I\n 156: iastore\n 157: iinc 5, 1\n 160: goto 90\n 163: aload_2\n 164: iload_0\n 165: iaload\n 166: ireturn\n\n public static final int minNumberOfCoinsForChangeTreeNaive(int, java.util.List<java.lang.Integer>);\n Code:\n 0: aload_1\n 1: ldc #10 // String denoms\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #65 // class algo/expert/solutions/medium/TreeNode\n 9: dup\n 10: iload_0\n 11: invokespecial #69 // Method algo/expert/solutions/medium/TreeNode.\"<init>\":(I)V\n 14: aload_1\n 15: invokestatic #73 // Method buildTree:(Lalgo/expert/solutions/medium/TreeNode;Ljava/util/List;)Lalgo/expert/solutions/medium/TreeNode;\n 18: astore_2\n 19: aload_2\n 20: iconst_0\n 21: invokestatic #77 // Method findShortestBranchEqualToZero:(Lalgo/expert/solutions/medium/TreeNode;I)I\n 24: istore_3\n 25: iload_3\n 26: ireturn\n\n public static final algo.expert.solutions.medium.TreeNode buildTree(algo.expert.solutions.medium.TreeNode, java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #83 // String node\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #10 // String denoms\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: invokeinterface #30, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 18: astore_2\n 19: aload_2\n 20: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 25: ifeq 76\n 28: aload_2\n 29: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 34: checkcast #42 // class java/lang/Number\n 37: invokevirtual #46 // Method java/lang/Number.intValue:()I\n 40: istore_3\n 41: aload_0\n 42: invokevirtual #86 // Method algo/expert/solutions/medium/TreeNode.getValue:()I\n 45: iload_3\n 46: isub\n 47: iflt 19\n 50: aload_0\n 51: invokevirtual #90 // Method algo/expert/solutions/medium/TreeNode.getChildren:()Ljava/util/List;\n 54: new #65 // class algo/expert/solutions/medium/TreeNode\n 57: dup\n 58: aload_0\n 59: invokevirtual #86 // Method algo/expert/solutions/medium/TreeNode.getValue:()I\n 62: iload_3\n 63: isub\n 64: invokespecial #69 // Method algo/expert/solutions/medium/TreeNode.\"<init>\":(I)V\n 67: invokeinterface #94, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 72: pop\n 73: goto 19\n 76: aload_0\n 77: invokevirtual #90 // Method algo/expert/solutions/medium/TreeNode.getChildren:()Ljava/util/List;\n 80: invokeinterface #30, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 85: astore_2\n 86: aload_2\n 87: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 92: ifeq 114\n 95: aload_2\n 96: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 101: checkcast #65 // class algo/expert/solutions/medium/TreeNode\n 104: astore_3\n 105: aload_3\n 106: aload_1\n 107: invokestatic #73 // Method buildTree:(Lalgo/expert/solutions/medium/TreeNode;Ljava/util/List;)Lalgo/expert/solutions/medium/TreeNode;\n 110: pop\n 111: goto 86\n 114: aload_0\n 115: areturn\n\n public static final int findShortestBranchEqualToZero(algo.expert.solutions.medium.TreeNode, int);\n Code:\n 0: aload_0\n 1: ldc #83 // String node\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #86 // Method algo/expert/solutions/medium/TreeNode.getValue:()I\n 10: ifne 15\n 13: iload_1\n 14: ireturn\n 15: aload_0\n 16: invokevirtual #90 // Method algo/expert/solutions/medium/TreeNode.getChildren:()Ljava/util/List;\n 19: invokeinterface #98, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 24: ifeq 30\n 27: ldc #99 // int 2147483647\n 29: ireturn\n 30: new #101 // class java/util/ArrayList\n 33: dup\n 34: invokespecial #104 // Method java/util/ArrayList.\"<init>\":()V\n 37: checkcast #26 // class java/util/List\n 40: astore_2\n 41: aload_0\n 42: invokevirtual #90 // Method algo/expert/solutions/medium/TreeNode.getChildren:()Ljava/util/List;\n 45: invokeinterface #30, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 50: astore_3\n 51: aload_3\n 52: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 57: ifeq 92\n 60: aload_3\n 61: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 66: checkcast #65 // class algo/expert/solutions/medium/TreeNode\n 69: astore 4\n 71: aload_2\n 72: aload 4\n 74: iload_1\n 75: iconst_1\n 76: iadd\n 77: invokestatic #77 // Method findShortestBranchEqualToZero:(Lalgo/expert/solutions/medium/TreeNode;I)I\n 80: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 83: invokeinterface #94, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 88: pop\n 89: goto 51\n 92: aload_2\n 93: checkcast #18 // class java/lang/Iterable\n 96: invokestatic #112 // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 99: dup\n 100: invokestatic #116 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 103: checkcast #42 // class java/lang/Number\n 106: invokevirtual #46 // Method java/lang/Number.intValue:()I\n 109: ireturn\n\n public static final int minNumberOfCoinsForChangeTreeOptimized(int, java.util.List<java.lang.Integer>);\n Code:\n 0: aload_1\n 1: ldc #10 // String denoms\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_0\n 7: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 10: invokestatic #123 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 13: aload_1\n 14: iconst_1\n 15: invokestatic #127 // Method treeOptimizedHelper:(Ljava/util/List;Ljava/util/List;I)I\n 18: ireturn\n\n public static final int treeOptimizedHelper(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>, int);\n Code:\n 0: aload_0\n 1: ldc #130 // String row\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #10 // String denoms\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokeinterface #98, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 18: ifeq 24\n 21: ldc #99 // int 2147483647\n 23: ireturn\n 24: new #101 // class java/util/ArrayList\n 27: dup\n 28: invokespecial #104 // Method java/util/ArrayList.\"<init>\":()V\n 31: checkcast #26 // class java/util/List\n 34: astore_3\n 35: aload_0\n 36: invokeinterface #30, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 41: astore 4\n 43: aload 4\n 45: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 50: ifeq 137\n 53: aload 4\n 55: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 60: checkcast #42 // class java/lang/Number\n 63: invokevirtual #46 // Method java/lang/Number.intValue:()I\n 66: istore 5\n 68: aload_1\n 69: invokeinterface #30, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 74: astore 6\n 76: aload 6\n 78: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 83: ifeq 43\n 86: aload 6\n 88: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 93: checkcast #42 // class java/lang/Number\n 96: invokevirtual #46 // Method java/lang/Number.intValue:()I\n 99: istore 7\n 101: iload 5\n 103: iload 7\n 105: isub\n 106: ifne 111\n 109: iload_2\n 110: ireturn\n 111: iload 5\n 113: iload 7\n 115: isub\n 116: ifle 76\n 119: aload_3\n 120: iload 5\n 122: iload 7\n 124: isub\n 125: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 128: invokeinterface #94, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 133: pop\n 134: goto 76\n 137: aload_3\n 138: aload_1\n 139: iload_2\n 140: iconst_1\n 141: iadd\n 142: invokestatic #127 // Method treeOptimizedHelper:(Ljava/util/List;Ljava/util/List;I)I\n 145: ireturn\n}\n", "javap_err": "" } ]
ajoz__kotlin-workshop__49ba07d/aoc2016/src/main/kotlin/io/github/ajoz/sequences/Sequences.kt
package io.github.ajoz.sequences /** * Returns a sequence containing the results of applying the given [transform] function to each element in the original * sequence and the result of previous application. For the case of first element in the sequence the [initial] value * will be used as the "previous result" and passed to [transform] function. * @param initial Initial element from which the scan should take place. * @param transform Two argument function used to perform scan operation. */ fun <T, R> Sequence<T>.scan(initial: R, transform: (R, T) -> R): Sequence<R> { return TransformingScanSequence(this, initial, transform) } /** * A sequence which returns the results of applying the given [transformer] function to the values in the underlying * [sequence]. Each [transformer] is given a previously calculated value and a new value. In case of the first element * of the given [sequence] the [transformer] function will use [initial] as the "previously calculated value". */ internal class TransformingScanSequence<T, R> constructor(private val sequence: Sequence<T>, private val initial: R, private val transformer: (R, T) -> R) : Sequence<R> { override fun iterator(): Iterator<R> = object : Iterator<R> { val iterator = sequence.iterator() var previous = initial override fun next(): R { val mapped = transformer(previous, iterator.next()) previous = mapped return mapped } override fun hasNext(): Boolean { return iterator.hasNext() } } } /** * Returns first repeated element in the [Sequence]. Can throw a [NoSuchElementException] if the [Sequence] doesn't have * elements or there are no repeating elements */ fun <T> Sequence<T>.firstRepeated(): T { val set = HashSet<T>() for (element in this) { if (set.contains(element)) return element else set.add(element) } throw NoSuchElementException("Sequence contains no repeating elements") }
[ { "class_path": "ajoz__kotlin-workshop__49ba07d/io/github/ajoz/sequences/SequencesKt.class", "javap": "Compiled from \"Sequences.kt\"\npublic final class io.github.ajoz.sequences.SequencesKt {\n public static final <T, R> kotlin.sequences.Sequence<R> scan(kotlin.sequences.Sequence<? extends T>, R, kotlin.jvm.functions.Function2<? super R, ? super T, ? extends R>);\n Code:\n 0: aload_0\n 1: ldc #10 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #18 // String transform\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #20 // class io/github/ajoz/sequences/TransformingScanSequence\n 15: dup\n 16: aload_0\n 17: aload_1\n 18: aload_2\n 19: invokespecial #24 // Method io/github/ajoz/sequences/TransformingScanSequence.\"<init>\":(Lkotlin/sequences/Sequence;Ljava/lang/Object;Lkotlin/jvm/functions/Function2;)V\n 22: checkcast #26 // class kotlin/sequences/Sequence\n 25: areturn\n\n public static final <T> T firstRepeated(kotlin.sequences.Sequence<? extends T>);\n Code:\n 0: aload_0\n 1: ldc #10 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #36 // class java/util/HashSet\n 9: dup\n 10: invokespecial #39 // Method java/util/HashSet.\"<init>\":()V\n 13: astore_1\n 14: aload_0\n 15: invokeinterface #43, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 20: astore_2\n 21: aload_2\n 22: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 27: ifeq 56\n 30: aload_2\n 31: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 36: astore_3\n 37: aload_1\n 38: aload_3\n 39: invokevirtual #57 // Method java/util/HashSet.contains:(Ljava/lang/Object;)Z\n 42: ifeq 47\n 45: aload_3\n 46: areturn\n 47: aload_1\n 48: aload_3\n 49: invokevirtual #60 // Method java/util/HashSet.add:(Ljava/lang/Object;)Z\n 52: pop\n 53: goto 21\n 56: new #62 // class java/util/NoSuchElementException\n 59: dup\n 60: ldc #64 // String Sequence contains no repeating elements\n 62: invokespecial #67 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 65: athrow\n}\n", "javap_err": "" } ]
keivanshamlu__All-cities__631b1d7/utility/bases/src/main/java/com/shamlou/bases/dataStructure/RadixTree.kt
package com.shamlou.bases.dataStructure import java.util.* /** * (In the following comparisons, it is assumed that the keys are of length k * and the data structure contains n members.) */ class RadixTree<T>(private val root: Node<T> = Node(false)) { /** * checks whether tree is empty or not */ fun isEmpty(): Boolean = root.edges.isEmpty() /** * compare two strings and will return first index which two strings differ */ private fun getFirstMismatchLetter(word: String, edgeWord: String): Int { for (i in 1 until word.length.coerceAtMost(edgeWord.length)) { if (word[i] != edgeWord[i]) return i } return NO_MISMATCH } /** * get list of objects and will insert them all into radix tree */ fun insertAll(items : List<Item<T>>){ items.map { insert(it) } } /** * get an object and will insert it to radix tree */ fun insert(item: Item<T>) { var current = root var currIndex = 0 //Iterative approach while (currIndex < item.label.length) { val transitionChar = item.label.lowercase()[currIndex] val curEdge = current.getTransition(transitionChar) //Updated version of the input word val currStr = item.label.lowercase().substring(currIndex) //There is no associated edge with the first character of the current string //so simply add the rest of the string and finish if (curEdge == null) { current.addEdge(transitionChar,Edge(currStr, Node(true, item))) break } var splitIndex = getFirstMismatchLetter(currStr, curEdge.label) if (splitIndex == NO_MISMATCH) { //The edge and leftover string are the same length //so finish and update the next node as a word node if (currStr.length == curEdge.label.length) { curEdge.next.isLeaf = true curEdge.next.item = item break } else if (currStr.length < curEdge.label.length) { //The leftover word is a prefix to the edge string, so split val suffix = curEdge.label.substring(currStr.length) curEdge.label = currStr val newNext = Node<T>(true, item) val afterNewNext = curEdge.next curEdge.next = newNext newNext.addEdge(suffix, afterNewNext) break } else { //There is leftover string after a perfect match splitIndex = curEdge.label.length } } else { //The leftover string and edge string differed, so split at point val suffix = curEdge.label.substring(splitIndex) curEdge.label = curEdge.label.substring(0, splitIndex) val prevNext = curEdge.next curEdge.next = Node(false) curEdge.next.addEdge(suffix, prevNext) } //Traverse the tree current = curEdge.next currIndex += splitIndex } } /** * searches for a prefix in radix tree * first of all search for particular node and then calls [getAllChildren] * and it will get all children of that node which is found data */ fun search(word: String): List<T> { if(word.isEmpty())return emptyList() var current = root var currIndex = 0 while (currIndex < word.length) { val transitionChar = word.lowercase()[currIndex] val edge = current.getTransition(transitionChar) ?: kotlin.run { return listOf() } currIndex += edge.label.length current = edge.next } return current.getAllChildren(word.lowercase()) } companion object { private const val NO_MISMATCH = -1 } } /** * represents edges of a node, containts the lable * of edge and the node the edge is referring to */ class Edge<T>(var label: String, var next: Node<T>) /** * holds item and the key that radix tree works with */ class Item<T>(var label: String, var item: T) /** * represents node of the radix tree, contains group * of edges that are hold a tree map so it's sorted * alphanumeric all the time so whenever we call [getAllChildren] * we get a list of <T> which is in alphanumeric order */ class Node<T>(var isLeaf: Boolean, var item: Item<T>? = null) { // i used TreeMap so it can keep everything sorted var edges: TreeMap<Char, Edge<T>> = TreeMap() /** * get the edge that a Char is referring in treemap */ fun getTransition(transitionChar: Char): Edge<T>? { return edges[transitionChar] } /** * adds a edge in edges treemap */ fun addEdge(label: String, next: Node<T>) { edges[label[0]] = Edge(label, next) } /** * adds a edge in edges treemap */ fun addEdge(char : Char , edge: Edge<T>){ edges[char] = edge } /** * gets a node in radix tree and the prefix text of that node * recursively calls itself until it reaches leaves and then * it will add them to a list */ fun getAllChildren(tillNow: String): List<T> { val list = mutableListOf<T>() if (isLeaf && item?.label?.lowercase()?.startsWith(tillNow) == true && item?.item != null) { item?.item?.let { return listOf(it) } } edges.map { if (it.value.next.isLeaf) list.add(it.value.next.item!!.item) else list.addAll( it.value.next.getAllChildren( StringBuilder() .append(tillNow) .append(it.value.label) .toString() ) ) } return list } }
[ { "class_path": "keivanshamlu__All-cities__631b1d7/com/shamlou/bases/dataStructure/RadixTree.class", "javap": "Compiled from \"RadixTree.kt\"\npublic final class com.shamlou.bases.dataStructure.RadixTree<T> {\n public static final com.shamlou.bases.dataStructure.RadixTree$Companion Companion;\n\n private final com.shamlou.bases.dataStructure.Node<T> root;\n\n private static final int NO_MISMATCH;\n\n public com.shamlou.bases.dataStructure.RadixTree(com.shamlou.bases.dataStructure.Node<T>);\n Code:\n 0: aload_1\n 1: ldc #11 // String root\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #20 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #23 // Field root:Lcom/shamlou/bases/dataStructure/Node;\n 15: return\n\n public com.shamlou.bases.dataStructure.RadixTree(com.shamlou.bases.dataStructure.Node, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 18\n 6: new #28 // class com/shamlou/bases/dataStructure/Node\n 9: dup\n 10: iconst_0\n 11: aconst_null\n 12: iconst_2\n 13: aconst_null\n 14: invokespecial #31 // Method com/shamlou/bases/dataStructure/Node.\"<init>\":(ZLcom/shamlou/bases/dataStructure/Item;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 17: astore_1\n 18: aload_0\n 19: aload_1\n 20: invokespecial #33 // Method \"<init>\":(Lcom/shamlou/bases/dataStructure/Node;)V\n 23: return\n\n public final boolean isEmpty();\n Code:\n 0: aload_0\n 1: getfield #23 // Field root:Lcom/shamlou/bases/dataStructure/Node;\n 4: invokevirtual #39 // Method com/shamlou/bases/dataStructure/Node.getEdges:()Ljava/util/TreeMap;\n 7: invokevirtual #43 // Method java/util/TreeMap.isEmpty:()Z\n 10: ireturn\n\n private final int getFirstMismatchLetter(java.lang.String, java.lang.String);\n Code:\n 0: iconst_1\n 1: istore_3\n 2: aload_1\n 3: invokevirtual #51 // Method java/lang/String.length:()I\n 6: aload_2\n 7: invokevirtual #51 // Method java/lang/String.length:()I\n 10: invokestatic #57 // Method kotlin/ranges/RangesKt.coerceAtMost:(II)I\n 13: istore 4\n 15: iload_3\n 16: iload 4\n 18: if_icmpge 42\n 21: aload_1\n 22: iload_3\n 23: invokevirtual #61 // Method java/lang/String.charAt:(I)C\n 26: aload_2\n 27: iload_3\n 28: invokevirtual #61 // Method java/lang/String.charAt:(I)C\n 31: if_icmpeq 36\n 34: iload_3\n 35: ireturn\n 36: iinc 3, 1\n 39: goto 15\n 42: iconst_m1\n 43: ireturn\n\n public final void insertAll(java.util.List<com.shamlou.bases.dataStructure.Item<T>>);\n Code:\n 0: aload_1\n 1: ldc #71 // String items\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #73 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #75 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #81 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #84 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #86 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #90, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 99\n 56: aload 7\n 58: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #101 // class com/shamlou/bases/dataStructure/Item\n 72: astore 9\n 74: astore 11\n 76: iconst_0\n 77: istore 10\n 79: aload_0\n 80: aload 9\n 82: invokevirtual #105 // Method insert:(Lcom/shamlou/bases/dataStructure/Item;)V\n 85: aload 11\n 87: getstatic #111 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 90: invokeinterface #115, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 95: pop\n 96: goto 46\n 99: aload 5\n 101: checkcast #117 // class java/util/List\n 104: nop\n 105: pop\n 106: return\n\n public final void insert(com.shamlou.bases.dataStructure.Item<T>);\n Code:\n 0: aload_1\n 1: ldc #133 // String item\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #23 // Field root:Lcom/shamlou/bases/dataStructure/Node;\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: iload_3\n 14: aload_1\n 15: invokevirtual #137 // Method com/shamlou/bases/dataStructure/Item.getLabel:()Ljava/lang/String;\n 18: invokevirtual #51 // Method java/lang/String.length:()I\n 21: if_icmpge 354\n 24: aload_1\n 25: invokevirtual #137 // Method com/shamlou/bases/dataStructure/Item.getLabel:()Ljava/lang/String;\n 28: getstatic #143 // Field java/util/Locale.ROOT:Ljava/util/Locale;\n 31: invokevirtual #147 // Method java/lang/String.toLowerCase:(Ljava/util/Locale;)Ljava/lang/String;\n 34: dup\n 35: ldc #149 // String toLowerCase(...)\n 37: invokestatic #152 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 40: iload_3\n 41: invokevirtual #61 // Method java/lang/String.charAt:(I)C\n 44: istore 4\n 46: aload_2\n 47: iload 4\n 49: invokevirtual #156 // Method com/shamlou/bases/dataStructure/Node.getTransition:(C)Lcom/shamlou/bases/dataStructure/Edge;\n 52: astore 5\n 54: nop\n 55: aload_1\n 56: invokevirtual #137 // Method com/shamlou/bases/dataStructure/Item.getLabel:()Ljava/lang/String;\n 59: getstatic #143 // Field java/util/Locale.ROOT:Ljava/util/Locale;\n 62: invokevirtual #147 // Method java/lang/String.toLowerCase:(Ljava/util/Locale;)Ljava/lang/String;\n 65: dup\n 66: ldc #149 // String toLowerCase(...)\n 68: invokestatic #152 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 71: iload_3\n 72: invokevirtual #160 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 75: dup\n 76: ldc #162 // String substring(...)\n 78: invokestatic #152 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 81: astore 6\n 83: aload 5\n 85: ifnonnull 115\n 88: aload_2\n 89: iload 4\n 91: new #164 // class com/shamlou/bases/dataStructure/Edge\n 94: dup\n 95: aload 6\n 97: new #28 // class com/shamlou/bases/dataStructure/Node\n 100: dup\n 101: iconst_1\n 102: aload_1\n 103: invokespecial #167 // Method com/shamlou/bases/dataStructure/Node.\"<init>\":(ZLcom/shamlou/bases/dataStructure/Item;)V\n 106: invokespecial #170 // Method com/shamlou/bases/dataStructure/Edge.\"<init>\":(Ljava/lang/String;Lcom/shamlou/bases/dataStructure/Node;)V\n 109: invokevirtual #174 // Method com/shamlou/bases/dataStructure/Node.addEdge:(CLcom/shamlou/bases/dataStructure/Edge;)V\n 112: goto 354\n 115: aload_0\n 116: aload 6\n 118: aload 5\n 120: invokevirtual #175 // Method com/shamlou/bases/dataStructure/Edge.getLabel:()Ljava/lang/String;\n 123: invokespecial #177 // Method getFirstMismatchLetter:(Ljava/lang/String;Ljava/lang/String;)I\n 126: istore 7\n 128: iload 7\n 130: iconst_m1\n 131: if_icmpne 265\n 134: aload 6\n 136: invokevirtual #51 // Method java/lang/String.length:()I\n 139: aload 5\n 141: invokevirtual #175 // Method com/shamlou/bases/dataStructure/Edge.getLabel:()Ljava/lang/String;\n 144: invokevirtual #51 // Method java/lang/String.length:()I\n 147: if_icmpne 171\n 150: aload 5\n 152: invokevirtual #181 // Method com/shamlou/bases/dataStructure/Edge.getNext:()Lcom/shamlou/bases/dataStructure/Node;\n 155: iconst_1\n 156: invokevirtual #185 // Method com/shamlou/bases/dataStructure/Node.setLeaf:(Z)V\n 159: aload 5\n 161: invokevirtual #181 // Method com/shamlou/bases/dataStructure/Edge.getNext:()Lcom/shamlou/bases/dataStructure/Node;\n 164: aload_1\n 165: invokevirtual #188 // Method com/shamlou/bases/dataStructure/Node.setItem:(Lcom/shamlou/bases/dataStructure/Item;)V\n 168: goto 354\n 171: aload 6\n 173: invokevirtual #51 // Method java/lang/String.length:()I\n 176: aload 5\n 178: invokevirtual #175 // Method com/shamlou/bases/dataStructure/Edge.getLabel:()Ljava/lang/String;\n 181: invokevirtual #51 // Method java/lang/String.length:()I\n 184: if_icmpge 252\n 187: aload 5\n 189: invokevirtual #175 // Method com/shamlou/bases/dataStructure/Edge.getLabel:()Ljava/lang/String;\n 192: aload 6\n 194: invokevirtual #51 // Method java/lang/String.length:()I\n 197: invokevirtual #160 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 200: dup\n 201: ldc #162 // String substring(...)\n 203: invokestatic #152 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 206: astore 8\n 208: aload 5\n 210: aload 6\n 212: invokevirtual #192 // Method com/shamlou/bases/dataStructure/Edge.setLabel:(Ljava/lang/String;)V\n 215: new #28 // class com/shamlou/bases/dataStructure/Node\n 218: dup\n 219: iconst_1\n 220: aload_1\n 221: invokespecial #167 // Method com/shamlou/bases/dataStructure/Node.\"<init>\":(ZLcom/shamlou/bases/dataStructure/Item;)V\n 224: astore 9\n 226: aload 5\n 228: invokevirtual #181 // Method com/shamlou/bases/dataStructure/Edge.getNext:()Lcom/shamlou/bases/dataStructure/Node;\n 231: astore 10\n 233: aload 5\n 235: aload 9\n 237: invokevirtual #195 // Method com/shamlou/bases/dataStructure/Edge.setNext:(Lcom/shamlou/bases/dataStructure/Node;)V\n 240: aload 9\n 242: aload 8\n 244: aload 10\n 246: invokevirtual #197 // Method com/shamlou/bases/dataStructure/Node.addEdge:(Ljava/lang/String;Lcom/shamlou/bases/dataStructure/Node;)V\n 249: goto 354\n 252: aload 5\n 254: invokevirtual #175 // Method com/shamlou/bases/dataStructure/Edge.getLabel:()Ljava/lang/String;\n 257: invokevirtual #51 // Method java/lang/String.length:()I\n 260: istore 7\n 262: goto 340\n 265: aload 5\n 267: invokevirtual #175 // Method com/shamlou/bases/dataStructure/Edge.getLabel:()Ljava/lang/String;\n 270: iload 7\n 272: invokevirtual #160 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 275: dup\n 276: ldc #162 // String substring(...)\n 278: invokestatic #152 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 281: astore 8\n 283: aload 5\n 285: aload 5\n 287: invokevirtual #175 // Method com/shamlou/bases/dataStructure/Edge.getLabel:()Ljava/lang/String;\n 290: iconst_0\n 291: iload 7\n 293: invokevirtual #200 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 296: dup\n 297: ldc #162 // String substring(...)\n 299: invokestatic #152 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 302: invokevirtual #192 // Method com/shamlou/bases/dataStructure/Edge.setLabel:(Ljava/lang/String;)V\n 305: aload 5\n 307: invokevirtual #181 // Method com/shamlou/bases/dataStructure/Edge.getNext:()Lcom/shamlou/bases/dataStructure/Node;\n 310: astore 9\n 312: aload 5\n 314: new #28 // class com/shamlou/bases/dataStructure/Node\n 317: dup\n 318: iconst_0\n 319: aconst_null\n 320: iconst_2\n 321: aconst_null\n 322: invokespecial #31 // Method com/shamlou/bases/dataStructure/Node.\"<init>\":(ZLcom/shamlou/bases/dataStructure/Item;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 325: invokevirtual #195 // Method com/shamlou/bases/dataStructure/Edge.setNext:(Lcom/shamlou/bases/dataStructure/Node;)V\n 328: aload 5\n 330: invokevirtual #181 // Method com/shamlou/bases/dataStructure/Edge.getNext:()Lcom/shamlou/bases/dataStructure/Node;\n 333: aload 8\n 335: aload 9\n 337: invokevirtual #197 // Method com/shamlou/bases/dataStructure/Node.addEdge:(Ljava/lang/String;Lcom/shamlou/bases/dataStructure/Node;)V\n 340: aload 5\n 342: invokevirtual #181 // Method com/shamlou/bases/dataStructure/Edge.getNext:()Lcom/shamlou/bases/dataStructure/Node;\n 345: astore_2\n 346: iload_3\n 347: iload 7\n 349: iadd\n 350: istore_3\n 351: goto 13\n 354: return\n\n public final java.util.List<T> search(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #216 // String word\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #218 // class java/lang/CharSequence\n 10: invokeinterface #219, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 15: ifne 22\n 18: iconst_1\n 19: goto 23\n 22: iconst_0\n 23: ifeq 30\n 26: invokestatic #223 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 29: areturn\n 30: aload_0\n 31: getfield #23 // Field root:Lcom/shamlou/bases/dataStructure/Node;\n 34: astore_2\n 35: iconst_0\n 36: istore_3\n 37: iload_3\n 38: aload_1\n 39: invokevirtual #51 // Method java/lang/String.length:()I\n 42: if_icmpge 104\n 45: aload_1\n 46: getstatic #143 // Field java/util/Locale.ROOT:Ljava/util/Locale;\n 49: invokevirtual #147 // Method java/lang/String.toLowerCase:(Ljava/util/Locale;)Ljava/lang/String;\n 52: dup\n 53: ldc #149 // String toLowerCase(...)\n 55: invokestatic #152 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 58: iload_3\n 59: invokevirtual #61 // Method java/lang/String.charAt:(I)C\n 62: istore 4\n 64: aload_2\n 65: iload 4\n 67: invokevirtual #156 // Method com/shamlou/bases/dataStructure/Node.getTransition:(C)Lcom/shamlou/bases/dataStructure/Edge;\n 70: dup\n 71: ifnonnull 82\n 74: pop\n 75: iconst_0\n 76: istore 6\n 78: invokestatic #223 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 81: areturn\n 82: astore 5\n 84: iload_3\n 85: aload 5\n 87: invokevirtual #175 // Method com/shamlou/bases/dataStructure/Edge.getLabel:()Ljava/lang/String;\n 90: invokevirtual #51 // Method java/lang/String.length:()I\n 93: iadd\n 94: istore_3\n 95: aload 5\n 97: invokevirtual #181 // Method com/shamlou/bases/dataStructure/Edge.getNext:()Lcom/shamlou/bases/dataStructure/Node;\n 100: astore_2\n 101: goto 37\n 104: aload_2\n 105: aload_1\n 106: getstatic #143 // Field java/util/Locale.ROOT:Ljava/util/Locale;\n 109: invokevirtual #147 // Method java/lang/String.toLowerCase:(Ljava/util/Locale;)Ljava/lang/String;\n 112: dup\n 113: ldc #149 // String toLowerCase(...)\n 115: invokestatic #152 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 118: invokevirtual #226 // Method com/shamlou/bases/dataStructure/Node.getAllChildren:(Ljava/lang/String;)Ljava/util/List;\n 121: areturn\n\n public com.shamlou.bases.dataStructure.RadixTree();\n Code:\n 0: aload_0\n 1: aconst_null\n 2: iconst_1\n 3: aconst_null\n 4: invokespecial #230 // Method \"<init>\":(Lcom/shamlou/bases/dataStructure/Node;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 7: return\n\n static {};\n Code:\n 0: new #233 // class com/shamlou/bases/dataStructure/RadixTree$Companion\n 3: dup\n 4: aconst_null\n 5: invokespecial #236 // Method com/shamlou/bases/dataStructure/RadixTree$Companion.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 8: putstatic #240 // Field Companion:Lcom/shamlou/bases/dataStructure/RadixTree$Companion;\n 11: return\n}\n", "javap_err": "" }, { "class_path": "keivanshamlu__All-cities__631b1d7/com/shamlou/bases/dataStructure/RadixTree$Companion.class", "javap": "Compiled from \"RadixTree.kt\"\npublic final class com.shamlou.bases.dataStructure.RadixTree$Companion {\n private com.shamlou.bases.dataStructure.RadixTree$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public com.shamlou.bases.dataStructure.RadixTree$Companion(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #12 // Method \"<init>\":()V\n 4: return\n}\n", "javap_err": "" } ]
hasanhaja__UoB-Codefest__c4c84db/src/year2018/dec/level6/ktSolutions.kt
package year2018.dec.level6 fun ktchallenge1(s: String): Int { val expression: List<String> = s.trim().split(" ") return evaluate(expression) } private enum class Ops(val symbol: String) { ADD("+"), MINUS("-"), MULTIPLY("*"), DIVIDE("/"), } private fun evaluate(expression: List<String>): Int { var total = 0 var currentOp = Ops.ADD for (value in expression) { try { val current = value.toInt() when (currentOp) { Ops.ADD -> total += current Ops.MINUS -> total -= current Ops.MULTIPLY -> total *= current Ops.DIVIDE -> total /= current } } catch (e: Exception) { when (value) { Ops.ADD.symbol -> currentOp = Ops.ADD Ops.MINUS.symbol -> currentOp = Ops.MINUS Ops.MULTIPLY.symbol -> currentOp = Ops.MULTIPLY Ops.DIVIDE.symbol -> currentOp = Ops.DIVIDE else -> e.printStackTrace() } } } return total } fun ktchallenge2(array: IntArray, a: Int): IntArray { val result = IntArray(2) for (i in 0 until array.size) { for (j in i+1 until array.size) { when (a) { array[i] + array[j]-> { result[0] = i result[1] = j } } } } return result } fun ktchallenge3(array1: IntArray, array2: IntArray): Int = (reverseArray(array1).sum() + reverseArray(array2).sum()) private fun reverseArray(array: IntArray): IntArray { return array. map { it.toString().reversed().toInt() }. toIntArray() } fun <T> ktchallenge4(c: Class<T>, a: Double, b: Double): T? { return null } fun ktchallenge5(s: String, a: Int): Int { var text = s // replace ops with op with spaces // for this case only text = text.replace("+", " + ") // Index of "r" in return val returnIndex = text.indexOf("return") val semiIndex = text.indexOf(";") // replace i with a (this will do it for all, but it doesn't matter text = text.replace("i", a.toString()) val expression = text.slice(returnIndex+6 until semiIndex ) return ktchallenge1(expression) }
[ { "class_path": "hasanhaja__UoB-Codefest__c4c84db/year2018/dec/level6/KtSolutionsKt.class", "javap": "Compiled from \"ktSolutions.kt\"\npublic final class year2018.dec.level6.KtSolutionsKt {\n public static final int ktchallenge1(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #9 // String s\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #17 // class java/lang/CharSequence\n 10: invokestatic #23 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 13: invokevirtual #27 // Method java/lang/Object.toString:()Ljava/lang/String;\n 16: checkcast #17 // class java/lang/CharSequence\n 19: iconst_1\n 20: anewarray #29 // class java/lang/String\n 23: astore_2\n 24: aload_2\n 25: iconst_0\n 26: ldc #31 // String\n 28: aastore\n 29: aload_2\n 30: iconst_0\n 31: iconst_0\n 32: bipush 6\n 34: aconst_null\n 35: invokestatic #35 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 38: astore_1\n 39: aload_1\n 40: invokestatic #39 // Method evaluate:(Ljava/util/List;)I\n 43: ireturn\n\n private static final int evaluate(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: getstatic #51 // Field year2018/dec/level6/Ops.ADD:Lyear2018/dec/level6/Ops;\n 5: astore_2\n 6: aload_0\n 7: invokeinterface #57, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 12: astore_3\n 13: aload_3\n 14: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 19: ifeq 218\n 22: aload_3\n 23: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 28: checkcast #29 // class java/lang/String\n 31: astore 4\n 33: nop\n 34: aload 4\n 36: invokestatic #72 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 39: istore 5\n 41: aload_2\n 42: getstatic #78 // Field year2018/dec/level6/KtSolutionsKt$WhenMappings.$EnumSwitchMapping$0:[I\n 45: swap\n 46: invokevirtual #82 // Method year2018/dec/level6/Ops.ordinal:()I\n 49: iaload\n 50: tableswitch { // 1 to 4\n 1: 80\n 2: 88\n 3: 96\n 4: 104\n default: 112\n }\n 80: iload_1\n 81: iload 5\n 83: iadd\n 84: istore_1\n 85: goto 13\n 88: iload_1\n 89: iload 5\n 91: isub\n 92: istore_1\n 93: goto 13\n 96: iload_1\n 97: iload 5\n 99: imul\n 100: istore_1\n 101: goto 13\n 104: iload_1\n 105: iload 5\n 107: idiv\n 108: istore_1\n 109: goto 13\n 112: new #84 // class kotlin/NoWhenBranchMatchedException\n 115: dup\n 116: invokespecial #88 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 119: athrow\n 120: astore 5\n 122: aload 4\n 124: astore 6\n 126: aload 6\n 128: getstatic #51 // Field year2018/dec/level6/Ops.ADD:Lyear2018/dec/level6/Ops;\n 131: invokevirtual #91 // Method year2018/dec/level6/Ops.getSymbol:()Ljava/lang/String;\n 134: invokestatic #95 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 137: ifeq 147\n 140: getstatic #51 // Field year2018/dec/level6/Ops.ADD:Lyear2018/dec/level6/Ops;\n 143: astore_2\n 144: goto 13\n 147: aload 6\n 149: getstatic #98 // Field year2018/dec/level6/Ops.MINUS:Lyear2018/dec/level6/Ops;\n 152: invokevirtual #91 // Method year2018/dec/level6/Ops.getSymbol:()Ljava/lang/String;\n 155: invokestatic #95 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 158: ifeq 168\n 161: getstatic #98 // Field year2018/dec/level6/Ops.MINUS:Lyear2018/dec/level6/Ops;\n 164: astore_2\n 165: goto 13\n 168: aload 6\n 170: getstatic #101 // Field year2018/dec/level6/Ops.MULTIPLY:Lyear2018/dec/level6/Ops;\n 173: invokevirtual #91 // Method year2018/dec/level6/Ops.getSymbol:()Ljava/lang/String;\n 176: invokestatic #95 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 179: ifeq 189\n 182: getstatic #101 // Field year2018/dec/level6/Ops.MULTIPLY:Lyear2018/dec/level6/Ops;\n 185: astore_2\n 186: goto 13\n 189: aload 6\n 191: getstatic #104 // Field year2018/dec/level6/Ops.DIVIDE:Lyear2018/dec/level6/Ops;\n 194: invokevirtual #91 // Method year2018/dec/level6/Ops.getSymbol:()Ljava/lang/String;\n 197: invokestatic #95 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 200: ifeq 210\n 203: getstatic #104 // Field year2018/dec/level6/Ops.DIVIDE:Lyear2018/dec/level6/Ops;\n 206: astore_2\n 207: goto 13\n 210: aload 5\n 212: invokevirtual #107 // Method java/lang/Exception.printStackTrace:()V\n 215: goto 13\n 218: iload_1\n 219: ireturn\n Exception table:\n from to target type\n 33 120 120 Class java/lang/Exception\n\n public static final int[] ktchallenge2(int[], int);\n Code:\n 0: aload_0\n 1: ldc #118 // String array\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_2\n 7: newarray int\n 9: astore_2\n 10: iconst_0\n 11: istore_3\n 12: aload_0\n 13: arraylength\n 14: istore 4\n 16: iload_3\n 17: iload 4\n 19: if_icmpge 71\n 22: iload_3\n 23: iconst_1\n 24: iadd\n 25: istore 5\n 27: aload_0\n 28: arraylength\n 29: istore 6\n 31: iload 5\n 33: iload 6\n 35: if_icmpge 65\n 38: iload_1\n 39: aload_0\n 40: iload_3\n 41: iaload\n 42: aload_0\n 43: iload 5\n 45: iaload\n 46: iadd\n 47: if_icmpne 59\n 50: aload_2\n 51: iconst_0\n 52: iload_3\n 53: iastore\n 54: aload_2\n 55: iconst_1\n 56: iload 5\n 58: iastore\n 59: iinc 5, 1\n 62: goto 31\n 65: iinc 3, 1\n 68: goto 16\n 71: aload_2\n 72: areturn\n\n public static final int ktchallenge3(int[], int[]);\n Code:\n 0: aload_0\n 1: ldc #127 // String array1\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #129 // String array2\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokestatic #133 // Method reverseArray:([I)[I\n 16: invokestatic #139 // Method kotlin/collections/ArraysKt.sum:([I)I\n 19: aload_1\n 20: invokestatic #133 // Method reverseArray:([I)[I\n 23: invokestatic #139 // Method kotlin/collections/ArraysKt.sum:([I)I\n 26: iadd\n 27: ireturn\n\n private static final int[] reverseArray(int[]);\n Code:\n 0: aload_0\n 1: astore_1\n 2: nop\n 3: iconst_0\n 4: istore_2\n 5: aload_1\n 6: astore_3\n 7: new #141 // class java/util/ArrayList\n 10: dup\n 11: aload_1\n 12: arraylength\n 13: invokespecial #144 // Method java/util/ArrayList.\"<init>\":(I)V\n 16: checkcast #146 // class java/util/Collection\n 19: astore 4\n 21: iconst_0\n 22: istore 5\n 24: iconst_0\n 25: istore 6\n 27: aload_3\n 28: arraylength\n 29: istore 7\n 31: iload 6\n 33: iload 7\n 35: if_icmpge 92\n 38: aload_3\n 39: iload 6\n 41: iaload\n 42: istore 8\n 44: aload 4\n 46: iload 8\n 48: istore 9\n 50: astore 11\n 52: iconst_0\n 53: istore 10\n 55: nop\n 56: iload 9\n 58: invokestatic #150 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 61: checkcast #17 // class java/lang/CharSequence\n 64: invokestatic #153 // Method kotlin/text/StringsKt.reversed:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 67: invokevirtual #27 // Method java/lang/Object.toString:()Ljava/lang/String;\n 70: invokestatic #72 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 73: nop\n 74: invokestatic #156 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 77: aload 11\n 79: swap\n 80: invokeinterface #160, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 85: pop\n 86: iinc 6, 1\n 89: goto 31\n 92: aload 4\n 94: checkcast #53 // class java/util/List\n 97: nop\n 98: checkcast #146 // class java/util/Collection\n 101: invokestatic #166 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I\n 104: areturn\n\n public static final <T> T ktchallenge4(java.lang.Class<T>, double, double);\n Code:\n 0: aload_0\n 1: ldc #181 // String c\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aconst_null\n 7: areturn\n\n public static final int ktchallenge5(java.lang.String, int);\n Code:\n 0: aload_0\n 1: ldc #9 // String s\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: astore_2\n 8: aload_2\n 9: ldc #188 // String +\n 11: ldc #190 // String +\n 13: iconst_0\n 14: iconst_4\n 15: aconst_null\n 16: invokestatic #194 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 19: astore_2\n 20: aload_2\n 21: checkcast #17 // class java/lang/CharSequence\n 24: ldc #196 // String return\n 26: iconst_0\n 27: iconst_0\n 28: bipush 6\n 30: aconst_null\n 31: invokestatic #200 // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;Ljava/lang/String;IZILjava/lang/Object;)I\n 34: istore_3\n 35: aload_2\n 36: checkcast #17 // class java/lang/CharSequence\n 39: ldc #202 // String ;\n 41: iconst_0\n 42: iconst_0\n 43: bipush 6\n 45: aconst_null\n 46: invokestatic #200 // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;Ljava/lang/String;IZILjava/lang/Object;)I\n 49: istore 4\n 51: aload_2\n 52: ldc #203 // String i\n 54: iload_1\n 55: invokestatic #150 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 58: iconst_0\n 59: iconst_4\n 60: aconst_null\n 61: invokestatic #194 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 64: astore_2\n 65: aload_2\n 66: iload_3\n 67: bipush 6\n 69: iadd\n 70: iload 4\n 72: invokestatic #209 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 75: invokestatic #213 // Method kotlin/text/StringsKt.slice:(Ljava/lang/String;Lkotlin/ranges/IntRange;)Ljava/lang/String;\n 78: astore 5\n 80: aload 5\n 82: invokestatic #215 // Method ktchallenge1:(Ljava/lang/String;)I\n 85: ireturn\n}\n", "javap_err": "" }, { "class_path": "hasanhaja__UoB-Codefest__c4c84db/year2018/dec/level6/KtSolutionsKt$WhenMappings.class", "javap": "Compiled from \"ktSolutions.kt\"\npublic final class year2018.dec.level6.KtSolutionsKt$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method year2018/dec/level6/Ops.values:()[Lyear2018/dec/level6/Ops;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field year2018/dec/level6/Ops.ADD:Lyear2018/dec/level6/Ops;\n 12: invokevirtual #22 // Method year2018/dec/level6/Ops.ordinal:()I\n 15: iconst_1\n 16: iastore\n 17: goto 21\n 20: astore_1\n 21: nop\n 22: aload_0\n 23: getstatic #25 // Field year2018/dec/level6/Ops.MINUS:Lyear2018/dec/level6/Ops;\n 26: invokevirtual #22 // Method year2018/dec/level6/Ops.ordinal:()I\n 29: iconst_2\n 30: iastore\n 31: goto 35\n 34: astore_1\n 35: nop\n 36: aload_0\n 37: getstatic #28 // Field year2018/dec/level6/Ops.MULTIPLY:Lyear2018/dec/level6/Ops;\n 40: invokevirtual #22 // Method year2018/dec/level6/Ops.ordinal:()I\n 43: iconst_3\n 44: iastore\n 45: goto 49\n 48: astore_1\n 49: nop\n 50: aload_0\n 51: getstatic #31 // Field year2018/dec/level6/Ops.DIVIDE:Lyear2018/dec/level6/Ops;\n 54: invokevirtual #22 // Method year2018/dec/level6/Ops.ordinal:()I\n 57: iconst_4\n 58: iastore\n 59: goto 63\n 62: astore_1\n 63: aload_0\n 64: putstatic #35 // Field $EnumSwitchMapping$0:[I\n 67: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n 21 31 34 Class java/lang/NoSuchFieldError\n 35 45 48 Class java/lang/NoSuchFieldError\n 49 59 62 Class java/lang/NoSuchFieldError\n}\n", "javap_err": "" } ]
mxrpr__learning__0082d8b/src/main/kotlin/leveinshtein.kt
package com.mxr.example import kotlin.system.measureNanoTime /** * For learning purposes * * Two solutions: * 1. create Leveinshtein class * 2. extend CharSequence functionality */ class Leveinshtein { fun leveinshteinDistance(lhs: String, rhs: String): Int { if (lhs === rhs) return 0 if (lhs.isEmpty()) return rhs.length if (rhs.isEmpty()) return lhs.length val res = Array(lhs.length){ IntArray(rhs.length)} for (i in 0 until lhs.length) res[i][0] = i for (j in 0 until rhs.length) res[0][j] = j var subst = 0 for (j in 1 until rhs.length) { for (i in 1 until lhs.length) { subst = if (lhs[i] == rhs[j]) 0 else 1 val deletion = res[i-1][j] + 1 val insertion = res[i][j-1] +1 val substitution = res[i-1][j-1] + subst res[i][j] = Math.min(Math.min(deletion, insertion), substitution) } } return res[lhs.length-1][rhs.length-1] } private fun cost(a: Char, b: Char ): Int = if (a == b) 0 else 1 } /** * Extend the CharSequence */ fun CharSequence.leveinshtein(lhs: String): Int{ if (this === lhs) return 0 if (lhs.isEmpty()) return this.length if (this.isEmpty()) return lhs.length val res = Array(lhs.length){ IntArray(this.length)} for (i in 0 until lhs.length) res[i][0] = i for (j in 0 until this.length) res[0][j] = j var subst = 0 for (j in 1 until this.length) { for (i in 1 until lhs.length) { subst = if (lhs[i] == this[j]) 0 else 1 val deletion = res[i-1][j] + 1 val insertion = res[i][j-1] +1 val substitution = res[i-1][j-1] + subst res[i][j] = Math.min(Math.min(deletion, insertion), substitution) } } return res[lhs.length-1][this.length-1] } fun main(args: Array<String>) { val lev = Leveinshtein() var time = measureNanoTime { println(lev.leveinshteinDistance("rosettacode", "raisethysword")) } println("time: $time") time = measureNanoTime { println("rosettacode".leveinshtein("raisethysword")) } println("time: $time") }
[ { "class_path": "mxrpr__learning__0082d8b/com/mxr/example/LeveinshteinKt.class", "javap": "Compiled from \"leveinshtein.kt\"\npublic final class com.mxr.example.LeveinshteinKt {\n public static final int leveinshtein(java.lang.CharSequence, java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #9 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #17 // String lhs\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_1\n 14: if_acmpne 19\n 17: iconst_0\n 18: ireturn\n 19: aload_1\n 20: checkcast #19 // class java/lang/CharSequence\n 23: invokeinterface #23, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 28: ifne 35\n 31: iconst_1\n 32: goto 36\n 35: iconst_0\n 36: ifeq 46\n 39: aload_0\n 40: invokeinterface #23, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 45: ireturn\n 46: aload_0\n 47: invokeinterface #23, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 52: ifne 59\n 55: iconst_1\n 56: goto 60\n 59: iconst_0\n 60: ifeq 68\n 63: aload_1\n 64: invokevirtual #26 // Method java/lang/String.length:()I\n 67: ireturn\n 68: iconst_0\n 69: istore_3\n 70: aload_1\n 71: invokevirtual #26 // Method java/lang/String.length:()I\n 74: istore 4\n 76: iload 4\n 78: anewarray #28 // class \"[I\"\n 81: astore 5\n 83: iload_3\n 84: iload 4\n 86: if_icmpge 111\n 89: iload_3\n 90: istore 6\n 92: aload 5\n 94: iload 6\n 96: aload_0\n 97: invokeinterface #23, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 102: newarray int\n 104: aastore\n 105: iinc 3, 1\n 108: goto 83\n 111: aload 5\n 113: astore_2\n 114: iconst_0\n 115: istore_3\n 116: aload_1\n 117: invokevirtual #26 // Method java/lang/String.length:()I\n 120: istore 4\n 122: iload_3\n 123: iload 4\n 125: if_icmpge 140\n 128: aload_2\n 129: iload_3\n 130: aaload\n 131: iconst_0\n 132: iload_3\n 133: iastore\n 134: iinc 3, 1\n 137: goto 122\n 140: iconst_0\n 141: istore_3\n 142: aload_0\n 143: invokeinterface #23, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 148: istore 4\n 150: iload_3\n 151: iload 4\n 153: if_icmpge 168\n 156: aload_2\n 157: iconst_0\n 158: aaload\n 159: iload_3\n 160: iload_3\n 161: iastore\n 162: iinc 3, 1\n 165: goto 150\n 168: iconst_0\n 169: istore_3\n 170: iconst_1\n 171: istore 4\n 173: aload_0\n 174: invokeinterface #23, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 179: istore 5\n 181: iload 4\n 183: iload 5\n 185: if_icmpge 299\n 188: iconst_1\n 189: istore 6\n 191: aload_1\n 192: invokevirtual #26 // Method java/lang/String.length:()I\n 195: istore 7\n 197: iload 6\n 199: iload 7\n 201: if_icmpge 293\n 204: aload_1\n 205: iload 6\n 207: invokevirtual #32 // Method java/lang/String.charAt:(I)C\n 210: aload_0\n 211: iload 4\n 213: invokeinterface #33, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 218: if_icmpne 225\n 221: iconst_0\n 222: goto 226\n 225: iconst_1\n 226: istore_3\n 227: aload_2\n 228: iload 6\n 230: iconst_1\n 231: isub\n 232: aaload\n 233: iload 4\n 235: iaload\n 236: iconst_1\n 237: iadd\n 238: istore 8\n 240: aload_2\n 241: iload 6\n 243: aaload\n 244: iload 4\n 246: iconst_1\n 247: isub\n 248: iaload\n 249: iconst_1\n 250: iadd\n 251: istore 9\n 253: aload_2\n 254: iload 6\n 256: iconst_1\n 257: isub\n 258: aaload\n 259: iload 4\n 261: iconst_1\n 262: isub\n 263: iaload\n 264: iload_3\n 265: iadd\n 266: istore 10\n 268: aload_2\n 269: iload 6\n 271: aaload\n 272: iload 4\n 274: iload 8\n 276: iload 9\n 278: invokestatic #39 // Method java/lang/Math.min:(II)I\n 281: iload 10\n 283: invokestatic #39 // Method java/lang/Math.min:(II)I\n 286: iastore\n 287: iinc 6, 1\n 290: goto 197\n 293: iinc 4, 1\n 296: goto 181\n 299: aload_2\n 300: aload_1\n 301: invokevirtual #26 // Method java/lang/String.length:()I\n 304: iconst_1\n 305: isub\n 306: aaload\n 307: aload_0\n 308: invokeinterface #23, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 313: iconst_1\n 314: isub\n 315: iaload\n 316: ireturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #56 // String args\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #58 // class com/mxr/example/Leveinshtein\n 9: dup\n 10: invokespecial #62 // Method com/mxr/example/Leveinshtein.\"<init>\":()V\n 13: astore_1\n 14: iconst_0\n 15: istore 4\n 17: invokestatic #68 // Method java/lang/System.nanoTime:()J\n 20: lstore 5\n 22: iconst_0\n 23: istore 7\n 25: aload_1\n 26: ldc #70 // String rosettacode\n 28: ldc #72 // String raisethysword\n 30: invokevirtual #76 // Method com/mxr/example/Leveinshtein.leveinshteinDistance:(Ljava/lang/String;Ljava/lang/String;)I\n 33: istore 8\n 35: getstatic #80 // Field java/lang/System.out:Ljava/io/PrintStream;\n 38: iload 8\n 40: invokevirtual #86 // Method java/io/PrintStream.println:(I)V\n 43: nop\n 44: nop\n 45: invokestatic #68 // Method java/lang/System.nanoTime:()J\n 48: lload 5\n 50: lsub\n 51: lstore_2\n 52: new #88 // class java/lang/StringBuilder\n 55: dup\n 56: invokespecial #89 // Method java/lang/StringBuilder.\"<init>\":()V\n 59: ldc #91 // String time:\n 61: invokevirtual #95 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 64: lload_2\n 65: invokevirtual #98 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 68: invokevirtual #102 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 71: getstatic #80 // Field java/lang/System.out:Ljava/io/PrintStream;\n 74: swap\n 75: invokevirtual #105 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 78: iconst_0\n 79: istore 4\n 81: invokestatic #68 // Method java/lang/System.nanoTime:()J\n 84: lstore 5\n 86: iconst_0\n 87: istore 7\n 89: ldc #70 // String rosettacode\n 91: checkcast #19 // class java/lang/CharSequence\n 94: ldc #72 // String raisethysword\n 96: invokestatic #107 // Method leveinshtein:(Ljava/lang/CharSequence;Ljava/lang/String;)I\n 99: istore 8\n 101: getstatic #80 // Field java/lang/System.out:Ljava/io/PrintStream;\n 104: iload 8\n 106: invokevirtual #86 // Method java/io/PrintStream.println:(I)V\n 109: nop\n 110: nop\n 111: invokestatic #68 // Method java/lang/System.nanoTime:()J\n 114: lload 5\n 116: lsub\n 117: lstore_2\n 118: new #88 // class java/lang/StringBuilder\n 121: dup\n 122: invokespecial #89 // Method java/lang/StringBuilder.\"<init>\":()V\n 125: ldc #91 // String time:\n 127: invokevirtual #95 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 130: lload_2\n 131: invokevirtual #98 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 134: invokevirtual #102 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 137: getstatic #80 // Field java/lang/System.out:Ljava/io/PrintStream;\n 140: swap\n 141: invokevirtual #105 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 144: return\n}\n", "javap_err": "" }, { "class_path": "mxrpr__learning__0082d8b/com/mxr/example/Leveinshtein.class", "javap": "Compiled from \"leveinshtein.kt\"\npublic final class com.mxr.example.Leveinshtein {\n public com.mxr.example.Leveinshtein();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int leveinshteinDistance(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String lhs\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #23 // String rhs\n 9: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: if_acmpne 19\n 17: iconst_0\n 18: ireturn\n 19: aload_1\n 20: checkcast #25 // class java/lang/CharSequence\n 23: invokeinterface #29, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 28: ifne 35\n 31: iconst_1\n 32: goto 36\n 35: iconst_0\n 36: ifeq 44\n 39: aload_2\n 40: invokevirtual #32 // Method java/lang/String.length:()I\n 43: ireturn\n 44: aload_2\n 45: checkcast #25 // class java/lang/CharSequence\n 48: invokeinterface #29, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 53: ifne 60\n 56: iconst_1\n 57: goto 61\n 60: iconst_0\n 61: ifeq 69\n 64: aload_1\n 65: invokevirtual #32 // Method java/lang/String.length:()I\n 68: ireturn\n 69: iconst_0\n 70: istore 4\n 72: aload_1\n 73: invokevirtual #32 // Method java/lang/String.length:()I\n 76: istore 5\n 78: iload 5\n 80: anewarray #34 // class \"[I\"\n 83: astore 6\n 85: iload 4\n 87: iload 5\n 89: if_icmpge 113\n 92: iload 4\n 94: istore 7\n 96: aload 6\n 98: iload 7\n 100: aload_2\n 101: invokevirtual #32 // Method java/lang/String.length:()I\n 104: newarray int\n 106: aastore\n 107: iinc 4, 1\n 110: goto 85\n 113: aload 6\n 115: astore_3\n 116: iconst_0\n 117: istore 4\n 119: aload_1\n 120: invokevirtual #32 // Method java/lang/String.length:()I\n 123: istore 5\n 125: iload 4\n 127: iload 5\n 129: if_icmpge 146\n 132: aload_3\n 133: iload 4\n 135: aaload\n 136: iconst_0\n 137: iload 4\n 139: iastore\n 140: iinc 4, 1\n 143: goto 125\n 146: iconst_0\n 147: istore 4\n 149: aload_2\n 150: invokevirtual #32 // Method java/lang/String.length:()I\n 153: istore 5\n 155: iload 4\n 157: iload 5\n 159: if_icmpge 176\n 162: aload_3\n 163: iconst_0\n 164: aaload\n 165: iload 4\n 167: iload 4\n 169: iastore\n 170: iinc 4, 1\n 173: goto 155\n 176: iconst_0\n 177: istore 4\n 179: iconst_1\n 180: istore 5\n 182: aload_2\n 183: invokevirtual #32 // Method java/lang/String.length:()I\n 186: istore 6\n 188: iload 5\n 190: iload 6\n 192: if_icmpge 306\n 195: iconst_1\n 196: istore 7\n 198: aload_1\n 199: invokevirtual #32 // Method java/lang/String.length:()I\n 202: istore 8\n 204: iload 7\n 206: iload 8\n 208: if_icmpge 300\n 211: aload_1\n 212: iload 7\n 214: invokevirtual #38 // Method java/lang/String.charAt:(I)C\n 217: aload_2\n 218: iload 5\n 220: invokevirtual #38 // Method java/lang/String.charAt:(I)C\n 223: if_icmpne 230\n 226: iconst_0\n 227: goto 231\n 230: iconst_1\n 231: istore 4\n 233: aload_3\n 234: iload 7\n 236: iconst_1\n 237: isub\n 238: aaload\n 239: iload 5\n 241: iaload\n 242: iconst_1\n 243: iadd\n 244: istore 9\n 246: aload_3\n 247: iload 7\n 249: aaload\n 250: iload 5\n 252: iconst_1\n 253: isub\n 254: iaload\n 255: iconst_1\n 256: iadd\n 257: istore 10\n 259: aload_3\n 260: iload 7\n 262: iconst_1\n 263: isub\n 264: aaload\n 265: iload 5\n 267: iconst_1\n 268: isub\n 269: iaload\n 270: iload 4\n 272: iadd\n 273: istore 11\n 275: aload_3\n 276: iload 7\n 278: aaload\n 279: iload 5\n 281: iload 9\n 283: iload 10\n 285: invokestatic #44 // Method java/lang/Math.min:(II)I\n 288: iload 11\n 290: invokestatic #44 // Method java/lang/Math.min:(II)I\n 293: iastore\n 294: iinc 7, 1\n 297: goto 204\n 300: iinc 5, 1\n 303: goto 188\n 306: aload_3\n 307: aload_1\n 308: invokevirtual #32 // Method java/lang/String.length:()I\n 311: iconst_1\n 312: isub\n 313: aaload\n 314: aload_2\n 315: invokevirtual #32 // Method java/lang/String.length:()I\n 318: iconst_1\n 319: isub\n 320: iaload\n 321: ireturn\n\n private final int cost(char, char);\n Code:\n 0: iload_1\n 1: iload_2\n 2: if_icmpne 9\n 5: iconst_0\n 6: goto 10\n 9: iconst_1\n 10: ireturn\n}\n", "javap_err": "" } ]
eniltonangelim__AlgorithmicToolbox__031bccb/src/main/kotlin/algorithmic_toolbox/week6/PlacingParentheses.kt
package algorithmic_toolbox.week6 import java.util.* import kotlin.math.max import kotlin.math.min fun getMaximValue(exp: String): Long { val n = exp.length / 2 + 1 var min = Array(n){ LongArray(n) } var max = Array(n){ LongArray(n) } for (i in 0 until n) { min[i][i] = (exp[i * 2] - '0').toLong() max[i][i] = (exp[i * 2] - '0').toLong() } for (s in 1 until n ) { for (z in 0 .. n -1 -s) { val j = s + z val minAndMax = getMinAndMax(exp, z, j, min, max) min[z][j] = minAndMax[0] max[z][j] = minAndMax[1] } } return max[0][n - 1] } fun getMinAndMax(exp: String, i: Int, j: Int, w: Array<LongArray>, W: Array<LongArray> ): LongArray { var minAndMax = longArrayOf(Long.MAX_VALUE, Long.MIN_VALUE) for (k in i until j) { val op = exp[k * 2 + 1] val a = eval(w[i][k], w[k+1][j], op) val b = eval(w[i][k], W[k+1][j], op) val c = eval(W[i][k], w[k+1][j], op) val d = eval(W[i][k], W[k+1][j], op) minAndMax[0] = min(a, min(b, min(c, min(d, minAndMax[0])))) minAndMax[1] = max(a, max(b, max(c, max(d, minAndMax[1])))) } return minAndMax } fun eval(a: Long, b: Long, op: Char): Long = when (op) { '+' -> a + b '-' -> a - b '*' -> a * b else -> { assert(false) 0 } } fun main(args: Array<String>) { val scanner = Scanner(System.`in`) val exp = scanner.next() println(getMaximValue(exp)) }
[ { "class_path": "eniltonangelim__AlgorithmicToolbox__031bccb/algorithmic_toolbox/week6/PlacingParenthesesKt.class", "javap": "Compiled from \"PlacingParentheses.kt\"\npublic final class algorithmic_toolbox.week6.PlacingParenthesesKt {\n public static final long getMaximValue(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #9 // String exp\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #21 // Method java/lang/String.length:()I\n 10: iconst_2\n 11: idiv\n 12: iconst_1\n 13: iadd\n 14: istore_1\n 15: iconst_0\n 16: istore_3\n 17: iload_1\n 18: anewarray #23 // class \"[J\"\n 21: astore 4\n 23: iload_3\n 24: iload_1\n 25: if_icmpge 45\n 28: iload_3\n 29: istore 5\n 31: aload 4\n 33: iload 5\n 35: iload_1\n 36: newarray long\n 38: aastore\n 39: iinc 3, 1\n 42: goto 23\n 45: aload 4\n 47: astore_2\n 48: iconst_0\n 49: istore 4\n 51: iload_1\n 52: anewarray #23 // class \"[J\"\n 55: astore 5\n 57: iload 4\n 59: iload_1\n 60: if_icmpge 81\n 63: iload 4\n 65: istore 6\n 67: aload 5\n 69: iload 6\n 71: iload_1\n 72: newarray long\n 74: aastore\n 75: iinc 4, 1\n 78: goto 57\n 81: aload 5\n 83: astore_3\n 84: iconst_0\n 85: istore 4\n 87: iload 4\n 89: iload_1\n 90: if_icmpge 137\n 93: aload_2\n 94: iload 4\n 96: aaload\n 97: iload 4\n 99: aload_0\n 100: iload 4\n 102: iconst_2\n 103: imul\n 104: invokevirtual #27 // Method java/lang/String.charAt:(I)C\n 107: bipush 48\n 109: isub\n 110: i2l\n 111: lastore\n 112: aload_3\n 113: iload 4\n 115: aaload\n 116: iload 4\n 118: aload_0\n 119: iload 4\n 121: iconst_2\n 122: imul\n 123: invokevirtual #27 // Method java/lang/String.charAt:(I)C\n 126: bipush 48\n 128: isub\n 129: i2l\n 130: lastore\n 131: iinc 4, 1\n 134: goto 87\n 137: iconst_1\n 138: istore 4\n 140: iload 4\n 142: iload_1\n 143: if_icmpge 224\n 146: iconst_0\n 147: istore 5\n 149: iload_1\n 150: iconst_1\n 151: isub\n 152: iload 4\n 154: isub\n 155: istore 6\n 157: iload 5\n 159: iload 6\n 161: if_icmpgt 218\n 164: iload 4\n 166: iload 5\n 168: iadd\n 169: istore 7\n 171: aload_0\n 172: iload 5\n 174: iload 7\n 176: aload_2\n 177: aload_3\n 178: invokestatic #31 // Method getMinAndMax:(Ljava/lang/String;II[[J[[J)[J\n 181: astore 8\n 183: aload_2\n 184: iload 5\n 186: aaload\n 187: iload 7\n 189: aload 8\n 191: iconst_0\n 192: laload\n 193: lastore\n 194: aload_3\n 195: iload 5\n 197: aaload\n 198: iload 7\n 200: aload 8\n 202: iconst_1\n 203: laload\n 204: lastore\n 205: iload 5\n 207: iload 6\n 209: if_icmpeq 218\n 212: iinc 5, 1\n 215: goto 164\n 218: iinc 4, 1\n 221: goto 140\n 224: aload_3\n 225: iconst_0\n 226: aaload\n 227: iload_1\n 228: iconst_1\n 229: isub\n 230: laload\n 231: lreturn\n\n public static final long[] getMinAndMax(java.lang.String, int, int, long[][], long[][]);\n Code:\n 0: aload_0\n 1: ldc #9 // String exp\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_3\n 7: ldc #45 // String w\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload 4\n 14: ldc #47 // String W\n 16: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 19: iconst_2\n 20: newarray long\n 22: astore 6\n 24: aload 6\n 26: iconst_0\n 27: ldc2_w #48 // long 9223372036854775807l\n 30: lastore\n 31: aload 6\n 33: iconst_1\n 34: ldc2_w #50 // long -9223372036854775808l\n 37: lastore\n 38: aload 6\n 40: astore 5\n 42: iload_1\n 43: istore 6\n 45: iload 6\n 47: iload_2\n 48: if_icmpge 213\n 51: aload_0\n 52: iload 6\n 54: iconst_2\n 55: imul\n 56: iconst_1\n 57: iadd\n 58: invokevirtual #27 // Method java/lang/String.charAt:(I)C\n 61: istore 7\n 63: aload_3\n 64: iload_1\n 65: aaload\n 66: iload 6\n 68: laload\n 69: aload_3\n 70: iload 6\n 72: iconst_1\n 73: iadd\n 74: aaload\n 75: iload_2\n 76: laload\n 77: iload 7\n 79: invokestatic #55 // Method eval:(JJC)J\n 82: lstore 8\n 84: aload_3\n 85: iload_1\n 86: aaload\n 87: iload 6\n 89: laload\n 90: aload 4\n 92: iload 6\n 94: iconst_1\n 95: iadd\n 96: aaload\n 97: iload_2\n 98: laload\n 99: iload 7\n 101: invokestatic #55 // Method eval:(JJC)J\n 104: lstore 10\n 106: aload 4\n 108: iload_1\n 109: aaload\n 110: iload 6\n 112: laload\n 113: aload_3\n 114: iload 6\n 116: iconst_1\n 117: iadd\n 118: aaload\n 119: iload_2\n 120: laload\n 121: iload 7\n 123: invokestatic #55 // Method eval:(JJC)J\n 126: lstore 12\n 128: aload 4\n 130: iload_1\n 131: aaload\n 132: iload 6\n 134: laload\n 135: aload 4\n 137: iload 6\n 139: iconst_1\n 140: iadd\n 141: aaload\n 142: iload_2\n 143: laload\n 144: iload 7\n 146: invokestatic #55 // Method eval:(JJC)J\n 149: lstore 14\n 151: aload 5\n 153: iconst_0\n 154: lload 8\n 156: lload 10\n 158: lload 12\n 160: lload 14\n 162: aload 5\n 164: iconst_0\n 165: laload\n 166: invokestatic #60 // Method java/lang/Math.min:(JJ)J\n 169: invokestatic #60 // Method java/lang/Math.min:(JJ)J\n 172: invokestatic #60 // Method java/lang/Math.min:(JJ)J\n 175: invokestatic #60 // Method java/lang/Math.min:(JJ)J\n 178: lastore\n 179: aload 5\n 181: iconst_1\n 182: lload 8\n 184: lload 10\n 186: lload 12\n 188: lload 14\n 190: aload 5\n 192: iconst_1\n 193: laload\n 194: invokestatic #62 // Method java/lang/Math.max:(JJ)J\n 197: invokestatic #62 // Method java/lang/Math.max:(JJ)J\n 200: invokestatic #62 // Method java/lang/Math.max:(JJ)J\n 203: invokestatic #62 // Method java/lang/Math.max:(JJ)J\n 206: lastore\n 207: iinc 6, 1\n 210: goto 45\n 213: aload 5\n 215: areturn\n\n public static final long eval(long, long, char);\n Code:\n 0: iload 4\n 2: tableswitch { // 42 to 45\n 42: 44\n 43: 32\n 44: 50\n 45: 38\n default: 50\n }\n 32: lload_0\n 33: lload_2\n 34: ladd\n 35: goto 71\n 38: lload_0\n 39: lload_2\n 40: lsub\n 41: goto 71\n 44: lload_0\n 45: lload_2\n 46: lmul\n 47: goto 71\n 50: getstatic #76 // Field kotlin/_Assertions.ENABLED:Z\n 53: ifeq 70\n 56: ldc #78 // String Assertion failed\n 58: astore 5\n 60: new #80 // class java/lang/AssertionError\n 63: dup\n 64: aload 5\n 66: invokespecial #84 // Method java/lang/AssertionError.\"<init>\":(Ljava/lang/Object;)V\n 69: athrow\n 70: lconst_0\n 71: lreturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #88 // String args\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #90 // class java/util/Scanner\n 9: dup\n 10: getstatic #96 // Field java/lang/System.in:Ljava/io/InputStream;\n 13: invokespecial #99 // Method java/util/Scanner.\"<init>\":(Ljava/io/InputStream;)V\n 16: astore_1\n 17: aload_1\n 18: invokevirtual #103 // Method java/util/Scanner.next:()Ljava/lang/String;\n 21: astore_2\n 22: aload_2\n 23: invokestatic #106 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 26: aload_2\n 27: invokestatic #108 // Method getMaximValue:(Ljava/lang/String;)J\n 30: lstore_3\n 31: getstatic #112 // Field java/lang/System.out:Ljava/io/PrintStream;\n 34: lload_3\n 35: invokevirtual #118 // Method java/io/PrintStream.println:(J)V\n 38: return\n}\n", "javap_err": "" } ]
eniltonangelim__AlgorithmicToolbox__031bccb/src/main/kotlin/algorithmic_toolbox/week2/FibonnaciWarmup.kt
package algorithmic_toolbox.week2 import java.util.* fun calcFib(n: Long): Long { return if (n <= 1) n else calcFib(n - 1) + calcFib(n - 2) } fun power(n: Long, x: Int = 2): Long { if (x == 0) return n return power(n * n, x - 1) } fun lastDigitOfNumber(n: Long): Long { var fibAList = LongArray((n+1).toInt()) fibAList[0] = 0 fibAList[1] = 1 if ( n < 2) return n for (i in 2..n) { fibAList[i.toInt()] = (fibAList[(i-1).toInt()] + fibAList[(i-2).toInt()]) % 10 } return fibAList[n.toInt()] } fun getPisanoPeriod(m: Long): Long { var period = 0L var previous = 0L var current = 1L for (i in 2 until m*m) { val tmpPrevious = previous previous = current current = (tmpPrevious+current) % m if (previous == 0L && current == 1L){ period = i - 1 break } } return period } fun calcFibMod(n: Long, m: Long): Long { if ( n <= 1) return n val pisanoPeriod = getPisanoPeriod(m) val remainder = n % pisanoPeriod var previous = 0L var current = 1L for (i in 0 until remainder-1) { val tmpPrevious = previous previous = current current = (tmpPrevious+current) % m } return current % m } fun calcLastDigitOfTheSumFibonacci(n: Long): Long { if (n <= 2) return n var fibAList = LongArray((n + 1).toInt()) fibAList[0] = 0L fibAList[1] = 1L for (i in 2..n) { fibAList[i.toInt()] = (fibAList[(i - 1).toInt()] + fibAList[(i - 2).toInt()]) % 10 } return fibAList.sum() % 10 } fun calcLastDigitOfTheSumFibonacci(m: Long, n: Long): Long { val pisanoPeriod = 60 // pisanoPeriod(10) = 60 var fibAList = LongArray(pisanoPeriod - 1) fibAList[0] = 0L fibAList[1] = 1L for (i in 2 until pisanoPeriod - 1) { fibAList[i] = (fibAList[i-1] + fibAList[i-2]) % 10 } var begin = m % pisanoPeriod var end = n % pisanoPeriod if (end < begin) end += pisanoPeriod var result = 0L for (i in begin..end) { result += fibAList[(i % pisanoPeriod).toInt()] } return result % 10 } fun calcLastDigitOfTheSumOfSquaresFibonacci(n: Long): Long { val pisanoPeriod = 60 val horizontal = lastDigitOfNumber((n +1) % pisanoPeriod) val vertical = lastDigitOfNumber( n % pisanoPeriod) return (horizontal * vertical) % 10 } fun main(args: Array<String>) { val scanner = Scanner(System.`in`) val n = scanner.nextLong() println(calcFib(n)) }
[ { "class_path": "eniltonangelim__AlgorithmicToolbox__031bccb/algorithmic_toolbox/week2/FibonnaciWarmupKt.class", "javap": "Compiled from \"FibonnaciWarmup.kt\"\npublic final class algorithmic_toolbox.week2.FibonnaciWarmupKt {\n public static final long calcFib(long);\n Code:\n 0: lload_0\n 1: lconst_1\n 2: lcmp\n 3: ifgt 10\n 6: lload_0\n 7: goto 24\n 10: lload_0\n 11: lconst_1\n 12: lsub\n 13: invokestatic #8 // Method calcFib:(J)J\n 16: lload_0\n 17: iconst_2\n 18: i2l\n 19: lsub\n 20: invokestatic #8 // Method calcFib:(J)J\n 23: ladd\n 24: lreturn\n\n public static final long power(long, int);\n Code:\n 0: iload_2\n 1: ifne 6\n 4: lload_0\n 5: lreturn\n 6: lload_0\n 7: lload_0\n 8: lmul\n 9: iload_2\n 10: iconst_1\n 11: isub\n 12: invokestatic #14 // Method power:(JI)J\n 15: lreturn\n\n public static long power$default(long, int, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_2\n 2: iand\n 3: ifeq 8\n 6: iconst_2\n 7: istore_2\n 8: lload_0\n 9: iload_2\n 10: invokestatic #14 // Method power:(JI)J\n 13: lreturn\n\n public static final long lastDigitOfNumber(long);\n Code:\n 0: lload_0\n 1: lconst_1\n 2: ladd\n 3: l2i\n 4: newarray long\n 6: astore_2\n 7: aload_2\n 8: iconst_0\n 9: lconst_0\n 10: lastore\n 11: aload_2\n 12: iconst_1\n 13: lconst_1\n 14: lastore\n 15: lload_0\n 16: ldc2_w #20 // long 2l\n 19: lcmp\n 20: ifge 25\n 23: lload_0\n 24: lreturn\n 25: ldc2_w #20 // long 2l\n 28: lstore_3\n 29: lload_3\n 30: lload_0\n 31: lcmp\n 32: ifgt 70\n 35: aload_2\n 36: lload_3\n 37: l2i\n 38: aload_2\n 39: lload_3\n 40: lconst_1\n 41: lsub\n 42: l2i\n 43: laload\n 44: aload_2\n 45: lload_3\n 46: iconst_2\n 47: i2l\n 48: lsub\n 49: l2i\n 50: laload\n 51: ladd\n 52: bipush 10\n 54: i2l\n 55: lrem\n 56: lastore\n 57: lload_3\n 58: lload_0\n 59: lcmp\n 60: ifeq 70\n 63: lload_3\n 64: lconst_1\n 65: ladd\n 66: lstore_3\n 67: goto 35\n 70: aload_2\n 71: lload_0\n 72: l2i\n 73: laload\n 74: lreturn\n\n public static final long getPisanoPeriod(long);\n Code:\n 0: lconst_0\n 1: lstore_2\n 2: lconst_0\n 3: lstore 4\n 5: lconst_1\n 6: lstore 6\n 8: ldc2_w #20 // long 2l\n 11: lstore 8\n 13: lload_0\n 14: lload_0\n 15: lmul\n 16: lstore 10\n 18: lload 8\n 20: lload 10\n 22: lcmp\n 23: ifge 74\n 26: lload 4\n 28: lstore 12\n 30: lload 6\n 32: lstore 4\n 34: lload 12\n 36: lload 6\n 38: ladd\n 39: lload_0\n 40: lrem\n 41: lstore 6\n 43: lload 4\n 45: lconst_0\n 46: lcmp\n 47: ifne 65\n 50: lload 6\n 52: lconst_1\n 53: lcmp\n 54: ifne 65\n 57: lload 8\n 59: lconst_1\n 60: lsub\n 61: lstore_2\n 62: goto 74\n 65: lload 8\n 67: lconst_1\n 68: ladd\n 69: lstore 8\n 71: goto 18\n 74: lload_2\n 75: lreturn\n\n public static final long calcFibMod(long, long);\n Code:\n 0: lload_0\n 1: lconst_1\n 2: lcmp\n 3: ifgt 8\n 6: lload_0\n 7: lreturn\n 8: lload_2\n 9: invokestatic #35 // Method getPisanoPeriod:(J)J\n 12: lstore 4\n 14: lload_0\n 15: lload 4\n 17: lrem\n 18: lstore 6\n 20: lconst_0\n 21: lstore 8\n 23: lconst_1\n 24: lstore 10\n 26: lconst_0\n 27: lstore 12\n 29: lload 6\n 31: lconst_1\n 32: lsub\n 33: lstore 14\n 35: lload 12\n 37: lload 14\n 39: lcmp\n 40: ifge 69\n 43: lload 8\n 45: lstore 16\n 47: lload 10\n 49: lstore 8\n 51: lload 16\n 53: lload 10\n 55: ladd\n 56: lload_2\n 57: lrem\n 58: lstore 10\n 60: lload 12\n 62: lconst_1\n 63: ladd\n 64: lstore 12\n 66: goto 35\n 69: lload 10\n 71: lload_2\n 72: lrem\n 73: lreturn\n\n public static final long calcLastDigitOfTheSumFibonacci(long);\n Code:\n 0: lload_0\n 1: ldc2_w #20 // long 2l\n 4: lcmp\n 5: ifgt 10\n 8: lload_0\n 9: lreturn\n 10: lload_0\n 11: lconst_1\n 12: ladd\n 13: l2i\n 14: newarray long\n 16: astore_2\n 17: aload_2\n 18: iconst_0\n 19: lconst_0\n 20: lastore\n 21: aload_2\n 22: iconst_1\n 23: lconst_1\n 24: lastore\n 25: ldc2_w #20 // long 2l\n 28: lstore_3\n 29: lload_3\n 30: lload_0\n 31: lcmp\n 32: ifgt 70\n 35: aload_2\n 36: lload_3\n 37: l2i\n 38: aload_2\n 39: lload_3\n 40: lconst_1\n 41: lsub\n 42: l2i\n 43: laload\n 44: aload_2\n 45: lload_3\n 46: iconst_2\n 47: i2l\n 48: lsub\n 49: l2i\n 50: laload\n 51: ladd\n 52: bipush 10\n 54: i2l\n 55: lrem\n 56: lastore\n 57: lload_3\n 58: lload_0\n 59: lcmp\n 60: ifeq 70\n 63: lload_3\n 64: lconst_1\n 65: ladd\n 66: lstore_3\n 67: goto 35\n 70: aload_2\n 71: invokestatic #44 // Method kotlin/collections/ArraysKt.sum:([J)J\n 74: bipush 10\n 76: i2l\n 77: lrem\n 78: lreturn\n\n public static final long calcLastDigitOfTheSumFibonacci(long, long);\n Code:\n 0: bipush 60\n 2: istore 4\n 4: iload 4\n 6: iconst_1\n 7: isub\n 8: newarray long\n 10: astore 5\n 12: aload 5\n 14: iconst_0\n 15: lconst_0\n 16: lastore\n 17: aload 5\n 19: iconst_1\n 20: lconst_1\n 21: lastore\n 22: iconst_2\n 23: istore 6\n 25: iload 4\n 27: iconst_1\n 28: isub\n 29: istore 7\n 31: iload 6\n 33: iload 7\n 35: if_icmpge 68\n 38: aload 5\n 40: iload 6\n 42: aload 5\n 44: iload 6\n 46: iconst_1\n 47: isub\n 48: laload\n 49: aload 5\n 51: iload 6\n 53: iconst_2\n 54: isub\n 55: laload\n 56: ladd\n 57: bipush 10\n 59: i2l\n 60: lrem\n 61: lastore\n 62: iinc 6, 1\n 65: goto 31\n 68: lload_0\n 69: iload 4\n 71: i2l\n 72: lrem\n 73: lstore 6\n 75: lload_2\n 76: iload 4\n 78: i2l\n 79: lrem\n 80: lstore 8\n 82: lload 8\n 84: lload 6\n 86: lcmp\n 87: ifge 98\n 90: lload 8\n 92: iload 4\n 94: i2l\n 95: ladd\n 96: lstore 8\n 98: lconst_0\n 99: lstore 10\n 101: lload 6\n 103: lstore 12\n 105: lload 8\n 107: lstore 14\n 109: lload 12\n 111: lload 14\n 113: lcmp\n 114: ifgt 149\n 117: lload 10\n 119: aload 5\n 121: lload 12\n 123: iload 4\n 125: i2l\n 126: lrem\n 127: l2i\n 128: laload\n 129: ladd\n 130: lstore 10\n 132: lload 12\n 134: lload 14\n 136: lcmp\n 137: ifeq 149\n 140: lload 12\n 142: lconst_1\n 143: ladd\n 144: lstore 12\n 146: goto 117\n 149: lload 10\n 151: bipush 10\n 153: i2l\n 154: lrem\n 155: lreturn\n\n public static final long calcLastDigitOfTheSumOfSquaresFibonacci(long);\n Code:\n 0: bipush 60\n 2: istore_2\n 3: lload_0\n 4: lconst_1\n 5: ladd\n 6: iload_2\n 7: i2l\n 8: lrem\n 9: invokestatic #50 // Method lastDigitOfNumber:(J)J\n 12: lstore_3\n 13: lload_0\n 14: iload_2\n 15: i2l\n 16: lrem\n 17: invokestatic #50 // Method lastDigitOfNumber:(J)J\n 20: lstore 5\n 22: lload_3\n 23: lload 5\n 25: lmul\n 26: bipush 10\n 28: i2l\n 29: lrem\n 30: lreturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #57 // String args\n 3: invokestatic #63 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #65 // class java/util/Scanner\n 9: dup\n 10: getstatic #71 // Field java/lang/System.in:Ljava/io/InputStream;\n 13: invokespecial #75 // Method java/util/Scanner.\"<init>\":(Ljava/io/InputStream;)V\n 16: astore_1\n 17: aload_1\n 18: invokevirtual #79 // Method java/util/Scanner.nextLong:()J\n 21: lstore_2\n 22: lload_2\n 23: invokestatic #8 // Method calcFib:(J)J\n 26: lstore 4\n 28: getstatic #83 // Field java/lang/System.out:Ljava/io/PrintStream;\n 31: lload 4\n 33: invokevirtual #89 // Method java/io/PrintStream.println:(J)V\n 36: return\n}\n", "javap_err": "" } ]
HSAR__KotlinHeroes__69a1187/src/main/kotlin/io/hsar/practice3/ProblemE.kt
package io.hsar.practice3 /* https://codeforces.com/contest/1298/problem/E Input: 10 4 5 4 1 5 4 3 7 1 2 5 4 6 2 1 10 8 3 5 Output: 5 4 0 5 3 3 9 0 2 5 */ fun findNumberOfValidMentees(skillsLookup: List<Pair<Int, Int>>, quarrelsLookup: Map<Int, Set<Int>>, skillLevel: Int, index: Int): Int { var mentees = 0 skillsLookup .forEach { (otherIndex, otherSkillLevel) -> if (otherSkillLevel < skillLevel) { if (!quarrelsLookup[index]!!.contains(otherIndex)) // not in quarrel { mentees++ } } else { return mentees } } return mentees } fun main() { val (numberOfProgrammers, numberOfQuarrels) = readLine()!! .split(" ") .map { it.toInt() } .let { splitArray -> splitArray[0] to splitArray[1] } val skillLevels = readLine()!! .split(" ") .map { it.toInt() } val quarrels = (0 until numberOfQuarrels) .map { readLine()!! .split(" ") .map { it.toInt() } } val quarrelsLookup = List(numberOfProgrammers) { index -> index + 1 to mutableSetOf<Int>() } .toMap() // fill in quarrels quarrels.forEach { quarrel -> val personA = quarrel[0] val personB = quarrel[1] quarrelsLookup[personA]!!.add(personB) quarrelsLookup[personB]!!.add(personA) } val skillsLookup = skillLevels .mapIndexed { index, skillLevel -> index + 1 to skillLevel } .sortedBy { (_, skillLevel) -> skillLevel } val results = skillLevels .mapIndexed { index, skillLevel -> findNumberOfValidMentees(skillsLookup, quarrelsLookup, skillLevel, index + 1) } println(results.joinToString(" ")) }
[ { "class_path": "HSAR__KotlinHeroes__69a1187/io/hsar/practice3/ProblemEKt.class", "javap": "Compiled from \"ProblemE.kt\"\npublic final class io.hsar.practice3.ProblemEKt {\n public static final int findNumberOfValidMentees(java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>>, java.util.Map<java.lang.Integer, ? extends java.util.Set<java.lang.Integer>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #10 // String skillsLookup\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #18 // String quarrelsLookup\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: iconst_0\n 13: istore 4\n 15: aload_0\n 16: checkcast #20 // class java/lang/Iterable\n 19: astore 5\n 21: nop\n 22: iconst_0\n 23: istore 6\n 25: aload 5\n 27: invokeinterface #24, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 7\n 34: aload 7\n 36: invokeinterface #30, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 142\n 44: aload 7\n 46: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: astore 8\n 53: aload 8\n 55: checkcast #36 // class kotlin/Pair\n 58: astore 9\n 60: iconst_0\n 61: istore 10\n 63: aload 9\n 65: invokevirtual #39 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 68: checkcast #41 // class java/lang/Number\n 71: invokevirtual #45 // Method java/lang/Number.intValue:()I\n 74: istore 11\n 76: aload 9\n 78: invokevirtual #48 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 81: checkcast #41 // class java/lang/Number\n 84: invokevirtual #45 // Method java/lang/Number.intValue:()I\n 87: istore 12\n 89: iload 12\n 91: iload_2\n 92: if_icmpge 134\n 95: aload_1\n 96: iload_3\n 97: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 100: invokeinterface #60, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 105: dup\n 106: invokestatic #64 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 109: checkcast #66 // class java/util/Set\n 112: iload 11\n 114: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 117: invokeinterface #70, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 122: ifne 137\n 125: iload 4\n 127: iconst_1\n 128: iadd\n 129: istore 4\n 131: goto 137\n 134: iload 4\n 136: ireturn\n 137: nop\n 138: nop\n 139: goto 34\n 142: nop\n 143: iload 4\n 145: ireturn\n\n public static final void main();\n Code:\n 0: invokestatic #94 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 3: dup\n 4: invokestatic #64 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 7: checkcast #96 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #98 // class java/lang/String\n 14: astore_1\n 15: aload_1\n 16: iconst_0\n 17: ldc #100 // String\n 19: aastore\n 20: aload_1\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #106 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: checkcast #20 // class java/lang/Iterable\n 32: astore_1\n 33: nop\n 34: iconst_0\n 35: istore_2\n 36: aload_1\n 37: astore_3\n 38: new #108 // class java/util/ArrayList\n 41: dup\n 42: aload_1\n 43: bipush 10\n 45: invokestatic #114 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 48: invokespecial #118 // Method java/util/ArrayList.\"<init>\":(I)V\n 51: checkcast #120 // class java/util/Collection\n 54: astore 4\n 56: iconst_0\n 57: istore 5\n 59: aload_3\n 60: invokeinterface #24, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 65: astore 6\n 67: aload 6\n 69: invokeinterface #30, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 74: ifeq 121\n 77: aload 6\n 79: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 84: astore 7\n 86: aload 4\n 88: aload 7\n 90: checkcast #98 // class java/lang/String\n 93: astore 8\n 95: astore 24\n 97: iconst_0\n 98: istore 9\n 100: aload 8\n 102: invokestatic #124 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 105: nop\n 106: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 109: aload 24\n 111: swap\n 112: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 117: pop\n 118: goto 67\n 121: aload 4\n 123: checkcast #86 // class java/util/List\n 126: nop\n 127: astore_2\n 128: iconst_0\n 129: istore_3\n 130: aload_2\n 131: iconst_0\n 132: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 137: aload_2\n 138: iconst_1\n 139: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 144: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 147: nop\n 148: astore_0\n 149: aload_0\n 150: invokevirtual #39 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 153: checkcast #41 // class java/lang/Number\n 156: invokevirtual #45 // Method java/lang/Number.intValue:()I\n 159: istore_1\n 160: aload_0\n 161: invokevirtual #48 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 164: checkcast #41 // class java/lang/Number\n 167: invokevirtual #45 // Method java/lang/Number.intValue:()I\n 170: istore_2\n 171: invokestatic #94 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 174: dup\n 175: invokestatic #64 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 178: checkcast #96 // class java/lang/CharSequence\n 181: iconst_1\n 182: anewarray #98 // class java/lang/String\n 185: astore 4\n 187: aload 4\n 189: iconst_0\n 190: ldc #100 // String\n 192: aastore\n 193: aload 4\n 195: iconst_0\n 196: iconst_0\n 197: bipush 6\n 199: aconst_null\n 200: invokestatic #106 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 203: checkcast #20 // class java/lang/Iterable\n 206: astore 4\n 208: nop\n 209: iconst_0\n 210: istore 5\n 212: aload 4\n 214: astore 6\n 216: new #108 // class java/util/ArrayList\n 219: dup\n 220: aload 4\n 222: bipush 10\n 224: invokestatic #114 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 227: invokespecial #118 // Method java/util/ArrayList.\"<init>\":(I)V\n 230: checkcast #120 // class java/util/Collection\n 233: astore 7\n 235: iconst_0\n 236: istore 8\n 238: aload 6\n 240: invokeinterface #24, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 245: astore 9\n 247: aload 9\n 249: invokeinterface #30, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 254: ifeq 301\n 257: aload 9\n 259: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 264: astore 10\n 266: aload 7\n 268: aload 10\n 270: checkcast #98 // class java/lang/String\n 273: astore 11\n 275: astore 24\n 277: iconst_0\n 278: istore 12\n 280: aload 11\n 282: invokestatic #124 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 285: nop\n 286: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 289: aload 24\n 291: swap\n 292: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 297: pop\n 298: goto 247\n 301: aload 7\n 303: checkcast #86 // class java/util/List\n 306: nop\n 307: astore_3\n 308: iconst_0\n 309: iload_2\n 310: invokestatic #142 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 313: checkcast #20 // class java/lang/Iterable\n 316: astore 5\n 318: nop\n 319: iconst_0\n 320: istore 6\n 322: aload 5\n 324: astore 7\n 326: new #108 // class java/util/ArrayList\n 329: dup\n 330: aload 5\n 332: bipush 10\n 334: invokestatic #114 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 337: invokespecial #118 // Method java/util/ArrayList.\"<init>\":(I)V\n 340: checkcast #120 // class java/util/Collection\n 343: astore 8\n 345: iconst_0\n 346: istore 9\n 348: aload 7\n 350: invokeinterface #24, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 355: astore 10\n 357: aload 10\n 359: invokeinterface #30, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 364: ifeq 537\n 367: aload 10\n 369: checkcast #144 // class kotlin/collections/IntIterator\n 372: invokevirtual #147 // Method kotlin/collections/IntIterator.nextInt:()I\n 375: istore 11\n 377: aload 8\n 379: iload 11\n 381: istore 12\n 383: astore 24\n 385: iconst_0\n 386: istore 13\n 388: invokestatic #94 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 391: dup\n 392: invokestatic #64 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 395: checkcast #96 // class java/lang/CharSequence\n 398: iconst_1\n 399: anewarray #98 // class java/lang/String\n 402: astore 14\n 404: aload 14\n 406: iconst_0\n 407: ldc #100 // String\n 409: aastore\n 410: aload 14\n 412: iconst_0\n 413: iconst_0\n 414: bipush 6\n 416: aconst_null\n 417: invokestatic #106 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 420: checkcast #20 // class java/lang/Iterable\n 423: astore 14\n 425: nop\n 426: iconst_0\n 427: istore 15\n 429: aload 14\n 431: astore 16\n 433: new #108 // class java/util/ArrayList\n 436: dup\n 437: aload 14\n 439: bipush 10\n 441: invokestatic #114 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 444: invokespecial #118 // Method java/util/ArrayList.\"<init>\":(I)V\n 447: checkcast #120 // class java/util/Collection\n 450: astore 17\n 452: iconst_0\n 453: istore 18\n 455: aload 16\n 457: invokeinterface #24, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 462: astore 19\n 464: aload 19\n 466: invokeinterface #30, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 471: ifeq 518\n 474: aload 19\n 476: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 481: astore 20\n 483: aload 17\n 485: aload 20\n 487: checkcast #98 // class java/lang/String\n 490: astore 21\n 492: astore 22\n 494: iconst_0\n 495: istore 23\n 497: aload 21\n 499: invokestatic #124 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 502: nop\n 503: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 506: aload 22\n 508: swap\n 509: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 514: pop\n 515: goto 464\n 518: aload 17\n 520: checkcast #86 // class java/util/List\n 523: nop\n 524: nop\n 525: aload 24\n 527: swap\n 528: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 533: pop\n 534: goto 357\n 537: aload 8\n 539: checkcast #86 // class java/util/List\n 542: nop\n 543: astore 4\n 545: new #108 // class java/util/ArrayList\n 548: dup\n 549: iload_1\n 550: invokespecial #118 // Method java/util/ArrayList.\"<init>\":(I)V\n 553: astore 6\n 555: iconst_0\n 556: istore 7\n 558: iload 7\n 560: iload_1\n 561: if_icmpge 612\n 564: iload 7\n 566: istore 8\n 568: aload 6\n 570: iload 8\n 572: istore 9\n 574: astore 24\n 576: iconst_0\n 577: istore 10\n 579: iload 9\n 581: iconst_1\n 582: iadd\n 583: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 586: new #149 // class java/util/LinkedHashSet\n 589: dup\n 590: invokespecial #151 // Method java/util/LinkedHashSet.\"<init>\":()V\n 593: checkcast #66 // class java/util/Set\n 596: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 599: aload 24\n 601: swap\n 602: invokevirtual #152 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 605: pop\n 606: iinc 7, 1\n 609: goto 558\n 612: aload 6\n 614: checkcast #86 // class java/util/List\n 617: checkcast #20 // class java/lang/Iterable\n 620: invokestatic #158 // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;\n 623: astore 5\n 625: aload 4\n 627: checkcast #20 // class java/lang/Iterable\n 630: astore 6\n 632: iconst_0\n 633: istore 7\n 635: aload 6\n 637: invokeinterface #24, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 642: astore 8\n 644: aload 8\n 646: invokeinterface #30, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 651: ifeq 770\n 654: aload 8\n 656: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 661: astore 9\n 663: aload 9\n 665: checkcast #86 // class java/util/List\n 668: astore 10\n 670: iconst_0\n 671: istore 11\n 673: aload 10\n 675: iconst_0\n 676: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 681: checkcast #41 // class java/lang/Number\n 684: invokevirtual #45 // Method java/lang/Number.intValue:()I\n 687: istore 12\n 689: aload 10\n 691: iconst_1\n 692: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 697: checkcast #41 // class java/lang/Number\n 700: invokevirtual #45 // Method java/lang/Number.intValue:()I\n 703: istore 13\n 705: aload 5\n 707: iload 12\n 709: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 712: invokeinterface #60, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 717: dup\n 718: invokestatic #64 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 721: checkcast #66 // class java/util/Set\n 724: iload 13\n 726: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 729: invokeinterface #159, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 734: pop\n 735: aload 5\n 737: iload 13\n 739: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 742: invokeinterface #60, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 747: dup\n 748: invokestatic #64 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 751: checkcast #66 // class java/util/Set\n 754: iload 12\n 756: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 759: invokeinterface #159, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 764: pop\n 765: nop\n 766: nop\n 767: goto 644\n 770: nop\n 771: aload_3\n 772: checkcast #20 // class java/lang/Iterable\n 775: astore 7\n 777: nop\n 778: iconst_0\n 779: istore 8\n 781: aload 7\n 783: astore 9\n 785: new #108 // class java/util/ArrayList\n 788: dup\n 789: aload 7\n 791: bipush 10\n 793: invokestatic #114 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 796: invokespecial #118 // Method java/util/ArrayList.\"<init>\":(I)V\n 799: checkcast #120 // class java/util/Collection\n 802: astore 10\n 804: iconst_0\n 805: istore 11\n 807: iconst_0\n 808: istore 12\n 810: aload 9\n 812: invokeinterface #24, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 817: astore 13\n 819: aload 13\n 821: invokeinterface #30, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 826: ifeq 901\n 829: aload 13\n 831: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 836: astore 14\n 838: aload 10\n 840: iload 12\n 842: iinc 12, 1\n 845: istore 15\n 847: iload 15\n 849: ifge 855\n 852: invokestatic #162 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 855: iload 15\n 857: aload 14\n 859: checkcast #41 // class java/lang/Number\n 862: invokevirtual #45 // Method java/lang/Number.intValue:()I\n 865: istore 16\n 867: istore 17\n 869: astore 24\n 871: iconst_0\n 872: istore 18\n 874: iload 17\n 876: iconst_1\n 877: iadd\n 878: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 881: iload 16\n 883: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 886: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 889: aload 24\n 891: swap\n 892: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 897: pop\n 898: goto 819\n 901: aload 10\n 903: checkcast #86 // class java/util/List\n 906: nop\n 907: checkcast #20 // class java/lang/Iterable\n 910: astore 7\n 912: nop\n 913: iconst_0\n 914: istore 8\n 916: aload 7\n 918: new #164 // class io/hsar/practice3/ProblemEKt$main$$inlined$sortedBy$1\n 921: dup\n 922: invokespecial #165 // Method io/hsar/practice3/ProblemEKt$main$$inlined$sortedBy$1.\"<init>\":()V\n 925: checkcast #167 // class java/util/Comparator\n 928: invokestatic #171 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 931: astore 6\n 933: aload_3\n 934: checkcast #20 // class java/lang/Iterable\n 937: astore 8\n 939: nop\n 940: iconst_0\n 941: istore 9\n 943: aload 8\n 945: astore 10\n 947: new #108 // class java/util/ArrayList\n 950: dup\n 951: aload 8\n 953: bipush 10\n 955: invokestatic #114 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 958: invokespecial #118 // Method java/util/ArrayList.\"<init>\":(I)V\n 961: checkcast #120 // class java/util/Collection\n 964: astore 11\n 966: iconst_0\n 967: istore 12\n 969: iconst_0\n 970: istore 13\n 972: aload 10\n 974: invokeinterface #24, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 979: astore 14\n 981: aload 14\n 983: invokeinterface #30, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 988: ifeq 1064\n 991: aload 14\n 993: invokeinterface #34, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 998: astore 15\n 1000: aload 11\n 1002: iload 13\n 1004: iinc 13, 1\n 1007: istore 16\n 1009: iload 16\n 1011: ifge 1017\n 1014: invokestatic #162 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 1017: iload 16\n 1019: aload 15\n 1021: checkcast #41 // class java/lang/Number\n 1024: invokevirtual #45 // Method java/lang/Number.intValue:()I\n 1027: istore 17\n 1029: istore 18\n 1031: astore 24\n 1033: iconst_0\n 1034: istore 19\n 1036: aload 6\n 1038: aload 5\n 1040: iload 17\n 1042: iload 18\n 1044: iconst_1\n 1045: iadd\n 1046: invokestatic #173 // Method findNumberOfValidMentees:(Ljava/util/List;Ljava/util/Map;II)I\n 1049: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1052: aload 24\n 1054: swap\n 1055: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 1060: pop\n 1061: goto 981\n 1064: aload 11\n 1066: checkcast #86 // class java/util/List\n 1069: nop\n 1070: astore 7\n 1072: aload 7\n 1074: checkcast #20 // class java/lang/Iterable\n 1077: ldc #100 // String\n 1079: checkcast #96 // class java/lang/CharSequence\n 1082: aconst_null\n 1083: aconst_null\n 1084: iconst_0\n 1085: aconst_null\n 1086: aconst_null\n 1087: bipush 62\n 1089: aconst_null\n 1090: invokestatic #177 // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;\n 1093: getstatic #183 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1096: swap\n 1097: invokevirtual #188 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 1100: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #225 // Method main:()V\n 3: return\n}\n", "javap_err": "" }, { "class_path": "HSAR__KotlinHeroes__69a1187/io/hsar/practice3/ProblemEKt$main$$inlined$sortedBy$1.class", "javap": "Compiled from \"Comparisons.kt\"\npublic final class io.hsar.practice3.ProblemEKt$main$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public io.hsar.practice3.ProblemEKt$main$$inlined$sortedBy$1();\n Code:\n 0: aload_0\n 1: invokespecial #16 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int compare(T, T);\n Code:\n 0: aload_1\n 1: checkcast #23 // class kotlin/Pair\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokevirtual #27 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 12: checkcast #29 // class java/lang/Number\n 15: invokevirtual #33 // Method java/lang/Number.intValue:()I\n 18: istore 5\n 20: iload 5\n 22: invokestatic #39 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 25: checkcast #41 // class java/lang/Comparable\n 28: aload_2\n 29: checkcast #23 // class kotlin/Pair\n 32: astore_3\n 33: astore 6\n 35: iconst_0\n 36: istore 4\n 38: aload_3\n 39: invokevirtual #27 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 42: checkcast #29 // class java/lang/Number\n 45: invokevirtual #33 // Method java/lang/Number.intValue:()I\n 48: istore 5\n 50: iload 5\n 52: invokestatic #39 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 55: aload 6\n 57: swap\n 58: checkcast #41 // class java/lang/Comparable\n 61: invokestatic #47 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 64: ireturn\n}\n", "javap_err": "" } ]
josue-lubaki__Rational__cbeb74d/src/ca/josue/rational/Rational.kt
package ca.josue.rational import java.math.BigInteger class Rational (private val numerator: BigInteger, private val denominator: BigInteger) : Comparable<Rational>{ init { if (denominator == BigInteger.ZERO) throw IllegalArgumentException("Denominator cannot be 0") } // Redefinition des opérateurs operator fun plus(other: Rational): Rational { val num = (numerator * other.denominator) + (denominator * other.numerator) val den = denominator * other.denominator return num.divBy(den) } operator fun minus(other: Rational) : Rational{ val num = (numerator * other.denominator) - (denominator * other.numerator) val den = denominator * other.denominator return num.divBy(den) } operator fun times(other: Rational): Rational{ return (numerator * other.numerator).divBy(denominator * other.denominator) } operator fun div(other: Rational):Rational{ return (numerator * other.denominator).divBy(denominator * other.numerator) } operator fun unaryMinus(): Rational = Rational(numerator.negate(),denominator) override fun compareTo(other: Rational): Int { return (numerator * other.denominator).compareTo(denominator * other.numerator) } private fun simplify(rational: Rational): Rational{ val greatCommonDivisor = rational.numerator.gcd(rational.denominator) val num = rational.numerator / greatCommonDivisor val den = rational.denominator / greatCommonDivisor return Rational(num, den) } private fun formatRational(): String = "$numerator/$denominator" override fun equals(other: Any?): Boolean { if (this === other) return true other as Rational val thisSimplified = simplify(this) val otherSimplified = simplify(other) val thisAsDouble = thisSimplified.numerator.toDouble() / thisSimplified.denominator.toDouble() val otherAsDouble = otherSimplified.numerator.toDouble() / otherSimplified.denominator.toDouble() return thisAsDouble == otherAsDouble } override fun toString(): String { val shouldBeOneNumber = denominator == BigInteger.ONE || numerator % denominator == BigInteger.ZERO return when { shouldBeOneNumber -> (numerator / denominator).toString() else -> { val thisSimplified = simplify(this) if (thisSimplified.denominator < BigInteger.ZERO || (thisSimplified.numerator < BigInteger.ZERO && thisSimplified.denominator < BigInteger.ZERO)){ Rational(thisSimplified.numerator.negate(), thisSimplified.denominator.negate()).formatRational() } else{ Rational(thisSimplified.numerator, thisSimplified.denominator).formatRational() } } } } override fun hashCode(): Int { var result = numerator.hashCode() result = 31 * result + denominator.hashCode() return result } } fun String.toRational():Rational{ val ratio = split('/') return when (ratio.size) { 1 -> Rational(ratio[0].toBigInteger(), BigInteger.ONE) 2 -> Rational(ratio[0].toBigInteger(), ratio[1].toBigInteger()) else -> throw IllegalArgumentException("Invalid format") } } // Infix infix fun Int.divBy(other: Int):Rational = Rational(toBigInteger(), other.toBigInteger()) infix fun Long.divBy(other: Long): Rational = Rational(toBigInteger(), other.toBigInteger()) infix fun BigInteger.divBy(other: BigInteger) = Rational(this, other) fun main() { val half = 1 divBy 2 val third = 1 divBy 3 val sum: Rational = half + third println(5 divBy 6 == sum) val difference: Rational = half - third println(1 divBy 6 == difference) val product: Rational = half * third println(1 divBy 6 == product) val quotient: Rational = half / third println(3 divBy 2 == quotient) val negation: Rational = -half println(-1 divBy 2 == negation) println((2 divBy 1).toString() == "2") println((-2 divBy 4).toString() == "-1/2") println("117/1098".toRational().toString() == "13/122") val twoThirds = 2 divBy 3 println(half < twoThirds) println(half in third..twoThirds) println(2000000000L divBy 4000000000L == 1 divBy 2) println("912016490186296920119201192141970416029".toBigInteger() divBy "1824032980372593840238402384283940832058".toBigInteger() == 1 divBy 2) }
[ { "class_path": "josue-lubaki__Rational__cbeb74d/ca/josue/rational/RationalKt.class", "javap": "Compiled from \"Rational.kt\"\npublic final class ca.josue.rational.RationalKt {\n public static final ca.josue.rational.Rational toRational(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #9 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #17 // class java/lang/CharSequence\n 10: iconst_1\n 11: newarray char\n 13: astore_2\n 14: aload_2\n 15: iconst_0\n 16: bipush 47\n 18: castore\n 19: aload_2\n 20: iconst_0\n 21: iconst_0\n 22: bipush 6\n 24: aconst_null\n 25: invokestatic #23 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 28: astore_1\n 29: aload_1\n 30: invokeinterface #29, 1 // InterfaceMethod java/util/List.size:()I\n 35: tableswitch { // 1 to 2\n 1: 56\n 2: 92\n default: 136\n }\n 56: new #31 // class ca/josue/rational/Rational\n 59: dup\n 60: new #33 // class java/math/BigInteger\n 63: dup\n 64: aload_1\n 65: iconst_0\n 66: invokeinterface #37, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 71: checkcast #39 // class java/lang/String\n 74: invokespecial #43 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 77: getstatic #47 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;\n 80: dup\n 81: ldc #48 // String ONE\n 83: invokestatic #51 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 86: invokespecial #54 // Method ca/josue/rational/Rational.\"<init>\":(Ljava/math/BigInteger;Ljava/math/BigInteger;)V\n 89: goto 146\n 92: new #31 // class ca/josue/rational/Rational\n 95: dup\n 96: new #33 // class java/math/BigInteger\n 99: dup\n 100: aload_1\n 101: iconst_0\n 102: invokeinterface #37, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 107: checkcast #39 // class java/lang/String\n 110: invokespecial #43 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 113: new #33 // class java/math/BigInteger\n 116: dup\n 117: aload_1\n 118: iconst_1\n 119: invokeinterface #37, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 124: checkcast #39 // class java/lang/String\n 127: invokespecial #43 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 130: invokespecial #54 // Method ca/josue/rational/Rational.\"<init>\":(Ljava/math/BigInteger;Ljava/math/BigInteger;)V\n 133: goto 146\n 136: new #56 // class java/lang/IllegalArgumentException\n 139: dup\n 140: ldc #58 // String Invalid format\n 142: invokespecial #59 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 145: athrow\n 146: areturn\n\n public static final ca.josue.rational.Rational divBy(int, int);\n Code:\n 0: new #31 // class ca/josue/rational/Rational\n 3: dup\n 4: iload_0\n 5: i2l\n 6: invokestatic #71 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 9: dup\n 10: ldc #73 // String valueOf(...)\n 12: invokestatic #51 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 15: iload_1\n 16: i2l\n 17: invokestatic #71 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 20: dup\n 21: ldc #73 // String valueOf(...)\n 23: invokestatic #51 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 26: invokespecial #54 // Method ca/josue/rational/Rational.\"<init>\":(Ljava/math/BigInteger;Ljava/math/BigInteger;)V\n 29: areturn\n\n public static final ca.josue.rational.Rational divBy(long, long);\n Code:\n 0: new #31 // class ca/josue/rational/Rational\n 3: dup\n 4: lload_0\n 5: invokestatic #71 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 8: dup\n 9: ldc #73 // String valueOf(...)\n 11: invokestatic #51 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: lload_2\n 15: invokestatic #71 // Method java/math/BigInteger.valueOf:(J)Ljava/math/BigInteger;\n 18: dup\n 19: ldc #73 // String valueOf(...)\n 21: invokestatic #51 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 24: invokespecial #54 // Method ca/josue/rational/Rational.\"<init>\":(Ljava/math/BigInteger;Ljava/math/BigInteger;)V\n 27: areturn\n\n public static final ca.josue.rational.Rational divBy(java.math.BigInteger, java.math.BigInteger);\n Code:\n 0: aload_0\n 1: ldc #9 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #80 // String other\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #31 // class ca/josue/rational/Rational\n 15: dup\n 16: aload_0\n 17: aload_1\n 18: invokespecial #54 // Method ca/josue/rational/Rational.\"<init>\":(Ljava/math/BigInteger;Ljava/math/BigInteger;)V\n 21: areturn\n\n public static final void main();\n Code:\n 0: iconst_1\n 1: iconst_2\n 2: invokestatic #84 // Method divBy:(II)Lca/josue/rational/Rational;\n 5: astore_0\n 6: iconst_1\n 7: iconst_3\n 8: invokestatic #84 // Method divBy:(II)Lca/josue/rational/Rational;\n 11: astore_1\n 12: aload_0\n 13: aload_1\n 14: invokevirtual #88 // Method ca/josue/rational/Rational.plus:(Lca/josue/rational/Rational;)Lca/josue/rational/Rational;\n 17: astore_2\n 18: iconst_5\n 19: bipush 6\n 21: invokestatic #84 // Method divBy:(II)Lca/josue/rational/Rational;\n 24: aload_2\n 25: invokestatic #92 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 28: istore_3\n 29: getstatic #98 // Field java/lang/System.out:Ljava/io/PrintStream;\n 32: iload_3\n 33: invokevirtual #104 // Method java/io/PrintStream.println:(Z)V\n 36: aload_0\n 37: aload_1\n 38: invokevirtual #107 // Method ca/josue/rational/Rational.minus:(Lca/josue/rational/Rational;)Lca/josue/rational/Rational;\n 41: astore_3\n 42: iconst_1\n 43: bipush 6\n 45: invokestatic #84 // Method divBy:(II)Lca/josue/rational/Rational;\n 48: aload_3\n 49: invokestatic #92 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 52: istore 4\n 54: getstatic #98 // Field java/lang/System.out:Ljava/io/PrintStream;\n 57: iload 4\n 59: invokevirtual #104 // Method java/io/PrintStream.println:(Z)V\n 62: aload_0\n 63: aload_1\n 64: invokevirtual #110 // Method ca/josue/rational/Rational.times:(Lca/josue/rational/Rational;)Lca/josue/rational/Rational;\n 67: astore 4\n 69: iconst_1\n 70: bipush 6\n 72: invokestatic #84 // Method divBy:(II)Lca/josue/rational/Rational;\n 75: aload 4\n 77: invokestatic #92 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 80: istore 5\n 82: getstatic #98 // Field java/lang/System.out:Ljava/io/PrintStream;\n 85: iload 5\n 87: invokevirtual #104 // Method java/io/PrintStream.println:(Z)V\n 90: aload_0\n 91: aload_1\n 92: invokevirtual #113 // Method ca/josue/rational/Rational.div:(Lca/josue/rational/Rational;)Lca/josue/rational/Rational;\n 95: astore 5\n 97: iconst_3\n 98: iconst_2\n 99: invokestatic #84 // Method divBy:(II)Lca/josue/rational/Rational;\n 102: aload 5\n 104: invokestatic #92 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 107: istore 6\n 109: getstatic #98 // Field java/lang/System.out:Ljava/io/PrintStream;\n 112: iload 6\n 114: invokevirtual #104 // Method java/io/PrintStream.println:(Z)V\n 117: aload_0\n 118: invokevirtual #117 // Method ca/josue/rational/Rational.unaryMinus:()Lca/josue/rational/Rational;\n 121: astore 6\n 123: iconst_m1\n 124: iconst_2\n 125: invokestatic #84 // Method divBy:(II)Lca/josue/rational/Rational;\n 128: aload 6\n 130: invokestatic #92 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 133: istore 7\n 135: getstatic #98 // Field java/lang/System.out:Ljava/io/PrintStream;\n 138: iload 7\n 140: invokevirtual #104 // Method java/io/PrintStream.println:(Z)V\n 143: iconst_2\n 144: iconst_1\n 145: invokestatic #84 // Method divBy:(II)Lca/josue/rational/Rational;\n 148: invokevirtual #121 // Method ca/josue/rational/Rational.toString:()Ljava/lang/String;\n 151: ldc #123 // String 2\n 153: invokestatic #92 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 156: istore 7\n 158: getstatic #98 // Field java/lang/System.out:Ljava/io/PrintStream;\n 161: iload 7\n 163: invokevirtual #104 // Method java/io/PrintStream.println:(Z)V\n 166: bipush -2\n 168: iconst_4\n 169: invokestatic #84 // Method divBy:(II)Lca/josue/rational/Rational;\n 172: invokevirtual #121 // Method ca/josue/rational/Rational.toString:()Ljava/lang/String;\n 175: ldc #125 // String -1/2\n 177: invokestatic #92 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 180: istore 7\n 182: getstatic #98 // Field java/lang/System.out:Ljava/io/PrintStream;\n 185: iload 7\n 187: invokevirtual #104 // Method java/io/PrintStream.println:(Z)V\n 190: ldc #127 // String 117/1098\n 192: invokestatic #129 // Method toRational:(Ljava/lang/String;)Lca/josue/rational/Rational;\n 195: invokevirtual #121 // Method ca/josue/rational/Rational.toString:()Ljava/lang/String;\n 198: ldc #131 // String 13/122\n 200: invokestatic #92 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 203: istore 7\n 205: getstatic #98 // Field java/lang/System.out:Ljava/io/PrintStream;\n 208: iload 7\n 210: invokevirtual #104 // Method java/io/PrintStream.println:(Z)V\n 213: iconst_2\n 214: iconst_3\n 215: invokestatic #84 // Method divBy:(II)Lca/josue/rational/Rational;\n 218: astore 7\n 220: aload_0\n 221: aload 7\n 223: invokevirtual #135 // Method ca/josue/rational/Rational.compareTo:(Lca/josue/rational/Rational;)I\n 226: ifge 233\n 229: iconst_1\n 230: goto 234\n 233: iconst_0\n 234: istore 8\n 236: getstatic #98 // Field java/lang/System.out:Ljava/io/PrintStream;\n 239: iload 8\n 241: invokevirtual #104 // Method java/io/PrintStream.println:(Z)V\n 244: iconst_0\n 245: aload_0\n 246: checkcast #137 // class java/lang/Comparable\n 249: aload_1\n 250: invokeinterface #140, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 255: if_icmpgt 280\n 258: aload_0\n 259: checkcast #137 // class java/lang/Comparable\n 262: aload 7\n 264: invokeinterface #140, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 269: ifgt 276\n 272: iconst_1\n 273: goto 281\n 276: iconst_0\n 277: goto 281\n 280: iconst_0\n 281: istore 8\n 283: getstatic #98 // Field java/lang/System.out:Ljava/io/PrintStream;\n 286: iload 8\n 288: invokevirtual #104 // Method java/io/PrintStream.println:(Z)V\n 291: ldc2_w #141 // long 2000000000l\n 294: ldc2_w #143 // long 4000000000l\n 297: invokestatic #146 // Method divBy:(JJ)Lca/josue/rational/Rational;\n 300: iconst_1\n 301: iconst_2\n 302: invokestatic #84 // Method divBy:(II)Lca/josue/rational/Rational;\n 305: invokestatic #92 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 308: istore 8\n 310: getstatic #98 // Field java/lang/System.out:Ljava/io/PrintStream;\n 313: iload 8\n 315: invokevirtual #104 // Method java/io/PrintStream.println:(Z)V\n 318: new #33 // class java/math/BigInteger\n 321: dup\n 322: ldc #148 // String 912016490186296920119201192141970416029\n 324: invokespecial #43 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 327: new #33 // class java/math/BigInteger\n 330: dup\n 331: ldc #150 // String 1824032980372593840238402384283940832058\n 333: invokespecial #43 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;)V\n 336: invokestatic #152 // Method divBy:(Ljava/math/BigInteger;Ljava/math/BigInteger;)Lca/josue/rational/Rational;\n 339: iconst_1\n 340: iconst_2\n 341: invokestatic #84 // Method divBy:(II)Lca/josue/rational/Rational;\n 344: invokestatic #92 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 347: istore 8\n 349: getstatic #98 // Field java/lang/System.out:Ljava/io/PrintStream;\n 352: iload 8\n 354: invokevirtual #104 // Method java/io/PrintStream.println:(Z)V\n 357: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #164 // Method main:()V\n 3: return\n}\n", "javap_err": "" }, { "class_path": "josue-lubaki__Rational__cbeb74d/ca/josue/rational/Rational.class", "javap": "Compiled from \"Rational.kt\"\npublic final class ca.josue.rational.Rational implements java.lang.Comparable<ca.josue.rational.Rational> {\n private final java.math.BigInteger numerator;\n\n private final java.math.BigInteger denominator;\n\n public ca.josue.rational.Rational(java.math.BigInteger, java.math.BigInteger);\n Code:\n 0: aload_1\n 1: ldc #12 // String numerator\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #20 // String denominator\n 9: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokespecial #23 // Method java/lang/Object.\"<init>\":()V\n 16: aload_0\n 17: aload_1\n 18: putfield #26 // Field numerator:Ljava/math/BigInteger;\n 21: aload_0\n 22: aload_2\n 23: putfield #28 // Field denominator:Ljava/math/BigInteger;\n 26: nop\n 27: aload_0\n 28: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 31: getstatic #33 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 34: invokestatic #37 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 37: ifeq 50\n 40: new #39 // class java/lang/IllegalArgumentException\n 43: dup\n 44: ldc #41 // String Denominator cannot be 0\n 46: invokespecial #44 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 49: athrow\n 50: nop\n 51: return\n\n public final ca.josue.rational.Rational plus(ca.josue.rational.Rational);\n Code:\n 0: aload_1\n 1: ldc #50 // String other\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: nop\n 7: aload_0\n 8: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 11: aload_1\n 12: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 15: invokevirtual #54 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 18: dup\n 19: ldc #56 // String multiply(...)\n 21: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 24: aload_0\n 25: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 28: aload_1\n 29: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 32: invokevirtual #54 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 35: dup\n 36: ldc #56 // String multiply(...)\n 38: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 41: invokevirtual #62 // Method java/math/BigInteger.add:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 44: dup\n 45: ldc #64 // String add(...)\n 47: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 50: astore_2\n 51: aload_0\n 52: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 55: aload_1\n 56: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 59: invokevirtual #54 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 62: dup\n 63: ldc #56 // String multiply(...)\n 65: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 68: astore_3\n 69: aload_2\n 70: aload_3\n 71: invokestatic #70 // Method ca/josue/rational/RationalKt.divBy:(Ljava/math/BigInteger;Ljava/math/BigInteger;)Lca/josue/rational/Rational;\n 74: areturn\n\n public final ca.josue.rational.Rational minus(ca.josue.rational.Rational);\n Code:\n 0: aload_1\n 1: ldc #50 // String other\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: nop\n 7: aload_0\n 8: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 11: aload_1\n 12: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 15: invokevirtual #54 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 18: dup\n 19: ldc #56 // String multiply(...)\n 21: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 24: aload_0\n 25: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 28: aload_1\n 29: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 32: invokevirtual #54 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 35: dup\n 36: ldc #56 // String multiply(...)\n 38: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 41: invokevirtual #76 // Method java/math/BigInteger.subtract:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 44: dup\n 45: ldc #78 // String subtract(...)\n 47: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 50: astore_2\n 51: aload_0\n 52: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 55: aload_1\n 56: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 59: invokevirtual #54 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 62: dup\n 63: ldc #56 // String multiply(...)\n 65: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 68: astore_3\n 69: aload_2\n 70: aload_3\n 71: invokestatic #70 // Method ca/josue/rational/RationalKt.divBy:(Ljava/math/BigInteger;Ljava/math/BigInteger;)Lca/josue/rational/Rational;\n 74: areturn\n\n public final ca.josue.rational.Rational times(ca.josue.rational.Rational);\n Code:\n 0: aload_1\n 1: ldc #50 // String other\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 10: aload_1\n 11: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 14: invokevirtual #54 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 17: dup\n 18: ldc #56 // String multiply(...)\n 20: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 23: aload_0\n 24: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 27: aload_1\n 28: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 31: invokevirtual #54 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 34: dup\n 35: ldc #56 // String multiply(...)\n 37: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 40: invokestatic #70 // Method ca/josue/rational/RationalKt.divBy:(Ljava/math/BigInteger;Ljava/math/BigInteger;)Lca/josue/rational/Rational;\n 43: areturn\n\n public final ca.josue.rational.Rational div(ca.josue.rational.Rational);\n Code:\n 0: aload_1\n 1: ldc #50 // String other\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 10: aload_1\n 11: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 14: invokevirtual #54 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 17: dup\n 18: ldc #56 // String multiply(...)\n 20: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 23: aload_0\n 24: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 27: aload_1\n 28: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 31: invokevirtual #54 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 34: dup\n 35: ldc #56 // String multiply(...)\n 37: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 40: invokestatic #70 // Method ca/josue/rational/RationalKt.divBy:(Ljava/math/BigInteger;Ljava/math/BigInteger;)Lca/josue/rational/Rational;\n 43: areturn\n\n public final ca.josue.rational.Rational unaryMinus();\n Code:\n 0: new #2 // class ca/josue/rational/Rational\n 3: dup\n 4: aload_0\n 5: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 8: invokevirtual #86 // Method java/math/BigInteger.negate:()Ljava/math/BigInteger;\n 11: dup\n 12: ldc #88 // String negate(...)\n 14: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 17: aload_0\n 18: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 21: invokespecial #90 // Method \"<init>\":(Ljava/math/BigInteger;Ljava/math/BigInteger;)V\n 24: areturn\n\n public int compareTo(ca.josue.rational.Rational);\n Code:\n 0: aload_1\n 1: ldc #50 // String other\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 10: aload_1\n 11: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 14: invokevirtual #54 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 17: dup\n 18: ldc #56 // String multiply(...)\n 20: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 23: aload_0\n 24: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 27: aload_1\n 28: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 31: invokevirtual #54 // Method java/math/BigInteger.multiply:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 34: dup\n 35: ldc #56 // String multiply(...)\n 37: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 40: invokevirtual #95 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I\n 43: ireturn\n\n private final ca.josue.rational.Rational simplify(ca.josue.rational.Rational);\n Code:\n 0: aload_1\n 1: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 4: aload_1\n 5: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 8: invokevirtual #99 // Method java/math/BigInteger.gcd:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 11: astore_2\n 12: aload_1\n 13: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 16: aload_2\n 17: invokestatic #103 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 20: aload_2\n 21: invokevirtual #106 // Method java/math/BigInteger.divide:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 24: dup\n 25: ldc #108 // String divide(...)\n 27: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 30: astore_3\n 31: aload_1\n 32: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 35: aload_2\n 36: invokevirtual #106 // Method java/math/BigInteger.divide:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 39: dup\n 40: ldc #108 // String divide(...)\n 42: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 45: astore 4\n 47: new #2 // class ca/josue/rational/Rational\n 50: dup\n 51: aload_3\n 52: aload 4\n 54: invokespecial #90 // Method \"<init>\":(Ljava/math/BigInteger;Ljava/math/BigInteger;)V\n 57: areturn\n\n private final java.lang.String formatRational();\n Code:\n 0: new #114 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #115 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: aload_0\n 8: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 11: invokevirtual #119 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 14: bipush 47\n 16: invokevirtual #122 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 19: aload_0\n 20: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 23: invokevirtual #119 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 26: invokevirtual #125 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 29: areturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_1\n 8: ldc #130 // String null cannot be cast to non-null type ca.josue.rational.Rational\n 10: invokestatic #132 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: aload_1\n 14: checkcast #2 // class ca/josue/rational/Rational\n 17: pop\n 18: aload_0\n 19: aload_0\n 20: invokespecial #134 // Method simplify:(Lca/josue/rational/Rational;)Lca/josue/rational/Rational;\n 23: astore_2\n 24: aload_0\n 25: aload_1\n 26: checkcast #2 // class ca/josue/rational/Rational\n 29: invokespecial #134 // Method simplify:(Lca/josue/rational/Rational;)Lca/josue/rational/Rational;\n 32: astore_3\n 33: aload_2\n 34: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 37: invokevirtual #138 // Method java/math/BigInteger.doubleValue:()D\n 40: aload_2\n 41: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 44: invokevirtual #138 // Method java/math/BigInteger.doubleValue:()D\n 47: ddiv\n 48: dstore 4\n 50: aload_3\n 51: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 54: invokevirtual #138 // Method java/math/BigInteger.doubleValue:()D\n 57: aload_3\n 58: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 61: invokevirtual #138 // Method java/math/BigInteger.doubleValue:()D\n 64: ddiv\n 65: dstore 6\n 67: dload 4\n 69: dload 6\n 71: dcmpg\n 72: ifne 79\n 75: iconst_1\n 76: goto 80\n 79: iconst_0\n 80: ireturn\n\n public java.lang.String toString();\n Code:\n 0: aload_0\n 1: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 4: getstatic #147 // Field java/math/BigInteger.ONE:Ljava/math/BigInteger;\n 7: invokestatic #37 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 10: ifne 39\n 13: aload_0\n 14: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 17: aload_0\n 18: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 21: invokevirtual #150 // Method java/math/BigInteger.remainder:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 24: dup\n 25: ldc #152 // String remainder(...)\n 27: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 30: getstatic #33 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 33: invokestatic #37 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 36: ifeq 43\n 39: iconst_1\n 40: goto 44\n 43: iconst_0\n 44: istore_1\n 45: nop\n 46: iload_1\n 47: ifeq 79\n 50: aload_0\n 51: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 54: aload_0\n 55: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 58: invokevirtual #106 // Method java/math/BigInteger.divide:(Ljava/math/BigInteger;)Ljava/math/BigInteger;\n 61: dup\n 62: ldc #108 // String divide(...)\n 64: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 67: invokevirtual #153 // Method java/math/BigInteger.toString:()Ljava/lang/String;\n 70: dup\n 71: ldc #155 // String toString(...)\n 73: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 76: goto 181\n 79: aload_0\n 80: aload_0\n 81: invokespecial #134 // Method simplify:(Lca/josue/rational/Rational;)Lca/josue/rational/Rational;\n 84: astore_2\n 85: aload_2\n 86: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 89: getstatic #33 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 92: invokevirtual #95 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I\n 95: iflt 124\n 98: aload_2\n 99: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 102: getstatic #33 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 105: invokevirtual #95 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I\n 108: ifge 163\n 111: aload_2\n 112: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 115: getstatic #33 // Field java/math/BigInteger.ZERO:Ljava/math/BigInteger;\n 118: invokevirtual #95 // Method java/math/BigInteger.compareTo:(Ljava/math/BigInteger;)I\n 121: ifge 163\n 124: new #2 // class ca/josue/rational/Rational\n 127: dup\n 128: aload_2\n 129: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 132: invokevirtual #86 // Method java/math/BigInteger.negate:()Ljava/math/BigInteger;\n 135: dup\n 136: ldc #88 // String negate(...)\n 138: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 141: aload_2\n 142: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 145: invokevirtual #86 // Method java/math/BigInteger.negate:()Ljava/math/BigInteger;\n 148: dup\n 149: ldc #88 // String negate(...)\n 151: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 154: invokespecial #90 // Method \"<init>\":(Ljava/math/BigInteger;Ljava/math/BigInteger;)V\n 157: invokespecial #157 // Method formatRational:()Ljava/lang/String;\n 160: goto 181\n 163: new #2 // class ca/josue/rational/Rational\n 166: dup\n 167: aload_2\n 168: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 171: aload_2\n 172: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 175: invokespecial #90 // Method \"<init>\":(Ljava/math/BigInteger;Ljava/math/BigInteger;)V\n 178: invokespecial #157 // Method formatRational:()Ljava/lang/String;\n 181: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #26 // Field numerator:Ljava/math/BigInteger;\n 4: invokevirtual #165 // Method java/math/BigInteger.hashCode:()I\n 7: istore_1\n 8: bipush 31\n 10: iload_1\n 11: imul\n 12: aload_0\n 13: getfield #28 // Field denominator:Ljava/math/BigInteger;\n 16: invokevirtual #165 // Method java/math/BigInteger.hashCode:()I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: ireturn\n\n public int compareTo(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #2 // class ca/josue/rational/Rational\n 5: invokevirtual #170 // Method compareTo:(Lca/josue/rational/Rational;)I\n 8: ireturn\n}\n", "javap_err": "" } ]
jksolbakken__aoc2022__afc771f/src/main/kotlin/jks/Day2.kt
package jks import java.io.File import java.lang.RuntimeException import jks.Item.PAPER import jks.Item.ROCK import jks.Item.SCISSORS import jks.Result.DRAW import jks.Result.LOSER import jks.Result.WINNER fun main() { val uri = object {}::class.java.getResource("/day2_input")?.toURI() ?: throw RuntimeException("oh noes!") val lines = File(uri).readLines() val sumPart1 = lines .map { chars -> Round(toItem(chars[0]), toItem(chars[2])) } .map { round -> Pair(round, result(round)) } .sumOf { (round, result) -> round.myItem.points + result.points } println("Part 1: $sumPart1") val sumPart2 = lines .map { chars -> Pair(toItem(chars[0]), toResult(chars[2])) } .map { Pair(it, itemForDesiredResult(it.first, it.second)) } .sumOf { (othersItemAndResult, myItem) -> myItem.points + othersItemAndResult.second.points } println("Part 2: $sumPart2") } data class Round(val opponentsItem: Item, val myItem: Item) enum class Item(val points: Int){ ROCK(1), PAPER(2), SCISSORS(3) } enum class Result(val points: Int) { WINNER(6), DRAW(3), LOSER(0) } private fun result(round: Round): Result = when (round) { Round(ROCK, ROCK) -> DRAW Round(ROCK, PAPER) -> WINNER Round(ROCK, SCISSORS) -> LOSER Round(PAPER, ROCK) -> LOSER Round(PAPER, PAPER) -> DRAW Round(PAPER, SCISSORS) -> WINNER Round(SCISSORS, ROCK) -> WINNER Round(SCISSORS, PAPER) -> LOSER Round(SCISSORS, SCISSORS) -> DRAW else -> throw RuntimeException("$round is not valid") } private fun toItem(c: Char) = when (c) { 'A', 'X' -> ROCK 'B', 'Y' -> PAPER 'C', 'Z' -> SCISSORS else -> throw RuntimeException("oh noes!") } private fun toResult(c: Char) = when (c) { 'X' -> LOSER 'Y' -> DRAW 'Z' -> WINNER else -> throw RuntimeException("oh noes!") } private fun itemForDesiredResult(othersItem: Item, desiredResult: Result) = when { desiredResult == DRAW -> othersItem othersItem == ROCK && desiredResult == WINNER -> PAPER othersItem == ROCK && desiredResult == LOSER -> SCISSORS othersItem == PAPER && desiredResult == WINNER -> SCISSORS othersItem == PAPER && desiredResult == LOSER -> ROCK othersItem == SCISSORS && desiredResult == WINNER -> ROCK othersItem == SCISSORS && desiredResult == LOSER -> PAPER else -> throw RuntimeException("oh noes!") }
[ { "class_path": "jksolbakken__aoc2022__afc771f/jks/Day2Kt.class", "javap": "Compiled from \"Day2.kt\"\npublic final class jks.Day2Kt {\n public static final void main();\n Code:\n 0: new #8 // class jks/Day2Kt$main$uri$1\n 3: dup\n 4: invokespecial #11 // Method jks/Day2Kt$main$uri$1.\"<init>\":()V\n 7: invokevirtual #15 // Method java/lang/Object.getClass:()Ljava/lang/Class;\n 10: ldc #17 // String /day2_input\n 12: invokevirtual #23 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;\n 15: dup\n 16: ifnull 26\n 19: invokevirtual #29 // Method java/net/URL.toURI:()Ljava/net/URI;\n 22: dup\n 23: ifnonnull 37\n 26: pop\n 27: new #31 // class java/lang/RuntimeException\n 30: dup\n 31: ldc #33 // String oh noes!\n 33: invokespecial #36 // Method java/lang/RuntimeException.\"<init>\":(Ljava/lang/String;)V\n 36: athrow\n 37: astore_0\n 38: new #38 // class java/io/File\n 41: dup\n 42: aload_0\n 43: invokespecial #41 // Method java/io/File.\"<init>\":(Ljava/net/URI;)V\n 46: aconst_null\n 47: iconst_1\n 48: aconst_null\n 49: invokestatic #47 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 52: astore_1\n 53: aload_1\n 54: checkcast #49 // class java/lang/Iterable\n 57: astore_3\n 58: nop\n 59: iconst_0\n 60: istore 4\n 62: aload_3\n 63: astore 5\n 65: new #51 // class java/util/ArrayList\n 68: dup\n 69: aload_3\n 70: bipush 10\n 72: invokestatic #57 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 75: invokespecial #60 // Method java/util/ArrayList.\"<init>\":(I)V\n 78: checkcast #62 // class java/util/Collection\n 81: astore 6\n 83: iconst_0\n 84: istore 7\n 86: aload 5\n 88: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 93: astore 8\n 95: aload 8\n 97: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 102: ifeq 165\n 105: aload 8\n 107: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 112: astore 9\n 114: aload 6\n 116: aload 9\n 118: checkcast #78 // class java/lang/String\n 121: astore 10\n 123: astore 13\n 125: iconst_0\n 126: istore 11\n 128: new #80 // class jks/Round\n 131: dup\n 132: aload 10\n 134: iconst_0\n 135: invokevirtual #84 // Method java/lang/String.charAt:(I)C\n 138: invokestatic #88 // Method toItem:(C)Ljks/Item;\n 141: aload 10\n 143: iconst_2\n 144: invokevirtual #84 // Method java/lang/String.charAt:(I)C\n 147: invokestatic #88 // Method toItem:(C)Ljks/Item;\n 150: invokespecial #91 // Method jks/Round.\"<init>\":(Ljks/Item;Ljks/Item;)V\n 153: aload 13\n 155: swap\n 156: invokeinterface #95, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 161: pop\n 162: goto 95\n 165: aload 6\n 167: checkcast #97 // class java/util/List\n 170: nop\n 171: checkcast #49 // class java/lang/Iterable\n 174: astore_3\n 175: nop\n 176: iconst_0\n 177: istore 4\n 179: aload_3\n 180: astore 5\n 182: new #51 // class java/util/ArrayList\n 185: dup\n 186: aload_3\n 187: bipush 10\n 189: invokestatic #57 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 192: invokespecial #60 // Method java/util/ArrayList.\"<init>\":(I)V\n 195: checkcast #62 // class java/util/Collection\n 198: astore 6\n 200: iconst_0\n 201: istore 7\n 203: aload 5\n 205: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 210: astore 8\n 212: aload 8\n 214: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 219: ifeq 271\n 222: aload 8\n 224: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 229: astore 9\n 231: aload 6\n 233: aload 9\n 235: checkcast #80 // class jks/Round\n 238: astore 10\n 240: astore 13\n 242: iconst_0\n 243: istore 11\n 245: new #99 // class kotlin/Pair\n 248: dup\n 249: aload 10\n 251: aload 10\n 253: invokestatic #103 // Method result:(Ljks/Round;)Ljks/Result;\n 256: invokespecial #106 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 259: aload 13\n 261: swap\n 262: invokeinterface #95, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 267: pop\n 268: goto 212\n 271: aload 6\n 273: checkcast #97 // class java/util/List\n 276: nop\n 277: checkcast #49 // class java/lang/Iterable\n 280: astore_3\n 281: iconst_0\n 282: istore 4\n 284: aload_3\n 285: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 290: astore 5\n 292: aload 5\n 294: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 299: ifeq 371\n 302: aload 5\n 304: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 309: astore 6\n 311: iload 4\n 313: aload 6\n 315: checkcast #99 // class kotlin/Pair\n 318: astore 7\n 320: istore 13\n 322: iconst_0\n 323: istore 8\n 325: aload 7\n 327: invokevirtual #109 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 330: checkcast #80 // class jks/Round\n 333: astore 9\n 335: aload 7\n 337: invokevirtual #112 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 340: checkcast #114 // class jks/Result\n 343: astore 10\n 345: aload 9\n 347: invokevirtual #118 // Method jks/Round.getMyItem:()Ljks/Item;\n 350: invokevirtual #124 // Method jks/Item.getPoints:()I\n 353: aload 10\n 355: invokevirtual #125 // Method jks/Result.getPoints:()I\n 358: iadd\n 359: istore 14\n 361: iload 13\n 363: iload 14\n 365: iadd\n 366: istore 4\n 368: goto 292\n 371: iload 4\n 373: istore_2\n 374: new #127 // class java/lang/StringBuilder\n 377: dup\n 378: invokespecial #128 // Method java/lang/StringBuilder.\"<init>\":()V\n 381: ldc #130 // String Part 1:\n 383: invokevirtual #134 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 386: iload_2\n 387: invokevirtual #137 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 390: invokevirtual #141 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 393: getstatic #147 // Field java/lang/System.out:Ljava/io/PrintStream;\n 396: swap\n 397: invokevirtual #153 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 400: aload_1\n 401: checkcast #49 // class java/lang/Iterable\n 404: astore 4\n 406: nop\n 407: iconst_0\n 408: istore 5\n 410: aload 4\n 412: astore 6\n 414: new #51 // class java/util/ArrayList\n 417: dup\n 418: aload 4\n 420: bipush 10\n 422: invokestatic #57 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 425: invokespecial #60 // Method java/util/ArrayList.\"<init>\":(I)V\n 428: checkcast #62 // class java/util/Collection\n 431: astore 7\n 433: iconst_0\n 434: istore 8\n 436: aload 6\n 438: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 443: astore 9\n 445: aload 9\n 447: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 452: ifeq 515\n 455: aload 9\n 457: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 462: astore 10\n 464: aload 7\n 466: aload 10\n 468: checkcast #78 // class java/lang/String\n 471: astore 11\n 473: astore 13\n 475: iconst_0\n 476: istore 12\n 478: new #99 // class kotlin/Pair\n 481: dup\n 482: aload 11\n 484: iconst_0\n 485: invokevirtual #84 // Method java/lang/String.charAt:(I)C\n 488: invokestatic #88 // Method toItem:(C)Ljks/Item;\n 491: aload 11\n 493: iconst_2\n 494: invokevirtual #84 // Method java/lang/String.charAt:(I)C\n 497: invokestatic #157 // Method toResult:(C)Ljks/Result;\n 500: invokespecial #106 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 503: aload 13\n 505: swap\n 506: invokeinterface #95, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 511: pop\n 512: goto 445\n 515: aload 7\n 517: checkcast #97 // class java/util/List\n 520: nop\n 521: checkcast #49 // class java/lang/Iterable\n 524: astore 4\n 526: nop\n 527: iconst_0\n 528: istore 5\n 530: aload 4\n 532: astore 6\n 534: new #51 // class java/util/ArrayList\n 537: dup\n 538: aload 4\n 540: bipush 10\n 542: invokestatic #57 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 545: invokespecial #60 // Method java/util/ArrayList.\"<init>\":(I)V\n 548: checkcast #62 // class java/util/Collection\n 551: astore 7\n 553: iconst_0\n 554: istore 8\n 556: aload 6\n 558: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 563: astore 9\n 565: aload 9\n 567: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 572: ifeq 638\n 575: aload 9\n 577: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 582: astore 10\n 584: aload 7\n 586: aload 10\n 588: checkcast #99 // class kotlin/Pair\n 591: astore 11\n 593: astore 13\n 595: iconst_0\n 596: istore 12\n 598: new #99 // class kotlin/Pair\n 601: dup\n 602: aload 11\n 604: aload 11\n 606: invokevirtual #160 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 609: checkcast #120 // class jks/Item\n 612: aload 11\n 614: invokevirtual #163 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 617: checkcast #114 // class jks/Result\n 620: invokestatic #167 // Method itemForDesiredResult:(Ljks/Item;Ljks/Result;)Ljks/Item;\n 623: invokespecial #106 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 626: aload 13\n 628: swap\n 629: invokeinterface #95, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 634: pop\n 635: goto 565\n 638: aload 7\n 640: checkcast #97 // class java/util/List\n 643: nop\n 644: checkcast #49 // class java/lang/Iterable\n 647: astore 4\n 649: iconst_0\n 650: istore 5\n 652: aload 4\n 654: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 659: astore 6\n 661: aload 6\n 663: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 668: ifeq 743\n 671: aload 6\n 673: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 678: astore 7\n 680: iload 5\n 682: aload 7\n 684: checkcast #99 // class kotlin/Pair\n 687: astore 8\n 689: istore 13\n 691: iconst_0\n 692: istore 9\n 694: aload 8\n 696: invokevirtual #109 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 699: checkcast #99 // class kotlin/Pair\n 702: astore 10\n 704: aload 8\n 706: invokevirtual #112 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 709: checkcast #120 // class jks/Item\n 712: astore 11\n 714: aload 11\n 716: invokevirtual #124 // Method jks/Item.getPoints:()I\n 719: aload 10\n 721: invokevirtual #163 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 724: checkcast #114 // class jks/Result\n 727: invokevirtual #125 // Method jks/Result.getPoints:()I\n 730: iadd\n 731: istore 14\n 733: iload 13\n 735: iload 14\n 737: iadd\n 738: istore 5\n 740: goto 661\n 743: iload 5\n 745: istore_3\n 746: new #127 // class java/lang/StringBuilder\n 749: dup\n 750: invokespecial #128 // Method java/lang/StringBuilder.\"<init>\":()V\n 753: ldc #169 // String Part 2:\n 755: invokevirtual #134 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 758: iload_3\n 759: invokevirtual #137 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 762: invokevirtual #141 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 765: getstatic #147 // Field java/lang/System.out:Ljava/io/PrintStream;\n 768: swap\n 769: invokevirtual #153 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 772: return\n\n private static final jks.Result result(jks.Round);\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: new #80 // class jks/Round\n 6: dup\n 7: getstatic #206 // Field jks/Item.ROCK:Ljks/Item;\n 10: getstatic #206 // Field jks/Item.ROCK:Ljks/Item;\n 13: invokespecial #91 // Method jks/Round.\"<init>\":(Ljks/Item;Ljks/Item;)V\n 16: invokestatic #212 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 19: ifeq 28\n 22: getstatic #215 // Field jks/Result.DRAW:Ljks/Result;\n 25: goto 263\n 28: aload_1\n 29: new #80 // class jks/Round\n 32: dup\n 33: getstatic #206 // Field jks/Item.ROCK:Ljks/Item;\n 36: getstatic #218 // Field jks/Item.PAPER:Ljks/Item;\n 39: invokespecial #91 // Method jks/Round.\"<init>\":(Ljks/Item;Ljks/Item;)V\n 42: invokestatic #212 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 45: ifeq 54\n 48: getstatic #221 // Field jks/Result.WINNER:Ljks/Result;\n 51: goto 263\n 54: aload_1\n 55: new #80 // class jks/Round\n 58: dup\n 59: getstatic #206 // Field jks/Item.ROCK:Ljks/Item;\n 62: getstatic #224 // Field jks/Item.SCISSORS:Ljks/Item;\n 65: invokespecial #91 // Method jks/Round.\"<init>\":(Ljks/Item;Ljks/Item;)V\n 68: invokestatic #212 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 71: ifeq 80\n 74: getstatic #227 // Field jks/Result.LOSER:Ljks/Result;\n 77: goto 263\n 80: aload_1\n 81: new #80 // class jks/Round\n 84: dup\n 85: getstatic #218 // Field jks/Item.PAPER:Ljks/Item;\n 88: getstatic #206 // Field jks/Item.ROCK:Ljks/Item;\n 91: invokespecial #91 // Method jks/Round.\"<init>\":(Ljks/Item;Ljks/Item;)V\n 94: invokestatic #212 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 97: ifeq 106\n 100: getstatic #227 // Field jks/Result.LOSER:Ljks/Result;\n 103: goto 263\n 106: aload_1\n 107: new #80 // class jks/Round\n 110: dup\n 111: getstatic #218 // Field jks/Item.PAPER:Ljks/Item;\n 114: getstatic #218 // Field jks/Item.PAPER:Ljks/Item;\n 117: invokespecial #91 // Method jks/Round.\"<init>\":(Ljks/Item;Ljks/Item;)V\n 120: invokestatic #212 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 123: ifeq 132\n 126: getstatic #215 // Field jks/Result.DRAW:Ljks/Result;\n 129: goto 263\n 132: aload_1\n 133: new #80 // class jks/Round\n 136: dup\n 137: getstatic #218 // Field jks/Item.PAPER:Ljks/Item;\n 140: getstatic #224 // Field jks/Item.SCISSORS:Ljks/Item;\n 143: invokespecial #91 // Method jks/Round.\"<init>\":(Ljks/Item;Ljks/Item;)V\n 146: invokestatic #212 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 149: ifeq 158\n 152: getstatic #221 // Field jks/Result.WINNER:Ljks/Result;\n 155: goto 263\n 158: aload_1\n 159: new #80 // class jks/Round\n 162: dup\n 163: getstatic #224 // Field jks/Item.SCISSORS:Ljks/Item;\n 166: getstatic #206 // Field jks/Item.ROCK:Ljks/Item;\n 169: invokespecial #91 // Method jks/Round.\"<init>\":(Ljks/Item;Ljks/Item;)V\n 172: invokestatic #212 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 175: ifeq 184\n 178: getstatic #221 // Field jks/Result.WINNER:Ljks/Result;\n 181: goto 263\n 184: aload_1\n 185: new #80 // class jks/Round\n 188: dup\n 189: getstatic #224 // Field jks/Item.SCISSORS:Ljks/Item;\n 192: getstatic #218 // Field jks/Item.PAPER:Ljks/Item;\n 195: invokespecial #91 // Method jks/Round.\"<init>\":(Ljks/Item;Ljks/Item;)V\n 198: invokestatic #212 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 201: ifeq 210\n 204: getstatic #227 // Field jks/Result.LOSER:Ljks/Result;\n 207: goto 263\n 210: aload_1\n 211: new #80 // class jks/Round\n 214: dup\n 215: getstatic #224 // Field jks/Item.SCISSORS:Ljks/Item;\n 218: getstatic #224 // Field jks/Item.SCISSORS:Ljks/Item;\n 221: invokespecial #91 // Method jks/Round.\"<init>\":(Ljks/Item;Ljks/Item;)V\n 224: invokestatic #212 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 227: ifeq 236\n 230: getstatic #215 // Field jks/Result.DRAW:Ljks/Result;\n 233: goto 263\n 236: new #31 // class java/lang/RuntimeException\n 239: dup\n 240: new #127 // class java/lang/StringBuilder\n 243: dup\n 244: invokespecial #128 // Method java/lang/StringBuilder.\"<init>\":()V\n 247: aload_0\n 248: invokevirtual #230 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 251: ldc #232 // String is not valid\n 253: invokevirtual #134 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 256: invokevirtual #141 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 259: invokespecial #36 // Method java/lang/RuntimeException.\"<init>\":(Ljava/lang/String;)V\n 262: athrow\n 263: areturn\n\n private static final jks.Item toItem(char);\n Code:\n 0: iload_0\n 1: lookupswitch { // 6\n 65: 60\n 66: 66\n 67: 72\n 88: 60\n 89: 66\n 90: 72\n default: 78\n }\n 60: getstatic #206 // Field jks/Item.ROCK:Ljks/Item;\n 63: goto 88\n 66: getstatic #218 // Field jks/Item.PAPER:Ljks/Item;\n 69: goto 88\n 72: getstatic #224 // Field jks/Item.SCISSORS:Ljks/Item;\n 75: goto 88\n 78: new #31 // class java/lang/RuntimeException\n 81: dup\n 82: ldc #33 // String oh noes!\n 84: invokespecial #36 // Method java/lang/RuntimeException.\"<init>\":(Ljava/lang/String;)V\n 87: athrow\n 88: areturn\n\n private static final jks.Result toResult(char);\n Code:\n 0: iload_0\n 1: tableswitch { // 88 to 90\n 88: 28\n 89: 34\n 90: 40\n default: 46\n }\n 28: getstatic #227 // Field jks/Result.LOSER:Ljks/Result;\n 31: goto 56\n 34: getstatic #215 // Field jks/Result.DRAW:Ljks/Result;\n 37: goto 56\n 40: getstatic #221 // Field jks/Result.WINNER:Ljks/Result;\n 43: goto 56\n 46: new #31 // class java/lang/RuntimeException\n 49: dup\n 50: ldc #33 // String oh noes!\n 52: invokespecial #36 // Method java/lang/RuntimeException.\"<init>\":(Ljava/lang/String;)V\n 55: athrow\n 56: areturn\n\n private static final jks.Item itemForDesiredResult(jks.Item, jks.Result);\n Code:\n 0: nop\n 1: aload_1\n 2: getstatic #215 // Field jks/Result.DRAW:Ljks/Result;\n 5: if_acmpne 12\n 8: aload_0\n 9: goto 142\n 12: aload_0\n 13: getstatic #206 // Field jks/Item.ROCK:Ljks/Item;\n 16: if_acmpne 32\n 19: aload_1\n 20: getstatic #221 // Field jks/Result.WINNER:Ljks/Result;\n 23: if_acmpne 32\n 26: getstatic #218 // Field jks/Item.PAPER:Ljks/Item;\n 29: goto 142\n 32: aload_0\n 33: getstatic #206 // Field jks/Item.ROCK:Ljks/Item;\n 36: if_acmpne 52\n 39: aload_1\n 40: getstatic #227 // Field jks/Result.LOSER:Ljks/Result;\n 43: if_acmpne 52\n 46: getstatic #224 // Field jks/Item.SCISSORS:Ljks/Item;\n 49: goto 142\n 52: aload_0\n 53: getstatic #218 // Field jks/Item.PAPER:Ljks/Item;\n 56: if_acmpne 72\n 59: aload_1\n 60: getstatic #221 // Field jks/Result.WINNER:Ljks/Result;\n 63: if_acmpne 72\n 66: getstatic #224 // Field jks/Item.SCISSORS:Ljks/Item;\n 69: goto 142\n 72: aload_0\n 73: getstatic #218 // Field jks/Item.PAPER:Ljks/Item;\n 76: if_acmpne 92\n 79: aload_1\n 80: getstatic #227 // Field jks/Result.LOSER:Ljks/Result;\n 83: if_acmpne 92\n 86: getstatic #206 // Field jks/Item.ROCK:Ljks/Item;\n 89: goto 142\n 92: aload_0\n 93: getstatic #224 // Field jks/Item.SCISSORS:Ljks/Item;\n 96: if_acmpne 112\n 99: aload_1\n 100: getstatic #221 // Field jks/Result.WINNER:Ljks/Result;\n 103: if_acmpne 112\n 106: getstatic #206 // Field jks/Item.ROCK:Ljks/Item;\n 109: goto 142\n 112: aload_0\n 113: getstatic #224 // Field jks/Item.SCISSORS:Ljks/Item;\n 116: if_acmpne 132\n 119: aload_1\n 120: getstatic #227 // Field jks/Result.LOSER:Ljks/Result;\n 123: if_acmpne 132\n 126: getstatic #218 // Field jks/Item.PAPER:Ljks/Item;\n 129: goto 142\n 132: new #31 // class java/lang/RuntimeException\n 135: dup\n 136: ldc #33 // String oh noes!\n 138: invokespecial #36 // Method java/lang/RuntimeException.\"<init>\":(Ljava/lang/String;)V\n 141: athrow\n 142: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #239 // Method main:()V\n 3: return\n}\n", "javap_err": "" }, { "class_path": "jksolbakken__aoc2022__afc771f/jks/Day2Kt$main$uri$1.class", "javap": "Compiled from \"Day2.kt\"\npublic final class jks.Day2Kt$main$uri$1 {\n jks.Day2Kt$main$uri$1();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n}\n", "javap_err": "" } ]
klnusbaum__aoc2023__d30db24/src/problems/day2/daytwo.kt
package problems.day2 import java.io.File private const val gamesFile = "input/day2/games.txt" fun main() { part1() part2() } private data class Round(val red: Int, val green: Int, val blue: Int) private data class Game(val id: Int, val rounds: List<Round>) { fun allRedUnder(max: Int) = rounds.all { it.red <= max } fun allGreenUnder(max: Int) = rounds.all { it.green <= max } fun allBlueUnder(max: Int) = rounds.all { it.blue <= max } fun power() = maxRed() * maxGreen() * maxBlue() private fun maxRed() = rounds.maxOf { it.red } private fun maxGreen() = rounds.maxOf { it.green } private fun maxBlue() = rounds.maxOf { it.blue } } private fun part1() { val idSum = File(gamesFile).bufferedReader().useLines { sumIDs(it) } println("ID sum is $idSum") } private fun sumIDs(lines: Sequence<String>) = lines.map { it.toGame() } .filter { it.allRedUnder(12) and it.allGreenUnder(13) and it.allBlueUnder(14) } .map { it.id } .sum() private fun String.toGame(): Game = Game( this.substringBefore(":").toGameID(), this.substringAfter(":").toRounds(), ) private fun String.toGameID(): Int = this.trim().removePrefix("Game ").toInt() private fun String.toRounds(): List<Round> = this.trim().split(";").map { it.toRound() } private fun String.toRound(): Round { var red = 0 var green = 0 var blue = 0 this.split(",").map { it.trim() }.forEach { val amount = it.substringBefore(" ").toInt() when (it.substringAfter(" ")) { "red" -> red = amount "blue" -> blue = amount "green" -> green = amount } } return Round(red, green, blue) } private fun part2() { val powerSum = File(gamesFile).bufferedReader().useLines { sumPower(it) } println("Power sum is $powerSum") } private fun sumPower(lines: Sequence<String>) = lines.map { it.toGame().power() }.sum()
[ { "class_path": "klnusbaum__aoc2023__d30db24/problems/day2/DaytwoKt.class", "javap": "Compiled from \"daytwo.kt\"\npublic final class problems.day2.DaytwoKt {\n private static final java.lang.String gamesFile;\n\n public static final void main();\n Code:\n 0: invokestatic #9 // Method part1:()V\n 3: invokestatic #12 // Method part2:()V\n 6: return\n\n private static final void part1();\n Code:\n 0: new #16 // class java/io/File\n 3: dup\n 4: ldc #18 // String input/day2/games.txt\n 6: invokespecial #22 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_1\n 10: getstatic #28 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_2\n 14: sipush 8192\n 17: istore_3\n 18: aload_1\n 19: astore 4\n 21: new #30 // class java/io/InputStreamReader\n 24: dup\n 25: new #32 // class java/io/FileInputStream\n 28: dup\n 29: aload 4\n 31: invokespecial #35 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 34: checkcast #37 // class java/io/InputStream\n 37: aload_2\n 38: invokespecial #40 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 41: checkcast #42 // class java/io/Reader\n 44: astore 4\n 46: aload 4\n 48: instanceof #44 // class java/io/BufferedReader\n 51: ifeq 62\n 54: aload 4\n 56: checkcast #44 // class java/io/BufferedReader\n 59: goto 72\n 62: new #44 // class java/io/BufferedReader\n 65: dup\n 66: aload 4\n 68: iload_3\n 69: invokespecial #47 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 72: checkcast #42 // class java/io/Reader\n 75: astore_1\n 76: nop\n 77: iconst_0\n 78: istore_2\n 79: aload_1\n 80: astore_3\n 81: sipush 8192\n 84: istore 4\n 86: aload_3\n 87: instanceof #44 // class java/io/BufferedReader\n 90: ifeq 100\n 93: aload_3\n 94: checkcast #44 // class java/io/BufferedReader\n 97: goto 110\n 100: new #44 // class java/io/BufferedReader\n 103: dup\n 104: aload_3\n 105: iload 4\n 107: invokespecial #47 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 110: checkcast #49 // class java/io/Closeable\n 113: astore_3\n 114: aconst_null\n 115: astore 4\n 117: nop\n 118: aload_3\n 119: checkcast #44 // class java/io/BufferedReader\n 122: astore 5\n 124: iconst_0\n 125: istore 6\n 127: aload 5\n 129: invokestatic #55 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 132: astore 7\n 134: iconst_0\n 135: istore 8\n 137: aload 7\n 139: invokestatic #59 // Method sumIDs:(Lkotlin/sequences/Sequence;)I\n 142: istore 5\n 144: aload_3\n 145: aload 4\n 147: invokestatic #65 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 150: iload 5\n 152: goto 175\n 155: astore 6\n 157: aload 6\n 159: astore 4\n 161: aload 6\n 163: athrow\n 164: astore 6\n 166: aload_3\n 167: aload 4\n 169: invokestatic #65 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 172: aload 6\n 174: athrow\n 175: nop\n 176: istore_0\n 177: new #67 // class java/lang/StringBuilder\n 180: dup\n 181: invokespecial #69 // Method java/lang/StringBuilder.\"<init>\":()V\n 184: ldc #71 // String ID sum is\n 186: invokevirtual #75 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 189: iload_0\n 190: invokevirtual #78 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 193: invokevirtual #82 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 196: getstatic #88 // Field java/lang/System.out:Ljava/io/PrintStream;\n 199: swap\n 200: invokevirtual #94 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 203: return\n Exception table:\n from to target type\n 117 144 155 Class java/lang/Throwable\n 117 144 164 any\n 155 164 164 any\n 164 166 164 any\n\n private static final int sumIDs(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokedynamic #129, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 6: invokestatic #135 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 9: invokedynamic #143, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 14: invokestatic #146 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 17: invokedynamic #154, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;\n 22: invokestatic #135 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 25: invokestatic #157 // Method kotlin/sequences/SequencesKt.sumOfInt:(Lkotlin/sequences/Sequence;)I\n 28: ireturn\n\n private static final problems.day2.Game toGame(java.lang.String);\n Code:\n 0: new #161 // class problems/day2/Game\n 3: dup\n 4: aload_0\n 5: ldc #163 // String :\n 7: aconst_null\n 8: iconst_2\n 9: aconst_null\n 10: invokestatic #169 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 13: invokestatic #173 // Method toGameID:(Ljava/lang/String;)I\n 16: aload_0\n 17: ldc #163 // String :\n 19: aconst_null\n 20: iconst_2\n 21: aconst_null\n 22: invokestatic #176 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 25: invokestatic #180 // Method toRounds:(Ljava/lang/String;)Ljava/util/List;\n 28: invokespecial #183 // Method problems/day2/Game.\"<init>\":(ILjava/util/List;)V\n 31: areturn\n\n private static final int toGameID(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #187 // class java/lang/CharSequence\n 4: invokestatic #191 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 7: invokevirtual #192 // Method java/lang/Object.toString:()Ljava/lang/String;\n 10: ldc #194 // String Game\n 12: checkcast #187 // class java/lang/CharSequence\n 15: invokestatic #198 // Method kotlin/text/StringsKt.removePrefix:(Ljava/lang/String;Ljava/lang/CharSequence;)Ljava/lang/String;\n 18: invokestatic #203 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 21: ireturn\n\n private static final java.util.List<problems.day2.Round> toRounds(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #187 // class java/lang/CharSequence\n 4: invokestatic #191 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 7: invokevirtual #192 // Method java/lang/Object.toString:()Ljava/lang/String;\n 10: checkcast #187 // class java/lang/CharSequence\n 13: iconst_1\n 14: anewarray #207 // class java/lang/String\n 17: astore_1\n 18: aload_1\n 19: iconst_0\n 20: ldc #209 // String ;\n 22: aastore\n 23: aload_1\n 24: iconst_0\n 25: iconst_0\n 26: bipush 6\n 28: aconst_null\n 29: invokestatic #213 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 32: checkcast #215 // class java/lang/Iterable\n 35: astore_1\n 36: iconst_0\n 37: istore_2\n 38: aload_1\n 39: astore_3\n 40: new #217 // class java/util/ArrayList\n 43: dup\n 44: aload_1\n 45: bipush 10\n 47: invokestatic #223 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 50: invokespecial #226 // Method java/util/ArrayList.\"<init>\":(I)V\n 53: checkcast #228 // class java/util/Collection\n 56: astore 4\n 58: iconst_0\n 59: istore 5\n 61: aload_3\n 62: invokeinterface #232, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 67: astore 6\n 69: aload 6\n 71: invokeinterface #238, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 76: ifeq 119\n 79: aload 6\n 81: invokeinterface #242, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: astore 7\n 88: aload 4\n 90: aload 7\n 92: checkcast #207 // class java/lang/String\n 95: astore 8\n 97: astore 10\n 99: iconst_0\n 100: istore 9\n 102: aload 8\n 104: invokestatic #246 // Method toRound:(Ljava/lang/String;)Lproblems/day2/Round;\n 107: aload 10\n 109: swap\n 110: invokeinterface #250, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 115: pop\n 116: goto 69\n 119: aload 4\n 121: checkcast #252 // class java/util/List\n 124: nop\n 125: areturn\n\n private static final problems.day2.Round toRound(java.lang.String);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: iconst_0\n 3: istore_2\n 4: iconst_0\n 5: istore_3\n 6: aload_0\n 7: checkcast #187 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #207 // class java/lang/String\n 14: astore 4\n 16: aload 4\n 18: iconst_0\n 19: ldc_w #265 // String ,\n 22: aastore\n 23: aload 4\n 25: iconst_0\n 26: iconst_0\n 27: bipush 6\n 29: aconst_null\n 30: invokestatic #213 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 33: checkcast #215 // class java/lang/Iterable\n 36: astore 4\n 38: iconst_0\n 39: istore 5\n 41: aload 4\n 43: astore 6\n 45: new #217 // class java/util/ArrayList\n 48: dup\n 49: aload 4\n 51: bipush 10\n 53: invokestatic #223 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 56: invokespecial #226 // Method java/util/ArrayList.\"<init>\":(I)V\n 59: checkcast #228 // class java/util/Collection\n 62: astore 7\n 64: iconst_0\n 65: istore 8\n 67: aload 6\n 69: invokeinterface #232, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 74: astore 9\n 76: aload 9\n 78: invokeinterface #238, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 83: ifeq 133\n 86: aload 9\n 88: invokeinterface #242, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 93: astore 10\n 95: aload 7\n 97: aload 10\n 99: checkcast #207 // class java/lang/String\n 102: astore 11\n 104: astore 13\n 106: iconst_0\n 107: istore 12\n 109: aload 11\n 111: checkcast #187 // class java/lang/CharSequence\n 114: invokestatic #191 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 117: invokevirtual #192 // Method java/lang/Object.toString:()Ljava/lang/String;\n 120: nop\n 121: aload 13\n 123: swap\n 124: invokeinterface #250, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 129: pop\n 130: goto 76\n 133: aload 7\n 135: checkcast #252 // class java/util/List\n 138: nop\n 139: checkcast #215 // class java/lang/Iterable\n 142: astore 4\n 144: nop\n 145: iconst_0\n 146: istore 5\n 148: aload 4\n 150: invokeinterface #232, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 155: astore 6\n 157: aload 6\n 159: invokeinterface #238, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 164: ifeq 318\n 167: aload 6\n 169: invokeinterface #242, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 174: astore 7\n 176: aload 7\n 178: checkcast #207 // class java/lang/String\n 181: astore 8\n 183: iconst_0\n 184: istore 9\n 186: aload 8\n 188: ldc_w #267 // String\n 191: aconst_null\n 192: iconst_2\n 193: aconst_null\n 194: invokestatic #169 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 197: invokestatic #203 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 200: istore 10\n 202: aload 8\n 204: ldc_w #267 // String\n 207: aconst_null\n 208: iconst_2\n 209: aconst_null\n 210: invokestatic #176 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 213: astore 11\n 215: aload 11\n 217: invokevirtual #271 // Method java/lang/String.hashCode:()I\n 220: lookupswitch { // 3\n 112785: 256\n 3027034: 284\n 98619139: 270\n default: 313\n }\n 256: aload 11\n 258: ldc_w #273 // String red\n 261: invokevirtual #276 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 264: ifne 298\n 267: goto 313\n 270: aload 11\n 272: ldc_w #278 // String green\n 275: invokevirtual #276 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 278: ifne 310\n 281: goto 313\n 284: aload 11\n 286: ldc_w #280 // String blue\n 289: invokevirtual #276 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 292: ifne 304\n 295: goto 313\n 298: iload 10\n 300: istore_1\n 301: goto 313\n 304: iload 10\n 306: istore_3\n 307: goto 313\n 310: iload 10\n 312: istore_2\n 313: nop\n 314: nop\n 315: goto 157\n 318: nop\n 319: new #282 // class problems/day2/Round\n 322: dup\n 323: iload_1\n 324: iload_2\n 325: iload_3\n 326: invokespecial #285 // Method problems/day2/Round.\"<init>\":(III)V\n 329: areturn\n\n private static final void part2();\n Code:\n 0: new #16 // class java/io/File\n 3: dup\n 4: ldc #18 // String input/day2/games.txt\n 6: invokespecial #22 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_1\n 10: getstatic #28 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_2\n 14: sipush 8192\n 17: istore_3\n 18: aload_1\n 19: astore 4\n 21: new #30 // class java/io/InputStreamReader\n 24: dup\n 25: new #32 // class java/io/FileInputStream\n 28: dup\n 29: aload 4\n 31: invokespecial #35 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 34: checkcast #37 // class java/io/InputStream\n 37: aload_2\n 38: invokespecial #40 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 41: checkcast #42 // class java/io/Reader\n 44: astore 4\n 46: aload 4\n 48: instanceof #44 // class java/io/BufferedReader\n 51: ifeq 62\n 54: aload 4\n 56: checkcast #44 // class java/io/BufferedReader\n 59: goto 72\n 62: new #44 // class java/io/BufferedReader\n 65: dup\n 66: aload 4\n 68: iload_3\n 69: invokespecial #47 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 72: checkcast #42 // class java/io/Reader\n 75: astore_1\n 76: nop\n 77: iconst_0\n 78: istore_2\n 79: aload_1\n 80: astore_3\n 81: sipush 8192\n 84: istore 4\n 86: aload_3\n 87: instanceof #44 // class java/io/BufferedReader\n 90: ifeq 100\n 93: aload_3\n 94: checkcast #44 // class java/io/BufferedReader\n 97: goto 110\n 100: new #44 // class java/io/BufferedReader\n 103: dup\n 104: aload_3\n 105: iload 4\n 107: invokespecial #47 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 110: checkcast #49 // class java/io/Closeable\n 113: astore_3\n 114: aconst_null\n 115: astore 4\n 117: nop\n 118: aload_3\n 119: checkcast #44 // class java/io/BufferedReader\n 122: astore 5\n 124: iconst_0\n 125: istore 6\n 127: aload 5\n 129: invokestatic #55 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 132: astore 7\n 134: iconst_0\n 135: istore 8\n 137: aload 7\n 139: invokestatic #295 // Method sumPower:(Lkotlin/sequences/Sequence;)I\n 142: istore 5\n 144: aload_3\n 145: aload 4\n 147: invokestatic #65 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 150: iload 5\n 152: goto 175\n 155: astore 6\n 157: aload 6\n 159: astore 4\n 161: aload 6\n 163: athrow\n 164: astore 6\n 166: aload_3\n 167: aload 4\n 169: invokestatic #65 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 172: aload 6\n 174: athrow\n 175: nop\n 176: istore_0\n 177: new #67 // class java/lang/StringBuilder\n 180: dup\n 181: invokespecial #69 // Method java/lang/StringBuilder.\"<init>\":()V\n 184: ldc_w #297 // String Power sum is\n 187: invokevirtual #75 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 190: iload_0\n 191: invokevirtual #78 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 194: invokevirtual #82 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 197: getstatic #88 // Field java/lang/System.out:Ljava/io/PrintStream;\n 200: swap\n 201: invokevirtual #94 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 204: return\n Exception table:\n from to target type\n 117 144 155 Class java/lang/Throwable\n 117 144 164 any\n 155 164 164 any\n 164 166 164 any\n\n private static final int sumPower(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokedynamic #306, 0 // InvokeDynamic #3:invoke:()Lkotlin/jvm/functions/Function1;\n 6: invokestatic #135 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 9: invokestatic #157 // Method kotlin/sequences/SequencesKt.sumOfInt:(Lkotlin/sequences/Sequence;)I\n 12: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #309 // Method main:()V\n 3: return\n\n private static final problems.day2.Game sumIDs$lambda$1(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #312 // String it\n 4: invokestatic #318 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokestatic #320 // Method toGame:(Ljava/lang/String;)Lproblems/day2/Game;\n 11: areturn\n\n private static final boolean sumIDs$lambda$2(problems.day2.Game);\n Code:\n 0: aload_0\n 1: ldc_w #312 // String it\n 4: invokestatic #318 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: bipush 12\n 10: invokevirtual #324 // Method problems/day2/Game.allRedUnder:(I)Z\n 13: aload_0\n 14: bipush 13\n 16: invokevirtual #327 // Method problems/day2/Game.allGreenUnder:(I)Z\n 19: iand\n 20: aload_0\n 21: bipush 14\n 23: invokevirtual #330 // Method problems/day2/Game.allBlueUnder:(I)Z\n 26: iand\n 27: ireturn\n\n private static final int sumIDs$lambda$3(problems.day2.Game);\n Code:\n 0: aload_0\n 1: ldc_w #312 // String it\n 4: invokestatic #318 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokevirtual #334 // Method problems/day2/Game.getId:()I\n 11: ireturn\n\n private static final int sumPower$lambda$8(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #312 // String it\n 4: invokestatic #318 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokestatic #320 // Method toGame:(Ljava/lang/String;)Lproblems/day2/Game;\n 11: invokevirtual #337 // Method problems/day2/Game.power:()I\n 14: ireturn\n}\n", "javap_err": "" } ]
klnusbaum__aoc2023__d30db24/src/problems/day1/dayone.kt
package problems.day1 import java.io.File private const val calibrationValues = "input/day1/calibration_values.txt" fun main() { part1() part2() } private fun part1() { val sum = File(calibrationValues) .bufferedReader() .useLines { sumLines(it) } println("Sum of values is $sum") } private fun sumLines(lines: Sequence<String>) = lines.map { parseLine(it) }.sum() private fun parseLine(input: String): Int { val numbers = input.filter { c -> c in '0'..'9' } return "${numbers.first()}${numbers.last()}".toInt() } private fun part2() { val sum = File(calibrationValues) .bufferedReader() .useLines { sumLinesV2(it) } println("Sum of values is $sum") } private fun sumLinesV2(lines: Sequence<String>) = lines.map { parseLineV2(it) }.sum() private fun parseLineV2(input: String): Int { val first = input.findAnyOf(numTargets)?.second?.toNumString() val last = input.findLastAnyOf(numTargets)?.second?.toNumString() return "$first$last".toInt() } private val numTargets = listOf( "1", "2", "3", "4", "5", "6", "7", "8", "9", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" ) private fun String.toNumString() = when (this) { "one" -> "1" "two" -> "2" "three" -> "3" "four" -> "4" "five" -> "5" "six" -> "6" "seven" -> "7" "eight" -> "8" "nine" -> "9" else -> this }
[ { "class_path": "klnusbaum__aoc2023__d30db24/problems/day1/DayoneKt.class", "javap": "Compiled from \"dayone.kt\"\npublic final class problems.day1.DayoneKt {\n private static final java.lang.String calibrationValues;\n\n private static final java.util.List<java.lang.String> numTargets;\n\n public static final void main();\n Code:\n 0: invokestatic #9 // Method part1:()V\n 3: invokestatic #12 // Method part2:()V\n 6: return\n\n private static final void part1();\n Code:\n 0: new #16 // class java/io/File\n 3: dup\n 4: ldc #18 // String input/day1/calibration_values.txt\n 6: invokespecial #22 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_1\n 10: getstatic #28 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_2\n 14: sipush 8192\n 17: istore_3\n 18: aload_1\n 19: astore 4\n 21: new #30 // class java/io/InputStreamReader\n 24: dup\n 25: new #32 // class java/io/FileInputStream\n 28: dup\n 29: aload 4\n 31: invokespecial #35 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 34: checkcast #37 // class java/io/InputStream\n 37: aload_2\n 38: invokespecial #40 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 41: checkcast #42 // class java/io/Reader\n 44: astore 4\n 46: aload 4\n 48: instanceof #44 // class java/io/BufferedReader\n 51: ifeq 62\n 54: aload 4\n 56: checkcast #44 // class java/io/BufferedReader\n 59: goto 72\n 62: new #44 // class java/io/BufferedReader\n 65: dup\n 66: aload 4\n 68: iload_3\n 69: invokespecial #47 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 72: checkcast #42 // class java/io/Reader\n 75: astore_1\n 76: nop\n 77: iconst_0\n 78: istore_2\n 79: aload_1\n 80: astore_3\n 81: sipush 8192\n 84: istore 4\n 86: aload_3\n 87: instanceof #44 // class java/io/BufferedReader\n 90: ifeq 100\n 93: aload_3\n 94: checkcast #44 // class java/io/BufferedReader\n 97: goto 110\n 100: new #44 // class java/io/BufferedReader\n 103: dup\n 104: aload_3\n 105: iload 4\n 107: invokespecial #47 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 110: checkcast #49 // class java/io/Closeable\n 113: astore_3\n 114: aconst_null\n 115: astore 4\n 117: nop\n 118: aload_3\n 119: checkcast #44 // class java/io/BufferedReader\n 122: astore 5\n 124: iconst_0\n 125: istore 6\n 127: aload 5\n 129: invokestatic #55 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 132: astore 7\n 134: iconst_0\n 135: istore 8\n 137: aload 7\n 139: invokestatic #59 // Method sumLines:(Lkotlin/sequences/Sequence;)I\n 142: istore 5\n 144: aload_3\n 145: aload 4\n 147: invokestatic #65 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 150: iload 5\n 152: goto 175\n 155: astore 6\n 157: aload 6\n 159: astore 4\n 161: aload 6\n 163: athrow\n 164: astore 6\n 166: aload_3\n 167: aload 4\n 169: invokestatic #65 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 172: aload 6\n 174: athrow\n 175: nop\n 176: istore_0\n 177: new #67 // class java/lang/StringBuilder\n 180: dup\n 181: invokespecial #69 // Method java/lang/StringBuilder.\"<init>\":()V\n 184: ldc #71 // String Sum of values is\n 186: invokevirtual #75 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 189: iload_0\n 190: invokevirtual #78 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 193: invokevirtual #82 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 196: getstatic #88 // Field java/lang/System.out:Ljava/io/PrintStream;\n 199: swap\n 200: invokevirtual #94 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 203: return\n Exception table:\n from to target type\n 117 144 155 Class java/lang/Throwable\n 117 144 164 any\n 155 164 164 any\n 164 166 164 any\n\n private static final int sumLines(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokedynamic #130, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 6: invokestatic #136 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 9: invokestatic #139 // Method kotlin/sequences/SequencesKt.sumOfInt:(Lkotlin/sequences/Sequence;)I\n 12: ireturn\n\n private static final int parseLine(java.lang.String);\n Code:\n 0: aload_0\n 1: astore_2\n 2: iconst_0\n 3: istore_3\n 4: aload_2\n 5: checkcast #143 // class java/lang/CharSequence\n 8: astore 4\n 10: new #67 // class java/lang/StringBuilder\n 13: dup\n 14: invokespecial #69 // Method java/lang/StringBuilder.\"<init>\":()V\n 17: checkcast #145 // class java/lang/Appendable\n 20: astore 5\n 22: iconst_0\n 23: istore 6\n 25: iconst_0\n 26: istore 7\n 28: aload 4\n 30: invokeinterface #149, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 35: istore 8\n 37: iload 7\n 39: iload 8\n 41: if_icmpge 104\n 44: aload 4\n 46: iload 7\n 48: invokeinterface #153, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 53: istore 9\n 55: iload 9\n 57: istore 10\n 59: iconst_0\n 60: istore 11\n 62: bipush 48\n 64: iload 10\n 66: if_icmpgt 84\n 69: iload 10\n 71: bipush 58\n 73: if_icmpge 80\n 76: iconst_1\n 77: goto 85\n 80: iconst_0\n 81: goto 85\n 84: iconst_0\n 85: ifeq 98\n 88: aload 5\n 90: iload 9\n 92: invokeinterface #156, 2 // InterfaceMethod java/lang/Appendable.append:(C)Ljava/lang/Appendable;\n 97: pop\n 98: iinc 7, 1\n 101: goto 37\n 104: aload 5\n 106: checkcast #67 // class java/lang/StringBuilder\n 109: invokevirtual #82 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 112: astore_1\n 113: new #67 // class java/lang/StringBuilder\n 116: dup\n 117: invokespecial #69 // Method java/lang/StringBuilder.\"<init>\":()V\n 120: aload_1\n 121: checkcast #143 // class java/lang/CharSequence\n 124: invokestatic #162 // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C\n 127: invokevirtual #165 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 130: aload_1\n 131: checkcast #143 // class java/lang/CharSequence\n 134: invokestatic #168 // Method kotlin/text/StringsKt.last:(Ljava/lang/CharSequence;)C\n 137: invokevirtual #165 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 140: invokevirtual #82 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 143: invokestatic #173 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 146: ireturn\n\n private static final void part2();\n Code:\n 0: new #16 // class java/io/File\n 3: dup\n 4: ldc #18 // String input/day1/calibration_values.txt\n 6: invokespecial #22 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_1\n 10: getstatic #28 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_2\n 14: sipush 8192\n 17: istore_3\n 18: aload_1\n 19: astore 4\n 21: new #30 // class java/io/InputStreamReader\n 24: dup\n 25: new #32 // class java/io/FileInputStream\n 28: dup\n 29: aload 4\n 31: invokespecial #35 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 34: checkcast #37 // class java/io/InputStream\n 37: aload_2\n 38: invokespecial #40 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 41: checkcast #42 // class java/io/Reader\n 44: astore 4\n 46: aload 4\n 48: instanceof #44 // class java/io/BufferedReader\n 51: ifeq 62\n 54: aload 4\n 56: checkcast #44 // class java/io/BufferedReader\n 59: goto 72\n 62: new #44 // class java/io/BufferedReader\n 65: dup\n 66: aload 4\n 68: iload_3\n 69: invokespecial #47 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 72: checkcast #42 // class java/io/Reader\n 75: astore_1\n 76: nop\n 77: iconst_0\n 78: istore_2\n 79: aload_1\n 80: astore_3\n 81: sipush 8192\n 84: istore 4\n 86: aload_3\n 87: instanceof #44 // class java/io/BufferedReader\n 90: ifeq 100\n 93: aload_3\n 94: checkcast #44 // class java/io/BufferedReader\n 97: goto 110\n 100: new #44 // class java/io/BufferedReader\n 103: dup\n 104: aload_3\n 105: iload 4\n 107: invokespecial #47 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 110: checkcast #49 // class java/io/Closeable\n 113: astore_3\n 114: aconst_null\n 115: astore 4\n 117: nop\n 118: aload_3\n 119: checkcast #44 // class java/io/BufferedReader\n 122: astore 5\n 124: iconst_0\n 125: istore 6\n 127: aload 5\n 129: invokestatic #55 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 132: astore 7\n 134: iconst_0\n 135: istore 8\n 137: aload 7\n 139: invokestatic #193 // Method sumLinesV2:(Lkotlin/sequences/Sequence;)I\n 142: istore 5\n 144: aload_3\n 145: aload 4\n 147: invokestatic #65 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 150: iload 5\n 152: goto 175\n 155: astore 6\n 157: aload 6\n 159: astore 4\n 161: aload 6\n 163: athrow\n 164: astore 6\n 166: aload_3\n 167: aload 4\n 169: invokestatic #65 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 172: aload 6\n 174: athrow\n 175: nop\n 176: istore_0\n 177: new #67 // class java/lang/StringBuilder\n 180: dup\n 181: invokespecial #69 // Method java/lang/StringBuilder.\"<init>\":()V\n 184: ldc #71 // String Sum of values is\n 186: invokevirtual #75 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 189: iload_0\n 190: invokevirtual #78 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 193: invokevirtual #82 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 196: getstatic #88 // Field java/lang/System.out:Ljava/io/PrintStream;\n 199: swap\n 200: invokevirtual #94 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 203: return\n Exception table:\n from to target type\n 117 144 155 Class java/lang/Throwable\n 117 144 164 any\n 155 164 164 any\n 164 166 164 any\n\n private static final int sumLinesV2(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokedynamic #199, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 6: invokestatic #136 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 9: invokestatic #139 // Method kotlin/sequences/SequencesKt.sumOfInt:(Lkotlin/sequences/Sequence;)I\n 12: ireturn\n\n private static final int parseLineV2(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #143 // class java/lang/CharSequence\n 4: getstatic #204 // Field numTargets:Ljava/util/List;\n 7: checkcast #206 // class java/util/Collection\n 10: iconst_0\n 11: iconst_0\n 12: bipush 6\n 14: aconst_null\n 15: invokestatic #210 // Method kotlin/text/StringsKt.findAnyOf$default:(Ljava/lang/CharSequence;Ljava/util/Collection;IZILjava/lang/Object;)Lkotlin/Pair;\n 18: dup\n 19: ifnull 38\n 22: invokevirtual #216 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 25: checkcast #190 // class java/lang/String\n 28: dup\n 29: ifnull 38\n 32: invokestatic #220 // Method toNumString:(Ljava/lang/String;)Ljava/lang/String;\n 35: goto 40\n 38: pop\n 39: aconst_null\n 40: astore_1\n 41: aload_0\n 42: checkcast #143 // class java/lang/CharSequence\n 45: getstatic #204 // Field numTargets:Ljava/util/List;\n 48: checkcast #206 // class java/util/Collection\n 51: iconst_0\n 52: iconst_0\n 53: bipush 6\n 55: aconst_null\n 56: invokestatic #223 // Method kotlin/text/StringsKt.findLastAnyOf$default:(Ljava/lang/CharSequence;Ljava/util/Collection;IZILjava/lang/Object;)Lkotlin/Pair;\n 59: dup\n 60: ifnull 79\n 63: invokevirtual #216 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 66: checkcast #190 // class java/lang/String\n 69: dup\n 70: ifnull 79\n 73: invokestatic #220 // Method toNumString:(Ljava/lang/String;)Ljava/lang/String;\n 76: goto 81\n 79: pop\n 80: aconst_null\n 81: astore_2\n 82: new #67 // class java/lang/StringBuilder\n 85: dup\n 86: invokespecial #69 // Method java/lang/StringBuilder.\"<init>\":()V\n 89: aload_1\n 90: invokevirtual #75 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 93: aload_2\n 94: invokevirtual #75 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 97: invokevirtual #82 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 100: invokestatic #173 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 103: ireturn\n\n private static final java.lang.String toNumString(java.lang.String);\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: invokevirtual #226 // Method java/lang/String.hashCode:()I\n 6: lookupswitch { // 9\n 110182: 124\n 113890: 100\n 115276: 148\n 3143346: 172\n 3149094: 112\n 3381426: 88\n 96505999: 184\n 109330445: 136\n 110339486: 160\n default: 247\n }\n 88: aload_1\n 89: ldc #228 // String nine\n 91: invokevirtual #232 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 94: ifne 241\n 97: goto 247\n 100: aload_1\n 101: ldc #234 // String six\n 103: invokevirtual #232 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 106: ifne 223\n 109: goto 247\n 112: aload_1\n 113: ldc #236 // String four\n 115: invokevirtual #232 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 118: ifne 211\n 121: goto 247\n 124: aload_1\n 125: ldc #238 // String one\n 127: invokevirtual #232 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 130: ifne 196\n 133: goto 247\n 136: aload_1\n 137: ldc #240 // String seven\n 139: invokevirtual #232 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 142: ifne 229\n 145: goto 247\n 148: aload_1\n 149: ldc #242 // String two\n 151: invokevirtual #232 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 154: ifne 201\n 157: goto 247\n 160: aload_1\n 161: ldc #244 // String three\n 163: invokevirtual #232 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 166: ifne 206\n 169: goto 247\n 172: aload_1\n 173: ldc #246 // String five\n 175: invokevirtual #232 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 178: ifne 217\n 181: goto 247\n 184: aload_1\n 185: ldc #248 // String eight\n 187: invokevirtual #232 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 190: ifne 235\n 193: goto 247\n 196: ldc #250 // String 1\n 198: goto 248\n 201: ldc #252 // String 2\n 203: goto 248\n 206: ldc #254 // String 3\n 208: goto 248\n 211: ldc_w #256 // String 4\n 214: goto 248\n 217: ldc_w #258 // String 5\n 220: goto 248\n 223: ldc_w #260 // String 6\n 226: goto 248\n 229: ldc_w #262 // String 7\n 232: goto 248\n 235: ldc_w #264 // String 8\n 238: goto 248\n 241: ldc_w #266 // String 9\n 244: goto 248\n 247: aload_0\n 248: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #270 // Method main:()V\n 3: return\n\n private static final int sumLines$lambda$1(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #273 // String it\n 4: invokestatic #279 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokestatic #281 // Method parseLine:(Ljava/lang/String;)I\n 11: ireturn\n\n private static final int sumLinesV2$lambda$4(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #273 // String it\n 4: invokestatic #279 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokestatic #283 // Method parseLineV2:(Ljava/lang/String;)I\n 11: ireturn\n\n static {};\n Code:\n 0: bipush 18\n 2: anewarray #190 // class java/lang/String\n 5: astore_0\n 6: aload_0\n 7: iconst_0\n 8: ldc #250 // String 1\n 10: aastore\n 11: aload_0\n 12: iconst_1\n 13: ldc #252 // String 2\n 15: aastore\n 16: aload_0\n 17: iconst_2\n 18: ldc #254 // String 3\n 20: aastore\n 21: aload_0\n 22: iconst_3\n 23: ldc_w #256 // String 4\n 26: aastore\n 27: aload_0\n 28: iconst_4\n 29: ldc_w #258 // String 5\n 32: aastore\n 33: aload_0\n 34: iconst_5\n 35: ldc_w #260 // String 6\n 38: aastore\n 39: aload_0\n 40: bipush 6\n 42: ldc_w #262 // String 7\n 45: aastore\n 46: aload_0\n 47: bipush 7\n 49: ldc_w #264 // String 8\n 52: aastore\n 53: aload_0\n 54: bipush 8\n 56: ldc_w #266 // String 9\n 59: aastore\n 60: aload_0\n 61: bipush 9\n 63: ldc #238 // String one\n 65: aastore\n 66: aload_0\n 67: bipush 10\n 69: ldc #242 // String two\n 71: aastore\n 72: aload_0\n 73: bipush 11\n 75: ldc #244 // String three\n 77: aastore\n 78: aload_0\n 79: bipush 12\n 81: ldc #236 // String four\n 83: aastore\n 84: aload_0\n 85: bipush 13\n 87: ldc #246 // String five\n 89: aastore\n 90: aload_0\n 91: bipush 14\n 93: ldc #234 // String six\n 95: aastore\n 96: aload_0\n 97: bipush 15\n 99: ldc #240 // String seven\n 101: aastore\n 102: aload_0\n 103: bipush 16\n 105: ldc #248 // String eight\n 107: aastore\n 108: aload_0\n 109: bipush 17\n 111: ldc #228 // String nine\n 113: aastore\n 114: aload_0\n 115: invokestatic #290 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 118: putstatic #204 // Field numTargets:Ljava/util/List;\n 121: return\n}\n", "javap_err": "" } ]
klnusbaum__aoc2023__d30db24/src/problems/day4/part1/part1.kt
package problems.day4.part1 import java.io.File import kotlin.math.pow //private const val testFile = "input/day4/test.txt" private const val cardsFile = "input/day4/cards.txt" fun main() { val cardValueSum = File(cardsFile).bufferedReader().useLines { sumCardValues(it) } println("Card Values Sum: $cardValueSum") } private fun sumCardValues(lines: Sequence<String>) = lines.map { it.toCard() }.sumOf { it.value() } private fun String.toCard() = Card( id = this.toCardID(), winningNumbers = this.toWinningNumbers(), possessedNumbers = this.toPossessedNumbers() ) private fun String.toCardID(): Int = this.substringBefore(":").substringAfter(" ").trim().toInt() private fun String.toWinningNumbers() = this.substringAfter(":").substringBefore("|").trim().split(" ").filter { it != "" }.map { it.toInt() } .toSet() private fun String.toPossessedNumbers(): Set<Int> = this.substringAfter("|").trim().split(" ").filter { it != "" }.map { it.trim().toInt() }.toSet() private data class Card(val id: Int, val winningNumbers: Set<Int>, val possessedNumbers: Set<Int>) { fun value(): Int = 2.0.pow(numMatching() - 1).toInt() fun numMatching() = winningNumbers.intersect(possessedNumbers).count() }
[ { "class_path": "klnusbaum__aoc2023__d30db24/problems/day4/part1/Part1Kt.class", "javap": "Compiled from \"part1.kt\"\npublic final class problems.day4.part1.Part1Kt {\n private static final java.lang.String cardsFile;\n\n public static final void main();\n Code:\n 0: new #10 // class java/io/File\n 3: dup\n 4: ldc #12 // String input/day4/cards.txt\n 6: invokespecial #16 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_1\n 10: getstatic #22 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_2\n 14: sipush 8192\n 17: istore_3\n 18: aload_1\n 19: astore 4\n 21: new #24 // class java/io/InputStreamReader\n 24: dup\n 25: new #26 // class java/io/FileInputStream\n 28: dup\n 29: aload 4\n 31: invokespecial #29 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 34: checkcast #31 // class java/io/InputStream\n 37: aload_2\n 38: invokespecial #34 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 41: checkcast #36 // class java/io/Reader\n 44: astore 4\n 46: aload 4\n 48: instanceof #38 // class java/io/BufferedReader\n 51: ifeq 62\n 54: aload 4\n 56: checkcast #38 // class java/io/BufferedReader\n 59: goto 72\n 62: new #38 // class java/io/BufferedReader\n 65: dup\n 66: aload 4\n 68: iload_3\n 69: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 72: checkcast #36 // class java/io/Reader\n 75: astore_1\n 76: nop\n 77: iconst_0\n 78: istore_2\n 79: aload_1\n 80: astore_3\n 81: sipush 8192\n 84: istore 4\n 86: aload_3\n 87: instanceof #38 // class java/io/BufferedReader\n 90: ifeq 100\n 93: aload_3\n 94: checkcast #38 // class java/io/BufferedReader\n 97: goto 110\n 100: new #38 // class java/io/BufferedReader\n 103: dup\n 104: aload_3\n 105: iload 4\n 107: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 110: checkcast #43 // class java/io/Closeable\n 113: astore_3\n 114: aconst_null\n 115: astore 4\n 117: nop\n 118: aload_3\n 119: checkcast #38 // class java/io/BufferedReader\n 122: astore 5\n 124: iconst_0\n 125: istore 6\n 127: aload 5\n 129: invokestatic #49 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 132: astore 7\n 134: iconst_0\n 135: istore 8\n 137: aload 7\n 139: invokestatic #53 // Method sumCardValues:(Lkotlin/sequences/Sequence;)I\n 142: istore 5\n 144: aload_3\n 145: aload 4\n 147: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 150: iload 5\n 152: goto 175\n 155: astore 6\n 157: aload 6\n 159: astore 4\n 161: aload 6\n 163: athrow\n 164: astore 6\n 166: aload_3\n 167: aload 4\n 169: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 172: aload 6\n 174: athrow\n 175: nop\n 176: istore_0\n 177: new #61 // class java/lang/StringBuilder\n 180: dup\n 181: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 184: ldc #65 // String Card Values Sum:\n 186: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 189: iload_0\n 190: invokevirtual #72 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 193: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 196: getstatic #82 // Field java/lang/System.out:Ljava/io/PrintStream;\n 199: swap\n 200: invokevirtual #88 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 203: return\n Exception table:\n from to target type\n 117 144 155 Class java/lang/Throwable\n 117 144 164 any\n 155 164 164 any\n 164 166 164 any\n\n private static final int sumCardValues(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokedynamic #123, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 6: invokestatic #129 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 9: astore_1\n 10: iconst_0\n 11: istore_2\n 12: aload_1\n 13: invokeinterface #133, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 18: astore_3\n 19: aload_3\n 20: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 25: ifeq 65\n 28: aload_3\n 29: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 34: astore 4\n 36: iload_2\n 37: aload 4\n 39: checkcast #145 // class problems/day4/part1/Card\n 42: astore 5\n 44: istore 7\n 46: iconst_0\n 47: istore 6\n 49: aload 5\n 51: invokevirtual #149 // Method problems/day4/part1/Card.value:()I\n 54: istore 8\n 56: iload 7\n 58: iload 8\n 60: iadd\n 61: istore_2\n 62: goto 19\n 65: iload_2\n 66: ireturn\n\n private static final problems.day4.part1.Card toCard(java.lang.String);\n Code:\n 0: new #145 // class problems/day4/part1/Card\n 3: dup\n 4: aload_0\n 5: invokestatic #157 // Method toCardID:(Ljava/lang/String;)I\n 8: aload_0\n 9: invokestatic #161 // Method toWinningNumbers:(Ljava/lang/String;)Ljava/util/Set;\n 12: aload_0\n 13: invokestatic #164 // Method toPossessedNumbers:(Ljava/lang/String;)Ljava/util/Set;\n 16: invokespecial #167 // Method problems/day4/part1/Card.\"<init>\":(ILjava/util/Set;Ljava/util/Set;)V\n 19: areturn\n\n private static final int toCardID(java.lang.String);\n Code:\n 0: nop\n 1: aload_0\n 2: ldc #171 // String :\n 4: aconst_null\n 5: iconst_2\n 6: aconst_null\n 7: invokestatic #177 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 10: ldc #179 // String\n 12: aconst_null\n 13: iconst_2\n 14: aconst_null\n 15: invokestatic #182 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 18: checkcast #184 // class java/lang/CharSequence\n 21: invokestatic #188 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 24: invokevirtual #189 // Method java/lang/Object.toString:()Ljava/lang/String;\n 27: invokestatic #194 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 30: ireturn\n\n private static final java.util.Set<java.lang.Integer> toWinningNumbers(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #171 // String :\n 3: aconst_null\n 4: iconst_2\n 5: aconst_null\n 6: invokestatic #182 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 9: ldc #198 // String |\n 11: aconst_null\n 12: iconst_2\n 13: aconst_null\n 14: invokestatic #177 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 17: checkcast #184 // class java/lang/CharSequence\n 20: invokestatic #188 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 23: invokevirtual #189 // Method java/lang/Object.toString:()Ljava/lang/String;\n 26: checkcast #184 // class java/lang/CharSequence\n 29: iconst_1\n 30: anewarray #200 // class java/lang/String\n 33: astore_1\n 34: aload_1\n 35: iconst_0\n 36: ldc #179 // String\n 38: aastore\n 39: aload_1\n 40: iconst_0\n 41: iconst_0\n 42: bipush 6\n 44: aconst_null\n 45: invokestatic #204 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 48: checkcast #206 // class java/lang/Iterable\n 51: astore_1\n 52: iconst_0\n 53: istore_2\n 54: aload_1\n 55: astore_3\n 56: new #208 // class java/util/ArrayList\n 59: dup\n 60: invokespecial #209 // Method java/util/ArrayList.\"<init>\":()V\n 63: checkcast #211 // class java/util/Collection\n 66: astore 4\n 68: iconst_0\n 69: istore 5\n 71: aload_3\n 72: invokeinterface #212, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 77: astore 6\n 79: aload 6\n 81: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 86: ifeq 139\n 89: aload 6\n 91: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 96: astore 7\n 98: aload 7\n 100: checkcast #200 // class java/lang/String\n 103: astore 8\n 105: iconst_0\n 106: istore 9\n 108: aload 8\n 110: ldc #214 // String\n 112: invokestatic #220 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 115: ifne 122\n 118: iconst_1\n 119: goto 123\n 122: iconst_0\n 123: ifeq 79\n 126: aload 4\n 128: aload 7\n 130: invokeinterface #224, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 135: pop\n 136: goto 79\n 139: aload 4\n 141: checkcast #226 // class java/util/List\n 144: nop\n 145: checkcast #206 // class java/lang/Iterable\n 148: astore_1\n 149: nop\n 150: iconst_0\n 151: istore_2\n 152: aload_1\n 153: astore_3\n 154: new #208 // class java/util/ArrayList\n 157: dup\n 158: aload_1\n 159: bipush 10\n 161: invokestatic #232 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 164: invokespecial #235 // Method java/util/ArrayList.\"<init>\":(I)V\n 167: checkcast #211 // class java/util/Collection\n 170: astore 4\n 172: iconst_0\n 173: istore 5\n 175: aload_3\n 176: invokeinterface #212, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 181: astore 6\n 183: aload 6\n 185: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 190: ifeq 237\n 193: aload 6\n 195: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 200: astore 7\n 202: aload 4\n 204: aload 7\n 206: checkcast #200 // class java/lang/String\n 209: astore 8\n 211: astore 10\n 213: iconst_0\n 214: istore 9\n 216: aload 8\n 218: invokestatic #194 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 221: nop\n 222: invokestatic #239 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 225: aload 10\n 227: swap\n 228: invokeinterface #224, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 233: pop\n 234: goto 183\n 237: aload 4\n 239: checkcast #226 // class java/util/List\n 242: nop\n 243: checkcast #206 // class java/lang/Iterable\n 246: invokestatic #243 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 249: areturn\n\n private static final java.util.Set<java.lang.Integer> toPossessedNumbers(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #198 // String |\n 3: aconst_null\n 4: iconst_2\n 5: aconst_null\n 6: invokestatic #182 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 9: checkcast #184 // class java/lang/CharSequence\n 12: invokestatic #188 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 15: invokevirtual #189 // Method java/lang/Object.toString:()Ljava/lang/String;\n 18: checkcast #184 // class java/lang/CharSequence\n 21: iconst_1\n 22: anewarray #200 // class java/lang/String\n 25: astore_1\n 26: aload_1\n 27: iconst_0\n 28: ldc #179 // String\n 30: aastore\n 31: aload_1\n 32: iconst_0\n 33: iconst_0\n 34: bipush 6\n 36: aconst_null\n 37: invokestatic #204 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 40: checkcast #206 // class java/lang/Iterable\n 43: astore_1\n 44: iconst_0\n 45: istore_2\n 46: aload_1\n 47: astore_3\n 48: new #208 // class java/util/ArrayList\n 51: dup\n 52: invokespecial #209 // Method java/util/ArrayList.\"<init>\":()V\n 55: checkcast #211 // class java/util/Collection\n 58: astore 4\n 60: iconst_0\n 61: istore 5\n 63: aload_3\n 64: invokeinterface #212, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 69: astore 6\n 71: aload 6\n 73: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 78: ifeq 131\n 81: aload 6\n 83: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 88: astore 7\n 90: aload 7\n 92: checkcast #200 // class java/lang/String\n 95: astore 8\n 97: iconst_0\n 98: istore 9\n 100: aload 8\n 102: ldc #214 // String\n 104: invokestatic #220 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 107: ifne 114\n 110: iconst_1\n 111: goto 115\n 114: iconst_0\n 115: ifeq 71\n 118: aload 4\n 120: aload 7\n 122: invokeinterface #224, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 127: pop\n 128: goto 71\n 131: aload 4\n 133: checkcast #226 // class java/util/List\n 136: nop\n 137: checkcast #206 // class java/lang/Iterable\n 140: astore_1\n 141: nop\n 142: iconst_0\n 143: istore_2\n 144: aload_1\n 145: astore_3\n 146: new #208 // class java/util/ArrayList\n 149: dup\n 150: aload_1\n 151: bipush 10\n 153: invokestatic #232 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 156: invokespecial #235 // Method java/util/ArrayList.\"<init>\":(I)V\n 159: checkcast #211 // class java/util/Collection\n 162: astore 4\n 164: iconst_0\n 165: istore 5\n 167: aload_3\n 168: invokeinterface #212, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 173: astore 6\n 175: aload 6\n 177: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 182: ifeq 239\n 185: aload 6\n 187: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 192: astore 7\n 194: aload 4\n 196: aload 7\n 198: checkcast #200 // class java/lang/String\n 201: astore 8\n 203: astore 10\n 205: iconst_0\n 206: istore 9\n 208: nop\n 209: aload 8\n 211: checkcast #184 // class java/lang/CharSequence\n 214: invokestatic #188 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 217: invokevirtual #189 // Method java/lang/Object.toString:()Ljava/lang/String;\n 220: invokestatic #194 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 223: nop\n 224: invokestatic #239 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 227: aload 10\n 229: swap\n 230: invokeinterface #224, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 235: pop\n 236: goto 175\n 239: aload 4\n 241: checkcast #226 // class java/util/List\n 244: nop\n 245: checkcast #206 // class java/lang/Iterable\n 248: invokestatic #243 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 251: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #266 // Method main:()V\n 3: return\n\n private static final problems.day4.part1.Card sumCardValues$lambda$1(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #269 // String it\n 4: invokestatic #273 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokestatic #275 // Method toCard:(Ljava/lang/String;)Lproblems/day4/part1/Card;\n 11: areturn\n}\n", "javap_err": "" } ]
klnusbaum__aoc2023__d30db24/src/problems/day3/part2/part2.kt
package problems.day3.part2 import java.io.File //private const val testFile = "input/day3/test.txt" private const val part_numbers = "input/day3/part_numbers.txt" fun main() { val gearRatioSum = File(part_numbers).bufferedReader().useLines { sumGearRatios(it) } println("Part Number Sum: $gearRatioSum") } private fun sumGearRatios(lines: Sequence<String>): Int { val possibleGears = mutableMapOf<Int, Map<Int, Int>>() val stars = mutableMapOf<Int, Set<Int>>() lines.forEachIndexed {row, line -> val res = parseLine(line) possibleGears[row] = res.possibleGears stars[row] = res.stars } return stars.flatMap { it.value.toRowCols(it.key) } .mapNotNull { it.gearRatio(possibleGears) } .sum() } private fun parseLine(line: String) = LineResult( accumulateNumbers(line), recordStarts(line), ) private data class LineResult(val possibleGears: Map<Int, Int>, val stars: Set<Int>) private fun accumulateNumbers(line: String): Map<Int, Int> { val accumulator = PossibleGearAccumulator() line.forEach { accumulator.nextChar(it) } return accumulator.end() } private fun recordStarts(line: String): Set<Int> { val stars = mutableSetOf<Int>() line.forEachIndexed { index, c -> if (c == '*') stars.add(index)} return stars } private fun Pair<Int, Int>.gearRatio(possibleGears: Map<Int, Map<Int, Int>>) : Int? { val adjacentNumbers = mutableSetOf<Int>() for (i in this.first-1..this.first+1) { for(j in this.second-1..this.second+1) { val number = possibleGears[i]?.get(j) if (number != null) { adjacentNumbers.add(number) } } } if (adjacentNumbers.count() != 2) { return null } return adjacentNumbers.fold(1) {acc, next -> acc * next} } private fun Set<Int>.toRowCols(row: Int): List<Pair<Int, Int>> = this.map {row to it} private class PossibleGearAccumulator() { private val possibleGears = mutableMapOf<Int,Int>() private val currentNumber = StringBuilder() private var currentCol = 0 private var currentStartCol = 0 private var currentEndCol = 0 private var currentState = State.OUT_NUMBER private enum class State { IN_NUMBER, OUT_NUMBER } fun nextChar(character: Char) { when { (character in '0'..'9') and (currentState == State.OUT_NUMBER) -> { currentState = State.IN_NUMBER currentNumber.append(character) currentStartCol = currentCol currentEndCol = currentCol } (character in '0'..'9') and (currentState == State.IN_NUMBER) -> { currentNumber.append(character) currentEndCol = currentCol } (character !in '0'..'9') and (currentState == State.IN_NUMBER) -> { currentState = State.OUT_NUMBER recordPossiblePN() currentNumber.clear() } } currentCol++ } private fun recordPossiblePN() { val number = currentNumber.toString().toInt() for (i in currentStartCol..currentEndCol) { possibleGears[i] = number } } fun end(): Map<Int, Int> { if (currentState == State.IN_NUMBER) { recordPossiblePN() } return possibleGears } }
[ { "class_path": "klnusbaum__aoc2023__d30db24/problems/day3/part2/Part2Kt.class", "javap": "Compiled from \"part2.kt\"\npublic final class problems.day3.part2.Part2Kt {\n private static final java.lang.String part_numbers;\n\n public static final void main();\n Code:\n 0: new #10 // class java/io/File\n 3: dup\n 4: ldc #12 // String input/day3/part_numbers.txt\n 6: invokespecial #16 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_1\n 10: getstatic #22 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_2\n 14: sipush 8192\n 17: istore_3\n 18: aload_1\n 19: astore 4\n 21: new #24 // class java/io/InputStreamReader\n 24: dup\n 25: new #26 // class java/io/FileInputStream\n 28: dup\n 29: aload 4\n 31: invokespecial #29 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 34: checkcast #31 // class java/io/InputStream\n 37: aload_2\n 38: invokespecial #34 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 41: checkcast #36 // class java/io/Reader\n 44: astore 4\n 46: aload 4\n 48: instanceof #38 // class java/io/BufferedReader\n 51: ifeq 62\n 54: aload 4\n 56: checkcast #38 // class java/io/BufferedReader\n 59: goto 72\n 62: new #38 // class java/io/BufferedReader\n 65: dup\n 66: aload 4\n 68: iload_3\n 69: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 72: checkcast #36 // class java/io/Reader\n 75: astore_1\n 76: nop\n 77: iconst_0\n 78: istore_2\n 79: aload_1\n 80: astore_3\n 81: sipush 8192\n 84: istore 4\n 86: aload_3\n 87: instanceof #38 // class java/io/BufferedReader\n 90: ifeq 100\n 93: aload_3\n 94: checkcast #38 // class java/io/BufferedReader\n 97: goto 110\n 100: new #38 // class java/io/BufferedReader\n 103: dup\n 104: aload_3\n 105: iload 4\n 107: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 110: checkcast #43 // class java/io/Closeable\n 113: astore_3\n 114: aconst_null\n 115: astore 4\n 117: nop\n 118: aload_3\n 119: checkcast #38 // class java/io/BufferedReader\n 122: astore 5\n 124: iconst_0\n 125: istore 6\n 127: aload 5\n 129: invokestatic #49 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 132: astore 7\n 134: iconst_0\n 135: istore 8\n 137: aload 7\n 139: invokestatic #53 // Method sumGearRatios:(Lkotlin/sequences/Sequence;)I\n 142: istore 5\n 144: aload_3\n 145: aload 4\n 147: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 150: iload 5\n 152: goto 175\n 155: astore 6\n 157: aload 6\n 159: astore 4\n 161: aload 6\n 163: athrow\n 164: astore 6\n 166: aload_3\n 167: aload 4\n 169: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 172: aload 6\n 174: athrow\n 175: nop\n 176: istore_0\n 177: new #61 // class java/lang/StringBuilder\n 180: dup\n 181: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 184: ldc #65 // String Part Number Sum:\n 186: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 189: iload_0\n 190: invokevirtual #72 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 193: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 196: getstatic #82 // Field java/lang/System.out:Ljava/io/PrintStream;\n 199: swap\n 200: invokevirtual #88 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 203: return\n Exception table:\n from to target type\n 117 144 155 Class java/lang/Throwable\n 117 144 164 any\n 155 164 164 any\n 164 166 164 any\n\n private static final int sumGearRatios(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: new #106 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #107 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #109 // class java/util/Map\n 10: astore_1\n 11: new #106 // class java/util/LinkedHashMap\n 14: dup\n 15: invokespecial #107 // Method java/util/LinkedHashMap.\"<init>\":()V\n 18: checkcast #109 // class java/util/Map\n 21: astore_2\n 22: aload_0\n 23: astore_3\n 24: iconst_0\n 25: istore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #113, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 140\n 48: aload 6\n 50: invokeinterface #123, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: iload 5\n 59: iinc 5, 1\n 62: istore 8\n 64: iload 8\n 66: ifge 72\n 69: invokestatic #128 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 72: iload 8\n 74: aload 7\n 76: checkcast #130 // class java/lang/String\n 79: astore 9\n 81: istore 10\n 83: iconst_0\n 84: istore 11\n 86: aload 9\n 88: invokestatic #134 // Method parseLine:(Ljava/lang/String;)Lproblems/day3/part2/LineResult;\n 91: astore 12\n 93: iload 10\n 95: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 98: astore 13\n 100: aload_1\n 101: aload 13\n 103: aload 12\n 105: invokevirtual #146 // Method problems/day3/part2/LineResult.getPossibleGears:()Ljava/util/Map;\n 108: invokeinterface #150, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 113: pop\n 114: iload 10\n 116: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 119: astore 13\n 121: aload_2\n 122: aload 13\n 124: aload 12\n 126: invokevirtual #154 // Method problems/day3/part2/LineResult.getStars:()Ljava/util/Set;\n 129: invokeinterface #150, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 134: pop\n 135: nop\n 136: nop\n 137: goto 38\n 140: nop\n 141: aload_2\n 142: astore_3\n 143: iconst_0\n 144: istore 4\n 146: aload_3\n 147: astore 5\n 149: new #156 // class java/util/ArrayList\n 152: dup\n 153: invokespecial #157 // Method java/util/ArrayList.\"<init>\":()V\n 156: checkcast #159 // class java/util/Collection\n 159: astore 6\n 161: iconst_0\n 162: istore 7\n 164: aload 5\n 166: invokeinterface #162, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 171: invokeinterface #165, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 176: astore 8\n 178: aload 8\n 180: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 185: ifeq 249\n 188: aload 8\n 190: invokeinterface #123, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 195: checkcast #167 // class java/util/Map$Entry\n 198: astore 9\n 200: aload 9\n 202: astore 10\n 204: iconst_0\n 205: istore 11\n 207: aload 10\n 209: invokeinterface #170, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 214: checkcast #164 // class java/util/Set\n 217: aload 10\n 219: invokeinterface #173, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 224: checkcast #175 // class java/lang/Number\n 227: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 230: invokestatic #183 // Method toRowCols:(Ljava/util/Set;I)Ljava/util/List;\n 233: checkcast #185 // class java/lang/Iterable\n 236: astore 10\n 238: aload 6\n 240: aload 10\n 242: invokestatic #189 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 245: pop\n 246: goto 178\n 249: aload 6\n 251: checkcast #191 // class java/util/List\n 254: nop\n 255: checkcast #185 // class java/lang/Iterable\n 258: astore_3\n 259: nop\n 260: iconst_0\n 261: istore 4\n 263: aload_3\n 264: astore 5\n 266: new #156 // class java/util/ArrayList\n 269: dup\n 270: invokespecial #157 // Method java/util/ArrayList.\"<init>\":()V\n 273: checkcast #159 // class java/util/Collection\n 276: astore 6\n 278: iconst_0\n 279: istore 7\n 281: aload 5\n 283: astore 8\n 285: iconst_0\n 286: istore 9\n 288: aload 8\n 290: invokeinterface #192, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 295: astore 10\n 297: aload 10\n 299: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 304: ifeq 366\n 307: aload 10\n 309: invokeinterface #123, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 314: astore 11\n 316: aload 11\n 318: astore 12\n 320: iconst_0\n 321: istore 13\n 323: aload 12\n 325: checkcast #194 // class kotlin/Pair\n 328: astore 14\n 330: iconst_0\n 331: istore 15\n 333: aload 14\n 335: aload_1\n 336: invokestatic #198 // Method gearRatio:(Lkotlin/Pair;Ljava/util/Map;)Ljava/lang/Integer;\n 339: dup\n 340: ifnull 361\n 343: astore 16\n 345: iconst_0\n 346: istore 17\n 348: aload 6\n 350: aload 16\n 352: invokeinterface #202, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 357: pop\n 358: goto 362\n 361: pop\n 362: nop\n 363: goto 297\n 366: nop\n 367: aload 6\n 369: checkcast #191 // class java/util/List\n 372: nop\n 373: checkcast #185 // class java/lang/Iterable\n 376: invokestatic #206 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 379: ireturn\n\n private static final problems.day3.part2.LineResult parseLine(java.lang.String);\n Code:\n 0: new #142 // class problems/day3/part2/LineResult\n 3: dup\n 4: aload_0\n 5: invokestatic #248 // Method accumulateNumbers:(Ljava/lang/String;)Ljava/util/Map;\n 8: aload_0\n 9: invokestatic #252 // Method recordStarts:(Ljava/lang/String;)Ljava/util/Set;\n 12: invokespecial #255 // Method problems/day3/part2/LineResult.\"<init>\":(Ljava/util/Map;Ljava/util/Set;)V\n 15: areturn\n\n private static final java.util.Map<java.lang.Integer, java.lang.Integer> accumulateNumbers(java.lang.String);\n Code:\n 0: new #258 // class problems/day3/part2/PossibleGearAccumulator\n 3: dup\n 4: invokespecial #259 // Method problems/day3/part2/PossibleGearAccumulator.\"<init>\":()V\n 7: astore_1\n 8: aload_0\n 9: checkcast #261 // class java/lang/CharSequence\n 12: astore_2\n 13: iconst_0\n 14: istore_3\n 15: iconst_0\n 16: istore 4\n 18: iload 4\n 20: aload_2\n 21: invokeinterface #264, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 26: if_icmpge 59\n 29: aload_2\n 30: iload 4\n 32: invokeinterface #268, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 37: istore 5\n 39: iload 5\n 41: istore 6\n 43: iconst_0\n 44: istore 7\n 46: aload_1\n 47: iload 6\n 49: invokevirtual #272 // Method problems/day3/part2/PossibleGearAccumulator.nextChar:(C)V\n 52: nop\n 53: iinc 4, 1\n 56: goto 18\n 59: nop\n 60: aload_1\n 61: invokevirtual #275 // Method problems/day3/part2/PossibleGearAccumulator.end:()Ljava/util/Map;\n 64: areturn\n\n private static final java.util.Set<java.lang.Integer> recordStarts(java.lang.String);\n Code:\n 0: new #285 // class java/util/LinkedHashSet\n 3: dup\n 4: invokespecial #286 // Method java/util/LinkedHashSet.\"<init>\":()V\n 7: checkcast #164 // class java/util/Set\n 10: astore_1\n 11: aload_0\n 12: checkcast #261 // class java/lang/CharSequence\n 15: astore_2\n 16: iconst_0\n 17: istore_3\n 18: iconst_0\n 19: istore 4\n 21: iconst_0\n 22: istore 5\n 24: iload 5\n 26: aload_2\n 27: invokeinterface #264, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 32: if_icmpge 85\n 35: aload_2\n 36: iload 5\n 38: invokeinterface #268, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 43: istore 6\n 45: iload 4\n 47: iinc 4, 1\n 50: iload 6\n 52: istore 7\n 54: istore 8\n 56: iconst_0\n 57: istore 9\n 59: iload 7\n 61: bipush 42\n 63: if_icmpne 78\n 66: aload_1\n 67: iload 8\n 69: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 72: invokeinterface #287, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 77: pop\n 78: nop\n 79: iinc 5, 1\n 82: goto 24\n 85: nop\n 86: aload_1\n 87: areturn\n\n private static final java.lang.Integer gearRatio(kotlin.Pair<java.lang.Integer, java.lang.Integer>, java.util.Map<java.lang.Integer, ? extends java.util.Map<java.lang.Integer, java.lang.Integer>>);\n Code:\n 0: new #285 // class java/util/LinkedHashSet\n 3: dup\n 4: invokespecial #286 // Method java/util/LinkedHashSet.\"<init>\":()V\n 7: checkcast #164 // class java/util/Set\n 10: astore_2\n 11: aload_0\n 12: invokevirtual #295 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 15: checkcast #175 // class java/lang/Number\n 18: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 21: iconst_1\n 22: isub\n 23: istore_3\n 24: aload_0\n 25: invokevirtual #295 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 28: checkcast #175 // class java/lang/Number\n 31: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 34: iconst_1\n 35: iadd\n 36: istore 4\n 38: iload_3\n 39: iload 4\n 41: if_icmpgt 155\n 44: aload_0\n 45: invokevirtual #298 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 48: checkcast #175 // class java/lang/Number\n 51: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 54: iconst_1\n 55: isub\n 56: istore 5\n 58: aload_0\n 59: invokevirtual #298 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 62: checkcast #175 // class java/lang/Number\n 65: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 68: iconst_1\n 69: iadd\n 70: istore 6\n 72: iload 5\n 74: iload 6\n 76: if_icmpgt 143\n 79: aload_1\n 80: iload_3\n 81: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 84: invokeinterface #302, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 89: checkcast #109 // class java/util/Map\n 92: dup\n 93: ifnull 112\n 96: iload 5\n 98: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 101: invokeinterface #302, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 106: checkcast #136 // class java/lang/Integer\n 109: goto 114\n 112: pop\n 113: aconst_null\n 114: astore 7\n 116: aload 7\n 118: ifnull 130\n 121: aload_2\n 122: aload 7\n 124: invokeinterface #287, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 129: pop\n 130: iload 5\n 132: iload 6\n 134: if_icmpeq 143\n 137: iinc 5, 1\n 140: goto 79\n 143: iload_3\n 144: iload 4\n 146: if_icmpeq 155\n 149: iinc 3, 1\n 152: goto 44\n 155: aload_2\n 156: checkcast #159 // class java/util/Collection\n 159: invokeinterface #305, 1 // InterfaceMethod java/util/Collection.size:()I\n 164: iconst_2\n 165: if_icmpeq 170\n 168: aconst_null\n 169: areturn\n 170: aload_2\n 171: checkcast #185 // class java/lang/Iterable\n 174: astore_3\n 175: iconst_1\n 176: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 179: astore 4\n 181: iconst_0\n 182: istore 5\n 184: aload 4\n 186: astore 6\n 188: aload_3\n 189: invokeinterface #192, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 194: astore 7\n 196: aload 7\n 198: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 203: ifeq 251\n 206: aload 7\n 208: invokeinterface #123, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 213: astore 8\n 215: aload 6\n 217: aload 8\n 219: checkcast #175 // class java/lang/Number\n 222: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 225: istore 9\n 227: checkcast #175 // class java/lang/Number\n 230: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 233: istore 10\n 235: iconst_0\n 236: istore 11\n 238: iload 10\n 240: iload 9\n 242: imul\n 243: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 246: astore 6\n 248: goto 196\n 251: aload 6\n 253: areturn\n\n private static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> toRowCols(java.util.Set<java.lang.Integer>, int);\n Code:\n 0: aload_0\n 1: checkcast #185 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: astore 4\n 10: new #156 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #322 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #325 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #159 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #192, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 100\n 50: aload 7\n 52: invokeinterface #123, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #175 // class java/lang/Number\n 66: invokevirtual #179 // Method java/lang/Number.intValue:()I\n 69: istore 9\n 71: astore 11\n 73: iconst_0\n 74: istore 10\n 76: iload_1\n 77: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 80: iload 9\n 82: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 85: invokestatic #331 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 88: aload 11\n 90: swap\n 91: invokeinterface #202, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 96: pop\n 97: goto 40\n 100: aload 5\n 102: checkcast #191 // class java/util/List\n 105: nop\n 106: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #341 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
klnusbaum__aoc2023__d30db24/src/problems/day3/part1/part1.kt
package problems.day3.part1 import java.io.File //private const val testFile = "input/day3/test.txt" private const val part_numbers = "input/day3/part_numbers.txt" fun main() { val partNumberSum = File(part_numbers).bufferedReader().useLines { sumPartNumbers(it) } println("Part Number Sum: $partNumberSum") } private fun sumPartNumbers(lines: Sequence<String>): Int { val possiblePNs: MutableList<PossiblePN> = mutableListOf() val symbols: MutableMap<Int, Set<Int>> = mutableMapOf() lines.forEachIndexed {row, line -> val res = parseLine(line, row) possiblePNs.addAll(res.possiblePNs) symbols[row] = res.symbols } return possiblePNs.filter { it.adjacentToSymbol(symbols) }.sumOf { it.value } } private fun parseLine(line: String, row: Int) = LineResult( accumulateNumbers(line, row), recordSymbols(line), ) private fun accumulateNumbers(line: String, row: Int): List<PossiblePN> { val accumulator = PossiblePNAccumulator(row) line.forEach { accumulator.nextChar(it) } return accumulator.end() } private fun recordSymbols(line: String): Set<Int> { val symbols = mutableSetOf<Int>() line.forEachIndexed { index, c -> if (c.isSymbol()) symbols.add(index)} return symbols } private fun Char.isSymbol() = (this !in '0'..'9') and (this != '.') private data class PossiblePN(val value: Int, val row: Int, val startCol: Int, val endCol: Int) { fun adjacentToSymbol(symbols: Map<Int, Set<Int>>): Boolean { return aboveRowContainsSymbol(symbols) or rowContainsSymbol(symbols) or belowRowContainsSymbols(symbols) } private fun aboveRowContainsSymbol(symbols: Map<Int, Set<Int>>) = checkRowSegment(symbols, row - 1) private fun rowContainsSymbol(symbols: Map<Int, Set<Int>>): Boolean { val targetRow = symbols[row] ?: return false return targetRow.contains(startCol - 1) or targetRow.contains(endCol + 1) } private fun belowRowContainsSymbols(symbols: Map<Int, Set<Int>>) = checkRowSegment(symbols, row + 1) private fun checkRowSegment(symbols: Map<Int, Set<Int>>, row: Int): Boolean { val targetRow = symbols[row] ?: return false for (col in startCol - 1..endCol + 1) { if (targetRow.contains(col)) return true } return false } } private data class LineResult(val possiblePNs: List<PossiblePN>, val symbols: Set<Int>) private class PossiblePNAccumulator(private val row: Int) { private val possiblePNs = mutableListOf<PossiblePN>() private val currentNumber = StringBuilder() private var currentCol = 0 private var currentStartCol = 0 private var currentEndCol = 0 private var currentState = State.OUT_NUMBER private enum class State { IN_NUMBER, OUT_NUMBER } fun nextChar(character: Char) { when { (character in '0'..'9') and (currentState == State.OUT_NUMBER) -> { currentState = State.IN_NUMBER currentNumber.append(character) currentStartCol = currentCol currentEndCol = currentCol } (character in '0'..'9') and (currentState == State.IN_NUMBER) -> { currentNumber.append(character) currentEndCol = currentCol } (character !in '0'..'9') and (currentState == State.IN_NUMBER) -> { currentState = State.OUT_NUMBER recordPossiblePN() currentNumber.clear() } } currentCol++ } private fun recordPossiblePN() { possiblePNs.add( PossiblePN( value = currentNumber.toString().toInt(), row = row, startCol = currentStartCol, endCol = currentEndCol, ) ) } fun end(): List<PossiblePN> { if (currentState == State.IN_NUMBER) { recordPossiblePN() } return possiblePNs } }
[ { "class_path": "klnusbaum__aoc2023__d30db24/problems/day3/part1/Part1Kt.class", "javap": "Compiled from \"part1.kt\"\npublic final class problems.day3.part1.Part1Kt {\n private static final java.lang.String part_numbers;\n\n public static final void main();\n Code:\n 0: new #10 // class java/io/File\n 3: dup\n 4: ldc #12 // String input/day3/part_numbers.txt\n 6: invokespecial #16 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_1\n 10: getstatic #22 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_2\n 14: sipush 8192\n 17: istore_3\n 18: aload_1\n 19: astore 4\n 21: new #24 // class java/io/InputStreamReader\n 24: dup\n 25: new #26 // class java/io/FileInputStream\n 28: dup\n 29: aload 4\n 31: invokespecial #29 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 34: checkcast #31 // class java/io/InputStream\n 37: aload_2\n 38: invokespecial #34 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 41: checkcast #36 // class java/io/Reader\n 44: astore 4\n 46: aload 4\n 48: instanceof #38 // class java/io/BufferedReader\n 51: ifeq 62\n 54: aload 4\n 56: checkcast #38 // class java/io/BufferedReader\n 59: goto 72\n 62: new #38 // class java/io/BufferedReader\n 65: dup\n 66: aload 4\n 68: iload_3\n 69: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 72: checkcast #36 // class java/io/Reader\n 75: astore_1\n 76: nop\n 77: iconst_0\n 78: istore_2\n 79: aload_1\n 80: astore_3\n 81: sipush 8192\n 84: istore 4\n 86: aload_3\n 87: instanceof #38 // class java/io/BufferedReader\n 90: ifeq 100\n 93: aload_3\n 94: checkcast #38 // class java/io/BufferedReader\n 97: goto 110\n 100: new #38 // class java/io/BufferedReader\n 103: dup\n 104: aload_3\n 105: iload 4\n 107: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 110: checkcast #43 // class java/io/Closeable\n 113: astore_3\n 114: aconst_null\n 115: astore 4\n 117: nop\n 118: aload_3\n 119: checkcast #38 // class java/io/BufferedReader\n 122: astore 5\n 124: iconst_0\n 125: istore 6\n 127: aload 5\n 129: invokestatic #49 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 132: astore 7\n 134: iconst_0\n 135: istore 8\n 137: aload 7\n 139: invokestatic #53 // Method sumPartNumbers:(Lkotlin/sequences/Sequence;)I\n 142: istore 5\n 144: aload_3\n 145: aload 4\n 147: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 150: iload 5\n 152: goto 175\n 155: astore 6\n 157: aload 6\n 159: astore 4\n 161: aload 6\n 163: athrow\n 164: astore 6\n 166: aload_3\n 167: aload 4\n 169: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 172: aload 6\n 174: athrow\n 175: nop\n 176: istore_0\n 177: new #61 // class java/lang/StringBuilder\n 180: dup\n 181: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 184: ldc #65 // String Part Number Sum:\n 186: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 189: iload_0\n 190: invokevirtual #72 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 193: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 196: getstatic #82 // Field java/lang/System.out:Ljava/io/PrintStream;\n 199: swap\n 200: invokevirtual #88 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 203: return\n Exception table:\n from to target type\n 117 144 155 Class java/lang/Throwable\n 117 144 164 any\n 155 164 164 any\n 164 166 164 any\n\n private static final int sumPartNumbers(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: new #106 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #107 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #109 // class java/util/List\n 10: astore_1\n 11: new #111 // class java/util/LinkedHashMap\n 14: dup\n 15: invokespecial #112 // Method java/util/LinkedHashMap.\"<init>\":()V\n 18: checkcast #114 // class java/util/Map\n 21: astore_2\n 22: aload_0\n 23: astore_3\n 24: iconst_0\n 25: istore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #118, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 136\n 48: aload 6\n 50: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: iload 5\n 59: iinc 5, 1\n 62: istore 8\n 64: iload 8\n 66: ifge 72\n 69: invokestatic #133 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 72: iload 8\n 74: aload 7\n 76: checkcast #135 // class java/lang/String\n 79: astore 9\n 81: istore 10\n 83: iconst_0\n 84: istore 11\n 86: aload 9\n 88: iload 10\n 90: invokestatic #139 // Method parseLine:(Ljava/lang/String;I)Lproblems/day3/part1/LineResult;\n 93: astore 12\n 95: aload_1\n 96: aload 12\n 98: invokevirtual #145 // Method problems/day3/part1/LineResult.getPossiblePNs:()Ljava/util/List;\n 101: checkcast #147 // class java/util/Collection\n 104: invokeinterface #151, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 109: pop\n 110: iload 10\n 112: invokestatic #157 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 115: astore 13\n 117: aload_2\n 118: aload 13\n 120: aload 12\n 122: invokevirtual #161 // Method problems/day3/part1/LineResult.getSymbols:()Ljava/util/Set;\n 125: invokeinterface #165, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 130: pop\n 131: nop\n 132: nop\n 133: goto 38\n 136: nop\n 137: aload_1\n 138: checkcast #167 // class java/lang/Iterable\n 141: astore_3\n 142: iconst_0\n 143: istore 4\n 145: aload_3\n 146: astore 5\n 148: new #106 // class java/util/ArrayList\n 151: dup\n 152: invokespecial #107 // Method java/util/ArrayList.\"<init>\":()V\n 155: checkcast #147 // class java/util/Collection\n 158: astore 6\n 160: iconst_0\n 161: istore 7\n 163: aload 5\n 165: invokeinterface #168, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 170: astore 8\n 172: aload 8\n 174: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 179: ifeq 223\n 182: aload 8\n 184: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 189: astore 9\n 191: aload 9\n 193: checkcast #170 // class problems/day3/part1/PossiblePN\n 196: astore 10\n 198: iconst_0\n 199: istore 11\n 201: aload 10\n 203: aload_2\n 204: invokevirtual #174 // Method problems/day3/part1/PossiblePN.adjacentToSymbol:(Ljava/util/Map;)Z\n 207: ifeq 172\n 210: aload 6\n 212: aload 9\n 214: invokeinterface #178, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 219: pop\n 220: goto 172\n 223: aload 6\n 225: checkcast #109 // class java/util/List\n 228: nop\n 229: checkcast #167 // class java/lang/Iterable\n 232: astore_3\n 233: iconst_0\n 234: istore 4\n 236: aload_3\n 237: invokeinterface #168, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 242: astore 5\n 244: aload 5\n 246: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 251: ifeq 294\n 254: aload 5\n 256: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 261: astore 6\n 263: iload 4\n 265: aload 6\n 267: checkcast #170 // class problems/day3/part1/PossiblePN\n 270: astore 7\n 272: istore 14\n 274: iconst_0\n 275: istore 8\n 277: aload 7\n 279: invokevirtual #182 // Method problems/day3/part1/PossiblePN.getValue:()I\n 282: istore 15\n 284: iload 14\n 286: iload 15\n 288: iadd\n 289: istore 4\n 291: goto 244\n 294: iload 4\n 296: ireturn\n\n private static final problems.day3.part1.LineResult parseLine(java.lang.String, int);\n Code:\n 0: new #141 // class problems/day3/part1/LineResult\n 3: dup\n 4: aload_0\n 5: iload_1\n 6: invokestatic #213 // Method accumulateNumbers:(Ljava/lang/String;I)Ljava/util/List;\n 9: aload_0\n 10: invokestatic #217 // Method recordSymbols:(Ljava/lang/String;)Ljava/util/Set;\n 13: invokespecial #220 // Method problems/day3/part1/LineResult.\"<init>\":(Ljava/util/List;Ljava/util/Set;)V\n 16: areturn\n\n private static final java.util.List<problems.day3.part1.PossiblePN> accumulateNumbers(java.lang.String, int);\n Code:\n 0: new #223 // class problems/day3/part1/PossiblePNAccumulator\n 3: dup\n 4: iload_1\n 5: invokespecial #226 // Method problems/day3/part1/PossiblePNAccumulator.\"<init>\":(I)V\n 8: astore_2\n 9: aload_0\n 10: checkcast #228 // class java/lang/CharSequence\n 13: astore_3\n 14: iconst_0\n 15: istore 4\n 17: iconst_0\n 18: istore 5\n 20: iload 5\n 22: aload_3\n 23: invokeinterface #231, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 28: if_icmpge 61\n 31: aload_3\n 32: iload 5\n 34: invokeinterface #235, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 39: istore 6\n 41: iload 6\n 43: istore 7\n 45: iconst_0\n 46: istore 8\n 48: aload_2\n 49: iload 7\n 51: invokevirtual #239 // Method problems/day3/part1/PossiblePNAccumulator.nextChar:(C)V\n 54: nop\n 55: iinc 5, 1\n 58: goto 20\n 61: nop\n 62: aload_2\n 63: invokevirtual #242 // Method problems/day3/part1/PossiblePNAccumulator.end:()Ljava/util/List;\n 66: areturn\n\n private static final java.util.Set<java.lang.Integer> recordSymbols(java.lang.String);\n Code:\n 0: new #253 // class java/util/LinkedHashSet\n 3: dup\n 4: invokespecial #254 // Method java/util/LinkedHashSet.\"<init>\":()V\n 7: checkcast #256 // class java/util/Set\n 10: astore_1\n 11: aload_0\n 12: checkcast #228 // class java/lang/CharSequence\n 15: astore_2\n 16: iconst_0\n 17: istore_3\n 18: iconst_0\n 19: istore 4\n 21: iconst_0\n 22: istore 5\n 24: iload 5\n 26: aload_2\n 27: invokeinterface #231, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 32: if_icmpge 86\n 35: aload_2\n 36: iload 5\n 38: invokeinterface #235, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 43: istore 6\n 45: iload 4\n 47: iinc 4, 1\n 50: iload 6\n 52: istore 7\n 54: istore 8\n 56: iconst_0\n 57: istore 9\n 59: iload 7\n 61: invokestatic #260 // Method isSymbol:(C)Z\n 64: ifeq 79\n 67: aload_1\n 68: iload 8\n 70: invokestatic #157 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 73: invokeinterface #261, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 78: pop\n 79: nop\n 80: iinc 5, 1\n 83: goto 24\n 86: nop\n 87: aload_1\n 88: areturn\n\n private static final boolean isSymbol(char);\n Code:\n 0: bipush 48\n 2: iload_0\n 3: if_icmpgt 20\n 6: iload_0\n 7: bipush 58\n 9: if_icmpge 16\n 12: iconst_1\n 13: goto 21\n 16: iconst_0\n 17: goto 21\n 20: iconst_0\n 21: ifne 28\n 24: iconst_1\n 25: goto 29\n 28: iconst_0\n 29: iload_0\n 30: bipush 46\n 32: if_icmpeq 39\n 35: iconst_1\n 36: goto 40\n 39: iconst_0\n 40: iand\n 41: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #269 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
klnusbaum__aoc2023__d30db24/src/problems/day5/part2/part2.kt
package problems.day5.part2 import java.io.File import java.util.* //const val testFile = "input/day5/test.txt" const val inputFile = "input/day5/input.txt" fun main() { val lowestLocationNum = File(inputFile).bufferedReader().useLines { lowestLocationNumber(it) } println("Lowest Location Num: $lowestLocationNum") } private fun lowestLocationNumber(lines: Sequence<String>): Long? { val almanac = lines.fold(AlmanacBuilder()) { builder, line -> builder.nextLine(line) }.build() for (i in 0..<Long.MAX_VALUE) { if (almanac.locationHasSeed(i)) { return i } } return null } private class Almanac(val seeds: TreeMap<Long,Long>, val reverseMaps: Map<String, OverrideMap>) { fun locationHasSeed(location: Long): Boolean { val humidity = reverseMaps["humidity-to-location"]?.get(location) ?: return false val temperature = reverseMaps["temperature-to-humidity"]?.get(humidity) ?: return false val light = reverseMaps["light-to-temperature"]?.get(temperature) ?: return false val water = reverseMaps["water-to-light"]?.get(light) ?: return false val fertilizer = reverseMaps["fertilizer-to-water"]?.get(water) ?: return false val soil = reverseMaps["soil-to-fertilizer"]?.get(fertilizer) ?: return false val seed = reverseMaps["seed-to-soil"]?.get(soil) ?: return false val floorSeed = seeds.floorEntry(seed) ?: return false return floorSeed.key <= seed && seed <= floorSeed.value } } private class AlmanacBuilder { private var state = State.SEEDS private var currentMapName = "" private var currentMap = TreeMap<Long, Override>() private val maps = mutableMapOf<String, OverrideMap>() private val seeds = TreeMap<Long, Long>() fun nextLine(line: String): AlmanacBuilder { when (state) { State.SEEDS -> { seeds.putAll(line.toSeeds()) state = State.SEEDS_BLANK } State.SEEDS_BLANK -> state = State.HEADER State.HEADER -> { currentMapName = line.substringBefore(" ") currentMap = TreeMap<Long, Override>() state = State.MAP } State.MAP -> { if (line != "") { addOverride(line) } else { recordMap() state = State.HEADER } } } return this } fun addOverride(line: String) { val overrides = line.split(" ").map { it.toLong() } val dstStart = overrides[0] val dstEnd = overrides[0] + overrides[2] - 1 val srcStart = overrides[1] currentMap[dstStart] = Override(dstStart, dstEnd, srcStart) } fun recordMap() { maps[currentMapName] = OverrideMap(currentMap) } fun build(): Almanac { if (state == State.MAP) { recordMap() } return Almanac(seeds, maps) } private enum class State { SEEDS, SEEDS_BLANK, HEADER, MAP, } } private fun String.toSeeds(): TreeMap<Long, Long> { val seedRanges = TreeMap<Long,Long>() val pairs = this.substringAfter(":").trim().split(" ").iterator() while (pairs.hasNext()) { val start = pairs.next().toLong() val length = pairs.next().toLong() seedRanges[start] = start+length-1 } return seedRanges } private class OverrideMap(val overrides: TreeMap<Long, Override>) { operator fun get(key: Long): Long { val possibleOverride = overrides.headMap(key, true).lastEntry()?.value ?: return key if (key <= possibleOverride.dstEnd) { return possibleOverride.srcStart + (key - possibleOverride.dstStart) } return key } } private data class Override(val dstStart: Long, val dstEnd: Long, val srcStart: Long)
[ { "class_path": "klnusbaum__aoc2023__d30db24/problems/day5/part2/Part2Kt.class", "javap": "Compiled from \"part2.kt\"\npublic final class problems.day5.part2.Part2Kt {\n public static final java.lang.String inputFile;\n\n public static final void main();\n Code:\n 0: new #10 // class java/io/File\n 3: dup\n 4: ldc #12 // String input/day5/input.txt\n 6: invokespecial #16 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_1\n 10: getstatic #22 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_2\n 14: sipush 8192\n 17: istore_3\n 18: aload_1\n 19: astore 4\n 21: new #24 // class java/io/InputStreamReader\n 24: dup\n 25: new #26 // class java/io/FileInputStream\n 28: dup\n 29: aload 4\n 31: invokespecial #29 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 34: checkcast #31 // class java/io/InputStream\n 37: aload_2\n 38: invokespecial #34 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 41: checkcast #36 // class java/io/Reader\n 44: astore 4\n 46: aload 4\n 48: instanceof #38 // class java/io/BufferedReader\n 51: ifeq 62\n 54: aload 4\n 56: checkcast #38 // class java/io/BufferedReader\n 59: goto 72\n 62: new #38 // class java/io/BufferedReader\n 65: dup\n 66: aload 4\n 68: iload_3\n 69: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 72: checkcast #36 // class java/io/Reader\n 75: astore_1\n 76: nop\n 77: iconst_0\n 78: istore_2\n 79: aload_1\n 80: astore_3\n 81: sipush 8192\n 84: istore 4\n 86: aload_3\n 87: instanceof #38 // class java/io/BufferedReader\n 90: ifeq 100\n 93: aload_3\n 94: checkcast #38 // class java/io/BufferedReader\n 97: goto 110\n 100: new #38 // class java/io/BufferedReader\n 103: dup\n 104: aload_3\n 105: iload 4\n 107: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 110: checkcast #43 // class java/io/Closeable\n 113: astore_3\n 114: aconst_null\n 115: astore 4\n 117: nop\n 118: aload_3\n 119: checkcast #38 // class java/io/BufferedReader\n 122: astore 5\n 124: iconst_0\n 125: istore 6\n 127: aload 5\n 129: invokestatic #49 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 132: astore 7\n 134: iconst_0\n 135: istore 8\n 137: aload 7\n 139: invokestatic #53 // Method lowestLocationNumber:(Lkotlin/sequences/Sequence;)Ljava/lang/Long;\n 142: astore 5\n 144: aload_3\n 145: aload 4\n 147: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 150: aload 5\n 152: goto 175\n 155: astore 6\n 157: aload 6\n 159: astore 4\n 161: aload 6\n 163: athrow\n 164: astore 6\n 166: aload_3\n 167: aload 4\n 169: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 172: aload 6\n 174: athrow\n 175: nop\n 176: astore_0\n 177: new #61 // class java/lang/StringBuilder\n 180: dup\n 181: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 184: ldc #65 // String Lowest Location Num:\n 186: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 189: aload_0\n 190: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 193: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 196: getstatic #82 // Field java/lang/System.out:Ljava/io/PrintStream;\n 199: swap\n 200: invokevirtual #88 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 203: return\n Exception table:\n from to target type\n 117 144 155 Class java/lang/Throwable\n 117 144 164 any\n 155 164 164 any\n 164 166 164 any\n\n private static final java.lang.Long lowestLocationNumber(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: aload_0\n 1: astore_2\n 2: new #109 // class problems/day5/part2/AlmanacBuilder\n 5: dup\n 6: invokespecial #110 // Method problems/day5/part2/AlmanacBuilder.\"<init>\":()V\n 9: astore_3\n 10: iconst_0\n 11: istore 4\n 13: aload_3\n 14: astore 5\n 16: aload_2\n 17: invokeinterface #114, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 22: astore 6\n 24: aload 6\n 26: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 31: ifeq 69\n 34: aload 6\n 36: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 41: astore 7\n 43: aload 5\n 45: aload 7\n 47: checkcast #126 // class java/lang/String\n 50: astore 8\n 52: astore 9\n 54: iconst_0\n 55: istore 10\n 57: aload 9\n 59: aload 8\n 61: invokevirtual #130 // Method problems/day5/part2/AlmanacBuilder.nextLine:(Ljava/lang/String;)Lproblems/day5/part2/AlmanacBuilder;\n 64: astore 5\n 66: goto 24\n 69: aload 5\n 71: invokevirtual #134 // Method problems/day5/part2/AlmanacBuilder.build:()Lproblems/day5/part2/Almanac;\n 74: astore_1\n 75: lconst_0\n 76: lstore_2\n 77: lload_2\n 78: ldc2_w #135 // long 9223372036854775807l\n 81: lcmp\n 82: ifge 105\n 85: aload_1\n 86: lload_2\n 87: invokevirtual #142 // Method problems/day5/part2/Almanac.locationHasSeed:(J)Z\n 90: ifeq 98\n 93: lload_2\n 94: invokestatic #146 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 97: areturn\n 98: lload_2\n 99: lconst_1\n 100: ladd\n 101: lstore_2\n 102: goto 77\n 105: aconst_null\n 106: areturn\n\n private static final java.util.TreeMap<java.lang.Long, java.lang.Long> toSeeds(java.lang.String);\n Code:\n 0: new #167 // class java/util/TreeMap\n 3: dup\n 4: invokespecial #168 // Method java/util/TreeMap.\"<init>\":()V\n 7: astore_1\n 8: aload_0\n 9: ldc #170 // String :\n 11: aconst_null\n 12: iconst_2\n 13: aconst_null\n 14: invokestatic #176 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 17: checkcast #178 // class java/lang/CharSequence\n 20: invokestatic #182 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 23: invokevirtual #183 // Method java/lang/Object.toString:()Ljava/lang/String;\n 26: checkcast #178 // class java/lang/CharSequence\n 29: iconst_1\n 30: anewarray #126 // class java/lang/String\n 33: astore_3\n 34: aload_3\n 35: iconst_0\n 36: ldc #185 // String\n 38: aastore\n 39: aload_3\n 40: iconst_0\n 41: iconst_0\n 42: bipush 6\n 44: aconst_null\n 45: invokestatic #189 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 48: invokeinterface #192, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 53: astore_2\n 54: aload_2\n 55: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 60: ifeq 120\n 63: aload_2\n 64: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: checkcast #126 // class java/lang/String\n 72: invokestatic #196 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 75: lstore_3\n 76: aload_2\n 77: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 82: checkcast #126 // class java/lang/String\n 85: invokestatic #196 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 88: lstore 5\n 90: lload_3\n 91: invokestatic #146 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 94: astore 7\n 96: aload_1\n 97: checkcast #198 // class java/util/Map\n 100: aload 7\n 102: lload_3\n 103: lload 5\n 105: ladd\n 106: lconst_1\n 107: lsub\n 108: invokestatic #146 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 111: invokeinterface #202, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 116: pop\n 117: goto 54\n 120: aload_1\n 121: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #212 // Method main:()V\n 3: return\n\n public static final java.util.TreeMap access$toSeeds(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #217 // Method toSeeds:(Ljava/lang/String;)Ljava/util/TreeMap;\n 4: areturn\n}\n", "javap_err": "" } ]
klnusbaum__aoc2023__d30db24/src/problems/day5/part1/part1.kt
package problems.day5.part1 import java.io.File import java.util.* //private const val testFile = "input/day5/test.txt" private const val inputFile = "input/day5/input.txt" fun main() { val lowestLocationNum = File(inputFile).bufferedReader().useLines { lowestLocationNumber(it) } println("Lowest Location Num: $lowestLocationNum") } private fun lowestLocationNumber(lines: Sequence<String>): Long { val almanac = lines.fold(AlmanacBuilder()) { builder, line -> builder.nextLine(line) }.build() return almanac.seeds.mapNotNull { almanac.seedLocation(it) }.min() } private class Almanac(val seeds: List<Long>, val maps: Map<String, OverrideMap>) { fun seedLocation(seed: Long): Long? { val soil = maps["seed-to-soil"]?.get(seed) ?: return null val fertilizer = maps["soil-to-fertilizer"]?.get(soil) ?: return null val water = maps["fertilizer-to-water"]?.get(fertilizer) ?: return null val light = maps["water-to-light"]?.get(water) ?: return null val temperature = maps["light-to-temperature"]?.get(light) ?: return null val humidity = maps["temperature-to-humidity"]?.get(temperature) ?: return null val location = maps["humidity-to-location"]?.get(humidity) ?: return null return location } } private class AlmanacBuilder { private var state = State.SEEDS private var currentMapName = "" private var currentMap = TreeMap<Long, Override>() private val maps = mutableMapOf<String, OverrideMap>() private val seeds = mutableListOf<Long>() fun nextLine(line: String): AlmanacBuilder { when (state) { State.SEEDS -> { seeds.addAll(line.toSeeds()) state = State.SEEDS_BLANK } State.SEEDS_BLANK -> state = State.HEADER State.HEADER -> { currentMapName = line.substringBefore(" ") currentMap = TreeMap<Long, Override>() state = State.MAP } State.MAP -> { if (line != "") { addOverride(line) } else { recordMap() state = State.HEADER } } } return this } fun addOverride(line: String) { val overrides = line.split(" ").map { it.toLong() } val srcStart = overrides[1] val srcEnd = overrides[1] + overrides[2] - 1 val dstStart = overrides[0] currentMap[srcStart] = Override(srcStart, srcEnd, dstStart) } fun recordMap() { maps[currentMapName] = OverrideMap(currentMap) } fun build(): Almanac { if (state == State.MAP) { recordMap() } return Almanac(seeds, maps) } private enum class State { SEEDS, SEEDS_BLANK, HEADER, MAP, } } private fun String.toSeeds() = this.substringAfter(":").trim().split(" ").map { it.toLong() } private class OverrideMap(val overrides: TreeMap<Long, Override>) { operator fun get(key: Long): Long { val possibleOverride = overrides.headMap(key, true).lastEntry()?.value ?: return key if (key <= possibleOverride.srcEnd) { return possibleOverride.dstStart + (key - possibleOverride.srcStart) } return key } } private data class Override(val srcStart: Long, val srcEnd: Long, val dstStart: Long)
[ { "class_path": "klnusbaum__aoc2023__d30db24/problems/day5/part1/Part1Kt.class", "javap": "Compiled from \"part1.kt\"\npublic final class problems.day5.part1.Part1Kt {\n private static final java.lang.String inputFile;\n\n public static final void main();\n Code:\n 0: new #10 // class java/io/File\n 3: dup\n 4: ldc #12 // String input/day5/input.txt\n 6: invokespecial #16 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_2\n 10: getstatic #22 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_3\n 14: sipush 8192\n 17: istore 4\n 19: aload_2\n 20: astore 5\n 22: new #24 // class java/io/InputStreamReader\n 25: dup\n 26: new #26 // class java/io/FileInputStream\n 29: dup\n 30: aload 5\n 32: invokespecial #29 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 35: checkcast #31 // class java/io/InputStream\n 38: aload_3\n 39: invokespecial #34 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 42: checkcast #36 // class java/io/Reader\n 45: astore 5\n 47: aload 5\n 49: instanceof #38 // class java/io/BufferedReader\n 52: ifeq 63\n 55: aload 5\n 57: checkcast #38 // class java/io/BufferedReader\n 60: goto 74\n 63: new #38 // class java/io/BufferedReader\n 66: dup\n 67: aload 5\n 69: iload 4\n 71: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 74: checkcast #36 // class java/io/Reader\n 77: astore_2\n 78: nop\n 79: iconst_0\n 80: istore_3\n 81: aload_2\n 82: astore 4\n 84: sipush 8192\n 87: istore 5\n 89: aload 4\n 91: instanceof #38 // class java/io/BufferedReader\n 94: ifeq 105\n 97: aload 4\n 99: checkcast #38 // class java/io/BufferedReader\n 102: goto 116\n 105: new #38 // class java/io/BufferedReader\n 108: dup\n 109: aload 4\n 111: iload 5\n 113: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 116: checkcast #43 // class java/io/Closeable\n 119: astore 4\n 121: aconst_null\n 122: astore 5\n 124: nop\n 125: aload 4\n 127: checkcast #38 // class java/io/BufferedReader\n 130: astore 6\n 132: iconst_0\n 133: istore 8\n 135: aload 6\n 137: invokestatic #49 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 140: astore 9\n 142: iconst_0\n 143: istore 10\n 145: aload 9\n 147: invokestatic #53 // Method lowestLocationNumber:(Lkotlin/sequences/Sequence;)J\n 150: lstore 6\n 152: aload 4\n 154: aload 5\n 156: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 159: lload 6\n 161: goto 185\n 164: astore 8\n 166: aload 8\n 168: astore 5\n 170: aload 8\n 172: athrow\n 173: astore 8\n 175: aload 4\n 177: aload 5\n 179: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 182: aload 8\n 184: athrow\n 185: nop\n 186: lstore_0\n 187: new #61 // class java/lang/StringBuilder\n 190: dup\n 191: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 194: ldc #65 // String Lowest Location Num:\n 196: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 199: lload_0\n 200: invokevirtual #72 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 203: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 206: getstatic #82 // Field java/lang/System.out:Ljava/io/PrintStream;\n 209: swap\n 210: invokevirtual #88 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 213: return\n Exception table:\n from to target type\n 124 152 164 Class java/lang/Throwable\n 124 152 173 any\n 164 173 173 any\n 173 175 173 any\n\n private static final long lowestLocationNumber(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: aload_0\n 1: astore_2\n 2: new #107 // class problems/day5/part1/AlmanacBuilder\n 5: dup\n 6: invokespecial #108 // Method problems/day5/part1/AlmanacBuilder.\"<init>\":()V\n 9: astore_3\n 10: iconst_0\n 11: istore 4\n 13: aload_3\n 14: astore 5\n 16: aload_2\n 17: invokeinterface #112, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 22: astore 6\n 24: aload 6\n 26: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 31: ifeq 69\n 34: aload 6\n 36: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 41: astore 7\n 43: aload 5\n 45: aload 7\n 47: checkcast #124 // class java/lang/String\n 50: astore 8\n 52: astore 9\n 54: iconst_0\n 55: istore 10\n 57: aload 9\n 59: aload 8\n 61: invokevirtual #128 // Method problems/day5/part1/AlmanacBuilder.nextLine:(Ljava/lang/String;)Lproblems/day5/part1/AlmanacBuilder;\n 64: astore 5\n 66: goto 24\n 69: aload 5\n 71: invokevirtual #132 // Method problems/day5/part1/AlmanacBuilder.build:()Lproblems/day5/part1/Almanac;\n 74: astore_1\n 75: aload_1\n 76: invokevirtual #138 // Method problems/day5/part1/Almanac.getSeeds:()Ljava/util/List;\n 79: checkcast #140 // class java/lang/Iterable\n 82: astore_2\n 83: iconst_0\n 84: istore_3\n 85: aload_2\n 86: astore 4\n 88: new #142 // class java/util/ArrayList\n 91: dup\n 92: invokespecial #143 // Method java/util/ArrayList.\"<init>\":()V\n 95: checkcast #145 // class java/util/Collection\n 98: astore 5\n 100: iconst_0\n 101: istore 6\n 103: aload 4\n 105: astore 7\n 107: iconst_0\n 108: istore 8\n 110: aload 7\n 112: invokeinterface #146, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 117: astore 9\n 119: aload 9\n 121: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 126: ifeq 191\n 129: aload 9\n 131: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 136: astore 10\n 138: aload 10\n 140: astore 11\n 142: iconst_0\n 143: istore 12\n 145: aload 11\n 147: checkcast #148 // class java/lang/Number\n 150: invokevirtual #152 // Method java/lang/Number.longValue:()J\n 153: lstore 13\n 155: iconst_0\n 156: istore 15\n 158: aload_1\n 159: lload 13\n 161: invokevirtual #156 // Method problems/day5/part1/Almanac.seedLocation:(J)Ljava/lang/Long;\n 164: dup\n 165: ifnull 186\n 168: astore 16\n 170: iconst_0\n 171: istore 17\n 173: aload 5\n 175: aload 16\n 177: invokeinterface #160, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 182: pop\n 183: goto 187\n 186: pop\n 187: nop\n 188: goto 119\n 191: nop\n 192: aload 5\n 194: checkcast #162 // class java/util/List\n 197: nop\n 198: checkcast #140 // class java/lang/Iterable\n 201: invokestatic #168 // Method kotlin/collections/CollectionsKt.minOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 204: checkcast #148 // class java/lang/Number\n 207: invokevirtual #152 // Method java/lang/Number.longValue:()J\n 210: lreturn\n\n private static final java.util.List<java.lang.Long> toSeeds(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #204 // String :\n 3: aconst_null\n 4: iconst_2\n 5: aconst_null\n 6: invokestatic #210 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 9: checkcast #212 // class java/lang/CharSequence\n 12: invokestatic #216 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 15: invokevirtual #217 // Method java/lang/Object.toString:()Ljava/lang/String;\n 18: checkcast #212 // class java/lang/CharSequence\n 21: iconst_1\n 22: anewarray #124 // class java/lang/String\n 25: astore_1\n 26: aload_1\n 27: iconst_0\n 28: ldc #219 // String\n 30: aastore\n 31: aload_1\n 32: iconst_0\n 33: iconst_0\n 34: bipush 6\n 36: aconst_null\n 37: invokestatic #223 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 40: checkcast #140 // class java/lang/Iterable\n 43: astore_1\n 44: iconst_0\n 45: istore_2\n 46: aload_1\n 47: astore_3\n 48: new #142 // class java/util/ArrayList\n 51: dup\n 52: aload_1\n 53: bipush 10\n 55: invokestatic #227 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 58: invokespecial #230 // Method java/util/ArrayList.\"<init>\":(I)V\n 61: checkcast #145 // class java/util/Collection\n 64: astore 4\n 66: iconst_0\n 67: istore 5\n 69: aload_3\n 70: invokeinterface #146, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 75: astore 6\n 77: aload 6\n 79: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 84: ifeq 131\n 87: aload 6\n 89: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 94: astore 7\n 96: aload 4\n 98: aload 7\n 100: checkcast #124 // class java/lang/String\n 103: astore 8\n 105: astore 10\n 107: iconst_0\n 108: istore 9\n 110: aload 8\n 112: invokestatic #234 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 115: nop\n 116: invokestatic #237 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 119: aload 10\n 121: swap\n 122: invokeinterface #160, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 127: pop\n 128: goto 77\n 131: aload 4\n 133: checkcast #162 // class java/util/List\n 136: nop\n 137: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #247 // Method main:()V\n 3: return\n\n public static final java.util.List access$toSeeds(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #252 // Method toSeeds:(Ljava/lang/String;)Ljava/util/List;\n 4: areturn\n}\n", "javap_err": "" } ]
klnusbaum__aoc2023__d30db24/src/problems/day7/part2/part2.kt
package problems.day7.part2 import java.io.File private const val inputFile = "input/day7/input.txt" //private const val testFile = "input/day7/test.txt" fun main() { val scoreSum = File(inputFile).bufferedReader().useLines { sumScores(it) } println("Sum of scores is $scoreSum") } private fun sumScores(lines: Sequence<String>): Int { return lines.map { it.toHand() } .sorted() .foldIndexed(0) { index, acc, hand -> acc + ((index + 1) * hand.bid) } } private data class Hand(val cards: List<Card>, val bid: Int, val handType: HandType) : Comparable<Hand> { override fun compareTo(other: Hand): Int { if (this.handType == other.handType) { return this.cards.compareTo(other.cards) } return this.handType.compareTo(other.handType) } } private fun List<Card>.compareTo(other: List<Card>): Int { for (pair in this.asSequence().zip(other.asSequence())) { if (pair.first != pair.second) { return pair.first.compareTo(pair.second) } } return 0 } private fun String.toHand(): Hand { val cards = this.substringBefore(" ").map { it.toCard() } val bid = this.substringAfter(" ").toInt() val handType = cards.toHandType() return Hand(cards, bid, handType) } private enum class HandType { HIGH_CARD, ONE_PAIR, TWO_PAIR, THREE_OF_A_KIND, FULL_HOUSE, FOUR_OF_A_KIND, FIVE_OF_A_KIND, } private fun List<Card>.toHandType(): HandType { val typeHistogram = mutableMapOf<Card, UInt>() for (card in this) { typeHistogram[card] = typeHistogram.getOrDefault(card, 0u) + 1u } return strongestHandType(typeHistogram) } private fun strongestHandType(typeHistogram: Map<Card, UInt>): HandType = when (typeHistogram[Card.JOKER]) { null -> simpleHandType(typeHistogram) 0u -> simpleHandType(typeHistogram) 5u -> HandType.FIVE_OF_A_KIND else -> typeHistogram.keys.filter { it != Card.JOKER }.maxOf { val possibleHistogram = typeHistogram.toMutableMap() possibleHistogram[Card.JOKER] = possibleHistogram[Card.JOKER]!! - 1u possibleHistogram[it] = possibleHistogram[it]!! + 1u strongestHandType(possibleHistogram) } } private fun simpleHandType(typeHistogram: Map<Card, UInt>): HandType = when { typeHistogram.any { it.value == 5u } -> HandType.FIVE_OF_A_KIND typeHistogram.any { it.value == 4u } -> HandType.FOUR_OF_A_KIND typeHistogram.any { it.value == 3u } and typeHistogram.any { it.value == 2u } -> HandType.FULL_HOUSE typeHistogram.any { it.value == 3u } -> HandType.THREE_OF_A_KIND typeHistogram.filter { it.value == 2u }.count() == 2 -> HandType.TWO_PAIR typeHistogram.any { it.value == 2u } -> HandType.ONE_PAIR else -> HandType.HIGH_CARD } private enum class Card { JOKER, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, QUEEN, KING, ACE, } private fun Char.toCard() = when (this) { 'J' -> Card.JOKER '2' -> Card.TWO '3' -> Card.THREE '4' -> Card.FOUR '5' -> Card.FIVE '6' -> Card.SIX '7' -> Card.SEVEN '8' -> Card.EIGHT '9' -> Card.NINE 'T' -> Card.TEN 'Q' -> Card.QUEEN 'K' -> Card.KING 'A' -> Card.ACE else -> throw IllegalArgumentException("Char $this does not have a corresponding card") }
[ { "class_path": "klnusbaum__aoc2023__d30db24/problems/day7/part2/Part2Kt.class", "javap": "Compiled from \"part2.kt\"\npublic final class problems.day7.part2.Part2Kt {\n private static final java.lang.String inputFile;\n\n public static final void main();\n Code:\n 0: new #10 // class java/io/File\n 3: dup\n 4: ldc #12 // String input/day7/input.txt\n 6: invokespecial #16 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_1\n 10: getstatic #22 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_2\n 14: sipush 8192\n 17: istore_3\n 18: aload_1\n 19: astore 4\n 21: new #24 // class java/io/InputStreamReader\n 24: dup\n 25: new #26 // class java/io/FileInputStream\n 28: dup\n 29: aload 4\n 31: invokespecial #29 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 34: checkcast #31 // class java/io/InputStream\n 37: aload_2\n 38: invokespecial #34 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 41: checkcast #36 // class java/io/Reader\n 44: astore 4\n 46: aload 4\n 48: instanceof #38 // class java/io/BufferedReader\n 51: ifeq 62\n 54: aload 4\n 56: checkcast #38 // class java/io/BufferedReader\n 59: goto 72\n 62: new #38 // class java/io/BufferedReader\n 65: dup\n 66: aload 4\n 68: iload_3\n 69: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 72: checkcast #36 // class java/io/Reader\n 75: astore_1\n 76: nop\n 77: iconst_0\n 78: istore_2\n 79: aload_1\n 80: astore_3\n 81: sipush 8192\n 84: istore 4\n 86: aload_3\n 87: instanceof #38 // class java/io/BufferedReader\n 90: ifeq 100\n 93: aload_3\n 94: checkcast #38 // class java/io/BufferedReader\n 97: goto 110\n 100: new #38 // class java/io/BufferedReader\n 103: dup\n 104: aload_3\n 105: iload 4\n 107: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 110: checkcast #43 // class java/io/Closeable\n 113: astore_3\n 114: aconst_null\n 115: astore 4\n 117: nop\n 118: aload_3\n 119: checkcast #38 // class java/io/BufferedReader\n 122: astore 5\n 124: iconst_0\n 125: istore 6\n 127: aload 5\n 129: invokestatic #49 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 132: astore 7\n 134: iconst_0\n 135: istore 8\n 137: aload 7\n 139: invokestatic #53 // Method sumScores:(Lkotlin/sequences/Sequence;)I\n 142: istore 5\n 144: aload_3\n 145: aload 4\n 147: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 150: iload 5\n 152: goto 175\n 155: astore 6\n 157: aload 6\n 159: astore 4\n 161: aload 6\n 163: athrow\n 164: astore 6\n 166: aload_3\n 167: aload 4\n 169: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 172: aload 6\n 174: athrow\n 175: nop\n 176: istore_0\n 177: new #61 // class java/lang/StringBuilder\n 180: dup\n 181: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 184: ldc #65 // String Sum of scores is\n 186: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 189: iload_0\n 190: invokevirtual #72 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 193: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 196: getstatic #82 // Field java/lang/System.out:Ljava/io/PrintStream;\n 199: swap\n 200: invokevirtual #88 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 203: return\n Exception table:\n from to target type\n 117 144 155 Class java/lang/Throwable\n 117 144 164 any\n 155 164 164 any\n 164 166 164 any\n\n private static final int sumScores(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokedynamic #123, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 6: invokestatic #129 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 9: invokestatic #133 // Method kotlin/sequences/SequencesKt.sorted:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 12: astore_1\n 13: iconst_0\n 14: istore_2\n 15: iconst_0\n 16: istore_3\n 17: iconst_0\n 18: istore 4\n 20: iload_2\n 21: istore 5\n 23: aload_1\n 24: invokeinterface #137, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 29: astore 6\n 31: aload 6\n 33: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 38: ifeq 101\n 41: aload 6\n 43: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 48: astore 7\n 50: iload 4\n 52: iinc 4, 1\n 55: istore 8\n 57: iload 8\n 59: ifge 65\n 62: invokestatic #152 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 65: iload 8\n 67: iload 5\n 69: aload 7\n 71: checkcast #154 // class problems/day7/part2/Hand\n 74: astore 9\n 76: istore 10\n 78: istore 11\n 80: iconst_0\n 81: istore 12\n 83: iload 10\n 85: iload 11\n 87: iconst_1\n 88: iadd\n 89: aload 9\n 91: invokevirtual #158 // Method problems/day7/part2/Hand.getBid:()I\n 94: imul\n 95: iadd\n 96: istore 5\n 98: goto 31\n 101: iload 5\n 103: ireturn\n\n private static final int compareTo(java.util.List<? extends problems.day7.part2.Card>, java.util.List<? extends problems.day7.part2.Card>);\n Code:\n 0: aload_0\n 1: checkcast #176 // class java/lang/Iterable\n 4: invokestatic #180 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 7: aload_1\n 8: checkcast #176 // class java/lang/Iterable\n 11: invokestatic #180 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 14: invokestatic #184 // Method kotlin/sequences/SequencesKt.zip:(Lkotlin/sequences/Sequence;Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 17: invokeinterface #137, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 22: astore_2\n 23: aload_2\n 24: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifeq 71\n 32: aload_2\n 33: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 38: checkcast #186 // class kotlin/Pair\n 41: astore_3\n 42: aload_3\n 43: invokevirtual #189 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 46: aload_3\n 47: invokevirtual #192 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 50: if_acmpeq 23\n 53: aload_3\n 54: invokevirtual #189 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 57: checkcast #194 // class problems/day7/part2/Card\n 60: aload_3\n 61: invokevirtual #192 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 64: checkcast #196 // class java/lang/Enum\n 67: invokevirtual #199 // Method problems/day7/part2/Card.compareTo:(Ljava/lang/Enum;)I\n 70: ireturn\n 71: iconst_0\n 72: ireturn\n\n private static final problems.day7.part2.Hand toHand(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #207 // String\n 3: aconst_null\n 4: iconst_2\n 5: aconst_null\n 6: invokestatic #213 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 9: checkcast #215 // class java/lang/CharSequence\n 12: astore_2\n 13: iconst_0\n 14: istore_3\n 15: aload_2\n 16: astore 4\n 18: new #217 // class java/util/ArrayList\n 21: dup\n 22: aload_2\n 23: invokeinterface #220, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 28: invokespecial #223 // Method java/util/ArrayList.\"<init>\":(I)V\n 31: checkcast #225 // class java/util/Collection\n 34: astore 5\n 36: iconst_0\n 37: istore 6\n 39: iconst_0\n 40: istore 7\n 42: iload 7\n 44: aload 4\n 46: invokeinterface #220, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 51: if_icmpge 96\n 54: aload 4\n 56: iload 7\n 58: invokeinterface #229, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 63: istore 8\n 65: aload 5\n 67: iload 8\n 69: istore 9\n 71: astore 11\n 73: iconst_0\n 74: istore 10\n 76: iload 9\n 78: invokestatic #233 // Method toCard:(C)Lproblems/day7/part2/Card;\n 81: aload 11\n 83: swap\n 84: invokeinterface #237, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 89: pop\n 90: iinc 7, 1\n 93: goto 42\n 96: aload 5\n 98: checkcast #239 // class java/util/List\n 101: nop\n 102: astore_1\n 103: aload_0\n 104: ldc #207 // String\n 106: aconst_null\n 107: iconst_2\n 108: aconst_null\n 109: invokestatic #242 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 112: invokestatic #248 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 115: istore_2\n 116: aload_1\n 117: invokestatic #252 // Method toHandType:(Ljava/util/List;)Lproblems/day7/part2/HandType;\n 120: astore_3\n 121: new #154 // class problems/day7/part2/Hand\n 124: dup\n 125: aload_1\n 126: iload_2\n 127: aload_3\n 128: invokespecial #255 // Method problems/day7/part2/Hand.\"<init>\":(Ljava/util/List;ILproblems/day7/part2/HandType;)V\n 131: areturn\n\n private static final problems.day7.part2.HandType toHandType(java.util.List<? extends problems.day7.part2.Card>);\n Code:\n 0: new #276 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #277 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #279 // class java/util/Map\n 10: astore_1\n 11: aload_0\n 12: invokeinterface #280, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 17: astore_2\n 18: aload_2\n 19: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 24: ifeq 74\n 27: aload_2\n 28: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 33: checkcast #194 // class problems/day7/part2/Card\n 36: astore_3\n 37: nop\n 38: aload_1\n 39: aload_3\n 40: aload_1\n 41: aload_3\n 42: iconst_0\n 43: invokestatic #286 // Method kotlin/UInt.\"box-impl\":(I)Lkotlin/UInt;\n 46: invokeinterface #290, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 51: checkcast #282 // class kotlin/UInt\n 54: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 57: iconst_1\n 58: iadd\n 59: invokestatic #297 // Method kotlin/UInt.\"constructor-impl\":(I)I\n 62: invokestatic #286 // Method kotlin/UInt.\"box-impl\":(I)Lkotlin/UInt;\n 65: invokeinterface #300, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 70: pop\n 71: goto 18\n 74: aload_1\n 75: invokestatic #304 // Method strongestHandType:(Ljava/util/Map;)Lproblems/day7/part2/HandType;\n 78: areturn\n\n private static final problems.day7.part2.HandType strongestHandType(java.util.Map<problems.day7.part2.Card, kotlin.UInt>);\n Code:\n 0: aload_0\n 1: getstatic #313 // Field problems/day7/part2/Card.JOKER:Lproblems/day7/part2/Card;\n 4: invokeinterface #316, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 9: checkcast #282 // class kotlin/UInt\n 12: astore_1\n 13: aload_1\n 14: ifnonnull 24\n 17: aload_0\n 18: invokestatic #319 // Method simpleHandType:(Ljava/util/Map;)Lproblems/day7/part2/HandType;\n 21: goto 446\n 24: aload_1\n 25: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 28: ifne 35\n 31: iconst_1\n 32: goto 36\n 35: iconst_0\n 36: ifeq 46\n 39: aload_0\n 40: invokestatic #319 // Method simpleHandType:(Ljava/util/Map;)Lproblems/day7/part2/HandType;\n 43: goto 446\n 46: aload_1\n 47: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 50: iconst_5\n 51: if_icmpne 58\n 54: iconst_1\n 55: goto 59\n 58: iconst_0\n 59: ifeq 68\n 62: getstatic #324 // Field problems/day7/part2/HandType.FIVE_OF_A_KIND:Lproblems/day7/part2/HandType;\n 65: goto 446\n 68: aload_0\n 69: invokeinterface #328, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 74: checkcast #176 // class java/lang/Iterable\n 77: astore_2\n 78: iconst_0\n 79: istore_3\n 80: aload_2\n 81: astore 4\n 83: new #217 // class java/util/ArrayList\n 86: dup\n 87: invokespecial #329 // Method java/util/ArrayList.\"<init>\":()V\n 90: checkcast #225 // class java/util/Collection\n 93: astore 5\n 95: iconst_0\n 96: istore 6\n 98: aload 4\n 100: invokeinterface #330, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 105: astore 7\n 107: aload 7\n 109: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 114: ifeq 165\n 117: aload 7\n 119: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 124: astore 8\n 126: aload 8\n 128: checkcast #194 // class problems/day7/part2/Card\n 131: astore 9\n 133: iconst_0\n 134: istore 10\n 136: aload 9\n 138: getstatic #313 // Field problems/day7/part2/Card.JOKER:Lproblems/day7/part2/Card;\n 141: if_acmpeq 148\n 144: iconst_1\n 145: goto 149\n 148: iconst_0\n 149: ifeq 107\n 152: aload 5\n 154: aload 8\n 156: invokeinterface #237, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 161: pop\n 162: goto 107\n 165: aload 5\n 167: checkcast #239 // class java/util/List\n 170: nop\n 171: checkcast #176 // class java/lang/Iterable\n 174: invokeinterface #330, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 179: astore_3\n 180: aload_3\n 181: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 186: ifne 197\n 189: new #332 // class java/util/NoSuchElementException\n 192: dup\n 193: invokespecial #333 // Method java/util/NoSuchElementException.\"<init>\":()V\n 196: athrow\n 197: aload_3\n 198: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 203: checkcast #194 // class problems/day7/part2/Card\n 206: astore 4\n 208: iconst_0\n 209: istore 5\n 211: aload_0\n 212: invokestatic #339 // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;\n 215: astore 6\n 217: nop\n 218: aload 6\n 220: getstatic #313 // Field problems/day7/part2/Card.JOKER:Lproblems/day7/part2/Card;\n 223: aload 6\n 225: getstatic #313 // Field problems/day7/part2/Card.JOKER:Lproblems/day7/part2/Card;\n 228: invokeinterface #316, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 233: dup\n 234: invokestatic #344 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 237: checkcast #282 // class kotlin/UInt\n 240: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 243: iconst_1\n 244: isub\n 245: invokestatic #297 // Method kotlin/UInt.\"constructor-impl\":(I)I\n 248: invokestatic #286 // Method kotlin/UInt.\"box-impl\":(I)Lkotlin/UInt;\n 251: invokeinterface #300, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 256: pop\n 257: nop\n 258: aload 6\n 260: aload 4\n 262: aload 6\n 264: aload 4\n 266: invokeinterface #316, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 271: dup\n 272: invokestatic #344 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 275: checkcast #282 // class kotlin/UInt\n 278: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 281: iconst_1\n 282: iadd\n 283: invokestatic #297 // Method kotlin/UInt.\"constructor-impl\":(I)I\n 286: invokestatic #286 // Method kotlin/UInt.\"box-impl\":(I)Lkotlin/UInt;\n 289: invokeinterface #300, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 294: pop\n 295: aload 6\n 297: invokestatic #304 // Method strongestHandType:(Ljava/util/Map;)Lproblems/day7/part2/HandType;\n 300: checkcast #346 // class java/lang/Comparable\n 303: astore 4\n 305: aload_3\n 306: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 311: ifeq 441\n 314: aload_3\n 315: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 320: checkcast #194 // class problems/day7/part2/Card\n 323: astore 5\n 325: iconst_0\n 326: istore 6\n 328: aload_0\n 329: invokestatic #339 // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;\n 332: astore 7\n 334: nop\n 335: aload 7\n 337: getstatic #313 // Field problems/day7/part2/Card.JOKER:Lproblems/day7/part2/Card;\n 340: aload 7\n 342: getstatic #313 // Field problems/day7/part2/Card.JOKER:Lproblems/day7/part2/Card;\n 345: invokeinterface #316, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 350: dup\n 351: invokestatic #344 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 354: checkcast #282 // class kotlin/UInt\n 357: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 360: iconst_1\n 361: isub\n 362: invokestatic #297 // Method kotlin/UInt.\"constructor-impl\":(I)I\n 365: invokestatic #286 // Method kotlin/UInt.\"box-impl\":(I)Lkotlin/UInt;\n 368: invokeinterface #300, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 373: pop\n 374: nop\n 375: aload 7\n 377: aload 5\n 379: aload 7\n 381: aload 5\n 383: invokeinterface #316, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 388: dup\n 389: invokestatic #344 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 392: checkcast #282 // class kotlin/UInt\n 395: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 398: iconst_1\n 399: iadd\n 400: invokestatic #297 // Method kotlin/UInt.\"constructor-impl\":(I)I\n 403: invokestatic #286 // Method kotlin/UInt.\"box-impl\":(I)Lkotlin/UInt;\n 406: invokeinterface #300, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 411: pop\n 412: aload 7\n 414: invokestatic #304 // Method strongestHandType:(Ljava/util/Map;)Lproblems/day7/part2/HandType;\n 417: checkcast #346 // class java/lang/Comparable\n 420: astore 5\n 422: aload 4\n 424: aload 5\n 426: invokeinterface #349, 2 // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I\n 431: ifge 305\n 434: aload 5\n 436: astore 4\n 438: goto 305\n 441: aload 4\n 443: checkcast #321 // class problems/day7/part2/HandType\n 446: areturn\n\n private static final problems.day7.part2.HandType simpleHandType(java.util.Map<problems.day7.part2.Card, kotlin.UInt>);\n Code:\n 0: nop\n 1: aload_0\n 2: astore_1\n 3: iconst_0\n 4: istore_2\n 5: aload_1\n 6: invokeinterface #361, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 11: ifeq 18\n 14: iconst_0\n 15: goto 87\n 18: aload_1\n 19: invokeinterface #364, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 24: invokeinterface #367, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 29: astore_3\n 30: aload_3\n 31: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 36: ifeq 86\n 39: aload_3\n 40: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 45: checkcast #369 // class java/util/Map$Entry\n 48: astore 4\n 50: aload 4\n 52: astore 5\n 54: iconst_0\n 55: istore 6\n 57: aload 5\n 59: invokeinterface #372, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 64: checkcast #282 // class kotlin/UInt\n 67: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 70: iconst_5\n 71: if_icmpne 78\n 74: iconst_1\n 75: goto 79\n 78: iconst_0\n 79: ifeq 30\n 82: iconst_1\n 83: goto 87\n 86: iconst_0\n 87: ifeq 96\n 90: getstatic #324 // Field problems/day7/part2/HandType.FIVE_OF_A_KIND:Lproblems/day7/part2/HandType;\n 93: goto 705\n 96: aload_0\n 97: astore_1\n 98: iconst_0\n 99: istore_2\n 100: aload_1\n 101: invokeinterface #361, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 106: ifeq 113\n 109: iconst_0\n 110: goto 182\n 113: aload_1\n 114: invokeinterface #364, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 119: invokeinterface #367, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 124: astore_3\n 125: aload_3\n 126: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 131: ifeq 181\n 134: aload_3\n 135: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 140: checkcast #369 // class java/util/Map$Entry\n 143: astore 4\n 145: aload 4\n 147: astore 5\n 149: iconst_0\n 150: istore 6\n 152: aload 5\n 154: invokeinterface #372, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 159: checkcast #282 // class kotlin/UInt\n 162: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 165: iconst_4\n 166: if_icmpne 173\n 169: iconst_1\n 170: goto 174\n 173: iconst_0\n 174: ifeq 125\n 177: iconst_1\n 178: goto 182\n 181: iconst_0\n 182: ifeq 191\n 185: getstatic #375 // Field problems/day7/part2/HandType.FOUR_OF_A_KIND:Lproblems/day7/part2/HandType;\n 188: goto 705\n 191: aload_0\n 192: astore_1\n 193: iconst_0\n 194: istore_2\n 195: aload_1\n 196: invokeinterface #361, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 201: ifeq 208\n 204: iconst_0\n 205: goto 277\n 208: aload_1\n 209: invokeinterface #364, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 214: invokeinterface #367, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 219: astore_3\n 220: aload_3\n 221: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 226: ifeq 276\n 229: aload_3\n 230: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 235: checkcast #369 // class java/util/Map$Entry\n 238: astore 4\n 240: aload 4\n 242: astore 5\n 244: iconst_0\n 245: istore 6\n 247: aload 5\n 249: invokeinterface #372, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 254: checkcast #282 // class kotlin/UInt\n 257: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 260: iconst_3\n 261: if_icmpne 268\n 264: iconst_1\n 265: goto 269\n 268: iconst_0\n 269: ifeq 220\n 272: iconst_1\n 273: goto 277\n 276: iconst_0\n 277: aload_0\n 278: astore_1\n 279: istore 10\n 281: iconst_0\n 282: istore_2\n 283: aload_1\n 284: invokeinterface #361, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 289: ifeq 296\n 292: iconst_0\n 293: goto 365\n 296: aload_1\n 297: invokeinterface #364, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 302: invokeinterface #367, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 307: astore_3\n 308: aload_3\n 309: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 314: ifeq 364\n 317: aload_3\n 318: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 323: checkcast #369 // class java/util/Map$Entry\n 326: astore 4\n 328: aload 4\n 330: astore 5\n 332: iconst_0\n 333: istore 6\n 335: aload 5\n 337: invokeinterface #372, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 342: checkcast #282 // class kotlin/UInt\n 345: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 348: iconst_2\n 349: if_icmpne 356\n 352: iconst_1\n 353: goto 357\n 356: iconst_0\n 357: ifeq 308\n 360: iconst_1\n 361: goto 365\n 364: iconst_0\n 365: istore 11\n 367: iload 10\n 369: iload 11\n 371: iand\n 372: ifeq 381\n 375: getstatic #378 // Field problems/day7/part2/HandType.FULL_HOUSE:Lproblems/day7/part2/HandType;\n 378: goto 705\n 381: aload_0\n 382: astore_1\n 383: iconst_0\n 384: istore_2\n 385: aload_1\n 386: invokeinterface #361, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 391: ifeq 398\n 394: iconst_0\n 395: goto 467\n 398: aload_1\n 399: invokeinterface #364, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 404: invokeinterface #367, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 409: astore_3\n 410: aload_3\n 411: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 416: ifeq 466\n 419: aload_3\n 420: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 425: checkcast #369 // class java/util/Map$Entry\n 428: astore 4\n 430: aload 4\n 432: astore 5\n 434: iconst_0\n 435: istore 6\n 437: aload 5\n 439: invokeinterface #372, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 444: checkcast #282 // class kotlin/UInt\n 447: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 450: iconst_3\n 451: if_icmpne 458\n 454: iconst_1\n 455: goto 459\n 458: iconst_0\n 459: ifeq 410\n 462: iconst_1\n 463: goto 467\n 466: iconst_0\n 467: ifeq 476\n 470: getstatic #381 // Field problems/day7/part2/HandType.THREE_OF_A_KIND:Lproblems/day7/part2/HandType;\n 473: goto 705\n 476: aload_0\n 477: astore_1\n 478: iconst_0\n 479: istore_2\n 480: aload_1\n 481: astore_3\n 482: new #276 // class java/util/LinkedHashMap\n 485: dup\n 486: invokespecial #277 // Method java/util/LinkedHashMap.\"<init>\":()V\n 489: checkcast #279 // class java/util/Map\n 492: astore 4\n 494: iconst_0\n 495: istore 5\n 497: aload_3\n 498: invokeinterface #364, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 503: invokeinterface #367, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 508: astore 6\n 510: aload 6\n 512: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 517: ifeq 589\n 520: aload 6\n 522: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 527: checkcast #369 // class java/util/Map$Entry\n 530: astore 7\n 532: aload 7\n 534: astore 8\n 536: iconst_0\n 537: istore 9\n 539: aload 8\n 541: invokeinterface #372, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 546: checkcast #282 // class kotlin/UInt\n 549: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 552: iconst_2\n 553: if_icmpne 560\n 556: iconst_1\n 557: goto 561\n 560: iconst_0\n 561: ifeq 510\n 564: aload 4\n 566: aload 7\n 568: invokeinterface #384, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 573: aload 7\n 575: invokeinterface #372, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 580: invokeinterface #300, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 585: pop\n 586: goto 510\n 589: aload 4\n 591: nop\n 592: invokeinterface #387, 1 // InterfaceMethod java/util/Map.size:()I\n 597: iconst_2\n 598: if_icmpne 607\n 601: getstatic #390 // Field problems/day7/part2/HandType.TWO_PAIR:Lproblems/day7/part2/HandType;\n 604: goto 705\n 607: aload_0\n 608: astore_1\n 609: iconst_0\n 610: istore_2\n 611: aload_1\n 612: invokeinterface #361, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 617: ifeq 624\n 620: iconst_0\n 621: goto 693\n 624: aload_1\n 625: invokeinterface #364, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 630: invokeinterface #367, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 635: astore_3\n 636: aload_3\n 637: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 642: ifeq 692\n 645: aload_3\n 646: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 651: checkcast #369 // class java/util/Map$Entry\n 654: astore 4\n 656: aload 4\n 658: astore 5\n 660: iconst_0\n 661: istore 6\n 663: aload 5\n 665: invokeinterface #372, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 670: checkcast #282 // class kotlin/UInt\n 673: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 676: iconst_2\n 677: if_icmpne 684\n 680: iconst_1\n 681: goto 685\n 684: iconst_0\n 685: ifeq 636\n 688: iconst_1\n 689: goto 693\n 692: iconst_0\n 693: ifeq 702\n 696: getstatic #393 // Field problems/day7/part2/HandType.ONE_PAIR:Lproblems/day7/part2/HandType;\n 699: goto 705\n 702: getstatic #396 // Field problems/day7/part2/HandType.HIGH_CARD:Lproblems/day7/part2/HandType;\n 705: areturn\n\n private static final problems.day7.part2.Card toCard(char);\n Code:\n 0: iload_0\n 1: lookupswitch { // 13\n 50: 122\n 51: 128\n 52: 134\n 53: 140\n 54: 146\n 55: 152\n 56: 158\n 57: 164\n 65: 188\n 74: 116\n 75: 182\n 81: 176\n 84: 170\n default: 194\n }\n 116: getstatic #313 // Field problems/day7/part2/Card.JOKER:Lproblems/day7/part2/Card;\n 119: goto 228\n 122: getstatic #409 // Field problems/day7/part2/Card.TWO:Lproblems/day7/part2/Card;\n 125: goto 228\n 128: getstatic #412 // Field problems/day7/part2/Card.THREE:Lproblems/day7/part2/Card;\n 131: goto 228\n 134: getstatic #415 // Field problems/day7/part2/Card.FOUR:Lproblems/day7/part2/Card;\n 137: goto 228\n 140: getstatic #418 // Field problems/day7/part2/Card.FIVE:Lproblems/day7/part2/Card;\n 143: goto 228\n 146: getstatic #421 // Field problems/day7/part2/Card.SIX:Lproblems/day7/part2/Card;\n 149: goto 228\n 152: getstatic #424 // Field problems/day7/part2/Card.SEVEN:Lproblems/day7/part2/Card;\n 155: goto 228\n 158: getstatic #427 // Field problems/day7/part2/Card.EIGHT:Lproblems/day7/part2/Card;\n 161: goto 228\n 164: getstatic #430 // Field problems/day7/part2/Card.NINE:Lproblems/day7/part2/Card;\n 167: goto 228\n 170: getstatic #433 // Field problems/day7/part2/Card.TEN:Lproblems/day7/part2/Card;\n 173: goto 228\n 176: getstatic #436 // Field problems/day7/part2/Card.QUEEN:Lproblems/day7/part2/Card;\n 179: goto 228\n 182: getstatic #439 // Field problems/day7/part2/Card.KING:Lproblems/day7/part2/Card;\n 185: goto 228\n 188: getstatic #442 // Field problems/day7/part2/Card.ACE:Lproblems/day7/part2/Card;\n 191: goto 228\n 194: new #444 // class java/lang/IllegalArgumentException\n 197: dup\n 198: new #61 // class java/lang/StringBuilder\n 201: dup\n 202: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 205: ldc_w #446 // String Char\n 208: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 211: iload_0\n 212: invokevirtual #449 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 215: ldc_w #451 // String does not have a corresponding card\n 218: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 221: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 224: invokespecial #452 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 227: athrow\n 228: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #456 // Method main:()V\n 3: return\n\n private static final problems.day7.part2.Hand sumScores$lambda$1(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #459 // String it\n 4: invokestatic #463 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokestatic #465 // Method toHand:(Ljava/lang/String;)Lproblems/day7/part2/Hand;\n 11: areturn\n\n public static final int access$compareTo(java.util.List, java.util.List);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #468 // Method compareTo:(Ljava/util/List;Ljava/util/List;)I\n 5: ireturn\n}\n", "javap_err": "" } ]
klnusbaum__aoc2023__d30db24/src/problems/day7/part1/part1.kt
package problems.day7.part1 import java.io.File private const val inputFile = "input/day7/input.txt" //private const val testFile = "input/day7/test.txt" fun main() { val scoreSum = File(inputFile).bufferedReader().useLines { sumScores(it) } println("Sum of scores is $scoreSum") } private fun sumScores(lines: Sequence<String>): Int { return lines.map { it.toHand() } .sorted() .foldIndexed(0) { index, acc, hand -> acc + ((index + 1) * hand.bid) } } private data class Hand(val cards: List<Card>, val bid: Int, val handType: HandType) : Comparable<Hand> { override fun compareTo(other: Hand): Int { if (this.handType == other.handType) { return this.cards.compareTo(other.cards) } return this.handType.compareTo(other.handType) } } private fun List<Card>.compareTo(other: List<Card>): Int { for (pair in this.asSequence().zip(other.asSequence())) { if (pair.first != pair.second) { return pair.first.compareTo(pair.second) } } return 0 } private fun String.toHand(): Hand { val cards = this.substringBefore(" ").map { it.toCard() } val bid = this.substringAfter(" ").toInt() val handType = cards.toHandType() return Hand(cards, bid, handType) } private enum class HandType { HIGH_CARD, ONE_PAIR, TWO_PAIR, THREE_OF_A_KIND, FULL_HOUSE, FOUR_OF_A_KIND, FIVE_OF_A_KIND, } private fun List<Card>.toHandType(): HandType { val typeHistogram = mutableMapOf<Card, UInt>() for (card in this) { typeHistogram[card] = typeHistogram.getOrDefault(card, 0u) + 1u } return when { typeHistogram.any { it.value == 5u } -> HandType.FIVE_OF_A_KIND typeHistogram.any { it.value == 4u } -> HandType.FOUR_OF_A_KIND typeHistogram.any { it.value == 3u } and typeHistogram.any { it.value == 2u } -> HandType.FULL_HOUSE typeHistogram.any { it.value == 3u } -> HandType.THREE_OF_A_KIND typeHistogram.filter { it.value == 2u }.count() == 2 -> HandType.TWO_PAIR typeHistogram.any { it.value == 2u } -> HandType.ONE_PAIR else -> HandType.HIGH_CARD } } private enum class Card { TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, TEN, JACK, QUEEN, KING, ACE, } private fun Char.toCard() = when (this) { '2' -> Card.TWO '3' -> Card.THREE '4' -> Card.FOUR '5' -> Card.FIVE '6' -> Card.SIX '7' -> Card.SEVEN '8' -> Card.EIGHT '9' -> Card.NINE 'T' -> Card.TEN 'J' -> Card.JACK 'Q' -> Card.QUEEN 'K' -> Card.KING 'A' -> Card.ACE else -> throw IllegalArgumentException("Char $this does not have a corresponding card") }
[ { "class_path": "klnusbaum__aoc2023__d30db24/problems/day7/part1/Part1Kt.class", "javap": "Compiled from \"part1.kt\"\npublic final class problems.day7.part1.Part1Kt {\n private static final java.lang.String inputFile;\n\n public static final void main();\n Code:\n 0: new #10 // class java/io/File\n 3: dup\n 4: ldc #12 // String input/day7/input.txt\n 6: invokespecial #16 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_1\n 10: getstatic #22 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_2\n 14: sipush 8192\n 17: istore_3\n 18: aload_1\n 19: astore 4\n 21: new #24 // class java/io/InputStreamReader\n 24: dup\n 25: new #26 // class java/io/FileInputStream\n 28: dup\n 29: aload 4\n 31: invokespecial #29 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 34: checkcast #31 // class java/io/InputStream\n 37: aload_2\n 38: invokespecial #34 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 41: checkcast #36 // class java/io/Reader\n 44: astore 4\n 46: aload 4\n 48: instanceof #38 // class java/io/BufferedReader\n 51: ifeq 62\n 54: aload 4\n 56: checkcast #38 // class java/io/BufferedReader\n 59: goto 72\n 62: new #38 // class java/io/BufferedReader\n 65: dup\n 66: aload 4\n 68: iload_3\n 69: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 72: checkcast #36 // class java/io/Reader\n 75: astore_1\n 76: nop\n 77: iconst_0\n 78: istore_2\n 79: aload_1\n 80: astore_3\n 81: sipush 8192\n 84: istore 4\n 86: aload_3\n 87: instanceof #38 // class java/io/BufferedReader\n 90: ifeq 100\n 93: aload_3\n 94: checkcast #38 // class java/io/BufferedReader\n 97: goto 110\n 100: new #38 // class java/io/BufferedReader\n 103: dup\n 104: aload_3\n 105: iload 4\n 107: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 110: checkcast #43 // class java/io/Closeable\n 113: astore_3\n 114: aconst_null\n 115: astore 4\n 117: nop\n 118: aload_3\n 119: checkcast #38 // class java/io/BufferedReader\n 122: astore 5\n 124: iconst_0\n 125: istore 6\n 127: aload 5\n 129: invokestatic #49 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 132: astore 7\n 134: iconst_0\n 135: istore 8\n 137: aload 7\n 139: invokestatic #53 // Method sumScores:(Lkotlin/sequences/Sequence;)I\n 142: istore 5\n 144: aload_3\n 145: aload 4\n 147: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 150: iload 5\n 152: goto 175\n 155: astore 6\n 157: aload 6\n 159: astore 4\n 161: aload 6\n 163: athrow\n 164: astore 6\n 166: aload_3\n 167: aload 4\n 169: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 172: aload 6\n 174: athrow\n 175: nop\n 176: istore_0\n 177: new #61 // class java/lang/StringBuilder\n 180: dup\n 181: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 184: ldc #65 // String Sum of scores is\n 186: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 189: iload_0\n 190: invokevirtual #72 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 193: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 196: getstatic #82 // Field java/lang/System.out:Ljava/io/PrintStream;\n 199: swap\n 200: invokevirtual #88 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 203: return\n Exception table:\n from to target type\n 117 144 155 Class java/lang/Throwable\n 117 144 164 any\n 155 164 164 any\n 164 166 164 any\n\n private static final int sumScores(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokedynamic #123, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 6: invokestatic #129 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 9: invokestatic #133 // Method kotlin/sequences/SequencesKt.sorted:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 12: astore_1\n 13: iconst_0\n 14: istore_2\n 15: iconst_0\n 16: istore_3\n 17: iconst_0\n 18: istore 4\n 20: iload_2\n 21: istore 5\n 23: aload_1\n 24: invokeinterface #137, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 29: astore 6\n 31: aload 6\n 33: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 38: ifeq 101\n 41: aload 6\n 43: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 48: astore 7\n 50: iload 4\n 52: iinc 4, 1\n 55: istore 8\n 57: iload 8\n 59: ifge 65\n 62: invokestatic #152 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 65: iload 8\n 67: iload 5\n 69: aload 7\n 71: checkcast #154 // class problems/day7/part1/Hand\n 74: astore 9\n 76: istore 10\n 78: istore 11\n 80: iconst_0\n 81: istore 12\n 83: iload 10\n 85: iload 11\n 87: iconst_1\n 88: iadd\n 89: aload 9\n 91: invokevirtual #158 // Method problems/day7/part1/Hand.getBid:()I\n 94: imul\n 95: iadd\n 96: istore 5\n 98: goto 31\n 101: iload 5\n 103: ireturn\n\n private static final int compareTo(java.util.List<? extends problems.day7.part1.Card>, java.util.List<? extends problems.day7.part1.Card>);\n Code:\n 0: aload_0\n 1: checkcast #176 // class java/lang/Iterable\n 4: invokestatic #180 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 7: aload_1\n 8: checkcast #176 // class java/lang/Iterable\n 11: invokestatic #180 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 14: invokestatic #184 // Method kotlin/sequences/SequencesKt.zip:(Lkotlin/sequences/Sequence;Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 17: invokeinterface #137, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 22: astore_2\n 23: aload_2\n 24: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifeq 71\n 32: aload_2\n 33: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 38: checkcast #186 // class kotlin/Pair\n 41: astore_3\n 42: aload_3\n 43: invokevirtual #189 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 46: aload_3\n 47: invokevirtual #192 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 50: if_acmpeq 23\n 53: aload_3\n 54: invokevirtual #189 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 57: checkcast #194 // class problems/day7/part1/Card\n 60: aload_3\n 61: invokevirtual #192 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 64: checkcast #196 // class java/lang/Enum\n 67: invokevirtual #199 // Method problems/day7/part1/Card.compareTo:(Ljava/lang/Enum;)I\n 70: ireturn\n 71: iconst_0\n 72: ireturn\n\n private static final problems.day7.part1.Hand toHand(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #207 // String\n 3: aconst_null\n 4: iconst_2\n 5: aconst_null\n 6: invokestatic #213 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 9: checkcast #215 // class java/lang/CharSequence\n 12: astore_2\n 13: iconst_0\n 14: istore_3\n 15: aload_2\n 16: astore 4\n 18: new #217 // class java/util/ArrayList\n 21: dup\n 22: aload_2\n 23: invokeinterface #220, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 28: invokespecial #223 // Method java/util/ArrayList.\"<init>\":(I)V\n 31: checkcast #225 // class java/util/Collection\n 34: astore 5\n 36: iconst_0\n 37: istore 6\n 39: iconst_0\n 40: istore 7\n 42: iload 7\n 44: aload 4\n 46: invokeinterface #220, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 51: if_icmpge 96\n 54: aload 4\n 56: iload 7\n 58: invokeinterface #229, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 63: istore 8\n 65: aload 5\n 67: iload 8\n 69: istore 9\n 71: astore 11\n 73: iconst_0\n 74: istore 10\n 76: iload 9\n 78: invokestatic #233 // Method toCard:(C)Lproblems/day7/part1/Card;\n 81: aload 11\n 83: swap\n 84: invokeinterface #237, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 89: pop\n 90: iinc 7, 1\n 93: goto 42\n 96: aload 5\n 98: checkcast #239 // class java/util/List\n 101: nop\n 102: astore_1\n 103: aload_0\n 104: ldc #207 // String\n 106: aconst_null\n 107: iconst_2\n 108: aconst_null\n 109: invokestatic #242 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 112: invokestatic #248 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 115: istore_2\n 116: aload_1\n 117: invokestatic #252 // Method toHandType:(Ljava/util/List;)Lproblems/day7/part1/HandType;\n 120: astore_3\n 121: new #154 // class problems/day7/part1/Hand\n 124: dup\n 125: aload_1\n 126: iload_2\n 127: aload_3\n 128: invokespecial #255 // Method problems/day7/part1/Hand.\"<init>\":(Ljava/util/List;ILproblems/day7/part1/HandType;)V\n 131: areturn\n\n private static final problems.day7.part1.HandType toHandType(java.util.List<? extends problems.day7.part1.Card>);\n Code:\n 0: new #276 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #277 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #279 // class java/util/Map\n 10: astore_1\n 11: aload_0\n 12: invokeinterface #280, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 17: astore_2\n 18: aload_2\n 19: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 24: ifeq 74\n 27: aload_2\n 28: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 33: checkcast #194 // class problems/day7/part1/Card\n 36: astore_3\n 37: nop\n 38: aload_1\n 39: aload_3\n 40: aload_1\n 41: aload_3\n 42: iconst_0\n 43: invokestatic #286 // Method kotlin/UInt.\"box-impl\":(I)Lkotlin/UInt;\n 46: invokeinterface #290, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 51: checkcast #282 // class kotlin/UInt\n 54: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 57: iconst_1\n 58: iadd\n 59: invokestatic #297 // Method kotlin/UInt.\"constructor-impl\":(I)I\n 62: invokestatic #286 // Method kotlin/UInt.\"box-impl\":(I)Lkotlin/UInt;\n 65: invokeinterface #300, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 70: pop\n 71: goto 18\n 74: nop\n 75: aload_1\n 76: astore_2\n 77: iconst_0\n 78: istore_3\n 79: aload_2\n 80: invokeinterface #303, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 85: ifeq 92\n 88: iconst_0\n 89: goto 164\n 92: aload_2\n 93: invokeinterface #307, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 98: invokeinterface #310, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 103: astore 4\n 105: aload 4\n 107: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 112: ifeq 163\n 115: aload 4\n 117: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 122: checkcast #312 // class java/util/Map$Entry\n 125: astore 5\n 127: aload 5\n 129: astore 6\n 131: iconst_0\n 132: istore 7\n 134: aload 6\n 136: invokeinterface #315, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 141: checkcast #282 // class kotlin/UInt\n 144: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 147: iconst_5\n 148: if_icmpne 155\n 151: iconst_1\n 152: goto 156\n 155: iconst_0\n 156: ifeq 105\n 159: iconst_1\n 160: goto 164\n 163: iconst_0\n 164: ifeq 173\n 167: getstatic #320 // Field problems/day7/part1/HandType.FIVE_OF_A_KIND:Lproblems/day7/part1/HandType;\n 170: goto 799\n 173: aload_1\n 174: astore_2\n 175: iconst_0\n 176: istore_3\n 177: aload_2\n 178: invokeinterface #303, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 183: ifeq 190\n 186: iconst_0\n 187: goto 262\n 190: aload_2\n 191: invokeinterface #307, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 196: invokeinterface #310, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 201: astore 4\n 203: aload 4\n 205: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 210: ifeq 261\n 213: aload 4\n 215: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 220: checkcast #312 // class java/util/Map$Entry\n 223: astore 5\n 225: aload 5\n 227: astore 6\n 229: iconst_0\n 230: istore 7\n 232: aload 6\n 234: invokeinterface #315, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 239: checkcast #282 // class kotlin/UInt\n 242: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 245: iconst_4\n 246: if_icmpne 253\n 249: iconst_1\n 250: goto 254\n 253: iconst_0\n 254: ifeq 203\n 257: iconst_1\n 258: goto 262\n 261: iconst_0\n 262: ifeq 271\n 265: getstatic #323 // Field problems/day7/part1/HandType.FOUR_OF_A_KIND:Lproblems/day7/part1/HandType;\n 268: goto 799\n 271: aload_1\n 272: astore_2\n 273: iconst_0\n 274: istore_3\n 275: aload_2\n 276: invokeinterface #303, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 281: ifeq 288\n 284: iconst_0\n 285: goto 360\n 288: aload_2\n 289: invokeinterface #307, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 294: invokeinterface #310, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 299: astore 4\n 301: aload 4\n 303: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 308: ifeq 359\n 311: aload 4\n 313: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 318: checkcast #312 // class java/util/Map$Entry\n 321: astore 5\n 323: aload 5\n 325: astore 6\n 327: iconst_0\n 328: istore 7\n 330: aload 6\n 332: invokeinterface #315, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 337: checkcast #282 // class kotlin/UInt\n 340: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 343: iconst_3\n 344: if_icmpne 351\n 347: iconst_1\n 348: goto 352\n 351: iconst_0\n 352: ifeq 301\n 355: iconst_1\n 356: goto 360\n 359: iconst_0\n 360: aload_1\n 361: astore_2\n 362: istore 11\n 364: iconst_0\n 365: istore_3\n 366: aload_2\n 367: invokeinterface #303, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 372: ifeq 379\n 375: iconst_0\n 376: goto 451\n 379: aload_2\n 380: invokeinterface #307, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 385: invokeinterface #310, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 390: astore 4\n 392: aload 4\n 394: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 399: ifeq 450\n 402: aload 4\n 404: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 409: checkcast #312 // class java/util/Map$Entry\n 412: astore 5\n 414: aload 5\n 416: astore 6\n 418: iconst_0\n 419: istore 7\n 421: aload 6\n 423: invokeinterface #315, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 428: checkcast #282 // class kotlin/UInt\n 431: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 434: iconst_2\n 435: if_icmpne 442\n 438: iconst_1\n 439: goto 443\n 442: iconst_0\n 443: ifeq 392\n 446: iconst_1\n 447: goto 451\n 450: iconst_0\n 451: istore 12\n 453: iload 11\n 455: iload 12\n 457: iand\n 458: ifeq 467\n 461: getstatic #326 // Field problems/day7/part1/HandType.FULL_HOUSE:Lproblems/day7/part1/HandType;\n 464: goto 799\n 467: aload_1\n 468: astore_2\n 469: iconst_0\n 470: istore_3\n 471: aload_2\n 472: invokeinterface #303, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 477: ifeq 484\n 480: iconst_0\n 481: goto 556\n 484: aload_2\n 485: invokeinterface #307, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 490: invokeinterface #310, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 495: astore 4\n 497: aload 4\n 499: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 504: ifeq 555\n 507: aload 4\n 509: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 514: checkcast #312 // class java/util/Map$Entry\n 517: astore 5\n 519: aload 5\n 521: astore 6\n 523: iconst_0\n 524: istore 7\n 526: aload 6\n 528: invokeinterface #315, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 533: checkcast #282 // class kotlin/UInt\n 536: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 539: iconst_3\n 540: if_icmpne 547\n 543: iconst_1\n 544: goto 548\n 547: iconst_0\n 548: ifeq 497\n 551: iconst_1\n 552: goto 556\n 555: iconst_0\n 556: ifeq 565\n 559: getstatic #329 // Field problems/day7/part1/HandType.THREE_OF_A_KIND:Lproblems/day7/part1/HandType;\n 562: goto 799\n 565: aload_1\n 566: astore_2\n 567: iconst_0\n 568: istore_3\n 569: aload_2\n 570: astore 4\n 572: new #276 // class java/util/LinkedHashMap\n 575: dup\n 576: invokespecial #277 // Method java/util/LinkedHashMap.\"<init>\":()V\n 579: checkcast #279 // class java/util/Map\n 582: astore 5\n 584: iconst_0\n 585: istore 6\n 587: aload 4\n 589: invokeinterface #307, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 594: invokeinterface #310, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 599: astore 7\n 601: aload 7\n 603: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 608: ifeq 680\n 611: aload 7\n 613: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 618: checkcast #312 // class java/util/Map$Entry\n 621: astore 8\n 623: aload 8\n 625: astore 9\n 627: iconst_0\n 628: istore 10\n 630: aload 9\n 632: invokeinterface #315, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 637: checkcast #282 // class kotlin/UInt\n 640: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 643: iconst_2\n 644: if_icmpne 651\n 647: iconst_1\n 648: goto 652\n 651: iconst_0\n 652: ifeq 601\n 655: aload 5\n 657: aload 8\n 659: invokeinterface #332, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 664: aload 8\n 666: invokeinterface #315, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 671: invokeinterface #300, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 676: pop\n 677: goto 601\n 680: aload 5\n 682: nop\n 683: invokeinterface #335, 1 // InterfaceMethod java/util/Map.size:()I\n 688: iconst_2\n 689: if_icmpne 698\n 692: getstatic #338 // Field problems/day7/part1/HandType.TWO_PAIR:Lproblems/day7/part1/HandType;\n 695: goto 799\n 698: aload_1\n 699: astore_2\n 700: iconst_0\n 701: istore_3\n 702: aload_2\n 703: invokeinterface #303, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 708: ifeq 715\n 711: iconst_0\n 712: goto 787\n 715: aload_2\n 716: invokeinterface #307, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 721: invokeinterface #310, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 726: astore 4\n 728: aload 4\n 730: invokeinterface #143, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 735: ifeq 786\n 738: aload 4\n 740: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 745: checkcast #312 // class java/util/Map$Entry\n 748: astore 5\n 750: aload 5\n 752: astore 6\n 754: iconst_0\n 755: istore 7\n 757: aload 6\n 759: invokeinterface #315, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 764: checkcast #282 // class kotlin/UInt\n 767: invokevirtual #293 // Method kotlin/UInt.\"unbox-impl\":()I\n 770: iconst_2\n 771: if_icmpne 778\n 774: iconst_1\n 775: goto 779\n 778: iconst_0\n 779: ifeq 728\n 782: iconst_1\n 783: goto 787\n 786: iconst_0\n 787: ifeq 796\n 790: getstatic #341 // Field problems/day7/part1/HandType.ONE_PAIR:Lproblems/day7/part1/HandType;\n 793: goto 799\n 796: getstatic #344 // Field problems/day7/part1/HandType.HIGH_CARD:Lproblems/day7/part1/HandType;\n 799: areturn\n\n private static final problems.day7.part1.Card toCard(char);\n Code:\n 0: iload_0\n 1: lookupswitch { // 13\n 50: 116\n 51: 122\n 52: 128\n 53: 134\n 54: 140\n 55: 146\n 56: 152\n 57: 158\n 65: 188\n 74: 170\n 75: 182\n 81: 176\n 84: 164\n default: 194\n }\n 116: getstatic #367 // Field problems/day7/part1/Card.TWO:Lproblems/day7/part1/Card;\n 119: goto 228\n 122: getstatic #370 // Field problems/day7/part1/Card.THREE:Lproblems/day7/part1/Card;\n 125: goto 228\n 128: getstatic #373 // Field problems/day7/part1/Card.FOUR:Lproblems/day7/part1/Card;\n 131: goto 228\n 134: getstatic #376 // Field problems/day7/part1/Card.FIVE:Lproblems/day7/part1/Card;\n 137: goto 228\n 140: getstatic #379 // Field problems/day7/part1/Card.SIX:Lproblems/day7/part1/Card;\n 143: goto 228\n 146: getstatic #382 // Field problems/day7/part1/Card.SEVEN:Lproblems/day7/part1/Card;\n 149: goto 228\n 152: getstatic #385 // Field problems/day7/part1/Card.EIGHT:Lproblems/day7/part1/Card;\n 155: goto 228\n 158: getstatic #388 // Field problems/day7/part1/Card.NINE:Lproblems/day7/part1/Card;\n 161: goto 228\n 164: getstatic #391 // Field problems/day7/part1/Card.TEN:Lproblems/day7/part1/Card;\n 167: goto 228\n 170: getstatic #394 // Field problems/day7/part1/Card.JACK:Lproblems/day7/part1/Card;\n 173: goto 228\n 176: getstatic #397 // Field problems/day7/part1/Card.QUEEN:Lproblems/day7/part1/Card;\n 179: goto 228\n 182: getstatic #400 // Field problems/day7/part1/Card.KING:Lproblems/day7/part1/Card;\n 185: goto 228\n 188: getstatic #403 // Field problems/day7/part1/Card.ACE:Lproblems/day7/part1/Card;\n 191: goto 228\n 194: new #405 // class java/lang/IllegalArgumentException\n 197: dup\n 198: new #61 // class java/lang/StringBuilder\n 201: dup\n 202: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 205: ldc_w #407 // String Char\n 208: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 211: iload_0\n 212: invokevirtual #410 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 215: ldc_w #412 // String does not have a corresponding card\n 218: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 221: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 224: invokespecial #413 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 227: athrow\n 228: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #417 // Method main:()V\n 3: return\n\n private static final problems.day7.part1.Hand sumScores$lambda$1(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #420 // String it\n 4: invokestatic #426 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokestatic #428 // Method toHand:(Ljava/lang/String;)Lproblems/day7/part1/Hand;\n 11: areturn\n\n public static final int access$compareTo(java.util.List, java.util.List);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #431 // Method compareTo:(Ljava/util/List;Ljava/util/List;)I\n 5: ireturn\n}\n", "javap_err": "" } ]
klnusbaum__aoc2023__d30db24/src/problems/day8/part2/part2.kt
package problems.day8.part2 import java.io.File //private const val test3 = "input/day8/test3.txt" private const val inputFile = "input/day8/input.txt" fun main() { val stepsCount = File(inputFile).bufferedReader().useLines { numSteps(it) } println("Number of steps $stepsCount") } private fun numSteps(lines: Sequence<String>): Long { val (instructions, rules) = lines.fold(RuleSetBuilder()) { builder, line -> builder.nextLine(line) }.build() val startingLocations = rules.keys.filter { it.endsWith("A") } val cycleLengths = startingLocations.map { cycleLength(it, instructions.copy(), rules) }.map { it.toLong() } return leastCommonMultiple(cycleLengths) } private fun cycleLength(startPos: String, instructions: Instructions, rules: Map<String, Rule>): Int { var currentLocation = startPos while (!currentLocation.endsWith("Z")) { val nextDirection = instructions.next() val nextRule = rules[currentLocation] ?: throw IllegalArgumentException("No such location: $currentLocation") currentLocation = if (nextDirection == 'L') { nextRule.left } else { nextRule.right } } return instructions.directionCount } private fun leastCommonMultiple(numbers: List<Long>): Long = numbers.reduce { a, b -> leastCommonMultipleOfPair(a, b) } private fun leastCommonMultipleOfPair(a: Long, b: Long): Long = (a * b) / greatestCommonDivisor(a, b) private fun greatestCommonDivisor(a: Long, b: Long): Long = when { a == 0L -> b b == 0L -> a a > b -> greatestCommonDivisor(a % b, b) else -> greatestCommonDivisor(a, b % a) } private class Instructions(val directions: String) : Iterator<Char> { var directionCount = 0 override fun hasNext() = true override fun next(): Char { val next = directions[directionCount % directions.count()] directionCount++ return next } fun copy() = Instructions(this.directions) } private data class Rule(val left: String, val right: String) private fun String.toRule(): Rule { val left = this.substringBefore(", ").trimStart { it == '(' } val right = this.substringAfter(", ").trimEnd { it == ')' } return Rule(left, right) } private data class ParseResult(val instructions: Instructions, val rules: Map<String, Rule>) private class RuleSetBuilder { private var state = State.INSTRUCTIONS private var instructions: Instructions? = null private val rules = mutableMapOf<String, Rule>() private enum class State { INSTRUCTIONS, BLANK, RULES, } fun nextLine(line: String): RuleSetBuilder { when (state) { State.INSTRUCTIONS -> { instructions = Instructions(line) state = State.BLANK } State.BLANK -> { state = State.RULES } State.RULES -> { rules[line.substringBefore(" =")] = line.substringAfter("= ").toRule() } } return this } fun build() = ParseResult( instructions ?: throw IllegalArgumentException("missing instructions"), rules ) }
[ { "class_path": "klnusbaum__aoc2023__d30db24/problems/day8/part2/Part2Kt.class", "javap": "Compiled from \"part2.kt\"\npublic final class problems.day8.part2.Part2Kt {\n private static final java.lang.String inputFile;\n\n public static final void main();\n Code:\n 0: new #10 // class java/io/File\n 3: dup\n 4: ldc #12 // String input/day8/input.txt\n 6: invokespecial #16 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_2\n 10: getstatic #22 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_3\n 14: sipush 8192\n 17: istore 4\n 19: aload_2\n 20: astore 5\n 22: new #24 // class java/io/InputStreamReader\n 25: dup\n 26: new #26 // class java/io/FileInputStream\n 29: dup\n 30: aload 5\n 32: invokespecial #29 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 35: checkcast #31 // class java/io/InputStream\n 38: aload_3\n 39: invokespecial #34 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 42: checkcast #36 // class java/io/Reader\n 45: astore 5\n 47: aload 5\n 49: instanceof #38 // class java/io/BufferedReader\n 52: ifeq 63\n 55: aload 5\n 57: checkcast #38 // class java/io/BufferedReader\n 60: goto 74\n 63: new #38 // class java/io/BufferedReader\n 66: dup\n 67: aload 5\n 69: iload 4\n 71: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 74: checkcast #36 // class java/io/Reader\n 77: astore_2\n 78: nop\n 79: iconst_0\n 80: istore_3\n 81: aload_2\n 82: astore 4\n 84: sipush 8192\n 87: istore 5\n 89: aload 4\n 91: instanceof #38 // class java/io/BufferedReader\n 94: ifeq 105\n 97: aload 4\n 99: checkcast #38 // class java/io/BufferedReader\n 102: goto 116\n 105: new #38 // class java/io/BufferedReader\n 108: dup\n 109: aload 4\n 111: iload 5\n 113: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 116: checkcast #43 // class java/io/Closeable\n 119: astore 4\n 121: aconst_null\n 122: astore 5\n 124: nop\n 125: aload 4\n 127: checkcast #38 // class java/io/BufferedReader\n 130: astore 6\n 132: iconst_0\n 133: istore 8\n 135: aload 6\n 137: invokestatic #49 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 140: astore 9\n 142: iconst_0\n 143: istore 10\n 145: aload 9\n 147: invokestatic #53 // Method numSteps:(Lkotlin/sequences/Sequence;)J\n 150: lstore 6\n 152: aload 4\n 154: aload 5\n 156: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 159: lload 6\n 161: goto 185\n 164: astore 8\n 166: aload 8\n 168: astore 5\n 170: aload 8\n 172: athrow\n 173: astore 8\n 175: aload 4\n 177: aload 5\n 179: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 182: aload 8\n 184: athrow\n 185: nop\n 186: lstore_0\n 187: new #61 // class java/lang/StringBuilder\n 190: dup\n 191: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 194: ldc #65 // String Number of steps\n 196: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 199: lload_0\n 200: invokevirtual #72 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 203: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 206: getstatic #82 // Field java/lang/System.out:Ljava/io/PrintStream;\n 209: swap\n 210: invokevirtual #88 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 213: return\n Exception table:\n from to target type\n 124 152 164 Class java/lang/Throwable\n 124 152 173 any\n 164 173 173 any\n 173 175 173 any\n\n private static final long numSteps(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: aload_0\n 1: astore_2\n 2: new #107 // class problems/day8/part2/RuleSetBuilder\n 5: dup\n 6: invokespecial #108 // Method problems/day8/part2/RuleSetBuilder.\"<init>\":()V\n 9: astore_3\n 10: iconst_0\n 11: istore 4\n 13: aload_3\n 14: astore 5\n 16: aload_2\n 17: invokeinterface #112, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 22: astore 6\n 24: aload 6\n 26: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 31: ifeq 69\n 34: aload 6\n 36: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 41: astore 7\n 43: aload 5\n 45: aload 7\n 47: checkcast #124 // class java/lang/String\n 50: astore 8\n 52: astore 9\n 54: iconst_0\n 55: istore 10\n 57: aload 9\n 59: aload 8\n 61: invokevirtual #128 // Method problems/day8/part2/RuleSetBuilder.nextLine:(Ljava/lang/String;)Lproblems/day8/part2/RuleSetBuilder;\n 64: astore 5\n 66: goto 24\n 69: aload 5\n 71: invokevirtual #132 // Method problems/day8/part2/RuleSetBuilder.build:()Lproblems/day8/part2/ParseResult;\n 74: astore_1\n 75: aload_1\n 76: invokevirtual #138 // Method problems/day8/part2/ParseResult.component1:()Lproblems/day8/part2/Instructions;\n 79: astore_2\n 80: aload_1\n 81: invokevirtual #142 // Method problems/day8/part2/ParseResult.component2:()Ljava/util/Map;\n 84: astore_3\n 85: aload_3\n 86: invokeinterface #148, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 91: checkcast #150 // class java/lang/Iterable\n 94: astore 5\n 96: iconst_0\n 97: istore 6\n 99: aload 5\n 101: astore 7\n 103: new #152 // class java/util/ArrayList\n 106: dup\n 107: invokespecial #153 // Method java/util/ArrayList.\"<init>\":()V\n 110: checkcast #155 // class java/util/Collection\n 113: astore 8\n 115: iconst_0\n 116: istore 9\n 118: aload 7\n 120: invokeinterface #156, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 125: astore 10\n 127: aload 10\n 129: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 134: ifeq 182\n 137: aload 10\n 139: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 144: astore 11\n 146: aload 11\n 148: checkcast #124 // class java/lang/String\n 151: astore 12\n 153: iconst_0\n 154: istore 13\n 156: aload 12\n 158: ldc #158 // String A\n 160: iconst_0\n 161: iconst_2\n 162: aconst_null\n 163: invokestatic #164 // Method kotlin/text/StringsKt.endsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 166: ifeq 127\n 169: aload 8\n 171: aload 11\n 173: invokeinterface #168, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 178: pop\n 179: goto 127\n 182: aload 8\n 184: checkcast #170 // class java/util/List\n 187: nop\n 188: astore 4\n 190: aload 4\n 192: checkcast #150 // class java/lang/Iterable\n 195: astore 6\n 197: iconst_0\n 198: istore 7\n 200: aload 6\n 202: astore 8\n 204: new #152 // class java/util/ArrayList\n 207: dup\n 208: aload 6\n 210: bipush 10\n 212: invokestatic #176 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 215: invokespecial #179 // Method java/util/ArrayList.\"<init>\":(I)V\n 218: checkcast #155 // class java/util/Collection\n 221: astore 9\n 223: iconst_0\n 224: istore 10\n 226: aload 8\n 228: invokeinterface #156, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 233: astore 11\n 235: aload 11\n 237: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 242: ifeq 293\n 245: aload 11\n 247: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 252: astore 12\n 254: aload 9\n 256: aload 12\n 258: checkcast #124 // class java/lang/String\n 261: astore 13\n 263: astore 15\n 265: iconst_0\n 266: istore 14\n 268: aload 13\n 270: aload_2\n 271: invokevirtual #184 // Method problems/day8/part2/Instructions.copy:()Lproblems/day8/part2/Instructions;\n 274: aload_3\n 275: invokestatic #188 // Method cycleLength:(Ljava/lang/String;Lproblems/day8/part2/Instructions;Ljava/util/Map;)I\n 278: invokestatic #194 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 281: aload 15\n 283: swap\n 284: invokeinterface #168, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 289: pop\n 290: goto 235\n 293: aload 9\n 295: checkcast #170 // class java/util/List\n 298: nop\n 299: checkcast #150 // class java/lang/Iterable\n 302: astore 6\n 304: nop\n 305: iconst_0\n 306: istore 7\n 308: aload 6\n 310: astore 8\n 312: new #152 // class java/util/ArrayList\n 315: dup\n 316: aload 6\n 318: bipush 10\n 320: invokestatic #176 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 323: invokespecial #179 // Method java/util/ArrayList.\"<init>\":(I)V\n 326: checkcast #155 // class java/util/Collection\n 329: astore 9\n 331: iconst_0\n 332: istore 10\n 334: aload 8\n 336: invokeinterface #156, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 341: astore 11\n 343: aload 11\n 345: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 350: ifeq 397\n 353: aload 11\n 355: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 360: astore 12\n 362: aload 9\n 364: aload 12\n 366: checkcast #196 // class java/lang/Number\n 369: invokevirtual #200 // Method java/lang/Number.intValue:()I\n 372: istore 13\n 374: astore 15\n 376: iconst_0\n 377: istore 14\n 379: iload 13\n 381: i2l\n 382: invokestatic #205 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 385: aload 15\n 387: swap\n 388: invokeinterface #168, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 393: pop\n 394: goto 343\n 397: aload 9\n 399: checkcast #170 // class java/util/List\n 402: nop\n 403: astore 5\n 405: aload 5\n 407: invokestatic #209 // Method leastCommonMultiple:(Ljava/util/List;)J\n 410: lreturn\n\n private static final int cycleLength(java.lang.String, problems.day8.part2.Instructions, java.util.Map<java.lang.String, problems.day8.part2.Rule>);\n Code:\n 0: aload_0\n 1: astore_3\n 2: aload_3\n 3: ldc #247 // String Z\n 5: iconst_0\n 6: iconst_2\n 7: aconst_null\n 8: invokestatic #164 // Method kotlin/text/StringsKt.endsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 11: ifne 92\n 14: aload_1\n 15: invokevirtual #250 // Method problems/day8/part2/Instructions.next:()Ljava/lang/Character;\n 18: invokevirtual #256 // Method java/lang/Character.charValue:()C\n 21: istore 4\n 23: aload_2\n 24: aload_3\n 25: invokeinterface #260, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 30: checkcast #262 // class problems/day8/part2/Rule\n 33: dup\n 34: ifnonnull 66\n 37: pop\n 38: new #264 // class java/lang/IllegalArgumentException\n 41: dup\n 42: new #61 // class java/lang/StringBuilder\n 45: dup\n 46: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 49: ldc_w #266 // String No such location:\n 52: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 55: aload_3\n 56: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 59: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 62: invokespecial #267 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 65: athrow\n 66: astore 5\n 68: iload 4\n 70: bipush 76\n 72: if_icmpne 83\n 75: aload 5\n 77: invokevirtual #270 // Method problems/day8/part2/Rule.getLeft:()Ljava/lang/String;\n 80: goto 88\n 83: aload 5\n 85: invokevirtual #273 // Method problems/day8/part2/Rule.getRight:()Ljava/lang/String;\n 88: astore_3\n 89: goto 2\n 92: aload_1\n 93: invokevirtual #276 // Method problems/day8/part2/Instructions.getDirectionCount:()I\n 96: ireturn\n\n private static final long leastCommonMultiple(java.util.List<java.lang.Long>);\n Code:\n 0: aload_0\n 1: checkcast #150 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #156, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifne 34\n 23: new #285 // class java/lang/UnsupportedOperationException\n 26: dup\n 27: ldc_w #287 // String Empty collection can\\'t be reduced.\n 30: invokespecial #288 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 33: athrow\n 34: aload_3\n 35: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 40: astore 4\n 42: aload_3\n 43: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 93\n 51: aload 4\n 53: aload_3\n 54: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 59: checkcast #196 // class java/lang/Number\n 62: invokevirtual #292 // Method java/lang/Number.longValue:()J\n 65: lstore 5\n 67: checkcast #196 // class java/lang/Number\n 70: invokevirtual #292 // Method java/lang/Number.longValue:()J\n 73: lstore 7\n 75: iconst_0\n 76: istore 9\n 78: lload 7\n 80: lload 5\n 82: invokestatic #296 // Method leastCommonMultipleOfPair:(JJ)J\n 85: invokestatic #205 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 88: astore 4\n 90: goto 42\n 93: aload 4\n 95: checkcast #196 // class java/lang/Number\n 98: invokevirtual #292 // Method java/lang/Number.longValue:()J\n 101: lreturn\n\n private static final long leastCommonMultipleOfPair(long, long);\n Code:\n 0: lload_0\n 1: lload_2\n 2: lmul\n 3: lload_0\n 4: lload_2\n 5: invokestatic #307 // Method greatestCommonDivisor:(JJ)J\n 8: ldiv\n 9: lreturn\n\n private static final long greatestCommonDivisor(long, long);\n Code:\n 0: nop\n 1: lload_0\n 2: lconst_0\n 3: lcmp\n 4: ifne 11\n 7: lload_2\n 8: goto 44\n 11: lload_2\n 12: lconst_0\n 13: lcmp\n 14: ifne 21\n 17: lload_0\n 18: goto 44\n 21: lload_0\n 22: lload_2\n 23: lcmp\n 24: ifle 37\n 27: lload_0\n 28: lload_2\n 29: lrem\n 30: lload_2\n 31: invokestatic #307 // Method greatestCommonDivisor:(JJ)J\n 34: goto 44\n 37: lload_0\n 38: lload_2\n 39: lload_0\n 40: lrem\n 41: invokestatic #307 // Method greatestCommonDivisor:(JJ)J\n 44: lreturn\n\n private static final problems.day8.part2.Rule toRule(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #311 // String ,\n 4: aconst_null\n 5: iconst_2\n 6: aconst_null\n 7: invokestatic #315 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: checkcast #317 // class java/lang/CharSequence\n 17: astore 4\n 19: iconst_0\n 20: istore 5\n 22: iconst_0\n 23: istore 6\n 25: aload 4\n 27: invokeinterface #320, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 32: istore 7\n 34: iload 6\n 36: iload 7\n 38: if_icmpge 95\n 41: aload 4\n 43: iload 6\n 45: invokeinterface #324, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 50: istore 8\n 52: iconst_0\n 53: istore 9\n 55: iload 8\n 57: bipush 40\n 59: if_icmpne 66\n 62: iconst_1\n 63: goto 67\n 66: iconst_0\n 67: ifne 89\n 70: aload 4\n 72: iload 6\n 74: aload 4\n 76: invokeinterface #320, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 81: invokeinterface #328, 3 // InterfaceMethod java/lang/CharSequence.subSequence:(II)Ljava/lang/CharSequence;\n 86: goto 101\n 89: iinc 6, 1\n 92: goto 34\n 95: ldc_w #330 // String\n 98: checkcast #317 // class java/lang/CharSequence\n 101: invokevirtual #331 // Method java/lang/Object.toString:()Ljava/lang/String;\n 104: astore_1\n 105: aload_0\n 106: ldc_w #311 // String ,\n 109: aconst_null\n 110: iconst_2\n 111: aconst_null\n 112: invokestatic #334 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 115: astore_3\n 116: iconst_0\n 117: istore 4\n 119: aload_3\n 120: checkcast #317 // class java/lang/CharSequence\n 123: astore 5\n 125: iconst_0\n 126: istore 6\n 128: aload 5\n 130: invokeinterface #320, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 135: iconst_m1\n 136: iadd\n 137: istore 7\n 139: iconst_0\n 140: iload 7\n 142: if_icmpgt 202\n 145: iload 7\n 147: istore 8\n 149: iinc 7, -1\n 152: aload 5\n 154: iload 8\n 156: invokeinterface #324, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 161: istore 9\n 163: iconst_0\n 164: istore 10\n 166: iload 9\n 168: bipush 41\n 170: if_icmpne 177\n 173: iconst_1\n 174: goto 178\n 177: iconst_0\n 178: ifne 196\n 181: aload 5\n 183: iconst_0\n 184: iload 8\n 186: iconst_1\n 187: iadd\n 188: invokeinterface #328, 3 // InterfaceMethod java/lang/CharSequence.subSequence:(II)Ljava/lang/CharSequence;\n 193: goto 208\n 196: iconst_0\n 197: iload 7\n 199: if_icmple 145\n 202: ldc_w #330 // String\n 205: checkcast #317 // class java/lang/CharSequence\n 208: invokevirtual #331 // Method java/lang/Object.toString:()Ljava/lang/String;\n 211: astore_2\n 212: new #262 // class problems/day8/part2/Rule\n 215: dup\n 216: aload_1\n 217: aload_2\n 218: invokespecial #337 // Method problems/day8/part2/Rule.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 221: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #353 // Method main:()V\n 3: return\n\n public static final problems.day8.part2.Rule access$toRule(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #358 // Method toRule:(Ljava/lang/String;)Lproblems/day8/part2/Rule;\n 4: areturn\n}\n", "javap_err": "" } ]
klnusbaum__aoc2023__d30db24/src/problems/day8/part1/part1.kt
package problems.day8.part1 import java.io.File //private const val test1file = "input/day8/test1.txt" //private const val test2file = "input/day8/test2.txt" private const val inputFile = "input/day8/input.txt" fun main() { val stepsCount = File(inputFile).bufferedReader().useLines { numSteps(it) } println("Number of steps $stepsCount") } private fun numSteps(lines: Sequence<String>): Int { val (instructions, rules) = lines.fold(RuleSetBuilder()) { builder, line -> builder.nextLine(line) }.build() var currentLocation = "AAA" while (currentLocation != "ZZZ") { val nextDirection = instructions.next() val nextRule = rules[currentLocation] ?: throw IllegalArgumentException("No such location: $currentLocation") currentLocation = if (nextDirection == 'L') { nextRule.left } else { nextRule.right } } return instructions.directionCount } private class Instructions(val directions: String) : Iterator<Char> { var directionCount = 0 override fun hasNext() = true override fun next(): Char { val next = directions[directionCount % directions.count()] directionCount++ return next } } private data class Rule(val left: String, val right: String) private fun String.toRule(): Rule { val left = this.substringBefore(", ").trimStart { it == '(' } val right = this.substringAfter(", ").trimEnd { it == ')' } return Rule(left, right) } private data class ParseResult(val instructions: Instructions, val rules: Map<String, Rule>) private class RuleSetBuilder { private var state = State.INSTRUCTIONS private var instructions: Instructions? = null private val rules = mutableMapOf<String, Rule>() private enum class State { INSTRUCTIONS, BLANK, RULES, } fun nextLine(line: String): RuleSetBuilder { when (state) { State.INSTRUCTIONS -> { instructions = Instructions(line) state = State.BLANK } State.BLANK -> { state = State.RULES } State.RULES -> { rules[line.substringBefore(" =")] = line.substringAfter("= ").toRule() } } return this } fun build() = ParseResult( instructions ?: throw IllegalArgumentException("missing instructions"), rules ) }
[ { "class_path": "klnusbaum__aoc2023__d30db24/problems/day8/part1/Part1Kt.class", "javap": "Compiled from \"part1.kt\"\npublic final class problems.day8.part1.Part1Kt {\n private static final java.lang.String inputFile;\n\n public static final void main();\n Code:\n 0: new #10 // class java/io/File\n 3: dup\n 4: ldc #12 // String input/day8/input.txt\n 6: invokespecial #16 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_1\n 10: getstatic #22 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_2\n 14: sipush 8192\n 17: istore_3\n 18: aload_1\n 19: astore 4\n 21: new #24 // class java/io/InputStreamReader\n 24: dup\n 25: new #26 // class java/io/FileInputStream\n 28: dup\n 29: aload 4\n 31: invokespecial #29 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 34: checkcast #31 // class java/io/InputStream\n 37: aload_2\n 38: invokespecial #34 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 41: checkcast #36 // class java/io/Reader\n 44: astore 4\n 46: aload 4\n 48: instanceof #38 // class java/io/BufferedReader\n 51: ifeq 62\n 54: aload 4\n 56: checkcast #38 // class java/io/BufferedReader\n 59: goto 72\n 62: new #38 // class java/io/BufferedReader\n 65: dup\n 66: aload 4\n 68: iload_3\n 69: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 72: checkcast #36 // class java/io/Reader\n 75: astore_1\n 76: nop\n 77: iconst_0\n 78: istore_2\n 79: aload_1\n 80: astore_3\n 81: sipush 8192\n 84: istore 4\n 86: aload_3\n 87: instanceof #38 // class java/io/BufferedReader\n 90: ifeq 100\n 93: aload_3\n 94: checkcast #38 // class java/io/BufferedReader\n 97: goto 110\n 100: new #38 // class java/io/BufferedReader\n 103: dup\n 104: aload_3\n 105: iload 4\n 107: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 110: checkcast #43 // class java/io/Closeable\n 113: astore_3\n 114: aconst_null\n 115: astore 4\n 117: nop\n 118: aload_3\n 119: checkcast #38 // class java/io/BufferedReader\n 122: astore 5\n 124: iconst_0\n 125: istore 6\n 127: aload 5\n 129: invokestatic #49 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 132: astore 7\n 134: iconst_0\n 135: istore 8\n 137: aload 7\n 139: invokestatic #53 // Method numSteps:(Lkotlin/sequences/Sequence;)I\n 142: istore 5\n 144: aload_3\n 145: aload 4\n 147: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 150: iload 5\n 152: goto 175\n 155: astore 6\n 157: aload 6\n 159: astore 4\n 161: aload 6\n 163: athrow\n 164: astore 6\n 166: aload_3\n 167: aload 4\n 169: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 172: aload 6\n 174: athrow\n 175: nop\n 176: istore_0\n 177: new #61 // class java/lang/StringBuilder\n 180: dup\n 181: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 184: ldc #65 // String Number of steps\n 186: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 189: iload_0\n 190: invokevirtual #72 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 193: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 196: getstatic #82 // Field java/lang/System.out:Ljava/io/PrintStream;\n 199: swap\n 200: invokevirtual #88 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 203: return\n Exception table:\n from to target type\n 117 144 155 Class java/lang/Throwable\n 117 144 164 any\n 155 164 164 any\n 164 166 164 any\n\n private static final int numSteps(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: aload_0\n 1: astore_2\n 2: new #106 // class problems/day8/part1/RuleSetBuilder\n 5: dup\n 6: invokespecial #107 // Method problems/day8/part1/RuleSetBuilder.\"<init>\":()V\n 9: astore_3\n 10: iconst_0\n 11: istore 4\n 13: aload_3\n 14: astore 5\n 16: aload_2\n 17: invokeinterface #111, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 22: astore 6\n 24: aload 6\n 26: invokeinterface #117, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 31: ifeq 69\n 34: aload 6\n 36: invokeinterface #121, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 41: astore 7\n 43: aload 5\n 45: aload 7\n 47: checkcast #123 // class java/lang/String\n 50: astore 8\n 52: astore 9\n 54: iconst_0\n 55: istore 10\n 57: aload 9\n 59: aload 8\n 61: invokevirtual #127 // Method problems/day8/part1/RuleSetBuilder.nextLine:(Ljava/lang/String;)Lproblems/day8/part1/RuleSetBuilder;\n 64: astore 5\n 66: goto 24\n 69: aload 5\n 71: invokevirtual #131 // Method problems/day8/part1/RuleSetBuilder.build:()Lproblems/day8/part1/ParseResult;\n 74: astore_1\n 75: aload_1\n 76: invokevirtual #137 // Method problems/day8/part1/ParseResult.component1:()Lproblems/day8/part1/Instructions;\n 79: astore_2\n 80: aload_1\n 81: invokevirtual #141 // Method problems/day8/part1/ParseResult.component2:()Ljava/util/Map;\n 84: astore_3\n 85: ldc #143 // String AAA\n 87: astore 4\n 89: aload 4\n 91: ldc #145 // String ZZZ\n 93: invokestatic #151 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 96: ifne 179\n 99: aload_2\n 100: invokevirtual #156 // Method problems/day8/part1/Instructions.next:()Ljava/lang/Character;\n 103: invokevirtual #162 // Method java/lang/Character.charValue:()C\n 106: istore 5\n 108: aload_3\n 109: aload 4\n 111: invokeinterface #168, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 116: checkcast #170 // class problems/day8/part1/Rule\n 119: dup\n 120: ifnonnull 152\n 123: pop\n 124: new #172 // class java/lang/IllegalArgumentException\n 127: dup\n 128: new #61 // class java/lang/StringBuilder\n 131: dup\n 132: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 135: ldc #174 // String No such location:\n 137: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 140: aload 4\n 142: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 145: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 148: invokespecial #175 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 151: athrow\n 152: astore 6\n 154: iload 5\n 156: bipush 76\n 158: if_icmpne 169\n 161: aload 6\n 163: invokevirtual #178 // Method problems/day8/part1/Rule.getLeft:()Ljava/lang/String;\n 166: goto 174\n 169: aload 6\n 171: invokevirtual #181 // Method problems/day8/part1/Rule.getRight:()Ljava/lang/String;\n 174: astore 4\n 176: goto 89\n 179: aload_2\n 180: invokevirtual #185 // Method problems/day8/part1/Instructions.getDirectionCount:()I\n 183: ireturn\n\n private static final problems.day8.part1.Rule toRule(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #210 // String ,\n 3: aconst_null\n 4: iconst_2\n 5: aconst_null\n 6: invokestatic #216 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 9: astore_2\n 10: iconst_0\n 11: istore_3\n 12: aload_2\n 13: checkcast #218 // class java/lang/CharSequence\n 16: astore 4\n 18: iconst_0\n 19: istore 5\n 21: iconst_0\n 22: istore 6\n 24: aload 4\n 26: invokeinterface #221, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 31: istore 7\n 33: iload 6\n 35: iload 7\n 37: if_icmpge 94\n 40: aload 4\n 42: iload 6\n 44: invokeinterface #225, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 49: istore 8\n 51: iconst_0\n 52: istore 9\n 54: iload 8\n 56: bipush 40\n 58: if_icmpne 65\n 61: iconst_1\n 62: goto 66\n 65: iconst_0\n 66: ifne 88\n 69: aload 4\n 71: iload 6\n 73: aload 4\n 75: invokeinterface #221, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 80: invokeinterface #229, 3 // InterfaceMethod java/lang/CharSequence.subSequence:(II)Ljava/lang/CharSequence;\n 85: goto 99\n 88: iinc 6, 1\n 91: goto 33\n 94: ldc #231 // String\n 96: checkcast #218 // class java/lang/CharSequence\n 99: invokevirtual #232 // Method java/lang/Object.toString:()Ljava/lang/String;\n 102: astore_1\n 103: aload_0\n 104: ldc #210 // String ,\n 106: aconst_null\n 107: iconst_2\n 108: aconst_null\n 109: invokestatic #235 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 112: astore_3\n 113: iconst_0\n 114: istore 4\n 116: aload_3\n 117: checkcast #218 // class java/lang/CharSequence\n 120: astore 5\n 122: iconst_0\n 123: istore 6\n 125: aload 5\n 127: invokeinterface #221, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 132: iconst_m1\n 133: iadd\n 134: istore 7\n 136: iconst_0\n 137: iload 7\n 139: if_icmpgt 199\n 142: iload 7\n 144: istore 8\n 146: iinc 7, -1\n 149: aload 5\n 151: iload 8\n 153: invokeinterface #225, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 158: istore 9\n 160: iconst_0\n 161: istore 10\n 163: iload 9\n 165: bipush 41\n 167: if_icmpne 174\n 170: iconst_1\n 171: goto 175\n 174: iconst_0\n 175: ifne 193\n 178: aload 5\n 180: iconst_0\n 181: iload 8\n 183: iconst_1\n 184: iadd\n 185: invokeinterface #229, 3 // InterfaceMethod java/lang/CharSequence.subSequence:(II)Ljava/lang/CharSequence;\n 190: goto 204\n 193: iconst_0\n 194: iload 7\n 196: if_icmple 142\n 199: ldc #231 // String\n 201: checkcast #218 // class java/lang/CharSequence\n 204: invokevirtual #232 // Method java/lang/Object.toString:()Ljava/lang/String;\n 207: astore_2\n 208: new #170 // class problems/day8/part1/Rule\n 211: dup\n 212: aload_1\n 213: aload_2\n 214: invokespecial #238 // Method problems/day8/part1/Rule.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 217: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #254 // Method main:()V\n 3: return\n\n public static final problems.day8.part1.Rule access$toRule(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #259 // Method toRule:(Ljava/lang/String;)Lproblems/day8/part1/Rule;\n 4: areturn\n}\n", "javap_err": "" } ]
klnusbaum__aoc2023__d30db24/src/problems/day6/part2/part2.kt
package problems.day6.part2 import java.io.File import kotlin.math.ceil import kotlin.math.floor import kotlin.math.sqrt private const val inputFile = "input/day6/input.txt" //const val testFile = "input/day6/test.txt" fun main() { val numberOfBeats = File(inputFile).bufferedReader().useLines { multiplyNumBeats(it) } println("The number of ways to be the current max is: $numberOfBeats") } private fun multiplyNumBeats(lines: Sequence<String>): Long { val iterator = lines.iterator() val time = iterator.next().toTime() val maxes = iterator.next().toMax() return Race(time, maxes).numBeats() } private fun String.toTime(): Long { return this.substringAfter("Time: ") .replace(" ","") .toLong() } private fun String.toMax(): Long { return this.substringAfter("Distance: ") .replace(" ","") .toLong() } private data class Race(val time: Long, val currentMax: Long) { fun numBeats(): Long { val a = -1 val b = time val c = -currentMax val discriminant = sqrt(((b * b) - (4.0 * a * c))) val low = (-b + discriminant) / (2 * a) val high = (-b - discriminant) / (2 * a) val flooredHigh = floor(high) val ceiledLow = ceil(low) var numBeats = (flooredHigh - ceiledLow).toLong() + 1 if (flooredHigh == high) { numBeats-- } if (ceiledLow == low) { numBeats-- } return numBeats } }
[ { "class_path": "klnusbaum__aoc2023__d30db24/problems/day6/part2/Part2Kt.class", "javap": "Compiled from \"part2.kt\"\npublic final class problems.day6.part2.Part2Kt {\n private static final java.lang.String inputFile;\n\n public static final void main();\n Code:\n 0: new #10 // class java/io/File\n 3: dup\n 4: ldc #12 // String input/day6/input.txt\n 6: invokespecial #16 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_2\n 10: getstatic #22 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_3\n 14: sipush 8192\n 17: istore 4\n 19: aload_2\n 20: astore 5\n 22: new #24 // class java/io/InputStreamReader\n 25: dup\n 26: new #26 // class java/io/FileInputStream\n 29: dup\n 30: aload 5\n 32: invokespecial #29 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 35: checkcast #31 // class java/io/InputStream\n 38: aload_3\n 39: invokespecial #34 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 42: checkcast #36 // class java/io/Reader\n 45: astore 5\n 47: aload 5\n 49: instanceof #38 // class java/io/BufferedReader\n 52: ifeq 63\n 55: aload 5\n 57: checkcast #38 // class java/io/BufferedReader\n 60: goto 74\n 63: new #38 // class java/io/BufferedReader\n 66: dup\n 67: aload 5\n 69: iload 4\n 71: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 74: checkcast #36 // class java/io/Reader\n 77: astore_2\n 78: nop\n 79: iconst_0\n 80: istore_3\n 81: aload_2\n 82: astore 4\n 84: sipush 8192\n 87: istore 5\n 89: aload 4\n 91: instanceof #38 // class java/io/BufferedReader\n 94: ifeq 105\n 97: aload 4\n 99: checkcast #38 // class java/io/BufferedReader\n 102: goto 116\n 105: new #38 // class java/io/BufferedReader\n 108: dup\n 109: aload 4\n 111: iload 5\n 113: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 116: checkcast #43 // class java/io/Closeable\n 119: astore 4\n 121: aconst_null\n 122: astore 5\n 124: nop\n 125: aload 4\n 127: checkcast #38 // class java/io/BufferedReader\n 130: astore 6\n 132: iconst_0\n 133: istore 8\n 135: aload 6\n 137: invokestatic #49 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 140: astore 9\n 142: iconst_0\n 143: istore 10\n 145: aload 9\n 147: invokestatic #53 // Method multiplyNumBeats:(Lkotlin/sequences/Sequence;)J\n 150: lstore 6\n 152: aload 4\n 154: aload 5\n 156: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 159: lload 6\n 161: goto 185\n 164: astore 8\n 166: aload 8\n 168: astore 5\n 170: aload 8\n 172: athrow\n 173: astore 8\n 175: aload 4\n 177: aload 5\n 179: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 182: aload 8\n 184: athrow\n 185: nop\n 186: lstore_0\n 187: new #61 // class java/lang/StringBuilder\n 190: dup\n 191: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 194: ldc #65 // String The number of ways to be the current max is:\n 196: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 199: lload_0\n 200: invokevirtual #72 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 203: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 206: getstatic #82 // Field java/lang/System.out:Ljava/io/PrintStream;\n 209: swap\n 210: invokevirtual #88 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 213: return\n Exception table:\n from to target type\n 124 152 164 Class java/lang/Throwable\n 124 152 173 any\n 164 173 173 any\n 173 175 173 any\n\n private static final long multiplyNumBeats(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokeinterface #109, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 6: astore_1\n 7: aload_1\n 8: invokeinterface #115, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 13: checkcast #117 // class java/lang/String\n 16: invokestatic #121 // Method toTime:(Ljava/lang/String;)J\n 19: lstore_2\n 20: aload_1\n 21: invokeinterface #115, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 26: checkcast #117 // class java/lang/String\n 29: invokestatic #124 // Method toMax:(Ljava/lang/String;)J\n 32: lstore 4\n 34: new #126 // class problems/day6/part2/Race\n 37: dup\n 38: lload_2\n 39: lload 4\n 41: invokespecial #129 // Method problems/day6/part2/Race.\"<init>\":(JJ)V\n 44: invokevirtual #133 // Method problems/day6/part2/Race.numBeats:()J\n 47: lreturn\n\n private static final long toTime(java.lang.String);\n Code:\n 0: nop\n 1: aload_0\n 2: ldc #139 // String Time:\n 4: aconst_null\n 5: iconst_2\n 6: aconst_null\n 7: invokestatic #145 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 10: ldc #147 // String\n 12: ldc #149 // String\n 14: iconst_0\n 15: iconst_4\n 16: aconst_null\n 17: invokestatic #153 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 20: invokestatic #158 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 23: lreturn\n\n private static final long toMax(java.lang.String);\n Code:\n 0: nop\n 1: aload_0\n 2: ldc #162 // String Distance:\n 4: aconst_null\n 5: iconst_2\n 6: aconst_null\n 7: invokestatic #145 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 10: ldc #147 // String\n 12: ldc #149 // String\n 14: iconst_0\n 15: iconst_4\n 16: aconst_null\n 17: invokestatic #153 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 20: invokestatic #158 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 23: lreturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #166 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
klnusbaum__aoc2023__d30db24/src/problems/day6/part1/part1.kt
package problems.day6.part1 import java.io.File import kotlin.math.ceil import kotlin.math.floor import kotlin.math.sqrt private const val inputFile = "input/day6/input.txt" //private const val testFile = "input/day6/test.txt" fun main() { val productOfNumBeats = File(inputFile).bufferedReader().useLines { multiplyNumBeats(it) } println("Product of number of ways to beat all races: $productOfNumBeats") } private fun multiplyNumBeats(lines: Sequence<String>): Int { val iterator = lines.iterator() val times = iterator.next().toTimes() val maxes = iterator.next().toMaxes() val races = times.zip(maxes) { time, max -> Race(time, max) } return races.map { it.numBeats() }.fold(1) { acc, next -> next * acc } } private fun String.toTimes(): List<Int> { return this.substringAfter("Time: ") .trim() .split("\\s+".toRegex()) .map { it.toInt() } } private fun String.toMaxes(): List<Int> { return this.substringAfter("Distance: ") .trim() .split("\\s+".toRegex()) .map { it.toInt() } } private data class Race(val time: Int, val currentMax: Int) { fun numBeats(): Int { val a = -1 val b = time val c = -currentMax val discriminant = sqrt(((b * b) - (4.0 * a * c))) val low = (-b + discriminant) / (2 * a) val high = (-b - discriminant) / (2 * a) val flooredHigh = floor(high) val ceiledLow = ceil(low) var numBeats = (flooredHigh - ceiledLow).toInt() + 1 if (flooredHigh == high) { numBeats-- } if (ceiledLow == low) { numBeats-- } return numBeats } }
[ { "class_path": "klnusbaum__aoc2023__d30db24/problems/day6/part1/Part1Kt.class", "javap": "Compiled from \"part1.kt\"\npublic final class problems.day6.part1.Part1Kt {\n private static final java.lang.String inputFile;\n\n public static final void main();\n Code:\n 0: new #10 // class java/io/File\n 3: dup\n 4: ldc #12 // String input/day6/input.txt\n 6: invokespecial #16 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_1\n 10: getstatic #22 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_2\n 14: sipush 8192\n 17: istore_3\n 18: aload_1\n 19: astore 4\n 21: new #24 // class java/io/InputStreamReader\n 24: dup\n 25: new #26 // class java/io/FileInputStream\n 28: dup\n 29: aload 4\n 31: invokespecial #29 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 34: checkcast #31 // class java/io/InputStream\n 37: aload_2\n 38: invokespecial #34 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 41: checkcast #36 // class java/io/Reader\n 44: astore 4\n 46: aload 4\n 48: instanceof #38 // class java/io/BufferedReader\n 51: ifeq 62\n 54: aload 4\n 56: checkcast #38 // class java/io/BufferedReader\n 59: goto 72\n 62: new #38 // class java/io/BufferedReader\n 65: dup\n 66: aload 4\n 68: iload_3\n 69: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 72: checkcast #36 // class java/io/Reader\n 75: astore_1\n 76: nop\n 77: iconst_0\n 78: istore_2\n 79: aload_1\n 80: astore_3\n 81: sipush 8192\n 84: istore 4\n 86: aload_3\n 87: instanceof #38 // class java/io/BufferedReader\n 90: ifeq 100\n 93: aload_3\n 94: checkcast #38 // class java/io/BufferedReader\n 97: goto 110\n 100: new #38 // class java/io/BufferedReader\n 103: dup\n 104: aload_3\n 105: iload 4\n 107: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 110: checkcast #43 // class java/io/Closeable\n 113: astore_3\n 114: aconst_null\n 115: astore 4\n 117: nop\n 118: aload_3\n 119: checkcast #38 // class java/io/BufferedReader\n 122: astore 5\n 124: iconst_0\n 125: istore 6\n 127: aload 5\n 129: invokestatic #49 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 132: astore 7\n 134: iconst_0\n 135: istore 8\n 137: aload 7\n 139: invokestatic #53 // Method multiplyNumBeats:(Lkotlin/sequences/Sequence;)I\n 142: istore 5\n 144: aload_3\n 145: aload 4\n 147: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 150: iload 5\n 152: goto 175\n 155: astore 6\n 157: aload 6\n 159: astore 4\n 161: aload 6\n 163: athrow\n 164: astore 6\n 166: aload_3\n 167: aload 4\n 169: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 172: aload 6\n 174: athrow\n 175: nop\n 176: istore_0\n 177: new #61 // class java/lang/StringBuilder\n 180: dup\n 181: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 184: ldc #65 // String Product of number of ways to beat all races:\n 186: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 189: iload_0\n 190: invokevirtual #72 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 193: invokevirtual #76 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 196: getstatic #82 // Field java/lang/System.out:Ljava/io/PrintStream;\n 199: swap\n 200: invokevirtual #88 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 203: return\n Exception table:\n from to target type\n 117 144 155 Class java/lang/Throwable\n 117 144 164 any\n 155 164 164 any\n 164 166 164 any\n\n private static final int multiplyNumBeats(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokeinterface #108, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 6: astore_1\n 7: aload_1\n 8: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 13: checkcast #116 // class java/lang/String\n 16: invokestatic #120 // Method toTimes:(Ljava/lang/String;)Ljava/util/List;\n 19: astore_2\n 20: aload_1\n 21: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 26: checkcast #116 // class java/lang/String\n 29: invokestatic #123 // Method toMaxes:(Ljava/lang/String;)Ljava/util/List;\n 32: astore_3\n 33: aload_2\n 34: checkcast #125 // class java/lang/Iterable\n 37: astore 5\n 39: iconst_0\n 40: istore 6\n 42: aload 5\n 44: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 49: astore 7\n 51: aload_3\n 52: checkcast #125 // class java/lang/Iterable\n 55: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 60: astore 8\n 62: new #128 // class java/util/ArrayList\n 65: dup\n 66: aload 5\n 68: bipush 10\n 70: invokestatic #134 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 73: aload_3\n 74: checkcast #125 // class java/lang/Iterable\n 77: bipush 10\n 79: invokestatic #134 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 82: invokestatic #140 // Method java/lang/Math.min:(II)I\n 85: invokespecial #143 // Method java/util/ArrayList.\"<init>\":(I)V\n 88: astore 9\n 90: aload 7\n 92: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 97: ifeq 168\n 100: aload 8\n 102: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 107: ifeq 168\n 110: aload 9\n 112: aload 7\n 114: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 119: aload 8\n 121: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 126: checkcast #149 // class java/lang/Number\n 129: invokevirtual #153 // Method java/lang/Number.intValue:()I\n 132: istore 10\n 134: checkcast #149 // class java/lang/Number\n 137: invokevirtual #153 // Method java/lang/Number.intValue:()I\n 140: istore 11\n 142: astore 14\n 144: iconst_0\n 145: istore 12\n 147: new #155 // class problems/day6/part1/Race\n 150: dup\n 151: iload 11\n 153: iload 10\n 155: invokespecial #158 // Method problems/day6/part1/Race.\"<init>\":(II)V\n 158: aload 14\n 160: swap\n 161: invokevirtual #162 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 164: pop\n 165: goto 90\n 168: aload 9\n 170: checkcast #164 // class java/util/List\n 173: astore 4\n 175: aload 4\n 177: checkcast #125 // class java/lang/Iterable\n 180: astore 5\n 182: iconst_0\n 183: istore 6\n 185: aload 5\n 187: astore 7\n 189: new #128 // class java/util/ArrayList\n 192: dup\n 193: aload 5\n 195: bipush 10\n 197: invokestatic #134 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 200: invokespecial #143 // Method java/util/ArrayList.\"<init>\":(I)V\n 203: checkcast #166 // class java/util/Collection\n 206: astore 8\n 208: iconst_0\n 209: istore 9\n 211: aload 7\n 213: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 218: astore 10\n 220: aload 10\n 222: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 227: ifeq 273\n 230: aload 10\n 232: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 237: astore 11\n 239: aload 8\n 241: aload 11\n 243: checkcast #155 // class problems/day6/part1/Race\n 246: astore 12\n 248: astore 14\n 250: iconst_0\n 251: istore 13\n 253: aload 12\n 255: invokevirtual #169 // Method problems/day6/part1/Race.numBeats:()I\n 258: invokestatic #175 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 261: aload 14\n 263: swap\n 264: invokeinterface #176, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 269: pop\n 270: goto 220\n 273: aload 8\n 275: checkcast #164 // class java/util/List\n 278: nop\n 279: checkcast #125 // class java/lang/Iterable\n 282: astore 5\n 284: iconst_1\n 285: istore 6\n 287: iconst_0\n 288: istore 7\n 290: iload 6\n 292: istore 8\n 294: aload 5\n 296: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 301: astore 9\n 303: aload 9\n 305: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 310: ifeq 349\n 313: aload 9\n 315: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 320: astore 10\n 322: iload 8\n 324: aload 10\n 326: checkcast #149 // class java/lang/Number\n 329: invokevirtual #153 // Method java/lang/Number.intValue:()I\n 332: istore 11\n 334: istore 12\n 336: iconst_0\n 337: istore 13\n 339: iload 11\n 341: iload 12\n 343: imul\n 344: istore 8\n 346: goto 303\n 349: iload 8\n 351: ireturn\n\n private static final java.util.List<java.lang.Integer> toTimes(java.lang.String);\n Code:\n 0: nop\n 1: aload_0\n 2: ldc #212 // String Time:\n 4: aconst_null\n 5: iconst_2\n 6: aconst_null\n 7: invokestatic #218 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 10: checkcast #220 // class java/lang/CharSequence\n 13: invokestatic #224 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 16: invokevirtual #225 // Method java/lang/Object.toString:()Ljava/lang/String;\n 19: checkcast #220 // class java/lang/CharSequence\n 22: astore_1\n 23: new #227 // class kotlin/text/Regex\n 26: dup\n 27: ldc #229 // String \\\\s+\n 29: invokespecial #230 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 32: astore_2\n 33: iconst_0\n 34: istore_3\n 35: aload_2\n 36: aload_1\n 37: iload_3\n 38: invokevirtual #234 // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 41: checkcast #125 // class java/lang/Iterable\n 44: astore_1\n 45: nop\n 46: iconst_0\n 47: istore_2\n 48: aload_1\n 49: astore_3\n 50: new #128 // class java/util/ArrayList\n 53: dup\n 54: aload_1\n 55: bipush 10\n 57: invokestatic #134 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 60: invokespecial #143 // Method java/util/ArrayList.\"<init>\":(I)V\n 63: checkcast #166 // class java/util/Collection\n 66: astore 4\n 68: iconst_0\n 69: istore 5\n 71: aload_3\n 72: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 77: astore 6\n 79: aload 6\n 81: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 86: ifeq 133\n 89: aload 6\n 91: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 96: astore 7\n 98: aload 4\n 100: aload 7\n 102: checkcast #116 // class java/lang/String\n 105: astore 8\n 107: astore 10\n 109: iconst_0\n 110: istore 9\n 112: aload 8\n 114: invokestatic #238 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 117: nop\n 118: invokestatic #175 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 121: aload 10\n 123: swap\n 124: invokeinterface #176, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 129: pop\n 130: goto 79\n 133: aload 4\n 135: checkcast #164 // class java/util/List\n 138: nop\n 139: areturn\n\n private static final java.util.List<java.lang.Integer> toMaxes(java.lang.String);\n Code:\n 0: nop\n 1: aload_0\n 2: ldc #243 // String Distance:\n 4: aconst_null\n 5: iconst_2\n 6: aconst_null\n 7: invokestatic #218 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 10: checkcast #220 // class java/lang/CharSequence\n 13: invokestatic #224 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 16: invokevirtual #225 // Method java/lang/Object.toString:()Ljava/lang/String;\n 19: checkcast #220 // class java/lang/CharSequence\n 22: astore_1\n 23: new #227 // class kotlin/text/Regex\n 26: dup\n 27: ldc #229 // String \\\\s+\n 29: invokespecial #230 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 32: astore_2\n 33: iconst_0\n 34: istore_3\n 35: aload_2\n 36: aload_1\n 37: iload_3\n 38: invokevirtual #234 // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 41: checkcast #125 // class java/lang/Iterable\n 44: astore_1\n 45: nop\n 46: iconst_0\n 47: istore_2\n 48: aload_1\n 49: astore_3\n 50: new #128 // class java/util/ArrayList\n 53: dup\n 54: aload_1\n 55: bipush 10\n 57: invokestatic #134 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 60: invokespecial #143 // Method java/util/ArrayList.\"<init>\":(I)V\n 63: checkcast #166 // class java/util/Collection\n 66: astore 4\n 68: iconst_0\n 69: istore 5\n 71: aload_3\n 72: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 77: astore 6\n 79: aload 6\n 81: invokeinterface #147, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 86: ifeq 133\n 89: aload 6\n 91: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 96: astore 7\n 98: aload 4\n 100: aload 7\n 102: checkcast #116 // class java/lang/String\n 105: astore 8\n 107: astore 10\n 109: iconst_0\n 110: istore 9\n 112: aload 8\n 114: invokestatic #238 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 117: nop\n 118: invokestatic #175 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 121: aload 10\n 123: swap\n 124: invokeinterface #176, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 129: pop\n 130: goto 79\n 133: aload 4\n 135: checkcast #164 // class java/util/List\n 138: nop\n 139: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #248 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
klnusbaum__aoc2023__d30db24/src/problems/day10/part1/part1.kt
package problems.day10.part1 import java.io.File private const val testFile1 = "input/day10/test1.txt" private const val inputFile = "input/day10/input.txt" fun main() { val farthestTileDistance = File(inputFile).bufferedReader().useLines { farthestTileDistance(it) } println("The tile farthest from start is $farthestTileDistance tiles away") } fun farthestTileDistance(it: Sequence<String>): Int { val board = it.fold(BoardBuilder()) { builder, line -> builder.nextLine(line) }.build() // println("Board: ${board.tiles}") // println("start: ${board.startRow} ${board.startCol}") val totalDistance = board.totalPipeDistance() return totalDistance / 2 } private class BoardBuilder { private val tiles = mutableMapOf<Location, Tile>() private var start: Location? = null private var rowIndex = 0 fun nextLine(line: String): BoardBuilder { line.forEachIndexed { colIndex, c -> val tile = c.toTile() val location = Location(rowIndex, colIndex) if (tile is Tile.Start) { start = location } tiles[location] = tile } rowIndex++ return this } fun build() = Board( tiles, start ?: throw IllegalArgumentException("No location found for start"), ) } private class Board(val tiles: Map<Location, Tile>, val start: Location) { fun totalPipeDistance(): Int { var previousLocation = start var (currentLocation, currentTile) = nextFromStart() var distance = 1 while (currentLocation != start) { val (nextLocation, nextTile) = nextTile(previousLocation, currentLocation, currentTile) previousLocation = currentLocation currentLocation = nextLocation currentTile = nextTile distance++ } return distance } private fun nextFromStart(): Pair<Location, Tile> { val northernLocation = start.toNorth() val northernTile = tiles[northernLocation] if (northernTile?.opensOn(Direction.SOUTH) == true) { return Pair(northernLocation, northernTile) } val southernLocation = start.toSouth() val southernTile = tiles[southernLocation] if (southernTile?.opensOn(Direction.NORTH) == true) { return Pair(southernLocation, southernTile) } val westernLocation = start.toWest() val westernTile = tiles[westernLocation] if (westernTile?.opensOn(Direction.EAST) == true) { return Pair(westernLocation, westernTile) } val easternLocation = start.toEast() val easternTile = tiles[easternLocation] if (easternTile?.opensOn(Direction.WEST) == true) { return Pair(easternLocation, easternTile) } throw IllegalArgumentException("No tile accessible from start") } private fun nextTile( previousLocation: Location, currentLocation: Location, currentTile: Tile ): Pair<Location, Tile> { if (currentTile.opensOn(Direction.NORTH)) { val northernLocation = currentLocation.toNorth() val northernTile = tiles[northernLocation] if (northernTile?.opensOn(Direction.SOUTH) == true && northernLocation != previousLocation) { return Pair(northernLocation, northernTile) } } if (currentTile.opensOn(Direction.SOUTH)) { val southernLocation = currentLocation.toSouth() val southernTile = tiles[southernLocation] if (southernTile?.opensOn(Direction.NORTH) == true && southernLocation != previousLocation) { return Pair(southernLocation, southernTile) } } if (currentTile.opensOn(Direction.WEST)) { val westernLocation = currentLocation.toWest() val westernTile = tiles[westernLocation] if (westernTile?.opensOn(Direction.EAST) == true && westernLocation != previousLocation) { return Pair(westernLocation, westernTile) } } if (currentTile.opensOn(Direction.EAST)) { val easternLocation = currentLocation.toEast() val easternTile = tiles[easternLocation] if (easternTile?.opensOn(Direction.WEST) == true && easternLocation != previousLocation) { return Pair(easternLocation, easternTile) } } throw IllegalArgumentException("No next tile from $currentLocation") } } private data class Location(val row: Int, val col: Int) { fun toNorth(): Location = Location(row - 1, col) fun toSouth(): Location = Location(row + 1, col) fun toWest(): Location = Location(row, col - 1) fun toEast(): Location = Location(row, col + 1) } private sealed class Tile { data class Pipe(val first: Direction, val second: Direction) : Tile() data object Ground : Tile() data object Start : Tile() fun opensOn(direction: Direction) = when (this) { is Pipe -> this.first == direction || this.second == direction is Start -> true else -> false } } private fun Char.toTile(): Tile = when (this) { '|' -> Tile.Pipe(Direction.NORTH, Direction.SOUTH) '-' -> Tile.Pipe(Direction.EAST, Direction.WEST) 'L' -> Tile.Pipe(Direction.NORTH, Direction.EAST) 'J' -> Tile.Pipe(Direction.NORTH, Direction.WEST) '7' -> Tile.Pipe(Direction.SOUTH, Direction.WEST) 'F' -> Tile.Pipe(Direction.SOUTH, Direction.EAST) 'S' -> Tile.Start else -> Tile.Ground } private enum class Direction { NORTH, SOUTH, EAST, WEST, }
[ { "class_path": "klnusbaum__aoc2023__d30db24/problems/day10/part1/Part1Kt.class", "javap": "Compiled from \"part1.kt\"\npublic final class problems.day10.part1.Part1Kt {\n private static final java.lang.String testFile1;\n\n private static final java.lang.String inputFile;\n\n public static final void main();\n Code:\n 0: new #10 // class java/io/File\n 3: dup\n 4: ldc #12 // String input/day10/input.txt\n 6: invokespecial #16 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: astore_1\n 10: getstatic #22 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 13: astore_2\n 14: sipush 8192\n 17: istore_3\n 18: aload_1\n 19: astore 4\n 21: new #24 // class java/io/InputStreamReader\n 24: dup\n 25: new #26 // class java/io/FileInputStream\n 28: dup\n 29: aload 4\n 31: invokespecial #29 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 34: checkcast #31 // class java/io/InputStream\n 37: aload_2\n 38: invokespecial #34 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 41: checkcast #36 // class java/io/Reader\n 44: astore 4\n 46: aload 4\n 48: instanceof #38 // class java/io/BufferedReader\n 51: ifeq 62\n 54: aload 4\n 56: checkcast #38 // class java/io/BufferedReader\n 59: goto 72\n 62: new #38 // class java/io/BufferedReader\n 65: dup\n 66: aload 4\n 68: iload_3\n 69: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 72: checkcast #36 // class java/io/Reader\n 75: astore_1\n 76: nop\n 77: iconst_0\n 78: istore_2\n 79: aload_1\n 80: astore_3\n 81: sipush 8192\n 84: istore 4\n 86: aload_3\n 87: instanceof #38 // class java/io/BufferedReader\n 90: ifeq 100\n 93: aload_3\n 94: checkcast #38 // class java/io/BufferedReader\n 97: goto 110\n 100: new #38 // class java/io/BufferedReader\n 103: dup\n 104: aload_3\n 105: iload 4\n 107: invokespecial #41 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 110: checkcast #43 // class java/io/Closeable\n 113: astore_3\n 114: aconst_null\n 115: astore 4\n 117: nop\n 118: aload_3\n 119: checkcast #38 // class java/io/BufferedReader\n 122: astore 5\n 124: iconst_0\n 125: istore 6\n 127: aload 5\n 129: invokestatic #49 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 132: astore 7\n 134: iconst_0\n 135: istore 8\n 137: aload 7\n 139: invokestatic #53 // Method farthestTileDistance:(Lkotlin/sequences/Sequence;)I\n 142: istore 5\n 144: aload_3\n 145: aload 4\n 147: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 150: iload 5\n 152: goto 175\n 155: astore 6\n 157: aload 6\n 159: astore 4\n 161: aload 6\n 163: athrow\n 164: astore 6\n 166: aload_3\n 167: aload 4\n 169: invokestatic #59 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 172: aload 6\n 174: athrow\n 175: nop\n 176: istore_0\n 177: new #61 // class java/lang/StringBuilder\n 180: dup\n 181: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 184: ldc #65 // String The tile farthest from start is\n 186: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 189: iload_0\n 190: invokevirtual #72 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 193: ldc #74 // String tiles away\n 195: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 198: invokevirtual #78 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 201: getstatic #84 // Field java/lang/System.out:Ljava/io/PrintStream;\n 204: swap\n 205: invokevirtual #90 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 208: return\n Exception table:\n from to target type\n 117 144 155 Class java/lang/Throwable\n 117 144 164 any\n 155 164 164 any\n 164 166 164 any\n\n public static final int farthestTileDistance(kotlin.sequences.Sequence<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #107 // String it\n 3: invokestatic #113 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: astore_2\n 8: new #115 // class problems/day10/part1/BoardBuilder\n 11: dup\n 12: invokespecial #116 // Method problems/day10/part1/BoardBuilder.\"<init>\":()V\n 15: astore_3\n 16: iconst_0\n 17: istore 4\n 19: aload_3\n 20: astore 5\n 22: aload_2\n 23: invokeinterface #120, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 28: astore 6\n 30: aload 6\n 32: invokeinterface #126, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 37: ifeq 75\n 40: aload 6\n 42: invokeinterface #130, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 47: astore 7\n 49: aload 5\n 51: aload 7\n 53: checkcast #132 // class java/lang/String\n 56: astore 8\n 58: astore 9\n 60: iconst_0\n 61: istore 10\n 63: aload 9\n 65: aload 8\n 67: invokevirtual #136 // Method problems/day10/part1/BoardBuilder.nextLine:(Ljava/lang/String;)Lproblems/day10/part1/BoardBuilder;\n 70: astore 5\n 72: goto 30\n 75: aload 5\n 77: invokevirtual #140 // Method problems/day10/part1/BoardBuilder.build:()Lproblems/day10/part1/Board;\n 80: astore_1\n 81: aload_1\n 82: invokevirtual #146 // Method problems/day10/part1/Board.totalPipeDistance:()I\n 85: istore_2\n 86: iload_2\n 87: iconst_2\n 88: idiv\n 89: ireturn\n\n private static final problems.day10.part1.Tile toTile(char);\n Code:\n 0: iload_0\n 1: lookupswitch { // 7\n 45: 87\n 55: 144\n 70: 163\n 74: 125\n 76: 106\n 83: 182\n 124: 68\n default: 191\n }\n 68: new #164 // class problems/day10/part1/Tile$Pipe\n 71: dup\n 72: getstatic #170 // Field problems/day10/part1/Direction.NORTH:Lproblems/day10/part1/Direction;\n 75: getstatic #173 // Field problems/day10/part1/Direction.SOUTH:Lproblems/day10/part1/Direction;\n 78: invokespecial #176 // Method problems/day10/part1/Tile$Pipe.\"<init>\":(Lproblems/day10/part1/Direction;Lproblems/day10/part1/Direction;)V\n 81: checkcast #178 // class problems/day10/part1/Tile\n 84: goto 197\n 87: new #164 // class problems/day10/part1/Tile$Pipe\n 90: dup\n 91: getstatic #181 // Field problems/day10/part1/Direction.EAST:Lproblems/day10/part1/Direction;\n 94: getstatic #184 // Field problems/day10/part1/Direction.WEST:Lproblems/day10/part1/Direction;\n 97: invokespecial #176 // Method problems/day10/part1/Tile$Pipe.\"<init>\":(Lproblems/day10/part1/Direction;Lproblems/day10/part1/Direction;)V\n 100: checkcast #178 // class problems/day10/part1/Tile\n 103: goto 197\n 106: new #164 // class problems/day10/part1/Tile$Pipe\n 109: dup\n 110: getstatic #170 // Field problems/day10/part1/Direction.NORTH:Lproblems/day10/part1/Direction;\n 113: getstatic #181 // Field problems/day10/part1/Direction.EAST:Lproblems/day10/part1/Direction;\n 116: invokespecial #176 // Method problems/day10/part1/Tile$Pipe.\"<init>\":(Lproblems/day10/part1/Direction;Lproblems/day10/part1/Direction;)V\n 119: checkcast #178 // class problems/day10/part1/Tile\n 122: goto 197\n 125: new #164 // class problems/day10/part1/Tile$Pipe\n 128: dup\n 129: getstatic #170 // Field problems/day10/part1/Direction.NORTH:Lproblems/day10/part1/Direction;\n 132: getstatic #184 // Field problems/day10/part1/Direction.WEST:Lproblems/day10/part1/Direction;\n 135: invokespecial #176 // Method problems/day10/part1/Tile$Pipe.\"<init>\":(Lproblems/day10/part1/Direction;Lproblems/day10/part1/Direction;)V\n 138: checkcast #178 // class problems/day10/part1/Tile\n 141: goto 197\n 144: new #164 // class problems/day10/part1/Tile$Pipe\n 147: dup\n 148: getstatic #173 // Field problems/day10/part1/Direction.SOUTH:Lproblems/day10/part1/Direction;\n 151: getstatic #184 // Field problems/day10/part1/Direction.WEST:Lproblems/day10/part1/Direction;\n 154: invokespecial #176 // Method problems/day10/part1/Tile$Pipe.\"<init>\":(Lproblems/day10/part1/Direction;Lproblems/day10/part1/Direction;)V\n 157: checkcast #178 // class problems/day10/part1/Tile\n 160: goto 197\n 163: new #164 // class problems/day10/part1/Tile$Pipe\n 166: dup\n 167: getstatic #173 // Field problems/day10/part1/Direction.SOUTH:Lproblems/day10/part1/Direction;\n 170: getstatic #181 // Field problems/day10/part1/Direction.EAST:Lproblems/day10/part1/Direction;\n 173: invokespecial #176 // Method problems/day10/part1/Tile$Pipe.\"<init>\":(Lproblems/day10/part1/Direction;Lproblems/day10/part1/Direction;)V\n 176: checkcast #178 // class problems/day10/part1/Tile\n 179: goto 197\n 182: getstatic #190 // Field problems/day10/part1/Tile$Start.INSTANCE:Lproblems/day10/part1/Tile$Start;\n 185: checkcast #178 // class problems/day10/part1/Tile\n 188: goto 197\n 191: getstatic #195 // Field problems/day10/part1/Tile$Ground.INSTANCE:Lproblems/day10/part1/Tile$Ground;\n 194: checkcast #178 // class problems/day10/part1/Tile\n 197: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #200 // Method main:()V\n 3: return\n\n public static final problems.day10.part1.Tile access$toTile(char);\n Code:\n 0: iload_0\n 1: invokestatic #205 // Method toTile:(C)Lproblems/day10/part1/Tile;\n 4: areturn\n}\n", "javap_err": "" } ]
PathFinder-SSAFY__PathFinder__57e9a94/client/PathFinder/app/src/main/java/com/dijkstra/pathfinder/util/KalmanFilter3D.kt
package com.dijkstra.pathfinder.util class KalmanFilter3D( initialState: List<Double>, initialCovariance: List<List<Double>> ) { private var state = initialState private var covariance = initialCovariance private val processNoise = listOf( listOf(0.1, 0.0, 0.0), listOf(0.0, 0.1, 0.0), listOf(0.0, 0.0, 0.1) ) fun update(measurement: List<Double>, measurementNoise: List<Double>): List<Double> { val kalmanGain = calculateKalmanGain(measurementNoise) val innovation = measurement.zip(state) { m, s -> m - s } state = state.zip( kalmanGain.map { row -> row.zip(innovation) { x, y -> x * y }.sum() } ).map { it.first + it.second } covariance = updateCovariance(kalmanGain) return state } private fun calculateKalmanGain(measurementNoise: List<Double>): List<List<Double>> { val sum = covariance.zip(processNoise) { a, b -> a.zip(b) { x, y -> x + y } } val sumDiagonal = sum.indices.map { sum[it][it] } val noisePlusSumDiagonal = measurementNoise.zip(sumDiagonal) { x, y -> x + y } return covariance.map { row -> row.zip(noisePlusSumDiagonal) { x, y -> x / y } } } private fun updateCovariance(kalmanGain: List<List<Double>>): List<List<Double>> { val gainTimesCovariance = kalmanGain.map { row -> row.zip(covariance) { x, col -> x * col.sum() } } val identityMinusGain = gainTimesCovariance.indices.map { i -> gainTimesCovariance[i].mapIndexed { j, value -> if (i == j) 1.0 - value else -value } } return identityMinusGain.map { row -> row.zip(covariance) { x, col -> x * col.sum() } } } }
[ { "class_path": "PathFinder-SSAFY__PathFinder__57e9a94/com/dijkstra/pathfinder/util/KalmanFilter3D.class", "javap": "Compiled from \"KalmanFilter3D.kt\"\npublic final class com.dijkstra.pathfinder.util.KalmanFilter3D {\n private java.util.List<java.lang.Double> state;\n\n private java.util.List<? extends java.util.List<java.lang.Double>> covariance;\n\n private final java.util.List<java.util.List<java.lang.Double>> processNoise;\n\n public com.dijkstra.pathfinder.util.KalmanFilter3D(java.util.List<java.lang.Double>, java.util.List<? extends java.util.List<java.lang.Double>>);\n Code:\n 0: aload_1\n 1: ldc #10 // String initialState\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #18 // String initialCovariance\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokespecial #21 // Method java/lang/Object.\"<init>\":()V\n 16: aload_0\n 17: aload_1\n 18: putfield #25 // Field state:Ljava/util/List;\n 21: aload_0\n 22: aload_2\n 23: putfield #28 // Field covariance:Ljava/util/List;\n 26: aload_0\n 27: iconst_3\n 28: anewarray #30 // class java/util/List\n 31: astore_3\n 32: aload_3\n 33: iconst_0\n 34: iconst_3\n 35: anewarray #32 // class java/lang/Double\n 38: astore 4\n 40: aload 4\n 42: iconst_0\n 43: ldc2_w #33 // double 0.1d\n 46: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 49: aastore\n 50: aload 4\n 52: iconst_1\n 53: dconst_0\n 54: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 57: aastore\n 58: aload 4\n 60: iconst_2\n 61: dconst_0\n 62: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 65: aastore\n 66: aload 4\n 68: invokestatic #44 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 71: aastore\n 72: aload_3\n 73: iconst_1\n 74: iconst_3\n 75: anewarray #32 // class java/lang/Double\n 78: astore 4\n 80: aload 4\n 82: iconst_0\n 83: dconst_0\n 84: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 87: aastore\n 88: aload 4\n 90: iconst_1\n 91: ldc2_w #33 // double 0.1d\n 94: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 97: aastore\n 98: aload 4\n 100: iconst_2\n 101: dconst_0\n 102: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 105: aastore\n 106: aload 4\n 108: invokestatic #44 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 111: aastore\n 112: aload_3\n 113: iconst_2\n 114: iconst_3\n 115: anewarray #32 // class java/lang/Double\n 118: astore 4\n 120: aload 4\n 122: iconst_0\n 123: dconst_0\n 124: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 127: aastore\n 128: aload 4\n 130: iconst_1\n 131: dconst_0\n 132: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 135: aastore\n 136: aload 4\n 138: iconst_2\n 139: ldc2_w #33 // double 0.1d\n 142: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 145: aastore\n 146: aload 4\n 148: invokestatic #44 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 151: aastore\n 152: aload_3\n 153: invokestatic #44 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 156: putfield #47 // Field processNoise:Ljava/util/List;\n 159: return\n\n public final java.util.List<java.lang.Double> update(java.util.List<java.lang.Double>, java.util.List<java.lang.Double>);\n Code:\n 0: aload_1\n 1: ldc #54 // String measurement\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #56 // String measurementNoise\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_2\n 14: invokespecial #60 // Method calculateKalmanGain:(Ljava/util/List;)Ljava/util/List;\n 17: astore_3\n 18: aload_1\n 19: checkcast #62 // class java/lang/Iterable\n 22: astore 5\n 24: aload_0\n 25: getfield #25 // Field state:Ljava/util/List;\n 28: checkcast #62 // class java/lang/Iterable\n 31: astore 6\n 33: iconst_0\n 34: istore 7\n 36: aload 5\n 38: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 43: astore 8\n 45: aload 6\n 47: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 52: astore 9\n 54: new #68 // class java/util/ArrayList\n 57: dup\n 58: aload 5\n 60: bipush 10\n 62: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 65: aload 6\n 67: bipush 10\n 69: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 72: invokestatic #78 // Method java/lang/Math.min:(II)I\n 75: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 78: astore 10\n 80: aload 8\n 82: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 87: ifeq 155\n 90: aload 9\n 92: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 97: ifeq 155\n 100: aload 10\n 102: aload 8\n 104: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 109: aload 9\n 111: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 116: checkcast #93 // class java/lang/Number\n 119: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 122: dstore 11\n 124: checkcast #93 // class java/lang/Number\n 127: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 130: dstore 13\n 132: astore 25\n 134: iconst_0\n 135: istore 15\n 137: dload 13\n 139: dload 11\n 141: dsub\n 142: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 145: aload 25\n 147: swap\n 148: invokevirtual #101 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 151: pop\n 152: goto 80\n 155: aload 10\n 157: checkcast #30 // class java/util/List\n 160: astore 4\n 162: aload_0\n 163: aload_0\n 164: getfield #25 // Field state:Ljava/util/List;\n 167: checkcast #62 // class java/lang/Iterable\n 170: aload_3\n 171: checkcast #62 // class java/lang/Iterable\n 174: astore 5\n 176: astore 26\n 178: astore 25\n 180: iconst_0\n 181: istore 6\n 183: aload 5\n 185: astore 7\n 187: new #68 // class java/util/ArrayList\n 190: dup\n 191: aload 5\n 193: bipush 10\n 195: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 198: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 201: checkcast #103 // class java/util/Collection\n 204: astore 8\n 206: iconst_0\n 207: istore 9\n 209: aload 7\n 211: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 216: astore 10\n 218: aload 10\n 220: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 225: ifeq 412\n 228: aload 10\n 230: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 235: astore 11\n 237: aload 8\n 239: aload 11\n 241: checkcast #30 // class java/util/List\n 244: astore 12\n 246: astore 27\n 248: iconst_0\n 249: istore 13\n 251: aload 12\n 253: checkcast #62 // class java/lang/Iterable\n 256: astore 14\n 258: iconst_0\n 259: istore 15\n 261: aload 14\n 263: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 268: astore 16\n 270: aload 4\n 272: checkcast #62 // class java/lang/Iterable\n 275: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 280: astore 17\n 282: new #68 // class java/util/ArrayList\n 285: dup\n 286: aload 14\n 288: bipush 10\n 290: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 293: aload 4\n 295: checkcast #62 // class java/lang/Iterable\n 298: bipush 10\n 300: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 303: invokestatic #78 // Method java/lang/Math.min:(II)I\n 306: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 309: astore 18\n 311: aload 16\n 313: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 318: ifeq 386\n 321: aload 17\n 323: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 328: ifeq 386\n 331: aload 18\n 333: aload 16\n 335: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 340: aload 17\n 342: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 347: checkcast #93 // class java/lang/Number\n 350: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 353: dstore 19\n 355: checkcast #93 // class java/lang/Number\n 358: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 361: dstore 21\n 363: astore 23\n 365: iconst_0\n 366: istore 24\n 368: dload 21\n 370: dload 19\n 372: dmul\n 373: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 376: aload 23\n 378: swap\n 379: invokevirtual #101 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 382: pop\n 383: goto 311\n 386: aload 18\n 388: checkcast #30 // class java/util/List\n 391: checkcast #62 // class java/lang/Iterable\n 394: invokestatic #107 // Method kotlin/collections/CollectionsKt.sumOfDouble:(Ljava/lang/Iterable;)D\n 397: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 400: aload 27\n 402: swap\n 403: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 408: pop\n 409: goto 218\n 412: aload 8\n 414: checkcast #30 // class java/util/List\n 417: nop\n 418: astore 27\n 420: aload 25\n 422: aload 26\n 424: aload 27\n 426: checkcast #62 // class java/lang/Iterable\n 429: invokestatic #112 // Method kotlin/collections/CollectionsKt.zip:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;\n 432: checkcast #62 // class java/lang/Iterable\n 435: astore 5\n 437: astore 25\n 439: iconst_0\n 440: istore 6\n 442: aload 5\n 444: astore 7\n 446: new #68 // class java/util/ArrayList\n 449: dup\n 450: aload 5\n 452: bipush 10\n 454: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 457: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 460: checkcast #103 // class java/util/Collection\n 463: astore 8\n 465: iconst_0\n 466: istore 9\n 468: aload 7\n 470: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 475: astore 10\n 477: aload 10\n 479: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 484: ifeq 548\n 487: aload 10\n 489: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 494: astore 11\n 496: aload 8\n 498: aload 11\n 500: checkcast #114 // class kotlin/Pair\n 503: astore 12\n 505: astore 26\n 507: iconst_0\n 508: istore 13\n 510: aload 12\n 512: invokevirtual #117 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 515: checkcast #93 // class java/lang/Number\n 518: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 521: aload 12\n 523: invokevirtual #120 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 526: checkcast #93 // class java/lang/Number\n 529: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 532: dadd\n 533: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 536: aload 26\n 538: swap\n 539: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 544: pop\n 545: goto 477\n 548: aload 8\n 550: checkcast #30 // class java/util/List\n 553: nop\n 554: aload 25\n 556: swap\n 557: putfield #25 // Field state:Ljava/util/List;\n 560: aload_0\n 561: aload_0\n 562: aload_3\n 563: invokespecial #123 // Method updateCovariance:(Ljava/util/List;)Ljava/util/List;\n 566: putfield #28 // Field covariance:Ljava/util/List;\n 569: aload_0\n 570: getfield #25 // Field state:Ljava/util/List;\n 573: areturn\n\n private final java.util.List<java.util.List<java.lang.Double>> calculateKalmanGain(java.util.List<java.lang.Double>);\n Code:\n 0: aload_0\n 1: getfield #28 // Field covariance:Ljava/util/List;\n 4: checkcast #62 // class java/lang/Iterable\n 7: astore_3\n 8: aload_0\n 9: getfield #47 // Field processNoise:Ljava/util/List;\n 12: checkcast #62 // class java/lang/Iterable\n 15: astore 4\n 17: iconst_0\n 18: istore 5\n 20: aload_3\n 21: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 26: astore 6\n 28: aload 4\n 30: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 35: astore 7\n 37: new #68 // class java/util/ArrayList\n 40: dup\n 41: aload_3\n 42: bipush 10\n 44: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 47: aload 4\n 49: bipush 10\n 51: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 54: invokestatic #78 // Method java/lang/Math.min:(II)I\n 57: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 60: astore 8\n 62: aload 6\n 64: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 69: ifeq 264\n 72: aload 7\n 74: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 79: ifeq 264\n 82: aload 8\n 84: aload 6\n 86: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 91: aload 7\n 93: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 98: checkcast #30 // class java/util/List\n 101: astore 9\n 103: checkcast #30 // class java/util/List\n 106: astore 10\n 108: astore 25\n 110: iconst_0\n 111: istore 11\n 113: aload 10\n 115: checkcast #62 // class java/lang/Iterable\n 118: astore 12\n 120: iconst_0\n 121: istore 13\n 123: aload 12\n 125: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 130: astore 14\n 132: aload 9\n 134: checkcast #62 // class java/lang/Iterable\n 137: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 142: astore 15\n 144: new #68 // class java/util/ArrayList\n 147: dup\n 148: aload 12\n 150: bipush 10\n 152: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 155: aload 9\n 157: checkcast #62 // class java/lang/Iterable\n 160: bipush 10\n 162: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 165: invokestatic #78 // Method java/lang/Math.min:(II)I\n 168: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 171: astore 16\n 173: aload 14\n 175: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 180: ifeq 248\n 183: aload 15\n 185: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 190: ifeq 248\n 193: aload 16\n 195: aload 14\n 197: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 202: aload 15\n 204: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 209: checkcast #93 // class java/lang/Number\n 212: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 215: dstore 17\n 217: checkcast #93 // class java/lang/Number\n 220: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 223: dstore 19\n 225: astore 21\n 227: iconst_0\n 228: istore 22\n 230: dload 19\n 232: dload 17\n 234: dadd\n 235: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 238: aload 21\n 240: swap\n 241: invokevirtual #101 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 244: pop\n 245: goto 173\n 248: aload 16\n 250: checkcast #30 // class java/util/List\n 253: nop\n 254: aload 25\n 256: swap\n 257: invokevirtual #101 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 260: pop\n 261: goto 62\n 264: aload 8\n 266: checkcast #30 // class java/util/List\n 269: astore_2\n 270: aload_2\n 271: checkcast #103 // class java/util/Collection\n 274: invokestatic #160 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 277: checkcast #62 // class java/lang/Iterable\n 280: astore 4\n 282: iconst_0\n 283: istore 5\n 285: aload 4\n 287: astore 6\n 289: new #68 // class java/util/ArrayList\n 292: dup\n 293: aload 4\n 295: bipush 10\n 297: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 300: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 303: checkcast #103 // class java/util/Collection\n 306: astore 7\n 308: iconst_0\n 309: istore 8\n 311: aload 6\n 313: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 318: astore 9\n 320: aload 9\n 322: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 327: ifeq 390\n 330: aload 9\n 332: checkcast #162 // class kotlin/collections/IntIterator\n 335: invokevirtual #166 // Method kotlin/collections/IntIterator.nextInt:()I\n 338: istore 10\n 340: aload 7\n 342: iload 10\n 344: istore 11\n 346: astore 25\n 348: iconst_0\n 349: istore 12\n 351: aload_2\n 352: iload 11\n 354: invokeinterface #170, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 359: checkcast #30 // class java/util/List\n 362: iload 11\n 364: invokeinterface #170, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 369: checkcast #93 // class java/lang/Number\n 372: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 375: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 378: aload 25\n 380: swap\n 381: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 386: pop\n 387: goto 320\n 390: aload 7\n 392: checkcast #30 // class java/util/List\n 395: nop\n 396: astore_3\n 397: aload_1\n 398: checkcast #62 // class java/lang/Iterable\n 401: astore 5\n 403: iconst_0\n 404: istore 6\n 406: aload 5\n 408: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 413: astore 7\n 415: aload_3\n 416: checkcast #62 // class java/lang/Iterable\n 419: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 424: astore 8\n 426: new #68 // class java/util/ArrayList\n 429: dup\n 430: aload 5\n 432: bipush 10\n 434: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 437: aload_3\n 438: checkcast #62 // class java/lang/Iterable\n 441: bipush 10\n 443: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 446: invokestatic #78 // Method java/lang/Math.min:(II)I\n 449: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 452: astore 9\n 454: aload 7\n 456: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 461: ifeq 529\n 464: aload 8\n 466: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 471: ifeq 529\n 474: aload 9\n 476: aload 7\n 478: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 483: aload 8\n 485: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 490: checkcast #93 // class java/lang/Number\n 493: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 496: dstore 10\n 498: checkcast #93 // class java/lang/Number\n 501: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 504: dstore 12\n 506: astore 25\n 508: iconst_0\n 509: istore 14\n 511: dload 12\n 513: dload 10\n 515: dadd\n 516: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 519: aload 25\n 521: swap\n 522: invokevirtual #101 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 525: pop\n 526: goto 454\n 529: aload 9\n 531: checkcast #30 // class java/util/List\n 534: astore 4\n 536: aload_0\n 537: getfield #28 // Field covariance:Ljava/util/List;\n 540: checkcast #62 // class java/lang/Iterable\n 543: astore 5\n 545: iconst_0\n 546: istore 6\n 548: aload 5\n 550: astore 7\n 552: new #68 // class java/util/ArrayList\n 555: dup\n 556: aload 5\n 558: bipush 10\n 560: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 563: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 566: checkcast #103 // class java/util/Collection\n 569: astore 8\n 571: iconst_0\n 572: istore 9\n 574: aload 7\n 576: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 581: astore 10\n 583: aload 10\n 585: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 590: ifeq 769\n 593: aload 10\n 595: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 600: astore 11\n 602: aload 8\n 604: aload 11\n 606: checkcast #30 // class java/util/List\n 609: astore 12\n 611: astore 25\n 613: iconst_0\n 614: istore 13\n 616: aload 12\n 618: checkcast #62 // class java/lang/Iterable\n 621: astore 14\n 623: iconst_0\n 624: istore 15\n 626: aload 14\n 628: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 633: astore 16\n 635: aload 4\n 637: checkcast #62 // class java/lang/Iterable\n 640: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 645: astore 17\n 647: new #68 // class java/util/ArrayList\n 650: dup\n 651: aload 14\n 653: bipush 10\n 655: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 658: aload 4\n 660: checkcast #62 // class java/lang/Iterable\n 663: bipush 10\n 665: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 668: invokestatic #78 // Method java/lang/Math.min:(II)I\n 671: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 674: astore 18\n 676: aload 16\n 678: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 683: ifeq 751\n 686: aload 17\n 688: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 693: ifeq 751\n 696: aload 18\n 698: aload 16\n 700: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 705: aload 17\n 707: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 712: checkcast #93 // class java/lang/Number\n 715: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 718: dstore 19\n 720: checkcast #93 // class java/lang/Number\n 723: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 726: dstore 21\n 728: astore 23\n 730: iconst_0\n 731: istore 24\n 733: dload 21\n 735: dload 19\n 737: ddiv\n 738: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 741: aload 23\n 743: swap\n 744: invokevirtual #101 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 747: pop\n 748: goto 676\n 751: aload 18\n 753: checkcast #30 // class java/util/List\n 756: nop\n 757: aload 25\n 759: swap\n 760: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 765: pop\n 766: goto 583\n 769: aload 8\n 771: checkcast #30 // class java/util/List\n 774: nop\n 775: areturn\n\n private final java.util.List<java.util.List<java.lang.Double>> updateCovariance(java.util.List<? extends java.util.List<java.lang.Double>>);\n Code:\n 0: aload_1\n 1: checkcast #62 // class java/lang/Iterable\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: astore 5\n 11: new #68 // class java/util/ArrayList\n 14: dup\n 15: aload_3\n 16: bipush 10\n 18: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 21: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 24: checkcast #103 // class java/util/Collection\n 27: astore 6\n 29: iconst_0\n 30: istore 7\n 32: aload 5\n 34: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 8\n 41: aload 8\n 43: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 233\n 51: aload 8\n 53: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 9\n 60: aload 6\n 62: aload 9\n 64: checkcast #30 // class java/util/List\n 67: astore 10\n 69: astore 27\n 71: iconst_0\n 72: istore 11\n 74: aload 10\n 76: checkcast #62 // class java/lang/Iterable\n 79: astore 12\n 81: aload_0\n 82: getfield #28 // Field covariance:Ljava/util/List;\n 85: checkcast #62 // class java/lang/Iterable\n 88: astore 13\n 90: iconst_0\n 91: istore 14\n 93: aload 12\n 95: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 100: astore 15\n 102: aload 13\n 104: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 109: astore 16\n 111: new #68 // class java/util/ArrayList\n 114: dup\n 115: aload 12\n 117: bipush 10\n 119: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 122: aload 13\n 124: bipush 10\n 126: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 129: invokestatic #78 // Method java/lang/Math.min:(II)I\n 132: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 135: astore 17\n 137: aload 15\n 139: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 144: ifeq 215\n 147: aload 16\n 149: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 154: ifeq 215\n 157: aload 17\n 159: aload 15\n 161: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 166: aload 16\n 168: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 173: checkcast #30 // class java/util/List\n 176: astore 18\n 178: checkcast #93 // class java/lang/Number\n 181: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 184: dstore 19\n 186: astore 21\n 188: iconst_0\n 189: istore 22\n 191: dload 19\n 193: aload 18\n 195: checkcast #62 // class java/lang/Iterable\n 198: invokestatic #107 // Method kotlin/collections/CollectionsKt.sumOfDouble:(Ljava/lang/Iterable;)D\n 201: dmul\n 202: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 205: aload 21\n 207: swap\n 208: invokevirtual #101 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 211: pop\n 212: goto 137\n 215: aload 17\n 217: checkcast #30 // class java/util/List\n 220: nop\n 221: aload 27\n 223: swap\n 224: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 229: pop\n 230: goto 41\n 233: aload 6\n 235: checkcast #30 // class java/util/List\n 238: nop\n 239: astore_2\n 240: aload_2\n 241: checkcast #103 // class java/util/Collection\n 244: invokestatic #160 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 247: checkcast #62 // class java/lang/Iterable\n 250: astore 4\n 252: iconst_0\n 253: istore 5\n 255: aload 4\n 257: astore 6\n 259: new #68 // class java/util/ArrayList\n 262: dup\n 263: aload 4\n 265: bipush 10\n 267: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 270: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 273: checkcast #103 // class java/util/Collection\n 276: astore 7\n 278: iconst_0\n 279: istore 8\n 281: aload 6\n 283: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 288: astore 9\n 290: aload 9\n 292: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 297: ifeq 481\n 300: aload 9\n 302: checkcast #162 // class kotlin/collections/IntIterator\n 305: invokevirtual #166 // Method kotlin/collections/IntIterator.nextInt:()I\n 308: istore 10\n 310: aload 7\n 312: iload 10\n 314: istore 11\n 316: astore 27\n 318: iconst_0\n 319: istore 12\n 321: aload_2\n 322: iload 11\n 324: invokeinterface #170, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 329: checkcast #62 // class java/lang/Iterable\n 332: astore 13\n 334: iconst_0\n 335: istore 14\n 337: aload 13\n 339: astore 15\n 341: new #68 // class java/util/ArrayList\n 344: dup\n 345: aload 13\n 347: bipush 10\n 349: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 352: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 355: checkcast #103 // class java/util/Collection\n 358: astore 16\n 360: iconst_0\n 361: istore 17\n 363: iconst_0\n 364: istore 18\n 366: aload 15\n 368: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 373: astore 19\n 375: aload 19\n 377: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 382: ifeq 462\n 385: aload 19\n 387: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 392: astore 20\n 394: aload 16\n 396: iload 18\n 398: iinc 18, 1\n 401: istore 21\n 403: iload 21\n 405: ifge 411\n 408: invokestatic #185 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 411: iload 21\n 413: aload 20\n 415: checkcast #93 // class java/lang/Number\n 418: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 421: dstore 22\n 423: istore 24\n 425: astore 25\n 427: iconst_0\n 428: istore 26\n 430: iload 11\n 432: iload 24\n 434: if_icmpne 444\n 437: dconst_1\n 438: dload 22\n 440: dsub\n 441: goto 447\n 444: dload 22\n 446: dneg\n 447: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 450: aload 25\n 452: swap\n 453: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 458: pop\n 459: goto 375\n 462: aload 16\n 464: checkcast #30 // class java/util/List\n 467: nop\n 468: nop\n 469: aload 27\n 471: swap\n 472: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 477: pop\n 478: goto 290\n 481: aload 7\n 483: checkcast #30 // class java/util/List\n 486: nop\n 487: astore_3\n 488: aload_3\n 489: checkcast #62 // class java/lang/Iterable\n 492: astore 4\n 494: iconst_0\n 495: istore 5\n 497: aload 4\n 499: astore 6\n 501: new #68 // class java/util/ArrayList\n 504: dup\n 505: aload 4\n 507: bipush 10\n 509: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 512: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 515: checkcast #103 // class java/util/Collection\n 518: astore 7\n 520: iconst_0\n 521: istore 8\n 523: aload 6\n 525: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 530: astore 9\n 532: aload 9\n 534: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 539: ifeq 724\n 542: aload 9\n 544: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 549: astore 10\n 551: aload 7\n 553: aload 10\n 555: checkcast #30 // class java/util/List\n 558: astore 11\n 560: astore 27\n 562: iconst_0\n 563: istore 12\n 565: aload 11\n 567: checkcast #62 // class java/lang/Iterable\n 570: astore 13\n 572: aload_0\n 573: getfield #28 // Field covariance:Ljava/util/List;\n 576: checkcast #62 // class java/lang/Iterable\n 579: astore 14\n 581: iconst_0\n 582: istore 15\n 584: aload 13\n 586: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 591: astore 16\n 593: aload 14\n 595: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 600: astore 17\n 602: new #68 // class java/util/ArrayList\n 605: dup\n 606: aload 13\n 608: bipush 10\n 610: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 613: aload 14\n 615: bipush 10\n 617: invokestatic #72 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 620: invokestatic #78 // Method java/lang/Math.min:(II)I\n 623: invokespecial #81 // Method java/util/ArrayList.\"<init>\":(I)V\n 626: astore 18\n 628: aload 16\n 630: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 635: ifeq 706\n 638: aload 17\n 640: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 645: ifeq 706\n 648: aload 18\n 650: aload 16\n 652: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 657: aload 17\n 659: invokeinterface #91, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 664: checkcast #30 // class java/util/List\n 667: astore 19\n 669: checkcast #93 // class java/lang/Number\n 672: invokevirtual #97 // Method java/lang/Number.doubleValue:()D\n 675: dstore 20\n 677: astore 22\n 679: iconst_0\n 680: istore 23\n 682: dload 20\n 684: aload 19\n 686: checkcast #62 // class java/lang/Iterable\n 689: invokestatic #107 // Method kotlin/collections/CollectionsKt.sumOfDouble:(Ljava/lang/Iterable;)D\n 692: dmul\n 693: invokestatic #38 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 696: aload 22\n 698: swap\n 699: invokevirtual #101 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 702: pop\n 703: goto 628\n 706: aload 18\n 708: checkcast #30 // class java/util/List\n 711: nop\n 712: aload 27\n 714: swap\n 715: invokeinterface #108, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 720: pop\n 721: goto 532\n 724: aload 7\n 726: checkcast #30 // class java/util/List\n 729: nop\n 730: areturn\n}\n", "javap_err": "" } ]
fitzf__leetcode__a2ea7df/src/main/kotlin/men/zhangfei/leetcode/medium/Problem0003.kt
package men.zhangfei.leetcode.medium /** * 3. 无重复字符的最长子串 * https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/ */ class Problem0003 { companion object { /** * 滑动窗口算法 * 1. 使用 HashSet 作为滑动窗口,存储字符 * 2. 设置窗口的左边和右边索引为 0 val l = 0, val r = 0 * 3. 循环判断窗口中是否包含字符串【s】右边索引下的字符,直到窗口滑动到字符串的末尾 * a. 不包含:右边索引右移 r++ 并更新窗口的最大长度 max = max(已存储的最大长度, 当前窗口长度) * b. 包含:左边索引右移 l++ 如果移动后的左边索引到末尾的长度不大于已存在的最大长度的话 跳出循环 */ fun slidingWindow(s: String): Int = when { s.isEmpty() -> 0 s.length == 1 -> 1 else -> { var max = 0 val len = s.length var l = 0 var r = 0 val set: MutableSet<Char> = mutableSetOf() while (r < len) { if (set.contains(s[r])) { set.remove(s[l++]) if (len - l <= max) { break } } else { set.add(s[r++]) max = max.coerceAtLeast(r - l) } } max } } /** * 优化的滑动窗口 * 0. 初始化窗口左边和右边的索引为 0 l = 0, r = 0 * 1. 窗口右边索引递增循环 r++; r < s.length * 2. 如果当前右边索引下的字符已经存在,则判断 当前左边索引 > (该字符上次索引 + 1) l > (map[s[\r]] + 1) * a. 是:则说明 (该字符上次索引 + 1) 至 当前左边索引中有其它重复字符,所以忽略,不改变左边索引 l * b. 否:将左边索引移动到 (该字符上次索引 + 1) 的位置 l = (map[s[\r]] + 1) * 4. 更新最长子串长度 max = max(已存储的最大长度, 当前窗口长度) * 5. 将当前右边索引和字符存入 HashMap<字符,索引>. e.g. {"a": 0, "b": 1} * 6. 转到 1 步 */ fun optimizedSlidingWindow(s: String): Int = when { s.isEmpty() -> 0 s.length == 1 -> 1 else -> { var max = 0 val len = s.length var l = 0 var c: Char val map: HashMap<Char, Int> = hashMapOf() for (r in 0 until len) { c = s[r] map[c]?.let { // 防止左边索引回跳 l = l.coerceAtLeast(it + 1) } max = max.coerceAtLeast(r - l + 1) map[c] = r } max } } } }
[ { "class_path": "fitzf__leetcode__a2ea7df/men/zhangfei/leetcode/medium/Problem0003.class", "javap": "Compiled from \"Problem0003.kt\"\npublic final class men.zhangfei.leetcode.medium.Problem0003 {\n public static final men.zhangfei.leetcode.medium.Problem0003$Companion Companion;\n\n public men.zhangfei.leetcode.medium.Problem0003();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #13 // class men/zhangfei/leetcode/medium/Problem0003$Companion\n 3: dup\n 4: aconst_null\n 5: invokespecial #16 // Method men/zhangfei/leetcode/medium/Problem0003$Companion.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 8: putstatic #20 // Field Companion:Lmen/zhangfei/leetcode/medium/Problem0003$Companion;\n 11: return\n}\n", "javap_err": "" }, { "class_path": "fitzf__leetcode__a2ea7df/men/zhangfei/leetcode/medium/Problem0003$Companion.class", "javap": "Compiled from \"Problem0003.kt\"\npublic final class men.zhangfei.leetcode.medium.Problem0003$Companion {\n private men.zhangfei.leetcode.medium.Problem0003$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int slidingWindow(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String s\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: nop\n 7: aload_1\n 8: checkcast #23 // class java/lang/CharSequence\n 11: invokeinterface #27, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 16: ifne 23\n 19: iconst_1\n 20: goto 24\n 23: iconst_0\n 24: ifeq 31\n 27: iconst_0\n 28: goto 158\n 31: aload_1\n 32: invokevirtual #30 // Method java/lang/String.length:()I\n 35: iconst_1\n 36: if_icmpne 43\n 39: iconst_1\n 40: goto 158\n 43: iconst_0\n 44: istore_2\n 45: aload_1\n 46: invokevirtual #30 // Method java/lang/String.length:()I\n 49: istore_3\n 50: iconst_0\n 51: istore 4\n 53: iconst_0\n 54: istore 5\n 56: new #32 // class java/util/LinkedHashSet\n 59: dup\n 60: invokespecial #33 // Method java/util/LinkedHashSet.\"<init>\":()V\n 63: checkcast #35 // class java/util/Set\n 66: astore 6\n 68: iload 5\n 70: iload_3\n 71: if_icmpge 157\n 74: aload 6\n 76: aload_1\n 77: iload 5\n 79: invokevirtual #39 // Method java/lang/String.charAt:(I)C\n 82: invokestatic #45 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 85: invokeinterface #49, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 90: ifeq 124\n 93: aload 6\n 95: aload_1\n 96: iload 4\n 98: iinc 4, 1\n 101: invokevirtual #39 // Method java/lang/String.charAt:(I)C\n 104: invokestatic #45 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 107: invokeinterface #52, 2 // InterfaceMethod java/util/Set.remove:(Ljava/lang/Object;)Z\n 112: pop\n 113: iload_3\n 114: iload 4\n 116: isub\n 117: iload_2\n 118: if_icmpgt 68\n 121: goto 157\n 124: aload 6\n 126: aload_1\n 127: iload 5\n 129: iinc 5, 1\n 132: invokevirtual #39 // Method java/lang/String.charAt:(I)C\n 135: invokestatic #45 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 138: invokeinterface #55, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 143: pop\n 144: iload_2\n 145: iload 5\n 147: iload 4\n 149: isub\n 150: invokestatic #61 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 153: istore_2\n 154: goto 68\n 157: iload_2\n 158: ireturn\n\n public final int optimizedSlidingWindow(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String s\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: nop\n 7: aload_1\n 8: checkcast #23 // class java/lang/CharSequence\n 11: invokeinterface #27, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 16: ifne 23\n 19: iconst_1\n 20: goto 24\n 23: iconst_0\n 24: ifeq 31\n 27: iconst_0\n 28: goto 175\n 31: aload_1\n 32: invokevirtual #30 // Method java/lang/String.length:()I\n 35: iconst_1\n 36: if_icmpne 43\n 39: iconst_1\n 40: goto 175\n 43: iconst_0\n 44: istore_2\n 45: aload_1\n 46: invokevirtual #30 // Method java/lang/String.length:()I\n 49: istore_3\n 50: iconst_0\n 51: istore 4\n 53: iconst_0\n 54: istore 5\n 56: new #72 // class java/util/HashMap\n 59: dup\n 60: invokespecial #73 // Method java/util/HashMap.\"<init>\":()V\n 63: astore 6\n 65: iconst_0\n 66: istore 7\n 68: iload 7\n 70: iload_3\n 71: if_icmpge 174\n 74: aload_1\n 75: iload 7\n 77: invokevirtual #39 // Method java/lang/String.charAt:(I)C\n 80: istore 5\n 82: aload 6\n 84: iload 5\n 86: invokestatic #45 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 89: invokevirtual #77 // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 92: checkcast #79 // class java/lang/Integer\n 95: dup\n 96: ifnull 125\n 99: checkcast #81 // class java/lang/Number\n 102: invokevirtual #84 // Method java/lang/Number.intValue:()I\n 105: istore 9\n 107: iconst_0\n 108: istore 10\n 110: iload 4\n 112: iload 9\n 114: iconst_1\n 115: iadd\n 116: invokestatic #61 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 119: istore 4\n 121: nop\n 122: goto 127\n 125: pop\n 126: nop\n 127: iload_2\n 128: iload 7\n 130: iload 4\n 132: isub\n 133: iconst_1\n 134: iadd\n 135: invokestatic #61 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 138: istore_2\n 139: iload 5\n 141: invokestatic #45 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 144: astore 8\n 146: iload 7\n 148: invokestatic #87 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 151: astore 9\n 153: aload 6\n 155: checkcast #89 // class java/util/Map\n 158: aload 8\n 160: aload 9\n 162: invokeinterface #93, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 167: pop\n 168: iinc 7, 1\n 171: goto 68\n 174: iload_2\n 175: ireturn\n\n public men.zhangfei.leetcode.medium.Problem0003$Companion(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #101 // Method \"<init>\":()V\n 4: return\n}\n", "javap_err": "" } ]
fitzf__leetcode__a2ea7df/src/main/kotlin/men/zhangfei/leetcode/medium/Problem0139.kt
package men.zhangfei.leetcode.medium import java.util.LinkedList import java.util.Queue /** * 139. 单词拆分 * https://leetcode-cn.com/problems/word-break/ */ class Problem0139 { companion object { /** * 动态规划 * 字符串 s 可以被拆分成子字符串 s1 和 s2 * 如果这些子字符串都可以独立地被拆分成符合要求的子字符串,那么整个字符串 s 也可以满足 * e.g. s = "catsanddog", wordDict = ["cats", "dog", "sand", "and", "cat"] * s1 = "catsand", s2 = "dog" * s1-1 = "cats", s1-2 = "and" * s1-1, s1-2 满足, 所以 s1 也满足, s1, s2 都满足,所以 s 也满足 */ fun dp(s: String, wordDict: List<String>): Boolean { val len = s.length val dp = BooleanArray(len + 1) // 空字符串总是字典的一部分, 剩余为 false dp[0] = true for (r in 1..len) { // 通过下标 l 将字符串 s[0, r) 拆分成 s1, s2 for (l in 0 until r) { // 检查 s1 s[0, j) 是否满足条件 检查 s2 s[j, r) 是否满足条件,如果满足,说明 s[0, r) 满足 dp[r] = true if (dp[l] && wordDict.contains(s.substring(l, r))) { dp[r] = true break } } } return dp[len] } /** * 宽度优先搜索 */ fun bfs(s: String, wordDict: List<String>): Boolean { val len = s.length val queue: Queue<Int> = LinkedList() val visited = IntArray(len) queue.add(0) var start: Int while (!queue.isEmpty()) { start = queue.remove() if (0 == visited[start]) { for (end in (start + 1)..len) { if (wordDict.contains(s.substring(start, end))) { queue.add(end) if (end == len) { return true } } } visited[start] = 1 } } return false } } }
[ { "class_path": "fitzf__leetcode__a2ea7df/men/zhangfei/leetcode/medium/Problem0139.class", "javap": "Compiled from \"Problem0139.kt\"\npublic final class men.zhangfei.leetcode.medium.Problem0139 {\n public static final men.zhangfei.leetcode.medium.Problem0139$Companion Companion;\n\n public men.zhangfei.leetcode.medium.Problem0139();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #13 // class men/zhangfei/leetcode/medium/Problem0139$Companion\n 3: dup\n 4: aconst_null\n 5: invokespecial #16 // Method men/zhangfei/leetcode/medium/Problem0139$Companion.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 8: putstatic #20 // Field Companion:Lmen/zhangfei/leetcode/medium/Problem0139$Companion;\n 11: return\n}\n", "javap_err": "" }, { "class_path": "fitzf__leetcode__a2ea7df/men/zhangfei/leetcode/medium/Problem0139$Companion.class", "javap": "Compiled from \"Problem0139.kt\"\npublic final class men.zhangfei.leetcode.medium.Problem0139$Companion {\n private men.zhangfei.leetcode.medium.Problem0139$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final boolean dp(java.lang.String, java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String s\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #24 // String wordDict\n 9: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: invokevirtual #30 // Method java/lang/String.length:()I\n 16: istore_3\n 17: iload_3\n 18: iconst_1\n 19: iadd\n 20: newarray boolean\n 22: astore 4\n 24: aload 4\n 26: iconst_0\n 27: iconst_1\n 28: bastore\n 29: iconst_1\n 30: istore 5\n 32: iload 5\n 34: iload_3\n 35: if_icmpgt 106\n 38: iconst_0\n 39: istore 6\n 41: iload 6\n 43: iload 5\n 45: if_icmpge 94\n 48: aload 4\n 50: iload 6\n 52: baload\n 53: ifeq 88\n 56: aload_2\n 57: aload_1\n 58: iload 6\n 60: iload 5\n 62: invokevirtual #34 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 65: dup\n 66: ldc #36 // String substring(...)\n 68: invokestatic #39 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 71: invokeinterface #45, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 76: ifeq 88\n 79: aload 4\n 81: iload 5\n 83: iconst_1\n 84: bastore\n 85: goto 94\n 88: iinc 6, 1\n 91: goto 41\n 94: iload 5\n 96: iload_3\n 97: if_icmpeq 106\n 100: iinc 5, 1\n 103: goto 38\n 106: aload 4\n 108: iload_3\n 109: baload\n 110: ireturn\n\n public final boolean bfs(java.lang.String, java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String s\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #24 // String wordDict\n 9: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: invokevirtual #30 // Method java/lang/String.length:()I\n 16: istore_3\n 17: new #56 // class java/util/LinkedList\n 20: dup\n 21: invokespecial #57 // Method java/util/LinkedList.\"<init>\":()V\n 24: checkcast #59 // class java/util/Queue\n 27: astore 4\n 29: iload_3\n 30: newarray int\n 32: astore 5\n 34: aload 4\n 36: iconst_0\n 37: invokestatic #65 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 40: invokeinterface #68, 2 // InterfaceMethod java/util/Queue.add:(Ljava/lang/Object;)Z\n 45: pop\n 46: iconst_0\n 47: istore 6\n 49: aload 4\n 51: invokeinterface #72, 1 // InterfaceMethod java/util/Queue.isEmpty:()Z\n 56: ifne 165\n 59: aload 4\n 61: invokeinterface #76, 1 // InterfaceMethod java/util/Queue.remove:()Ljava/lang/Object;\n 66: dup\n 67: ldc #78 // String remove(...)\n 69: invokestatic #39 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 72: checkcast #80 // class java/lang/Number\n 75: invokevirtual #83 // Method java/lang/Number.intValue:()I\n 78: istore 6\n 80: aload 5\n 82: iload 6\n 84: iaload\n 85: ifne 49\n 88: iload 6\n 90: iconst_1\n 91: iadd\n 92: istore 7\n 94: iload 7\n 96: iload_3\n 97: if_icmpgt 156\n 100: aload_2\n 101: aload_1\n 102: iload 6\n 104: iload 7\n 106: invokevirtual #34 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 109: dup\n 110: ldc #36 // String substring(...)\n 112: invokestatic #39 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 115: invokeinterface #45, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 120: ifeq 144\n 123: aload 4\n 125: iload 7\n 127: invokestatic #65 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 130: invokeinterface #68, 2 // InterfaceMethod java/util/Queue.add:(Ljava/lang/Object;)Z\n 135: pop\n 136: iload 7\n 138: iload_3\n 139: if_icmpne 144\n 142: iconst_1\n 143: ireturn\n 144: iload 7\n 146: iload_3\n 147: if_icmpeq 156\n 150: iinc 7, 1\n 153: goto 100\n 156: aload 5\n 158: iload 6\n 160: iconst_1\n 161: iastore\n 162: goto 49\n 165: iconst_0\n 166: ireturn\n\n public men.zhangfei.leetcode.medium.Problem0139$Companion(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #92 // Method \"<init>\":()V\n 4: return\n}\n", "javap_err": "" } ]
xfornesa__aoc2022__dc14292/src/main/kotlin/day04/Problem.kt
package day04 fun solveProblem01(input: List<String>): Long { return input.stream() .map { it.split(",") } .map { val (left, right) = it val (left_l, left_h) = left.split("-").map { it.toInt() } val (right_l, right_h) = right.split("-").map { it.toInt() } left_l <= right_l && right_h <= left_h || right_l <= left_l && left_h <= right_h } .filter { it } .count() } fun solveProblem02(input: List<String>): Long { return input.stream() .map { it.split(",") } .map { val (left, right) = it val (left_l, left_h) = left.split("-").map { it.toInt() } val (right_l, right_h) = right.split("-").map { it.toInt() } right_l in left_l..left_h || right_h in left_l..left_h || left_l in right_l..right_h || left_h in right_l..right_h } .filter { it } .count() }
[ { "class_path": "xfornesa__aoc2022__dc14292/day04/ProblemKt.class", "javap": "Compiled from \"Problem.kt\"\npublic final class day04.ProblemKt {\n public static final long solveProblem01(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #22, 1 // InterfaceMethod java/util/List.stream:()Ljava/util/stream/Stream;\n 12: invokedynamic #41, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 17: invokedynamic #52, 0 // InvokeDynamic #1:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;\n 22: invokeinterface #58, 2 // InterfaceMethod java/util/stream/Stream.map:(Ljava/util/function/Function;)Ljava/util/stream/Stream;\n 27: invokedynamic #65, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;\n 32: invokedynamic #73, 0 // InvokeDynamic #3:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;\n 37: invokeinterface #58, 2 // InterfaceMethod java/util/stream/Stream.map:(Ljava/util/function/Function;)Ljava/util/stream/Stream;\n 42: invokedynamic #81, 0 // InvokeDynamic #4:invoke:()Lkotlin/jvm/functions/Function1;\n 47: invokedynamic #92, 0 // InvokeDynamic #5:test:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Predicate;\n 52: invokeinterface #96, 2 // InterfaceMethod java/util/stream/Stream.filter:(Ljava/util/function/Predicate;)Ljava/util/stream/Stream;\n 57: invokeinterface #100, 1 // InterfaceMethod java/util/stream/Stream.count:()J\n 62: lreturn\n\n public static final long solveProblem02(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #22, 1 // InterfaceMethod java/util/List.stream:()Ljava/util/stream/Stream;\n 12: invokedynamic #107, 0 // InvokeDynamic #6:invoke:()Lkotlin/jvm/functions/Function1;\n 17: invokedynamic #112, 0 // InvokeDynamic #7:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;\n 22: invokeinterface #58, 2 // InterfaceMethod java/util/stream/Stream.map:(Ljava/util/function/Function;)Ljava/util/stream/Stream;\n 27: invokedynamic #117, 0 // InvokeDynamic #8:invoke:()Lkotlin/jvm/functions/Function1;\n 32: invokedynamic #122, 0 // InvokeDynamic #9:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;\n 37: invokeinterface #58, 2 // InterfaceMethod java/util/stream/Stream.map:(Ljava/util/function/Function;)Ljava/util/stream/Stream;\n 42: invokedynamic #127, 0 // InvokeDynamic #10:invoke:()Lkotlin/jvm/functions/Function1;\n 47: invokedynamic #132, 0 // InvokeDynamic #11:test:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Predicate;\n 52: invokeinterface #96, 2 // InterfaceMethod java/util/stream/Stream.filter:(Ljava/util/function/Predicate;)Ljava/util/stream/Stream;\n 57: invokeinterface #100, 1 // InterfaceMethod java/util/stream/Stream.count:()J\n 62: lreturn\n\n private static final java.util.List solveProblem01$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #136 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 4: aload_0\n 5: checkcast #138 // class java/lang/CharSequence\n 8: iconst_1\n 9: anewarray #140 // class java/lang/String\n 12: astore_1\n 13: aload_1\n 14: iconst_0\n 15: ldc #142 // String ,\n 17: aastore\n 18: aload_1\n 19: iconst_0\n 20: iconst_0\n 21: bipush 6\n 23: aconst_null\n 24: invokestatic #148 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 27: areturn\n\n private static final java.util.List solveProblem01$lambda$1(kotlin.jvm.functions.Function1, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #154, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #18 // class java/util/List\n 10: areturn\n\n private static final java.lang.Boolean solveProblem01$lambda$4(java.util.List);\n Code:\n 0: aload_0\n 1: invokestatic #136 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 4: aload_0\n 5: iconst_0\n 6: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 11: checkcast #140 // class java/lang/String\n 14: astore_1\n 15: aload_0\n 16: iconst_1\n 17: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 22: checkcast #140 // class java/lang/String\n 25: astore_2\n 26: aload_1\n 27: checkcast #138 // class java/lang/CharSequence\n 30: iconst_1\n 31: anewarray #140 // class java/lang/String\n 34: astore 4\n 36: aload 4\n 38: iconst_0\n 39: ldc #164 // String -\n 41: aastore\n 42: aload 4\n 44: iconst_0\n 45: iconst_0\n 46: bipush 6\n 48: aconst_null\n 49: invokestatic #148 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 52: checkcast #166 // class java/lang/Iterable\n 55: astore 4\n 57: iconst_0\n 58: istore 5\n 60: aload 4\n 62: astore 6\n 64: new #168 // class java/util/ArrayList\n 67: dup\n 68: aload 4\n 70: bipush 10\n 72: invokestatic #174 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 75: invokespecial #178 // Method java/util/ArrayList.\"<init>\":(I)V\n 78: checkcast #180 // class java/util/Collection\n 81: astore 7\n 83: iconst_0\n 84: istore 8\n 86: aload 6\n 88: invokeinterface #184, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 93: astore 9\n 95: aload 9\n 97: invokeinterface #190, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 102: ifeq 149\n 105: aload 9\n 107: invokeinterface #194, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 112: astore 10\n 114: aload 7\n 116: aload 10\n 118: checkcast #140 // class java/lang/String\n 121: astore 11\n 123: astore 16\n 125: iconst_0\n 126: istore 12\n 128: aload 11\n 130: invokestatic #200 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 133: nop\n 134: invokestatic #204 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 137: aload 16\n 139: swap\n 140: invokeinterface #207, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 145: pop\n 146: goto 95\n 149: aload 7\n 151: checkcast #18 // class java/util/List\n 154: nop\n 155: astore_3\n 156: aload_3\n 157: iconst_0\n 158: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 163: checkcast #209 // class java/lang/Number\n 166: invokevirtual #213 // Method java/lang/Number.intValue:()I\n 169: istore 4\n 171: aload_3\n 172: iconst_1\n 173: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 178: checkcast #209 // class java/lang/Number\n 181: invokevirtual #213 // Method java/lang/Number.intValue:()I\n 184: istore 5\n 186: aload_2\n 187: checkcast #138 // class java/lang/CharSequence\n 190: iconst_1\n 191: anewarray #140 // class java/lang/String\n 194: astore 7\n 196: aload 7\n 198: iconst_0\n 199: ldc #164 // String -\n 201: aastore\n 202: aload 7\n 204: iconst_0\n 205: iconst_0\n 206: bipush 6\n 208: aconst_null\n 209: invokestatic #148 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 212: checkcast #166 // class java/lang/Iterable\n 215: astore 7\n 217: iconst_0\n 218: istore 8\n 220: aload 7\n 222: astore 9\n 224: new #168 // class java/util/ArrayList\n 227: dup\n 228: aload 7\n 230: bipush 10\n 232: invokestatic #174 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 235: invokespecial #178 // Method java/util/ArrayList.\"<init>\":(I)V\n 238: checkcast #180 // class java/util/Collection\n 241: astore 10\n 243: iconst_0\n 244: istore 11\n 246: aload 9\n 248: invokeinterface #184, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 253: astore 12\n 255: aload 12\n 257: invokeinterface #190, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 262: ifeq 309\n 265: aload 12\n 267: invokeinterface #194, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 272: astore 13\n 274: aload 10\n 276: aload 13\n 278: checkcast #140 // class java/lang/String\n 281: astore 14\n 283: astore 16\n 285: iconst_0\n 286: istore 15\n 288: aload 14\n 290: invokestatic #200 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 293: nop\n 294: invokestatic #204 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 297: aload 16\n 299: swap\n 300: invokeinterface #207, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 305: pop\n 306: goto 255\n 309: aload 10\n 311: checkcast #18 // class java/util/List\n 314: nop\n 315: astore 6\n 317: aload 6\n 319: iconst_0\n 320: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 325: checkcast #209 // class java/lang/Number\n 328: invokevirtual #213 // Method java/lang/Number.intValue:()I\n 331: istore 7\n 333: aload 6\n 335: iconst_1\n 336: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 341: checkcast #209 // class java/lang/Number\n 344: invokevirtual #213 // Method java/lang/Number.intValue:()I\n 347: istore 8\n 349: iload 4\n 351: iload 7\n 353: if_icmpgt 363\n 356: iload 8\n 358: iload 5\n 360: if_icmple 377\n 363: iload 7\n 365: iload 4\n 367: if_icmpgt 381\n 370: iload 5\n 372: iload 8\n 374: if_icmpgt 381\n 377: iconst_1\n 378: goto 382\n 381: iconst_0\n 382: invokestatic #218 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 385: areturn\n\n private static final java.lang.Boolean solveProblem01$lambda$5(kotlin.jvm.functions.Function1, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #154, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #215 // class java/lang/Boolean\n 10: areturn\n\n private static final boolean solveProblem01$lambda$6(java.lang.Boolean);\n Code:\n 0: aload_0\n 1: invokestatic #136 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 4: aload_0\n 5: invokevirtual #238 // Method java/lang/Boolean.booleanValue:()Z\n 8: ireturn\n\n private static final boolean solveProblem01$lambda$7(kotlin.jvm.functions.Function1, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #154, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #215 // class java/lang/Boolean\n 10: invokevirtual #238 // Method java/lang/Boolean.booleanValue:()Z\n 13: ireturn\n\n private static final java.util.List solveProblem02$lambda$8(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #136 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 4: aload_0\n 5: checkcast #138 // class java/lang/CharSequence\n 8: iconst_1\n 9: anewarray #140 // class java/lang/String\n 12: astore_1\n 13: aload_1\n 14: iconst_0\n 15: ldc #142 // String ,\n 17: aastore\n 18: aload_1\n 19: iconst_0\n 20: iconst_0\n 21: bipush 6\n 23: aconst_null\n 24: invokestatic #148 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 27: areturn\n\n private static final java.util.List solveProblem02$lambda$9(kotlin.jvm.functions.Function1, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #154, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #18 // class java/util/List\n 10: areturn\n\n private static final java.lang.Boolean solveProblem02$lambda$12(java.util.List);\n Code:\n 0: aload_0\n 1: invokestatic #136 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 4: aload_0\n 5: iconst_0\n 6: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 11: checkcast #140 // class java/lang/String\n 14: astore_1\n 15: aload_0\n 16: iconst_1\n 17: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 22: checkcast #140 // class java/lang/String\n 25: astore_2\n 26: aload_1\n 27: checkcast #138 // class java/lang/CharSequence\n 30: iconst_1\n 31: anewarray #140 // class java/lang/String\n 34: astore 4\n 36: aload 4\n 38: iconst_0\n 39: ldc #164 // String -\n 41: aastore\n 42: aload 4\n 44: iconst_0\n 45: iconst_0\n 46: bipush 6\n 48: aconst_null\n 49: invokestatic #148 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 52: checkcast #166 // class java/lang/Iterable\n 55: astore 4\n 57: iconst_0\n 58: istore 5\n 60: aload 4\n 62: astore 6\n 64: new #168 // class java/util/ArrayList\n 67: dup\n 68: aload 4\n 70: bipush 10\n 72: invokestatic #174 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 75: invokespecial #178 // Method java/util/ArrayList.\"<init>\":(I)V\n 78: checkcast #180 // class java/util/Collection\n 81: astore 7\n 83: iconst_0\n 84: istore 8\n 86: aload 6\n 88: invokeinterface #184, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 93: astore 9\n 95: aload 9\n 97: invokeinterface #190, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 102: ifeq 149\n 105: aload 9\n 107: invokeinterface #194, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 112: astore 10\n 114: aload 7\n 116: aload 10\n 118: checkcast #140 // class java/lang/String\n 121: astore 11\n 123: astore 16\n 125: iconst_0\n 126: istore 12\n 128: aload 11\n 130: invokestatic #200 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 133: nop\n 134: invokestatic #204 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 137: aload 16\n 139: swap\n 140: invokeinterface #207, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 145: pop\n 146: goto 95\n 149: aload 7\n 151: checkcast #18 // class java/util/List\n 154: nop\n 155: astore_3\n 156: aload_3\n 157: iconst_0\n 158: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 163: checkcast #209 // class java/lang/Number\n 166: invokevirtual #213 // Method java/lang/Number.intValue:()I\n 169: istore 4\n 171: aload_3\n 172: iconst_1\n 173: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 178: checkcast #209 // class java/lang/Number\n 181: invokevirtual #213 // Method java/lang/Number.intValue:()I\n 184: istore 5\n 186: aload_2\n 187: checkcast #138 // class java/lang/CharSequence\n 190: iconst_1\n 191: anewarray #140 // class java/lang/String\n 194: astore 7\n 196: aload 7\n 198: iconst_0\n 199: ldc #164 // String -\n 201: aastore\n 202: aload 7\n 204: iconst_0\n 205: iconst_0\n 206: bipush 6\n 208: aconst_null\n 209: invokestatic #148 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 212: checkcast #166 // class java/lang/Iterable\n 215: astore 7\n 217: iconst_0\n 218: istore 8\n 220: aload 7\n 222: astore 9\n 224: new #168 // class java/util/ArrayList\n 227: dup\n 228: aload 7\n 230: bipush 10\n 232: invokestatic #174 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 235: invokespecial #178 // Method java/util/ArrayList.\"<init>\":(I)V\n 238: checkcast #180 // class java/util/Collection\n 241: astore 10\n 243: iconst_0\n 244: istore 11\n 246: aload 9\n 248: invokeinterface #184, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 253: astore 12\n 255: aload 12\n 257: invokeinterface #190, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 262: ifeq 309\n 265: aload 12\n 267: invokeinterface #194, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 272: astore 13\n 274: aload 10\n 276: aload 13\n 278: checkcast #140 // class java/lang/String\n 281: astore 14\n 283: astore 16\n 285: iconst_0\n 286: istore 15\n 288: aload 14\n 290: invokestatic #200 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 293: nop\n 294: invokestatic #204 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 297: aload 16\n 299: swap\n 300: invokeinterface #207, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 305: pop\n 306: goto 255\n 309: aload 10\n 311: checkcast #18 // class java/util/List\n 314: nop\n 315: astore 6\n 317: aload 6\n 319: iconst_0\n 320: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 325: checkcast #209 // class java/lang/Number\n 328: invokevirtual #213 // Method java/lang/Number.intValue:()I\n 331: istore 7\n 333: aload 6\n 335: iconst_1\n 336: invokeinterface #162, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 341: checkcast #209 // class java/lang/Number\n 344: invokevirtual #213 // Method java/lang/Number.intValue:()I\n 347: istore 8\n 349: iload 4\n 351: iload 7\n 353: if_icmpgt 371\n 356: iload 7\n 358: iload 5\n 360: if_icmpgt 367\n 363: iconst_1\n 364: goto 372\n 367: iconst_0\n 368: goto 372\n 371: iconst_0\n 372: ifne 453\n 375: iload 4\n 377: iload 8\n 379: if_icmpgt 397\n 382: iload 8\n 384: iload 5\n 386: if_icmpgt 393\n 389: iconst_1\n 390: goto 398\n 393: iconst_0\n 394: goto 398\n 397: iconst_0\n 398: ifne 453\n 401: iload 7\n 403: iload 4\n 405: if_icmpgt 423\n 408: iload 4\n 410: iload 8\n 412: if_icmpgt 419\n 415: iconst_1\n 416: goto 424\n 419: iconst_0\n 420: goto 424\n 423: iconst_0\n 424: ifne 453\n 427: iload 7\n 429: iload 5\n 431: if_icmpgt 449\n 434: iload 5\n 436: iload 8\n 438: if_icmpgt 445\n 441: iconst_1\n 442: goto 450\n 445: iconst_0\n 446: goto 450\n 449: iconst_0\n 450: ifeq 457\n 453: iconst_1\n 454: goto 458\n 457: iconst_0\n 458: invokestatic #218 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 461: areturn\n\n private static final java.lang.Boolean solveProblem02$lambda$13(kotlin.jvm.functions.Function1, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #154, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #215 // class java/lang/Boolean\n 10: areturn\n\n private static final boolean solveProblem02$lambda$14(java.lang.Boolean);\n Code:\n 0: aload_0\n 1: invokestatic #136 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 4: aload_0\n 5: invokevirtual #238 // Method java/lang/Boolean.booleanValue:()Z\n 8: ireturn\n\n private static final boolean solveProblem02$lambda$15(kotlin.jvm.functions.Function1, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #154, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #215 // class java/lang/Boolean\n 10: invokevirtual #238 // Method java/lang/Boolean.booleanValue:()Z\n 13: ireturn\n}\n", "javap_err": "" } ]
xfornesa__aoc2022__dc14292/src/main/kotlin/day03/Problem.kt
package day03 fun solveProblem01(input: List<String>): Int { val commonTypes = mutableListOf<Char>() input.forEach { val first = it.substring(0 until it.length/2) val second = it.substring((it.length / 2) until it.length) val commonType = commonType(first, second) commonTypes.add(commonType) } return commonTypes.sumOf { toScore(it) } } fun toScore(it: Char): Int { return if (it.isLowerCase()) it.minus('a') + 1 else it.minus('A') + 27 } fun commonType(first: String, second: String): Char { val occurrencesFirst = HashSet<Char>() first.forEach { occurrencesFirst.add(it) } val occurrencesSecond = HashSet<Char>() second.forEach { occurrencesSecond.add(it) } val common = first.asIterable().toSet() intersect second.asIterable().toSet() return common.first() } fun solveProblem02(input: List<String>): Int { val windowed = input.windowed(3, 3) return windowed.map { findCommonTypes(it) }.sumOf { toScore(it) } } fun findCommonTypes(it: List<String>): Char { val (first, second, third) = it val occurrencesFirst = HashSet<Char>() first.forEach { occurrencesFirst.add(it) } val occurrencesSecond = HashSet<Char>() second.forEach { occurrencesSecond.add(it) } val occurrencesThird = HashSet<Char>() third.forEach { occurrencesThird.add(it) } val common = first.toSet() intersect second.toSet() intersect third.toSet() return common.first() }
[ { "class_path": "xfornesa__aoc2022__dc14292/day03/ProblemKt.class", "javap": "Compiled from \"Problem.kt\"\npublic final class day03.ProblemKt {\n public static final int solveProblem01(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #18 // class java/util/ArrayList\n 9: dup\n 10: invokespecial #22 // Method java/util/ArrayList.\"<init>\":()V\n 13: checkcast #24 // class java/util/List\n 16: astore_1\n 17: aload_0\n 18: checkcast #26 // class java/lang/Iterable\n 21: astore_2\n 22: iconst_0\n 23: istore_3\n 24: aload_2\n 25: invokeinterface #30, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 30: astore 4\n 32: aload 4\n 34: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 39: ifeq 127\n 42: aload 4\n 44: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 49: astore 5\n 51: aload 5\n 53: checkcast #42 // class java/lang/String\n 56: astore 6\n 58: iconst_0\n 59: istore 7\n 61: aload 6\n 63: iconst_0\n 64: aload 6\n 66: invokevirtual #46 // Method java/lang/String.length:()I\n 69: iconst_2\n 70: idiv\n 71: invokestatic #52 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 74: invokestatic #58 // Method kotlin/text/StringsKt.substring:(Ljava/lang/String;Lkotlin/ranges/IntRange;)Ljava/lang/String;\n 77: astore 8\n 79: aload 6\n 81: aload 6\n 83: invokevirtual #46 // Method java/lang/String.length:()I\n 86: iconst_2\n 87: idiv\n 88: aload 6\n 90: invokevirtual #46 // Method java/lang/String.length:()I\n 93: invokestatic #52 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 96: invokestatic #58 // Method kotlin/text/StringsKt.substring:(Ljava/lang/String;Lkotlin/ranges/IntRange;)Ljava/lang/String;\n 99: astore 9\n 101: aload 8\n 103: aload 9\n 105: invokestatic #62 // Method commonType:(Ljava/lang/String;Ljava/lang/String;)C\n 108: istore 10\n 110: aload_1\n 111: iload 10\n 113: invokestatic #68 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 116: invokeinterface #72, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 121: pop\n 122: nop\n 123: nop\n 124: goto 32\n 127: nop\n 128: aload_1\n 129: checkcast #26 // class java/lang/Iterable\n 132: astore_2\n 133: iconst_0\n 134: istore_3\n 135: aload_2\n 136: invokeinterface #30, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 141: astore 4\n 143: aload 4\n 145: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 150: ifeq 194\n 153: aload 4\n 155: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 160: astore 5\n 162: iload_3\n 163: aload 5\n 165: checkcast #64 // class java/lang/Character\n 168: invokevirtual #76 // Method java/lang/Character.charValue:()C\n 171: istore 6\n 173: istore 11\n 175: iconst_0\n 176: istore 7\n 178: iload 6\n 180: invokestatic #80 // Method toScore:(C)I\n 183: istore 12\n 185: iload 11\n 187: iload 12\n 189: iadd\n 190: istore_3\n 191: goto 143\n 194: iload_3\n 195: ireturn\n\n public static final int toScore(char);\n Code:\n 0: iload_0\n 1: invokestatic #99 // Method java/lang/Character.isLowerCase:(C)Z\n 4: ifeq 16\n 7: iload_0\n 8: bipush 97\n 10: isub\n 11: iconst_1\n 12: iadd\n 13: goto 23\n 16: iload_0\n 17: bipush 65\n 19: isub\n 20: bipush 27\n 22: iadd\n 23: ireturn\n\n public static final char commonType(java.lang.String, java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #100 // String first\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #101 // String second\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #103 // class java/util/HashSet\n 15: dup\n 16: invokespecial #104 // Method java/util/HashSet.\"<init>\":()V\n 19: astore_2\n 20: aload_0\n 21: checkcast #106 // class java/lang/CharSequence\n 24: astore_3\n 25: iconst_0\n 26: istore 4\n 28: iconst_0\n 29: istore 5\n 31: iload 5\n 33: aload_3\n 34: invokeinterface #107, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 39: if_icmpge 77\n 42: aload_3\n 43: iload 5\n 45: invokeinterface #111, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 50: istore 6\n 52: iload 6\n 54: istore 7\n 56: iconst_0\n 57: istore 8\n 59: aload_2\n 60: iload 7\n 62: invokestatic #68 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 65: invokevirtual #112 // Method java/util/HashSet.add:(Ljava/lang/Object;)Z\n 68: pop\n 69: nop\n 70: nop\n 71: iinc 5, 1\n 74: goto 31\n 77: nop\n 78: new #103 // class java/util/HashSet\n 81: dup\n 82: invokespecial #104 // Method java/util/HashSet.\"<init>\":()V\n 85: astore_3\n 86: aload_1\n 87: checkcast #106 // class java/lang/CharSequence\n 90: astore 4\n 92: iconst_0\n 93: istore 5\n 95: iconst_0\n 96: istore 6\n 98: iload 6\n 100: aload 4\n 102: invokeinterface #107, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 107: if_icmpge 146\n 110: aload 4\n 112: iload 6\n 114: invokeinterface #111, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 119: istore 7\n 121: iload 7\n 123: istore 8\n 125: iconst_0\n 126: istore 9\n 128: aload_3\n 129: iload 8\n 131: invokestatic #68 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 134: invokevirtual #112 // Method java/util/HashSet.add:(Ljava/lang/Object;)Z\n 137: pop\n 138: nop\n 139: nop\n 140: iinc 6, 1\n 143: goto 98\n 146: nop\n 147: aload_0\n 148: checkcast #106 // class java/lang/CharSequence\n 151: invokestatic #116 // Method kotlin/text/StringsKt.asIterable:(Ljava/lang/CharSequence;)Ljava/lang/Iterable;\n 154: invokestatic #122 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 157: checkcast #26 // class java/lang/Iterable\n 160: aload_1\n 161: checkcast #106 // class java/lang/CharSequence\n 164: invokestatic #116 // Method kotlin/text/StringsKt.asIterable:(Ljava/lang/CharSequence;)Ljava/lang/Iterable;\n 167: invokestatic #122 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 170: checkcast #26 // class java/lang/Iterable\n 173: invokestatic #126 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 176: astore 4\n 178: aload 4\n 180: checkcast #26 // class java/lang/Iterable\n 183: invokestatic #129 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 186: checkcast #64 // class java/lang/Character\n 189: invokevirtual #76 // Method java/lang/Character.charValue:()C\n 192: ireturn\n\n public static final int solveProblem02(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #26 // class java/lang/Iterable\n 10: iconst_3\n 11: iconst_3\n 12: iconst_0\n 13: iconst_4\n 14: aconst_null\n 15: invokestatic #142 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;\n 18: astore_1\n 19: aload_1\n 20: checkcast #26 // class java/lang/Iterable\n 23: astore_2\n 24: iconst_0\n 25: istore_3\n 26: aload_2\n 27: astore 4\n 29: new #18 // class java/util/ArrayList\n 32: dup\n 33: aload_2\n 34: bipush 10\n 36: invokestatic #146 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 39: invokespecial #149 // Method java/util/ArrayList.\"<init>\":(I)V\n 42: checkcast #151 // class java/util/Collection\n 45: astore 5\n 47: iconst_0\n 48: istore 6\n 50: aload 4\n 52: invokeinterface #30, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 57: astore 7\n 59: aload 7\n 61: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 66: ifeq 112\n 69: aload 7\n 71: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 76: astore 8\n 78: aload 5\n 80: aload 8\n 82: checkcast #24 // class java/util/List\n 85: astore 9\n 87: astore 11\n 89: iconst_0\n 90: istore 10\n 92: aload 9\n 94: invokestatic #155 // Method findCommonTypes:(Ljava/util/List;)C\n 97: invokestatic #68 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 100: aload 11\n 102: swap\n 103: invokeinterface #156, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 108: pop\n 109: goto 59\n 112: aload 5\n 114: checkcast #24 // class java/util/List\n 117: nop\n 118: checkcast #26 // class java/lang/Iterable\n 121: astore_2\n 122: iconst_0\n 123: istore_3\n 124: aload_2\n 125: invokeinterface #30, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 130: astore 4\n 132: aload 4\n 134: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 139: ifeq 183\n 142: aload 4\n 144: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 149: astore 5\n 151: iload_3\n 152: aload 5\n 154: checkcast #64 // class java/lang/Character\n 157: invokevirtual #76 // Method java/lang/Character.charValue:()C\n 160: istore 6\n 162: istore 11\n 164: iconst_0\n 165: istore 7\n 167: iload 6\n 169: invokestatic #80 // Method toScore:(C)I\n 172: istore 12\n 174: iload 11\n 176: iload 12\n 178: iadd\n 179: istore_3\n 180: goto 132\n 183: iload_3\n 184: ireturn\n\n public static final char findCommonTypes(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #168 // String it\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iconst_0\n 8: invokeinterface #172, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 13: checkcast #42 // class java/lang/String\n 16: astore_1\n 17: aload_0\n 18: iconst_1\n 19: invokeinterface #172, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 24: checkcast #42 // class java/lang/String\n 27: astore_2\n 28: aload_0\n 29: iconst_2\n 30: invokeinterface #172, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 35: checkcast #42 // class java/lang/String\n 38: astore_3\n 39: new #103 // class java/util/HashSet\n 42: dup\n 43: invokespecial #104 // Method java/util/HashSet.\"<init>\":()V\n 46: astore 4\n 48: aload_1\n 49: checkcast #106 // class java/lang/CharSequence\n 52: astore 5\n 54: iconst_0\n 55: istore 6\n 57: iconst_0\n 58: istore 7\n 60: iload 7\n 62: aload 5\n 64: invokeinterface #107, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 69: if_icmpge 109\n 72: aload 5\n 74: iload 7\n 76: invokeinterface #111, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 81: istore 8\n 83: iload 8\n 85: istore 9\n 87: iconst_0\n 88: istore 10\n 90: aload 4\n 92: iload 9\n 94: invokestatic #68 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 97: invokevirtual #112 // Method java/util/HashSet.add:(Ljava/lang/Object;)Z\n 100: pop\n 101: nop\n 102: nop\n 103: iinc 7, 1\n 106: goto 60\n 109: nop\n 110: new #103 // class java/util/HashSet\n 113: dup\n 114: invokespecial #104 // Method java/util/HashSet.\"<init>\":()V\n 117: astore 5\n 119: aload_2\n 120: checkcast #106 // class java/lang/CharSequence\n 123: astore 6\n 125: iconst_0\n 126: istore 7\n 128: iconst_0\n 129: istore 8\n 131: iload 8\n 133: aload 6\n 135: invokeinterface #107, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 140: if_icmpge 180\n 143: aload 6\n 145: iload 8\n 147: invokeinterface #111, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 152: istore 9\n 154: iload 9\n 156: istore 10\n 158: iconst_0\n 159: istore 11\n 161: aload 5\n 163: iload 10\n 165: invokestatic #68 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 168: invokevirtual #112 // Method java/util/HashSet.add:(Ljava/lang/Object;)Z\n 171: pop\n 172: nop\n 173: nop\n 174: iinc 8, 1\n 177: goto 131\n 180: nop\n 181: new #103 // class java/util/HashSet\n 184: dup\n 185: invokespecial #104 // Method java/util/HashSet.\"<init>\":()V\n 188: astore 6\n 190: aload_3\n 191: checkcast #106 // class java/lang/CharSequence\n 194: astore 7\n 196: iconst_0\n 197: istore 8\n 199: iconst_0\n 200: istore 9\n 202: iload 9\n 204: aload 7\n 206: invokeinterface #107, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 211: if_icmpge 251\n 214: aload 7\n 216: iload 9\n 218: invokeinterface #111, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 223: istore 10\n 225: iload 10\n 227: istore 11\n 229: iconst_0\n 230: istore 12\n 232: aload 6\n 234: iload 11\n 236: invokestatic #68 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 239: invokevirtual #112 // Method java/util/HashSet.add:(Ljava/lang/Object;)Z\n 242: pop\n 243: nop\n 244: nop\n 245: iinc 9, 1\n 248: goto 202\n 251: nop\n 252: aload_1\n 253: checkcast #106 // class java/lang/CharSequence\n 256: invokestatic #175 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 259: checkcast #26 // class java/lang/Iterable\n 262: aload_2\n 263: checkcast #106 // class java/lang/CharSequence\n 266: invokestatic #175 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 269: checkcast #26 // class java/lang/Iterable\n 272: invokestatic #126 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 275: checkcast #26 // class java/lang/Iterable\n 278: aload_3\n 279: checkcast #106 // class java/lang/CharSequence\n 282: invokestatic #175 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 285: checkcast #26 // class java/lang/Iterable\n 288: invokestatic #126 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 291: astore 7\n 293: aload 7\n 295: checkcast #26 // class java/lang/Iterable\n 298: invokestatic #129 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 301: checkcast #64 // class java/lang/Character\n 304: invokevirtual #76 // Method java/lang/Character.charValue:()C\n 307: ireturn\n}\n", "javap_err": "" } ]
xfornesa__aoc2022__dc14292/src/main/kotlin/day02/Problem.kt
package day02 fun solveProblem01(input: List<Pair<String, String>>): Int { var score = 0 input.forEach { score += round01(it) } return score } // A for Rock, B for Paper, and C for Scissors // X for Rock, Y for Paper, and Z for Scissors // score: (1 for Rock, 2 for Paper, and 3 for Scissors) + (0 if you lost, 3 if the round was a draw, and 6 if you won) private fun round01(pair: Pair<String, String>): Int { var figureScore = 0 when (pair.second) { "X" -> figureScore = 1 "Y" -> figureScore = 2 "Z" -> figureScore = 3 } var winningScore = 0 when (pair) { Pair("A", "X") -> winningScore = 3 Pair("A", "Y") -> winningScore = 6 Pair("A", "Z") -> winningScore = 0 Pair("B", "X") -> winningScore = 0 Pair("B", "Y") -> winningScore = 3 Pair("B", "Z") -> winningScore = 6 Pair("C", "X") -> winningScore = 6 Pair("C", "Y") -> winningScore = 0 Pair("C", "Z") -> winningScore = 3 } return figureScore + winningScore } fun solveProblem02(input: List<Pair<String, String>>): Int { var score = 0 input.forEach { score += round02(it) } return score } // A for Rock, B for Paper, and C for Scissors // X for lose, Y for draw, and Z for win // score: (1 for Rock, 2 for Paper, and 3 for Scissors) + (0 if you lost, 3 if the round was a draw, and 6 if you won) private fun round02(pair: Pair<String, String>): Int { var winningScore = 0 when (pair.second) { "X" -> winningScore = 0 "Y" -> winningScore = 3 "Z" -> winningScore = 6 } var figureScore = 0 when (pair) { // rock Pair("A", "X") -> figureScore = 3 // lose with scissors Pair("A", "Y") -> figureScore = 1 // draw with rock Pair("A", "Z") -> figureScore = 2 // win with paper // paper Pair("B", "X") -> figureScore = 1 // lose with rock Pair("B", "Y") -> figureScore = 2 // draw with paper Pair("B", "Z") -> figureScore = 3 // win with scissors // scissors Pair("C", "X") -> figureScore = 2 // lose with paper Pair("C", "Y") -> figureScore = 3 // draw with scissors Pair("C", "Z") -> figureScore = 1 // win with rock } return figureScore + winningScore }
[ { "class_path": "xfornesa__aoc2022__dc14292/day02/ProblemKt.class", "javap": "Compiled from \"Problem.kt\"\npublic final class day02.ProblemKt {\n public static final int solveProblem01(java.util.List<kotlin.Pair<java.lang.String, java.lang.String>>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_1\n 8: aload_0\n 9: checkcast #18 // class java/lang/Iterable\n 12: astore_2\n 13: iconst_0\n 14: istore_3\n 15: aload_2\n 16: invokeinterface #22, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 21: astore 4\n 23: aload 4\n 25: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 30: ifeq 65\n 33: aload 4\n 35: invokeinterface #32, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 40: astore 5\n 42: aload 5\n 44: checkcast #34 // class kotlin/Pair\n 47: astore 6\n 49: iconst_0\n 50: istore 7\n 52: iload_1\n 53: aload 6\n 55: invokestatic #38 // Method round01:(Lkotlin/Pair;)I\n 58: iadd\n 59: istore_1\n 60: nop\n 61: nop\n 62: goto 23\n 65: nop\n 66: iload_1\n 67: ireturn\n\n private static final int round01(kotlin.Pair<java.lang.String, java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: aload_0\n 3: invokevirtual #55 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 6: checkcast #57 // class java/lang/String\n 9: astore_2\n 10: aload_2\n 11: invokevirtual #61 // Method java/lang/String.hashCode:()I\n 14: tableswitch { // 88 to 90\n 88: 40\n 89: 52\n 90: 64\n default: 88\n }\n 40: aload_2\n 41: ldc #63 // String X\n 43: invokevirtual #67 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 46: ifne 76\n 49: goto 88\n 52: aload_2\n 53: ldc #69 // String Y\n 55: invokevirtual #67 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 58: ifne 81\n 61: goto 88\n 64: aload_2\n 65: ldc #71 // String Z\n 67: invokevirtual #67 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 70: ifne 86\n 73: goto 88\n 76: iconst_1\n 77: istore_1\n 78: goto 88\n 81: iconst_2\n 82: istore_1\n 83: goto 88\n 86: iconst_3\n 87: istore_1\n 88: iconst_0\n 89: istore_2\n 90: aload_0\n 91: astore_3\n 92: aload_3\n 93: new #34 // class kotlin/Pair\n 96: dup\n 97: ldc #73 // String A\n 99: ldc #63 // String X\n 101: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 104: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 107: ifeq 115\n 110: iconst_3\n 111: istore_2\n 112: goto 299\n 115: aload_3\n 116: new #34 // class kotlin/Pair\n 119: dup\n 120: ldc #73 // String A\n 122: ldc #69 // String Y\n 124: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 127: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 130: ifeq 139\n 133: bipush 6\n 135: istore_2\n 136: goto 299\n 139: aload_3\n 140: new #34 // class kotlin/Pair\n 143: dup\n 144: ldc #73 // String A\n 146: ldc #71 // String Z\n 148: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 151: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 154: ifeq 162\n 157: iconst_0\n 158: istore_2\n 159: goto 299\n 162: aload_3\n 163: new #34 // class kotlin/Pair\n 166: dup\n 167: ldc #83 // String B\n 169: ldc #63 // String X\n 171: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 174: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 177: ifeq 185\n 180: iconst_0\n 181: istore_2\n 182: goto 299\n 185: aload_3\n 186: new #34 // class kotlin/Pair\n 189: dup\n 190: ldc #83 // String B\n 192: ldc #69 // String Y\n 194: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 197: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 200: ifeq 208\n 203: iconst_3\n 204: istore_2\n 205: goto 299\n 208: aload_3\n 209: new #34 // class kotlin/Pair\n 212: dup\n 213: ldc #83 // String B\n 215: ldc #71 // String Z\n 217: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 220: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 223: ifeq 232\n 226: bipush 6\n 228: istore_2\n 229: goto 299\n 232: aload_3\n 233: new #34 // class kotlin/Pair\n 236: dup\n 237: ldc #85 // String C\n 239: ldc #63 // String X\n 241: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 244: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 247: ifeq 256\n 250: bipush 6\n 252: istore_2\n 253: goto 299\n 256: aload_3\n 257: new #34 // class kotlin/Pair\n 260: dup\n 261: ldc #85 // String C\n 263: ldc #69 // String Y\n 265: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 268: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 271: ifeq 279\n 274: iconst_0\n 275: istore_2\n 276: goto 299\n 279: aload_3\n 280: new #34 // class kotlin/Pair\n 283: dup\n 284: ldc #85 // String C\n 286: ldc #71 // String Z\n 288: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 291: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 294: ifeq 299\n 297: iconst_3\n 298: istore_2\n 299: iload_1\n 300: iload_2\n 301: iadd\n 302: ireturn\n\n public static final int solveProblem02(java.util.List<kotlin.Pair<java.lang.String, java.lang.String>>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_1\n 8: aload_0\n 9: checkcast #18 // class java/lang/Iterable\n 12: astore_2\n 13: iconst_0\n 14: istore_3\n 15: aload_2\n 16: invokeinterface #22, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 21: astore 4\n 23: aload 4\n 25: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 30: ifeq 65\n 33: aload 4\n 35: invokeinterface #32, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 40: astore 5\n 42: aload 5\n 44: checkcast #34 // class kotlin/Pair\n 47: astore 6\n 49: iconst_0\n 50: istore 7\n 52: iload_1\n 53: aload 6\n 55: invokestatic #92 // Method round02:(Lkotlin/Pair;)I\n 58: iadd\n 59: istore_1\n 60: nop\n 61: nop\n 62: goto 23\n 65: nop\n 66: iload_1\n 67: ireturn\n\n private static final int round02(kotlin.Pair<java.lang.String, java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: aload_0\n 3: invokevirtual #55 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 6: checkcast #57 // class java/lang/String\n 9: astore_2\n 10: aload_2\n 11: invokevirtual #61 // Method java/lang/String.hashCode:()I\n 14: tableswitch { // 88 to 90\n 88: 40\n 89: 52\n 90: 64\n default: 89\n }\n 40: aload_2\n 41: ldc #63 // String X\n 43: invokevirtual #67 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 46: ifne 76\n 49: goto 89\n 52: aload_2\n 53: ldc #69 // String Y\n 55: invokevirtual #67 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 58: ifne 81\n 61: goto 89\n 64: aload_2\n 65: ldc #71 // String Z\n 67: invokevirtual #67 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 70: ifne 86\n 73: goto 89\n 76: iconst_0\n 77: istore_1\n 78: goto 89\n 81: iconst_3\n 82: istore_1\n 83: goto 89\n 86: bipush 6\n 88: istore_1\n 89: iconst_0\n 90: istore_2\n 91: aload_0\n 92: astore_3\n 93: aload_3\n 94: new #34 // class kotlin/Pair\n 97: dup\n 98: ldc #73 // String A\n 100: ldc #63 // String X\n 102: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 105: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 108: ifeq 116\n 111: iconst_3\n 112: istore_2\n 113: goto 297\n 116: aload_3\n 117: new #34 // class kotlin/Pair\n 120: dup\n 121: ldc #73 // String A\n 123: ldc #69 // String Y\n 125: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 128: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 131: ifeq 139\n 134: iconst_1\n 135: istore_2\n 136: goto 297\n 139: aload_3\n 140: new #34 // class kotlin/Pair\n 143: dup\n 144: ldc #73 // String A\n 146: ldc #71 // String Z\n 148: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 151: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 154: ifeq 162\n 157: iconst_2\n 158: istore_2\n 159: goto 297\n 162: aload_3\n 163: new #34 // class kotlin/Pair\n 166: dup\n 167: ldc #83 // String B\n 169: ldc #63 // String X\n 171: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 174: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 177: ifeq 185\n 180: iconst_1\n 181: istore_2\n 182: goto 297\n 185: aload_3\n 186: new #34 // class kotlin/Pair\n 189: dup\n 190: ldc #83 // String B\n 192: ldc #69 // String Y\n 194: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 197: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 200: ifeq 208\n 203: iconst_2\n 204: istore_2\n 205: goto 297\n 208: aload_3\n 209: new #34 // class kotlin/Pair\n 212: dup\n 213: ldc #83 // String B\n 215: ldc #71 // String Z\n 217: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 220: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 223: ifeq 231\n 226: iconst_3\n 227: istore_2\n 228: goto 297\n 231: aload_3\n 232: new #34 // class kotlin/Pair\n 235: dup\n 236: ldc #85 // String C\n 238: ldc #63 // String X\n 240: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 243: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 246: ifeq 254\n 249: iconst_2\n 250: istore_2\n 251: goto 297\n 254: aload_3\n 255: new #34 // class kotlin/Pair\n 258: dup\n 259: ldc #85 // String C\n 261: ldc #69 // String Y\n 263: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 266: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 269: ifeq 277\n 272: iconst_3\n 273: istore_2\n 274: goto 297\n 277: aload_3\n 278: new #34 // class kotlin/Pair\n 281: dup\n 282: ldc #85 // String C\n 284: ldc #71 // String Z\n 286: invokespecial #77 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 289: invokestatic #81 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 292: ifeq 297\n 295: iconst_1\n 296: istore_2\n 297: iload_2\n 298: iload_1\n 299: iadd\n 300: ireturn\n}\n", "javap_err": "" } ]
xfornesa__aoc2022__dc14292/src/main/kotlin/day05/Problem.kt
package day05 import java.util.* fun solveProblem01(input: List<String>): String { val stackInput = Stack<String>() val movements = mutableListOf<String>() var stackHalf = true for (value in input) { if (value.isEmpty()) { stackHalf = false continue } if (stackHalf) { stackInput.push(value) } else { movements.add(value) } } val stacks = buildInitialStack(stackInput) for (movement in movements) { val (num, from, to) = parseMovement(movement) repeat(num) { val value = stacks[from]?.pop() stacks[to]?.push(value) } } return (1..stacks.size) .mapNotNull { stacks[it]?.pop() } .joinToString("") } fun parseMovement(movement: String): List<Int> { val regex = """move (\d+) from (\d+) to (\d+)""".toRegex() val matchResult = regex.find(movement) val destructured = matchResult!!.destructured return destructured.toList().map { it.toInt() } } fun buildInitialStack(stackInput: Stack<String>): MutableMap<Int, Stack<String>> { val result = mutableMapOf<Int, Stack<String>>() val keys = stackInput .pop() .trim().split("\\s+".toRegex()) .map { it.toInt() } keys .forEach { result[it] = Stack<String>() } val rowLength = keys.count()*4 - 1 for (value in stackInput.reversed()) { val row = value.padEnd(rowLength) row.asSequence() .windowed(3, 4) .forEachIndexed { index, letters -> val letter = letters.filter { it.isLetter() }.joinToString("") if (letter.isNotBlank()) { result[index+1]?.push(letter) } } } return result } fun solveProblem02(input: List<String>): String { val stackInput = Stack<String>() val movements = mutableListOf<String>() var stackHalf = true for (value in input) { if (value.isEmpty()) { stackHalf = false continue } if (stackHalf) { stackInput.push(value) } else { movements.add(value) } } val stacks = buildInitialStack(stackInput) for (movement in movements) { val (num, from, to) = parseMovement(movement) val temp = Stack<String>() repeat(num) { val value = stacks[from]?.pop() temp.push(value) } repeat(num) { val value = temp.pop() stacks[to]?.push(value) } } return (1..stacks.size) .mapNotNull { stacks[it]?.pop() } .joinToString("") }
[ { "class_path": "xfornesa__aoc2022__dc14292/day05/ProblemKt.class", "javap": "Compiled from \"Problem.kt\"\npublic final class day05.ProblemKt {\n public static final java.lang.String solveProblem01(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #18 // class java/util/Stack\n 9: dup\n 10: invokespecial #22 // Method java/util/Stack.\"<init>\":()V\n 13: astore_1\n 14: new #24 // class java/util/ArrayList\n 17: dup\n 18: invokespecial #25 // Method java/util/ArrayList.\"<init>\":()V\n 21: checkcast #27 // class java/util/List\n 24: astore_2\n 25: iconst_1\n 26: istore_3\n 27: aload_0\n 28: invokeinterface #31, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 33: astore 4\n 35: aload 4\n 37: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 42: ifeq 111\n 45: aload 4\n 47: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 52: checkcast #43 // class java/lang/String\n 55: astore 5\n 57: aload 5\n 59: checkcast #45 // class java/lang/CharSequence\n 62: invokeinterface #49, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 67: ifne 74\n 70: iconst_1\n 71: goto 75\n 74: iconst_0\n 75: ifeq 83\n 78: iconst_0\n 79: istore_3\n 80: goto 35\n 83: iload_3\n 84: ifeq 96\n 87: aload_1\n 88: aload 5\n 90: invokevirtual #53 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 93: goto 107\n 96: aload_2\n 97: aload 5\n 99: invokeinterface #57, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 104: invokestatic #63 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 107: pop\n 108: goto 35\n 111: aload_1\n 112: invokestatic #67 // Method buildInitialStack:(Ljava/util/Stack;)Ljava/util/Map;\n 115: astore 4\n 117: aload_2\n 118: invokeinterface #31, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 123: astore 5\n 125: aload 5\n 127: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 132: ifeq 290\n 135: aload 5\n 137: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 142: checkcast #43 // class java/lang/String\n 145: astore 6\n 147: aload 6\n 149: invokestatic #71 // Method parseMovement:(Ljava/lang/String;)Ljava/util/List;\n 152: astore 7\n 154: aload 7\n 156: iconst_0\n 157: invokeinterface #75, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 162: checkcast #77 // class java/lang/Number\n 165: invokevirtual #80 // Method java/lang/Number.intValue:()I\n 168: istore 8\n 170: aload 7\n 172: iconst_1\n 173: invokeinterface #75, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 178: checkcast #77 // class java/lang/Number\n 181: invokevirtual #80 // Method java/lang/Number.intValue:()I\n 184: istore 9\n 186: aload 7\n 188: iconst_2\n 189: invokeinterface #75, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 194: checkcast #77 // class java/lang/Number\n 197: invokevirtual #80 // Method java/lang/Number.intValue:()I\n 200: istore 10\n 202: iconst_0\n 203: istore 11\n 205: iload 11\n 207: iload 8\n 209: if_icmpge 125\n 212: iload 11\n 214: istore 12\n 216: iconst_0\n 217: istore 13\n 219: aload 4\n 221: iload 9\n 223: invokestatic #85 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 226: invokeinterface #89, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 231: checkcast #18 // class java/util/Stack\n 234: dup\n 235: ifnull 247\n 238: invokevirtual #92 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 241: checkcast #43 // class java/lang/String\n 244: goto 249\n 247: pop\n 248: aconst_null\n 249: astore 14\n 251: aload 4\n 253: iload 10\n 255: invokestatic #85 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 258: invokeinterface #89, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 263: checkcast #18 // class java/util/Stack\n 266: dup\n 267: ifnull 282\n 270: aload 14\n 272: invokevirtual #53 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 275: checkcast #43 // class java/lang/String\n 278: pop\n 279: goto 283\n 282: pop\n 283: nop\n 284: iinc 11, 1\n 287: goto 205\n 290: new #94 // class kotlin/ranges/IntRange\n 293: dup\n 294: iconst_1\n 295: aload 4\n 297: invokeinterface #97, 1 // InterfaceMethod java/util/Map.size:()I\n 302: invokespecial #100 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 305: checkcast #102 // class java/lang/Iterable\n 308: astore 5\n 310: nop\n 311: iconst_0\n 312: istore 6\n 314: aload 5\n 316: astore 7\n 318: new #24 // class java/util/ArrayList\n 321: dup\n 322: invokespecial #25 // Method java/util/ArrayList.\"<init>\":()V\n 325: checkcast #104 // class java/util/Collection\n 328: astore 8\n 330: iconst_0\n 331: istore 9\n 333: aload 7\n 335: astore 10\n 337: iconst_0\n 338: istore 11\n 340: aload 10\n 342: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 347: astore 12\n 349: aload 12\n 351: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 356: ifeq 440\n 359: aload 12\n 361: checkcast #107 // class kotlin/collections/IntIterator\n 364: invokevirtual #110 // Method kotlin/collections/IntIterator.nextInt:()I\n 367: istore 13\n 369: iload 13\n 371: istore 14\n 373: iconst_0\n 374: istore 15\n 376: iload 14\n 378: istore 16\n 380: iconst_0\n 381: istore 17\n 383: aload 4\n 385: iload 16\n 387: invokestatic #85 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 390: invokeinterface #89, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 395: checkcast #18 // class java/util/Stack\n 398: dup\n 399: ifnull 411\n 402: invokevirtual #92 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 405: checkcast #43 // class java/lang/String\n 408: goto 413\n 411: pop\n 412: aconst_null\n 413: dup\n 414: ifnull 435\n 417: astore 18\n 419: iconst_0\n 420: istore 19\n 422: aload 8\n 424: aload 18\n 426: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 431: pop\n 432: goto 436\n 435: pop\n 436: nop\n 437: goto 349\n 440: nop\n 441: aload 8\n 443: checkcast #27 // class java/util/List\n 446: nop\n 447: checkcast #102 // class java/lang/Iterable\n 450: ldc #113 // String\n 452: checkcast #45 // class java/lang/CharSequence\n 455: aconst_null\n 456: aconst_null\n 457: iconst_0\n 458: aconst_null\n 459: aconst_null\n 460: bipush 62\n 462: aconst_null\n 463: invokestatic #119 // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;\n 466: areturn\n\n public static final java.util.List<java.lang.Integer> parseMovement(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #154 // String movement\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #156 // class kotlin/text/Regex\n 9: dup\n 10: ldc #158 // String move (\\\\d+) from (\\\\d+) to (\\\\d+)\n 12: invokespecial #161 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 15: astore_1\n 16: aload_1\n 17: aload_0\n 18: checkcast #45 // class java/lang/CharSequence\n 21: iconst_0\n 22: iconst_2\n 23: aconst_null\n 24: invokestatic #165 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 27: astore_2\n 28: aload_2\n 29: dup\n 30: invokestatic #169 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 33: invokeinterface #175, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 38: astore_3\n 39: aload_3\n 40: invokevirtual #181 // Method kotlin/text/MatchResult$Destructured.toList:()Ljava/util/List;\n 43: checkcast #102 // class java/lang/Iterable\n 46: astore 4\n 48: iconst_0\n 49: istore 5\n 51: aload 4\n 53: astore 6\n 55: new #24 // class java/util/ArrayList\n 58: dup\n 59: aload 4\n 61: bipush 10\n 63: invokestatic #185 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 66: invokespecial #188 // Method java/util/ArrayList.\"<init>\":(I)V\n 69: checkcast #104 // class java/util/Collection\n 72: astore 7\n 74: iconst_0\n 75: istore 8\n 77: aload 6\n 79: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 84: astore 9\n 86: aload 9\n 88: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 93: ifeq 140\n 96: aload 9\n 98: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 103: astore 10\n 105: aload 7\n 107: aload 10\n 109: checkcast #43 // class java/lang/String\n 112: astore 11\n 114: astore 13\n 116: iconst_0\n 117: istore 12\n 119: aload 11\n 121: invokestatic #192 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 124: nop\n 125: invokestatic #85 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 128: aload 13\n 130: swap\n 131: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 136: pop\n 137: goto 86\n 140: aload 7\n 142: checkcast #27 // class java/util/List\n 145: nop\n 146: areturn\n\n public static final java.util.Map<java.lang.Integer, java.util.Stack<java.lang.String>> buildInitialStack(java.util.Stack<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #206 // String stackInput\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #208 // class java/util/LinkedHashMap\n 9: dup\n 10: invokespecial #209 // Method java/util/LinkedHashMap.\"<init>\":()V\n 13: checkcast #87 // class java/util/Map\n 16: astore_1\n 17: aload_0\n 18: invokevirtual #92 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 21: dup\n 22: ldc #211 // String pop(...)\n 24: invokestatic #214 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 27: checkcast #43 // class java/lang/String\n 30: checkcast #45 // class java/lang/CharSequence\n 33: invokestatic #220 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 36: invokevirtual #224 // Method java/lang/Object.toString:()Ljava/lang/String;\n 39: checkcast #45 // class java/lang/CharSequence\n 42: astore_3\n 43: new #156 // class kotlin/text/Regex\n 46: dup\n 47: ldc #226 // String \\\\s+\n 49: invokespecial #161 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 52: astore 4\n 54: iconst_0\n 55: istore 5\n 57: aload 4\n 59: aload_3\n 60: iload 5\n 62: invokevirtual #230 // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 65: checkcast #102 // class java/lang/Iterable\n 68: astore_3\n 69: nop\n 70: iconst_0\n 71: istore 4\n 73: aload_3\n 74: astore 5\n 76: new #24 // class java/util/ArrayList\n 79: dup\n 80: aload_3\n 81: bipush 10\n 83: invokestatic #185 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 86: invokespecial #188 // Method java/util/ArrayList.\"<init>\":(I)V\n 89: checkcast #104 // class java/util/Collection\n 92: astore 6\n 94: iconst_0\n 95: istore 7\n 97: aload 5\n 99: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 104: astore 8\n 106: aload 8\n 108: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 113: ifeq 160\n 116: aload 8\n 118: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 123: astore 9\n 125: aload 6\n 127: aload 9\n 129: checkcast #43 // class java/lang/String\n 132: astore 10\n 134: astore 26\n 136: iconst_0\n 137: istore 11\n 139: aload 10\n 141: invokestatic #192 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 144: nop\n 145: invokestatic #85 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 148: aload 26\n 150: swap\n 151: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 156: pop\n 157: goto 106\n 160: aload 6\n 162: checkcast #27 // class java/util/List\n 165: nop\n 166: astore_2\n 167: aload_2\n 168: checkcast #102 // class java/lang/Iterable\n 171: astore_3\n 172: nop\n 173: iconst_0\n 174: istore 4\n 176: aload_3\n 177: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 182: astore 5\n 184: aload 5\n 186: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 191: ifeq 244\n 194: aload 5\n 196: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 201: astore 6\n 203: aload 6\n 205: checkcast #77 // class java/lang/Number\n 208: invokevirtual #80 // Method java/lang/Number.intValue:()I\n 211: istore 7\n 213: iconst_0\n 214: istore 8\n 216: iload 7\n 218: invokestatic #85 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 221: astore 9\n 223: aload_1\n 224: aload 9\n 226: new #18 // class java/util/Stack\n 229: dup\n 230: invokespecial #22 // Method java/util/Stack.\"<init>\":()V\n 233: invokeinterface #234, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 238: pop\n 239: nop\n 240: nop\n 241: goto 184\n 244: nop\n 245: aload_2\n 246: checkcast #104 // class java/util/Collection\n 249: invokeinterface #235, 1 // InterfaceMethod java/util/Collection.size:()I\n 254: iconst_4\n 255: imul\n 256: iconst_1\n 257: isub\n 258: istore_3\n 259: aload_0\n 260: checkcast #102 // class java/lang/Iterable\n 263: invokestatic #239 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 266: invokeinterface #31, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 271: astore 4\n 273: aload 4\n 275: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 280: ifeq 573\n 283: aload 4\n 285: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 290: checkcast #43 // class java/lang/String\n 293: astore 5\n 295: aload 5\n 297: invokestatic #169 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 300: aload 5\n 302: iload_3\n 303: iconst_0\n 304: iconst_2\n 305: aconst_null\n 306: invokestatic #243 // Method kotlin/text/StringsKt.padEnd$default:(Ljava/lang/String;ICILjava/lang/Object;)Ljava/lang/String;\n 309: astore 6\n 311: aload 6\n 313: checkcast #45 // class java/lang/CharSequence\n 316: invokestatic #247 // Method kotlin/text/StringsKt.asSequence:(Ljava/lang/CharSequence;)Lkotlin/sequences/Sequence;\n 319: iconst_3\n 320: iconst_4\n 321: iconst_0\n 322: iconst_4\n 323: aconst_null\n 324: invokestatic #253 // Method kotlin/sequences/SequencesKt.windowed$default:(Lkotlin/sequences/Sequence;IIZILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 327: astore 7\n 329: nop\n 330: iconst_0\n 331: istore 8\n 333: iconst_0\n 334: istore 9\n 336: aload 7\n 338: invokeinterface #256, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 343: astore 10\n 345: aload 10\n 347: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 352: ifeq 569\n 355: aload 10\n 357: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 362: astore 11\n 364: iload 9\n 366: iinc 9, 1\n 369: istore 12\n 371: iload 12\n 373: ifge 379\n 376: invokestatic #259 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 379: iload 12\n 381: aload 11\n 383: checkcast #27 // class java/util/List\n 386: astore 13\n 388: istore 14\n 390: iconst_0\n 391: istore 15\n 393: aload 13\n 395: checkcast #102 // class java/lang/Iterable\n 398: astore 16\n 400: iconst_0\n 401: istore 17\n 403: aload 16\n 405: astore 18\n 407: new #24 // class java/util/ArrayList\n 410: dup\n 411: invokespecial #25 // Method java/util/ArrayList.\"<init>\":()V\n 414: checkcast #104 // class java/util/Collection\n 417: astore 19\n 419: iconst_0\n 420: istore 20\n 422: aload 18\n 424: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 429: astore 21\n 431: aload 21\n 433: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 438: ifeq 485\n 441: aload 21\n 443: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 448: astore 22\n 450: aload 22\n 452: checkcast #261 // class java/lang/Character\n 455: invokevirtual #265 // Method java/lang/Character.charValue:()C\n 458: istore 23\n 460: iconst_0\n 461: istore 24\n 463: iload 23\n 465: invokestatic #269 // Method java/lang/Character.isLetter:(C)Z\n 468: nop\n 469: ifeq 431\n 472: aload 19\n 474: aload 22\n 476: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 481: pop\n 482: goto 431\n 485: aload 19\n 487: checkcast #27 // class java/util/List\n 490: nop\n 491: checkcast #102 // class java/lang/Iterable\n 494: ldc #113 // String\n 496: checkcast #45 // class java/lang/CharSequence\n 499: aconst_null\n 500: aconst_null\n 501: iconst_0\n 502: aconst_null\n 503: aconst_null\n 504: bipush 62\n 506: aconst_null\n 507: invokestatic #119 // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;\n 510: astore 25\n 512: aload 25\n 514: checkcast #45 // class java/lang/CharSequence\n 517: invokestatic #273 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 520: ifne 527\n 523: iconst_1\n 524: goto 528\n 527: iconst_0\n 528: ifeq 564\n 531: aload_1\n 532: iload 14\n 534: iconst_1\n 535: iadd\n 536: invokestatic #85 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 539: invokeinterface #89, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 544: checkcast #18 // class java/util/Stack\n 547: dup\n 548: ifnull 563\n 551: aload 25\n 553: invokevirtual #53 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 556: checkcast #43 // class java/lang/String\n 559: pop\n 560: goto 564\n 563: pop\n 564: nop\n 565: nop\n 566: goto 345\n 569: nop\n 570: goto 273\n 573: aload_1\n 574: areturn\n\n public static final java.lang.String solveProblem02(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #10 // String input\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #18 // class java/util/Stack\n 9: dup\n 10: invokespecial #22 // Method java/util/Stack.\"<init>\":()V\n 13: astore_1\n 14: new #24 // class java/util/ArrayList\n 17: dup\n 18: invokespecial #25 // Method java/util/ArrayList.\"<init>\":()V\n 21: checkcast #27 // class java/util/List\n 24: astore_2\n 25: iconst_1\n 26: istore_3\n 27: aload_0\n 28: invokeinterface #31, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 33: astore 4\n 35: aload 4\n 37: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 42: ifeq 111\n 45: aload 4\n 47: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 52: checkcast #43 // class java/lang/String\n 55: astore 5\n 57: aload 5\n 59: checkcast #45 // class java/lang/CharSequence\n 62: invokeinterface #49, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 67: ifne 74\n 70: iconst_1\n 71: goto 75\n 74: iconst_0\n 75: ifeq 83\n 78: iconst_0\n 79: istore_3\n 80: goto 35\n 83: iload_3\n 84: ifeq 96\n 87: aload_1\n 88: aload 5\n 90: invokevirtual #53 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 93: goto 107\n 96: aload_2\n 97: aload 5\n 99: invokeinterface #57, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 104: invokestatic #63 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 107: pop\n 108: goto 35\n 111: aload_1\n 112: invokestatic #67 // Method buildInitialStack:(Ljava/util/Stack;)Ljava/util/Map;\n 115: astore 4\n 117: aload_2\n 118: invokeinterface #31, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 123: astore 5\n 125: aload 5\n 127: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 132: ifeq 341\n 135: aload 5\n 137: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 142: checkcast #43 // class java/lang/String\n 145: astore 6\n 147: aload 6\n 149: invokestatic #71 // Method parseMovement:(Ljava/lang/String;)Ljava/util/List;\n 152: astore 7\n 154: aload 7\n 156: iconst_0\n 157: invokeinterface #75, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 162: checkcast #77 // class java/lang/Number\n 165: invokevirtual #80 // Method java/lang/Number.intValue:()I\n 168: istore 8\n 170: aload 7\n 172: iconst_1\n 173: invokeinterface #75, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 178: checkcast #77 // class java/lang/Number\n 181: invokevirtual #80 // Method java/lang/Number.intValue:()I\n 184: istore 9\n 186: aload 7\n 188: iconst_2\n 189: invokeinterface #75, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 194: checkcast #77 // class java/lang/Number\n 197: invokevirtual #80 // Method java/lang/Number.intValue:()I\n 200: istore 10\n 202: new #18 // class java/util/Stack\n 205: dup\n 206: invokespecial #22 // Method java/util/Stack.\"<init>\":()V\n 209: astore 11\n 211: iconst_0\n 212: istore 12\n 214: iload 12\n 216: iload 8\n 218: if_icmpge 275\n 221: iload 12\n 223: istore 13\n 225: iconst_0\n 226: istore 14\n 228: aload 4\n 230: iload 9\n 232: invokestatic #85 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 235: invokeinterface #89, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 240: checkcast #18 // class java/util/Stack\n 243: dup\n 244: ifnull 256\n 247: invokevirtual #92 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 250: checkcast #43 // class java/lang/String\n 253: goto 258\n 256: pop\n 257: aconst_null\n 258: astore 15\n 260: aload 11\n 262: aload 15\n 264: invokevirtual #53 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 267: pop\n 268: nop\n 269: iinc 12, 1\n 272: goto 214\n 275: iconst_0\n 276: istore 12\n 278: iload 12\n 280: iload 8\n 282: if_icmpge 125\n 285: iload 12\n 287: istore 13\n 289: iconst_0\n 290: istore 14\n 292: aload 11\n 294: invokevirtual #92 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 297: checkcast #43 // class java/lang/String\n 300: astore 15\n 302: aload 4\n 304: iload 10\n 306: invokestatic #85 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 309: invokeinterface #89, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 314: checkcast #18 // class java/util/Stack\n 317: dup\n 318: ifnull 333\n 321: aload 15\n 323: invokevirtual #53 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 326: checkcast #43 // class java/lang/String\n 329: pop\n 330: goto 334\n 333: pop\n 334: nop\n 335: iinc 12, 1\n 338: goto 278\n 341: new #94 // class kotlin/ranges/IntRange\n 344: dup\n 345: iconst_1\n 346: aload 4\n 348: invokeinterface #97, 1 // InterfaceMethod java/util/Map.size:()I\n 353: invokespecial #100 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 356: checkcast #102 // class java/lang/Iterable\n 359: astore 5\n 361: nop\n 362: iconst_0\n 363: istore 6\n 365: aload 5\n 367: astore 7\n 369: new #24 // class java/util/ArrayList\n 372: dup\n 373: invokespecial #25 // Method java/util/ArrayList.\"<init>\":()V\n 376: checkcast #104 // class java/util/Collection\n 379: astore 8\n 381: iconst_0\n 382: istore 9\n 384: aload 7\n 386: astore 10\n 388: iconst_0\n 389: istore 11\n 391: aload 10\n 393: invokeinterface #105, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 398: astore 12\n 400: aload 12\n 402: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 407: ifeq 491\n 410: aload 12\n 412: checkcast #107 // class kotlin/collections/IntIterator\n 415: invokevirtual #110 // Method kotlin/collections/IntIterator.nextInt:()I\n 418: istore 13\n 420: iload 13\n 422: istore 14\n 424: iconst_0\n 425: istore 15\n 427: iload 14\n 429: istore 16\n 431: iconst_0\n 432: istore 17\n 434: aload 4\n 436: iload 16\n 438: invokestatic #85 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 441: invokeinterface #89, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 446: checkcast #18 // class java/util/Stack\n 449: dup\n 450: ifnull 462\n 453: invokevirtual #92 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 456: checkcast #43 // class java/lang/String\n 459: goto 464\n 462: pop\n 463: aconst_null\n 464: dup\n 465: ifnull 486\n 468: astore 18\n 470: iconst_0\n 471: istore 19\n 473: aload 8\n 475: aload 18\n 477: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 482: pop\n 483: goto 487\n 486: pop\n 487: nop\n 488: goto 400\n 491: nop\n 492: aload 8\n 494: checkcast #27 // class java/util/List\n 497: nop\n 498: checkcast #102 // class java/lang/Iterable\n 501: ldc #113 // String\n 503: checkcast #45 // class java/lang/CharSequence\n 506: aconst_null\n 507: aconst_null\n 508: iconst_0\n 509: aconst_null\n 510: aconst_null\n 511: bipush 62\n 513: aconst_null\n 514: invokestatic #119 // Method kotlin/collections/CollectionsKt.joinToString$default:(Ljava/lang/Iterable;Ljava/lang/CharSequence;Ljava/lang/CharSequence;Ljava/lang/CharSequence;ILjava/lang/CharSequence;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/lang/String;\n 517: areturn\n}\n", "javap_err": "" } ]
P3tran__CodilityLessonsKotlin__15c6065/src/lesson8/EquiLeader.kt
package lesson8 import java.util.* /* * Find leaders in 2 array slices by checking if leader exists * and using prefix occurrences sums after, on all array slices * */ class EquiLeader { companion object { @JvmStatic fun main(args: Array<String>) { val result = solution(intArrayOf(4, 3, 4, 4, 4, 2)) println("result : $result") } fun solution(A: IntArray): Int { if (A.size < 2) return 0 val stack = Stack<Int>() for (i in A.indices) { stack.push(A[i]) } for (i in A.indices) { when { stack.isEmpty() -> stack.push(A[i]) stack.peek() != A[i] -> stack.pop() else -> stack.push(A[i]) } } if (stack.size == 0) return 0 val candidate = stack.pop() var candidateOccurrences = 0 val sumOccurrences = IntArray(A.size) {0} var equis = 0 for (i in A.indices) { if (A[i] == candidate) { candidateOccurrences++ if (i > 0) sumOccurrences[i] = sumOccurrences[i - 1] + 1 else sumOccurrences[i] = 1 } else { if (i > 0) sumOccurrences[i] = sumOccurrences[i - 1] else sumOccurrences[i] = 0 } } if (candidateOccurrences > (A.size / 2)) { println("we have a leader $candidate") for (i in A.indices) { println("in index $i : ") println("sum occ from start: ${sumOccurrences[i]}, occur from end: ${sumOccurrences[A.size-1] - sumOccurrences[i]}") println("compared to ${i+1/2} and compared to ${(A.size -1 - i)/2 }") if(sumOccurrences[i] > (i+1).toDouble() /2 && ((sumOccurrences[A.size-1] - sumOccurrences[i]) > (A.size -1 - i).toDouble() /2 )) { equis++ println("bingo") } } return equis } return 0 } } }
[ { "class_path": "P3tran__CodilityLessonsKotlin__15c6065/lesson8/EquiLeader$Companion.class", "javap": "Compiled from \"EquiLeader.kt\"\npublic final class lesson8.EquiLeader$Companion {\n private lesson8.EquiLeader$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final void main(java.lang.String[]);\n Code:\n 0: aload_1\n 1: ldc #16 // String args\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: bipush 6\n 9: newarray int\n 11: astore_3\n 12: aload_3\n 13: iconst_0\n 14: iconst_4\n 15: iastore\n 16: aload_3\n 17: iconst_1\n 18: iconst_3\n 19: iastore\n 20: aload_3\n 21: iconst_2\n 22: iconst_4\n 23: iastore\n 24: aload_3\n 25: iconst_3\n 26: iconst_4\n 27: iastore\n 28: aload_3\n 29: iconst_4\n 30: iconst_4\n 31: iastore\n 32: aload_3\n 33: iconst_5\n 34: iconst_2\n 35: iastore\n 36: aload_3\n 37: invokevirtual #26 // Method solution:([I)I\n 40: istore_2\n 41: new #28 // class java/lang/StringBuilder\n 44: dup\n 45: invokespecial #29 // Method java/lang/StringBuilder.\"<init>\":()V\n 48: ldc #31 // String result :\n 50: invokevirtual #35 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 53: iload_2\n 54: invokevirtual #38 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 57: invokevirtual #42 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 60: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 63: swap\n 64: invokevirtual #54 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 67: return\n\n public final int solution(int[]);\n Code:\n 0: aload_1\n 1: ldc #59 // String A\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: arraylength\n 8: iconst_2\n 9: if_icmpge 14\n 12: iconst_0\n 13: ireturn\n 14: new #61 // class java/util/Stack\n 17: dup\n 18: invokespecial #62 // Method java/util/Stack.\"<init>\":()V\n 21: astore_2\n 22: iconst_0\n 23: istore_3\n 24: aload_1\n 25: arraylength\n 26: istore 4\n 28: iload_3\n 29: iload 4\n 31: if_icmpge 51\n 34: aload_2\n 35: aload_1\n 36: iload_3\n 37: iaload\n 38: invokestatic #68 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 41: invokevirtual #72 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 44: pop\n 45: iinc 3, 1\n 48: goto 28\n 51: iconst_0\n 52: istore_3\n 53: aload_1\n 54: arraylength\n 55: istore 4\n 57: iload_3\n 58: iload 4\n 60: if_icmpge 145\n 63: nop\n 64: aload_2\n 65: invokevirtual #76 // Method java/util/Stack.isEmpty:()Z\n 68: ifeq 87\n 71: aload_2\n 72: aload_1\n 73: iload_3\n 74: iaload\n 75: invokestatic #68 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 78: invokevirtual #72 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 81: checkcast #64 // class java/lang/Integer\n 84: goto 138\n 87: aload_2\n 88: invokevirtual #80 // Method java/util/Stack.peek:()Ljava/lang/Object;\n 91: checkcast #64 // class java/lang/Integer\n 94: aload_1\n 95: iload_3\n 96: iaload\n 97: istore 5\n 99: dup\n 100: ifnonnull 107\n 103: pop\n 104: goto 115\n 107: invokevirtual #84 // Method java/lang/Integer.intValue:()I\n 110: iload 5\n 112: if_icmpeq 125\n 115: aload_2\n 116: invokevirtual #87 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 119: checkcast #64 // class java/lang/Integer\n 122: goto 138\n 125: aload_2\n 126: aload_1\n 127: iload_3\n 128: iaload\n 129: invokestatic #68 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 132: invokevirtual #72 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 135: checkcast #64 // class java/lang/Integer\n 138: pop\n 139: iinc 3, 1\n 142: goto 57\n 145: aload_2\n 146: invokevirtual #90 // Method java/util/Stack.size:()I\n 149: ifne 154\n 152: iconst_0\n 153: ireturn\n 154: aload_2\n 155: invokevirtual #87 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 158: checkcast #64 // class java/lang/Integer\n 161: astore_3\n 162: iconst_0\n 163: istore 4\n 165: iconst_0\n 166: istore 6\n 168: aload_1\n 169: arraylength\n 170: istore 7\n 172: iload 7\n 174: newarray int\n 176: astore 8\n 178: iload 6\n 180: iload 7\n 182: if_icmpge 201\n 185: iload 6\n 187: istore 9\n 189: aload 8\n 191: iload 9\n 193: iconst_0\n 194: iastore\n 195: iinc 6, 1\n 198: goto 178\n 201: aload 8\n 203: astore 5\n 205: iconst_0\n 206: istore 6\n 208: iconst_0\n 209: istore 7\n 211: aload_1\n 212: arraylength\n 213: istore 8\n 215: iload 7\n 217: iload 8\n 219: if_icmpge 308\n 222: aload_1\n 223: iload 7\n 225: iaload\n 226: aload_3\n 227: dup\n 228: ifnonnull 236\n 231: pop\n 232: pop\n 233: goto 276\n 236: invokevirtual #84 // Method java/lang/Integer.intValue:()I\n 239: if_icmpne 276\n 242: iinc 4, 1\n 245: iload 7\n 247: ifle 267\n 250: aload 5\n 252: iload 7\n 254: aload 5\n 256: iload 7\n 258: iconst_1\n 259: isub\n 260: iaload\n 261: iconst_1\n 262: iadd\n 263: iastore\n 264: goto 302\n 267: aload 5\n 269: iload 7\n 271: iconst_1\n 272: iastore\n 273: goto 302\n 276: iload 7\n 278: ifle 296\n 281: aload 5\n 283: iload 7\n 285: aload 5\n 287: iload 7\n 289: iconst_1\n 290: isub\n 291: iaload\n 292: iastore\n 293: goto 302\n 296: aload 5\n 298: iload 7\n 300: iconst_0\n 301: iastore\n 302: iinc 7, 1\n 305: goto 215\n 308: iload 4\n 310: aload_1\n 311: arraylength\n 312: iconst_2\n 313: idiv\n 314: if_icmple 554\n 317: new #28 // class java/lang/StringBuilder\n 320: dup\n 321: invokespecial #29 // Method java/lang/StringBuilder.\"<init>\":()V\n 324: ldc #92 // String we have a leader\n 326: invokevirtual #35 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 329: aload_3\n 330: invokevirtual #95 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 333: invokevirtual #42 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 336: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 339: swap\n 340: invokevirtual #54 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 343: iconst_0\n 344: istore 7\n 346: aload_1\n 347: arraylength\n 348: istore 8\n 350: iload 7\n 352: iload 8\n 354: if_icmpge 551\n 357: new #28 // class java/lang/StringBuilder\n 360: dup\n 361: invokespecial #29 // Method java/lang/StringBuilder.\"<init>\":()V\n 364: ldc #97 // String in index\n 366: invokevirtual #35 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 369: iload 7\n 371: invokevirtual #38 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 374: ldc #99 // String :\n 376: invokevirtual #35 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 379: invokevirtual #42 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 382: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 385: swap\n 386: invokevirtual #54 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 389: new #28 // class java/lang/StringBuilder\n 392: dup\n 393: invokespecial #29 // Method java/lang/StringBuilder.\"<init>\":()V\n 396: ldc #101 // String sum occ from start:\n 398: invokevirtual #35 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 401: aload 5\n 403: iload 7\n 405: iaload\n 406: invokevirtual #38 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 409: ldc #103 // String , occur from end:\n 411: invokevirtual #35 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 414: aload 5\n 416: aload_1\n 417: arraylength\n 418: iconst_1\n 419: isub\n 420: iaload\n 421: aload 5\n 423: iload 7\n 425: iaload\n 426: isub\n 427: invokevirtual #38 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 430: invokevirtual #42 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 433: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 436: swap\n 437: invokevirtual #54 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 440: new #28 // class java/lang/StringBuilder\n 443: dup\n 444: invokespecial #29 // Method java/lang/StringBuilder.\"<init>\":()V\n 447: ldc #105 // String compared to\n 449: invokevirtual #35 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 452: iload 7\n 454: iconst_0\n 455: iadd\n 456: invokevirtual #38 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 459: ldc #107 // String and compared to\n 461: invokevirtual #35 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 464: aload_1\n 465: arraylength\n 466: iconst_1\n 467: isub\n 468: iload 7\n 470: isub\n 471: iconst_2\n 472: idiv\n 473: invokevirtual #38 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 476: invokevirtual #42 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 479: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 482: swap\n 483: invokevirtual #54 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 486: aload 5\n 488: iload 7\n 490: iaload\n 491: i2d\n 492: iload 7\n 494: iconst_1\n 495: iadd\n 496: i2d\n 497: iconst_2\n 498: i2d\n 499: ddiv\n 500: dcmpl\n 501: ifle 545\n 504: aload 5\n 506: aload_1\n 507: arraylength\n 508: iconst_1\n 509: isub\n 510: iaload\n 511: aload 5\n 513: iload 7\n 515: iaload\n 516: isub\n 517: i2d\n 518: aload_1\n 519: arraylength\n 520: iconst_1\n 521: isub\n 522: iload 7\n 524: isub\n 525: i2d\n 526: iconst_2\n 527: i2d\n 528: ddiv\n 529: dcmpl\n 530: ifle 545\n 533: iinc 6, 1\n 536: ldc #109 // String bingo\n 538: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 541: swap\n 542: invokevirtual #54 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 545: iinc 7, 1\n 548: goto 350\n 551: iload 6\n 553: ireturn\n 554: iconst_0\n 555: ireturn\n\n public lesson8.EquiLeader$Companion(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #121 // Method \"<init>\":()V\n 4: return\n}\n", "javap_err": "" }, { "class_path": "P3tran__CodilityLessonsKotlin__15c6065/lesson8/EquiLeader.class", "javap": "Compiled from \"EquiLeader.kt\"\npublic final class lesson8.EquiLeader {\n public static final lesson8.EquiLeader$Companion Companion;\n\n public lesson8.EquiLeader();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public static final void main(java.lang.String[]);\n Code:\n 0: getstatic #18 // Field Companion:Llesson8/EquiLeader$Companion;\n 3: aload_0\n 4: invokevirtual #22 // Method lesson8/EquiLeader$Companion.main:([Ljava/lang/String;)V\n 7: return\n\n static {};\n Code:\n 0: new #20 // class lesson8/EquiLeader$Companion\n 3: dup\n 4: aconst_null\n 5: invokespecial #28 // Method lesson8/EquiLeader$Companion.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 8: putstatic #18 // Field Companion:Llesson8/EquiLeader$Companion;\n 11: return\n}\n", "javap_err": "" } ]
fi-jb__leetcode__f0d59da/src/main/kotlin/fijb/leetcode/algorithms/A5LongestPalindromicSubstring.kt
package fijb.leetcode.algorithms // https://leetcode.com/problems/longest-palindromic-substring/ object A5LongestPalindromicSubstring { fun longestPalindrome(s: String): String { var max = Pair(0, 0) for (i in s.indices) max = maxPairOf(max, maxPairOf(getOddPair(s, i), getEvenPair(s, i))) return s.substring(max.first, max.second) } // "aba" for example private fun getOddPair(s: String, point: Int): Pair<Int, Int> { var i = 0 while (point - i - 1 >= 0 && point + i + 1 <= s.length - 1 && s[point - i - 1] == s[point + i + 1]) i ++ return Pair(maxOf(0, point - i), minOf(s.length, point + i) + 1) } // "abba" for example private fun getEvenPair(s: String, point: Int): Pair<Int, Int> { var i = 0 if (point + 1 > s.length - 1 || s[point] != s[point + 1]) return Pair(0, 0) while (point - i - 1 >= 0 && point + i + 2 <= s.length - 1 && s[point - i - 1] == s[point + i + 2]) i ++ return Pair(maxOf(0, point - i), minOf(s.length, point + i + 1) + 1) } private fun maxPairOf(p1: Pair<Int, Int>, p2: Pair<Int, Int>) = if (p1.second - p1.first >= p2.second - p2.first) p1 else p2 }
[ { "class_path": "fi-jb__leetcode__f0d59da/fijb/leetcode/algorithms/A5LongestPalindromicSubstring.class", "javap": "Compiled from \"A5LongestPalindromicSubstring.kt\"\npublic final class fijb.leetcode.algorithms.A5LongestPalindromicSubstring {\n public static final fijb.leetcode.algorithms.A5LongestPalindromicSubstring INSTANCE;\n\n private fijb.leetcode.algorithms.A5LongestPalindromicSubstring();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final java.lang.String longestPalindrome(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String s\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #23 // class kotlin/Pair\n 9: dup\n 10: iconst_0\n 11: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 14: iconst_0\n 15: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: invokespecial #32 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 21: astore_2\n 22: iconst_0\n 23: istore_3\n 24: aload_1\n 25: checkcast #34 // class java/lang/CharSequence\n 28: invokeinterface #38, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 33: istore 4\n 35: iload_3\n 36: iload 4\n 38: if_icmpge 69\n 41: aload_0\n 42: aload_2\n 43: aload_0\n 44: aload_0\n 45: aload_1\n 46: iload_3\n 47: invokespecial #42 // Method getOddPair:(Ljava/lang/String;I)Lkotlin/Pair;\n 50: aload_0\n 51: aload_1\n 52: iload_3\n 53: invokespecial #45 // Method getEvenPair:(Ljava/lang/String;I)Lkotlin/Pair;\n 56: invokespecial #49 // Method maxPairOf:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;\n 59: invokespecial #49 // Method maxPairOf:(Lkotlin/Pair;Lkotlin/Pair;)Lkotlin/Pair;\n 62: astore_2\n 63: iinc 3, 1\n 66: goto 35\n 69: aload_1\n 70: aload_2\n 71: invokevirtual #53 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 74: checkcast #55 // class java/lang/Number\n 77: invokevirtual #58 // Method java/lang/Number.intValue:()I\n 80: aload_2\n 81: invokevirtual #61 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 84: checkcast #55 // class java/lang/Number\n 87: invokevirtual #58 // Method java/lang/Number.intValue:()I\n 90: invokevirtual #67 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 93: dup\n 94: ldc #69 // String substring(...)\n 96: invokestatic #72 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 99: areturn\n\n private final kotlin.Pair<java.lang.Integer, java.lang.Integer> getOddPair(java.lang.String, int);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: iload_2\n 3: iload_3\n 4: isub\n 5: iconst_1\n 6: isub\n 7: iflt 51\n 10: iload_2\n 11: iload_3\n 12: iadd\n 13: iconst_1\n 14: iadd\n 15: aload_1\n 16: invokevirtual #79 // Method java/lang/String.length:()I\n 19: iconst_1\n 20: isub\n 21: if_icmpgt 51\n 24: aload_1\n 25: iload_2\n 26: iload_3\n 27: isub\n 28: iconst_1\n 29: isub\n 30: invokevirtual #83 // Method java/lang/String.charAt:(I)C\n 33: aload_1\n 34: iload_2\n 35: iload_3\n 36: iadd\n 37: iconst_1\n 38: iadd\n 39: invokevirtual #83 // Method java/lang/String.charAt:(I)C\n 42: if_icmpne 51\n 45: iinc 3, 1\n 48: goto 2\n 51: new #23 // class kotlin/Pair\n 54: dup\n 55: iconst_0\n 56: iload_2\n 57: iload_3\n 58: isub\n 59: invokestatic #88 // Method java/lang/Math.max:(II)I\n 62: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 65: aload_1\n 66: invokevirtual #79 // Method java/lang/String.length:()I\n 69: iload_2\n 70: iload_3\n 71: iadd\n 72: invokestatic #91 // Method java/lang/Math.min:(II)I\n 75: iconst_1\n 76: iadd\n 77: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 80: invokespecial #32 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 83: areturn\n\n private final kotlin.Pair<java.lang.Integer, java.lang.Integer> getEvenPair(java.lang.String, int);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: iload_2\n 3: iconst_1\n 4: iadd\n 5: aload_1\n 6: invokevirtual #79 // Method java/lang/String.length:()I\n 9: iconst_1\n 10: isub\n 11: if_icmpgt 29\n 14: aload_1\n 15: iload_2\n 16: invokevirtual #83 // Method java/lang/String.charAt:(I)C\n 19: aload_1\n 20: iload_2\n 21: iconst_1\n 22: iadd\n 23: invokevirtual #83 // Method java/lang/String.charAt:(I)C\n 26: if_icmpeq 45\n 29: new #23 // class kotlin/Pair\n 32: dup\n 33: iconst_0\n 34: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 37: iconst_0\n 38: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 41: invokespecial #32 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 44: areturn\n 45: iload_2\n 46: iload_3\n 47: isub\n 48: iconst_1\n 49: isub\n 50: iflt 94\n 53: iload_2\n 54: iload_3\n 55: iadd\n 56: iconst_2\n 57: iadd\n 58: aload_1\n 59: invokevirtual #79 // Method java/lang/String.length:()I\n 62: iconst_1\n 63: isub\n 64: if_icmpgt 94\n 67: aload_1\n 68: iload_2\n 69: iload_3\n 70: isub\n 71: iconst_1\n 72: isub\n 73: invokevirtual #83 // Method java/lang/String.charAt:(I)C\n 76: aload_1\n 77: iload_2\n 78: iload_3\n 79: iadd\n 80: iconst_2\n 81: iadd\n 82: invokevirtual #83 // Method java/lang/String.charAt:(I)C\n 85: if_icmpne 94\n 88: iinc 3, 1\n 91: goto 45\n 94: new #23 // class kotlin/Pair\n 97: dup\n 98: iconst_0\n 99: iload_2\n 100: iload_3\n 101: isub\n 102: invokestatic #88 // Method java/lang/Math.max:(II)I\n 105: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 108: aload_1\n 109: invokevirtual #79 // Method java/lang/String.length:()I\n 112: iload_2\n 113: iload_3\n 114: iadd\n 115: iconst_1\n 116: iadd\n 117: invokestatic #91 // Method java/lang/Math.min:(II)I\n 120: iconst_1\n 121: iadd\n 122: invokestatic #29 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 125: invokespecial #32 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 128: areturn\n\n private final kotlin.Pair<java.lang.Integer, java.lang.Integer> maxPairOf(kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_1\n 1: invokevirtual #61 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 4: checkcast #55 // class java/lang/Number\n 7: invokevirtual #58 // Method java/lang/Number.intValue:()I\n 10: aload_1\n 11: invokevirtual #53 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 14: checkcast #55 // class java/lang/Number\n 17: invokevirtual #58 // Method java/lang/Number.intValue:()I\n 20: isub\n 21: aload_2\n 22: invokevirtual #61 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 25: checkcast #55 // class java/lang/Number\n 28: invokevirtual #58 // Method java/lang/Number.intValue:()I\n 31: aload_2\n 32: invokevirtual #53 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 35: checkcast #55 // class java/lang/Number\n 38: invokevirtual #58 // Method java/lang/Number.intValue:()I\n 41: isub\n 42: if_icmplt 49\n 45: aload_1\n 46: goto 50\n 49: aload_2\n 50: areturn\n\n static {};\n Code:\n 0: new #2 // class fijb/leetcode/algorithms/A5LongestPalindromicSubstring\n 3: dup\n 4: invokespecial #97 // Method \"<init>\":()V\n 7: putstatic #100 // Field INSTANCE:Lfijb/leetcode/algorithms/A5LongestPalindromicSubstring;\n 10: return\n}\n", "javap_err": "" } ]
fi-jb__leetcode__f0d59da/src/main/kotlin/fijb/leetcode/algorithms/A2AddTwoNumbers.kt
package fijb.leetcode.algorithms //https://leetcode.com/problems/add-two-numbers/ object A2AddTwoNumbers { fun addTwoNumbers(l1: ListNode?, l2: ListNode?): ListNode? { var result : ListNode? = null var it: ListNode? = null var it1 = l1 var it2 = l2 var dev = 0 while (it1 != null) { var sum = if (it2 == null) it1.`val` + dev else it1.`val` + it2.`val` + dev dev = sum / 10 sum %= 10 if (result == null) { result = ListNode(sum) it = result } else { it?.next = ListNode(sum) it = it?.next } it1 = it1.next it2 = it2?.next } while (it2 != null) { var sum = it2.`val` + dev dev = sum / 10 sum %= 10 it?.next = ListNode(sum) it = it?.next it2 = it2.next } if (dev != 0) it?.next = ListNode(dev) return result } class ListNode(var `val`: Int) { var next: ListNode? = null override fun toString(): String { val result = StringBuilder() var it : ListNode? = this while (it != null) { result.append("${it.`val`} ") it = it.next } return "[" + result.toString().trim().replace(" ", ",") + "]" } override fun equals(other: Any?): Boolean { var it1: ListNode? = this var it2: ListNode? = other as ListNode while (it1 != null) { if (it1.`val` != it2?.`val`) return false it1 = it1.next it2 = it2.next } if (it2 != null) return false return true } override fun hashCode(): Int { var result = `val` result = 31 * result + (next?.hashCode() ?: 0) return result } } }
[ { "class_path": "fi-jb__leetcode__f0d59da/fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.class", "javap": "Compiled from \"A2AddTwoNumbers.kt\"\npublic final class fijb.leetcode.algorithms.A2AddTwoNumbers$ListNode {\n private int val;\n\n private fijb.leetcode.algorithms.A2AddTwoNumbers$ListNode next;\n\n public fijb.leetcode.algorithms.A2AddTwoNumbers$ListNode(int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field val:I\n 9: return\n\n public final int getVal();\n Code:\n 0: aload_0\n 1: getfield #13 // Field val:I\n 4: ireturn\n\n public final void setVal(int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #13 // Field val:I\n 5: return\n\n public final fijb.leetcode.algorithms.A2AddTwoNumbers$ListNode getNext();\n Code:\n 0: aload_0\n 1: getfield #25 // Field next:Lfijb/leetcode/algorithms/A2AddTwoNumbers$ListNode;\n 4: areturn\n\n public final void setNext(fijb.leetcode.algorithms.A2AddTwoNumbers$ListNode);\n Code:\n 0: aload_0\n 1: aload_1\n 2: putfield #25 // Field next:Lfijb/leetcode/algorithms/A2AddTwoNumbers$ListNode;\n 5: return\n\n public java.lang.String toString();\n Code:\n 0: new #32 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #33 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: astore_1\n 8: aload_0\n 9: astore_2\n 10: aload_2\n 11: ifnull 49\n 14: aload_1\n 15: new #32 // class java/lang/StringBuilder\n 18: dup\n 19: invokespecial #33 // Method java/lang/StringBuilder.\"<init>\":()V\n 22: aload_2\n 23: getfield #13 // Field val:I\n 26: invokevirtual #37 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 29: bipush 32\n 31: invokevirtual #40 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 34: invokevirtual #42 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 37: invokevirtual #45 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 40: pop\n 41: aload_2\n 42: getfield #25 // Field next:Lfijb/leetcode/algorithms/A2AddTwoNumbers$ListNode;\n 45: astore_2\n 46: goto 10\n 49: new #32 // class java/lang/StringBuilder\n 52: dup\n 53: invokespecial #33 // Method java/lang/StringBuilder.\"<init>\":()V\n 56: bipush 91\n 58: invokevirtual #40 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 61: aload_1\n 62: invokevirtual #42 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 65: dup\n 66: ldc #47 // String toString(...)\n 68: invokestatic #53 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 71: checkcast #55 // class java/lang/CharSequence\n 74: invokestatic #61 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 77: invokevirtual #62 // Method java/lang/Object.toString:()Ljava/lang/String;\n 80: ldc #64 // String\n 82: ldc #66 // String ,\n 84: iconst_0\n 85: iconst_4\n 86: aconst_null\n 87: invokestatic #70 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 90: invokevirtual #45 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 93: bipush 93\n 95: invokevirtual #40 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 98: invokevirtual #42 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 101: areturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: astore_2\n 2: aload_1\n 3: ldc #77 // String null cannot be cast to non-null type fijb.leetcode.algorithms.A2AddTwoNumbers.ListNode\n 5: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V\n 8: aload_1\n 9: checkcast #2 // class fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode\n 12: astore_3\n 13: aload_2\n 14: ifnull 64\n 17: aload_3\n 18: astore 4\n 20: aload 4\n 22: ifnull 45\n 25: aload_2\n 26: getfield #13 // Field val:I\n 29: aload 4\n 31: getfield #13 // Field val:I\n 34: if_icmpne 41\n 37: iconst_1\n 38: goto 46\n 41: iconst_0\n 42: goto 46\n 45: iconst_0\n 46: ifne 51\n 49: iconst_0\n 50: ireturn\n 51: aload_2\n 52: getfield #25 // Field next:Lfijb/leetcode/algorithms/A2AddTwoNumbers$ListNode;\n 55: astore_2\n 56: aload_3\n 57: getfield #25 // Field next:Lfijb/leetcode/algorithms/A2AddTwoNumbers$ListNode;\n 60: astore_3\n 61: goto 13\n 64: aload_3\n 65: ifnull 70\n 68: iconst_0\n 69: ireturn\n 70: iconst_1\n 71: ireturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #13 // Field val:I\n 4: istore_1\n 5: bipush 31\n 7: iload_1\n 8: imul\n 9: aload_0\n 10: getfield #25 // Field next:Lfijb/leetcode/algorithms/A2AddTwoNumbers$ListNode;\n 13: dup\n 14: ifnull 23\n 17: invokevirtual #87 // Method hashCode:()I\n 20: goto 25\n 23: pop\n 24: iconst_0\n 25: iadd\n 26: istore_1\n 27: iload_1\n 28: ireturn\n}\n", "javap_err": "" }, { "class_path": "fi-jb__leetcode__f0d59da/fijb/leetcode/algorithms/A2AddTwoNumbers.class", "javap": "Compiled from \"A2AddTwoNumbers.kt\"\npublic final class fijb.leetcode.algorithms.A2AddTwoNumbers {\n public static final fijb.leetcode.algorithms.A2AddTwoNumbers INSTANCE;\n\n private fijb.leetcode.algorithms.A2AddTwoNumbers();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final fijb.leetcode.algorithms.A2AddTwoNumbers$ListNode addTwoNumbers(fijb.leetcode.algorithms.A2AddTwoNumbers$ListNode, fijb.leetcode.algorithms.A2AddTwoNumbers$ListNode);\n Code:\n 0: aconst_null\n 1: astore_3\n 2: aconst_null\n 3: astore 4\n 5: aload_1\n 6: astore 5\n 8: aload_2\n 9: astore 6\n 11: iconst_0\n 12: istore 7\n 14: aload 5\n 16: ifnull 149\n 19: aload 6\n 21: ifnonnull 35\n 24: aload 5\n 26: invokevirtual #19 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.getVal:()I\n 29: iload 7\n 31: iadd\n 32: goto 49\n 35: aload 5\n 37: invokevirtual #19 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.getVal:()I\n 40: aload 6\n 42: invokevirtual #19 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.getVal:()I\n 45: iadd\n 46: iload 7\n 48: iadd\n 49: istore 8\n 51: iload 8\n 53: bipush 10\n 55: idiv\n 56: istore 7\n 58: iload 8\n 60: bipush 10\n 62: irem\n 63: istore 8\n 65: aload_3\n 66: ifnonnull 85\n 69: new #15 // class fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode\n 72: dup\n 73: iload 8\n 75: invokespecial #22 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.\"<init>\":(I)V\n 78: astore_3\n 79: aload_3\n 80: astore 4\n 82: goto 123\n 85: aload 4\n 87: dup\n 88: ifnull 106\n 91: new #15 // class fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode\n 94: dup\n 95: iload 8\n 97: invokespecial #22 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.\"<init>\":(I)V\n 100: invokevirtual #26 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.setNext:(Lfijb/leetcode/algorithms/A2AddTwoNumbers$ListNode;)V\n 103: goto 107\n 106: pop\n 107: aload 4\n 109: dup\n 110: ifnull 119\n 113: invokevirtual #30 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.getNext:()Lfijb/leetcode/algorithms/A2AddTwoNumbers$ListNode;\n 116: goto 121\n 119: pop\n 120: aconst_null\n 121: astore 4\n 123: aload 5\n 125: invokevirtual #30 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.getNext:()Lfijb/leetcode/algorithms/A2AddTwoNumbers$ListNode;\n 128: astore 5\n 130: aload 6\n 132: dup\n 133: ifnull 142\n 136: invokevirtual #30 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.getNext:()Lfijb/leetcode/algorithms/A2AddTwoNumbers$ListNode;\n 139: goto 144\n 142: pop\n 143: aconst_null\n 144: astore 6\n 146: goto 14\n 149: aload 6\n 151: ifnull 226\n 154: aload 6\n 156: invokevirtual #19 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.getVal:()I\n 159: iload 7\n 161: iadd\n 162: istore 8\n 164: iload 8\n 166: bipush 10\n 168: idiv\n 169: istore 7\n 171: iload 8\n 173: bipush 10\n 175: irem\n 176: istore 8\n 178: aload 4\n 180: dup\n 181: ifnull 199\n 184: new #15 // class fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode\n 187: dup\n 188: iload 8\n 190: invokespecial #22 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.\"<init>\":(I)V\n 193: invokevirtual #26 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.setNext:(Lfijb/leetcode/algorithms/A2AddTwoNumbers$ListNode;)V\n 196: goto 200\n 199: pop\n 200: aload 4\n 202: dup\n 203: ifnull 212\n 206: invokevirtual #30 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.getNext:()Lfijb/leetcode/algorithms/A2AddTwoNumbers$ListNode;\n 209: goto 214\n 212: pop\n 213: aconst_null\n 214: astore 4\n 216: aload 6\n 218: invokevirtual #30 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.getNext:()Lfijb/leetcode/algorithms/A2AddTwoNumbers$ListNode;\n 221: astore 6\n 223: goto 149\n 226: iload 7\n 228: ifeq 253\n 231: aload 4\n 233: dup\n 234: ifnull 252\n 237: new #15 // class fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode\n 240: dup\n 241: iload 7\n 243: invokespecial #22 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.\"<init>\":(I)V\n 246: invokevirtual #26 // Method fijb/leetcode/algorithms/A2AddTwoNumbers$ListNode.setNext:(Lfijb/leetcode/algorithms/A2AddTwoNumbers$ListNode;)V\n 249: goto 253\n 252: pop\n 253: aload_3\n 254: areturn\n\n static {};\n Code:\n 0: new #2 // class fijb/leetcode/algorithms/A2AddTwoNumbers\n 3: dup\n 4: invokespecial #42 // Method \"<init>\":()V\n 7: putstatic #45 // Field INSTANCE:Lfijb/leetcode/algorithms/A2AddTwoNumbers;\n 10: return\n}\n", "javap_err": "" } ]
fi-jb__leetcode__f0d59da/src/main/kotlin/fijb/leetcode/algorithms/A4MedianOfTwoSortedArrays.kt
package fijb.leetcode.algorithms //https://leetcode.com/problems/median-of-two-sorted-arrays/ object A4MedianOfTwoSortedArrays { fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray): Double { val nums = arrayListOf<Int>() var i1 = 0 var i2 = 0 val s = (nums1.size + nums2.size) while (i1 < nums1.size && i2 < nums2.size) { if (i1 + i2 > s) break if (nums1[i1] < nums2[i2]) nums.add( nums1[i1 ++] ) else nums.add( nums2[i2 ++] ) } val h = s / 2 val h1 = minOf(nums1.size, h + 1) val h2 = minOf(nums2.size, h + 1) while (i1 < h1) nums.add( nums1[i1 ++] ) while (i2 < h2) nums.add( nums2[i2 ++] ) return if (s % 2 == 0) 0.5 * (nums[h - 1] + nums[h]) else nums[h].toDouble() } }
[ { "class_path": "fi-jb__leetcode__f0d59da/fijb/leetcode/algorithms/A4MedianOfTwoSortedArrays.class", "javap": "Compiled from \"A4MedianOfTwoSortedArrays.kt\"\npublic final class fijb.leetcode.algorithms.A4MedianOfTwoSortedArrays {\n public static final fijb.leetcode.algorithms.A4MedianOfTwoSortedArrays INSTANCE;\n\n private fijb.leetcode.algorithms.A4MedianOfTwoSortedArrays();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final double findMedianSortedArrays(int[], int[]);\n Code:\n 0: aload_1\n 1: ldc #15 // String nums1\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #23 // String nums2\n 9: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #25 // class java/util/ArrayList\n 15: dup\n 16: invokespecial #26 // Method java/util/ArrayList.\"<init>\":()V\n 19: astore_3\n 20: iconst_0\n 21: istore 4\n 23: iconst_0\n 24: istore 5\n 26: aload_1\n 27: arraylength\n 28: aload_2\n 29: arraylength\n 30: iadd\n 31: istore 6\n 33: iload 4\n 35: aload_1\n 36: arraylength\n 37: if_icmpge 103\n 40: iload 5\n 42: aload_2\n 43: arraylength\n 44: if_icmpge 103\n 47: iload 4\n 49: iload 5\n 51: iadd\n 52: iload 6\n 54: if_icmpgt 103\n 57: aload_1\n 58: iload 4\n 60: iaload\n 61: aload_2\n 62: iload 5\n 64: iaload\n 65: if_icmpge 85\n 68: aload_3\n 69: aload_1\n 70: iload 4\n 72: iinc 4, 1\n 75: iaload\n 76: invokestatic #32 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 79: invokevirtual #36 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 82: goto 99\n 85: aload_3\n 86: aload_2\n 87: iload 5\n 89: iinc 5, 1\n 92: iaload\n 93: invokestatic #32 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 96: invokevirtual #36 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 99: pop\n 100: goto 33\n 103: iload 6\n 105: iconst_2\n 106: idiv\n 107: istore 7\n 109: aload_1\n 110: arraylength\n 111: iload 7\n 113: iconst_1\n 114: iadd\n 115: invokestatic #42 // Method java/lang/Math.min:(II)I\n 118: istore 8\n 120: aload_2\n 121: arraylength\n 122: iload 7\n 124: iconst_1\n 125: iadd\n 126: invokestatic #42 // Method java/lang/Math.min:(II)I\n 129: istore 9\n 131: iload 4\n 133: iload 8\n 135: if_icmpge 156\n 138: aload_3\n 139: aload_1\n 140: iload 4\n 142: iinc 4, 1\n 145: iaload\n 146: invokestatic #32 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 149: invokevirtual #36 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 152: pop\n 153: goto 131\n 156: iload 5\n 158: iload 9\n 160: if_icmpge 181\n 163: aload_3\n 164: aload_2\n 165: iload 5\n 167: iinc 5, 1\n 170: iaload\n 171: invokestatic #32 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 174: invokevirtual #36 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 177: pop\n 178: goto 156\n 181: iload 6\n 183: iconst_2\n 184: irem\n 185: ifne 229\n 188: ldc2_w #43 // double 0.5d\n 191: aload_3\n 192: iload 7\n 194: iconst_1\n 195: isub\n 196: invokevirtual #48 // Method java/util/ArrayList.get:(I)Ljava/lang/Object;\n 199: checkcast #50 // class java/lang/Number\n 202: invokevirtual #54 // Method java/lang/Number.intValue:()I\n 205: aload_3\n 206: iload 7\n 208: invokevirtual #48 // Method java/util/ArrayList.get:(I)Ljava/lang/Object;\n 211: dup\n 212: ldc #56 // String get(...)\n 214: invokestatic #59 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 217: checkcast #50 // class java/lang/Number\n 220: invokevirtual #54 // Method java/lang/Number.intValue:()I\n 223: iadd\n 224: i2d\n 225: dmul\n 226: goto 242\n 229: aload_3\n 230: iload 7\n 232: invokevirtual #48 // Method java/util/ArrayList.get:(I)Ljava/lang/Object;\n 235: checkcast #50 // class java/lang/Number\n 238: invokevirtual #54 // Method java/lang/Number.intValue:()I\n 241: i2d\n 242: dreturn\n\n static {};\n Code:\n 0: new #2 // class fijb/leetcode/algorithms/A4MedianOfTwoSortedArrays\n 3: dup\n 4: invokespecial #72 // Method \"<init>\":()V\n 7: putstatic #75 // Field INSTANCE:Lfijb/leetcode/algorithms/A4MedianOfTwoSortedArrays;\n 10: return\n}\n", "javap_err": "" } ]
DPNT-Sourcecode__CHK-dkni01__2955860/bin/main/solutions/CHK/CheckoutSolution.kt
package solutions.CHK object CheckoutSolution { val prices = hashMapOf( "A" to 50, "B" to 30, "C" to 20, "D" to 15, "E" to 40, "F" to 10, "G" to 20, "H" to 10, "I" to 35, "J" to 60, "K" to 80, "L" to 90, "M" to 15, "N" to 40, "O" to 10, "P" to 50, "Q" to 30, "R" to 50, "S" to 30, "T" to 20, "U" to 40, "V" to 50, "W" to 20, "X" to 90, "Z" to 50, "Y" to 10 ) const val PRICE_A = 50 const val PRICE_B = 30 const val PRICE_C = 20 const val PRICE_D = 15 const val PRICE_E = 40 const val PRICE_F = 10 const val A_OFFER3 = 130 const val A_OFFER5 = 200 const val B_OFFER2 = 45 fun checkout(skus: String): Int { if (skus.any { !listOf('A', 'B', 'C', 'D', 'E', 'F').contains(it) }) { return -1 } // calculating As val offerA5 = calculateOffer( PRICE_A, skus.count { it == 'A' } * PRICE_A, 5, A_OFFER5 ) val offerA3 = calculateOffer( PRICE_A, offerA5.second, 3, A_OFFER3 ) val totalA = offerA5.first + offerA3.first + offerA3.second // calculating Es val offerE = calculateOffer( PRICE_E, skus.count { it == 'E' } * PRICE_E, 2, 1 ) val adjustedBCount = skus.count { it == 'B' } - offerE.first // calculating Bs val newB = calculateOffer( PRICE_B, adjustedBCount * PRICE_B, 2, B_OFFER2 ) val totalB = newB.first + newB.second // calculating Fs val offerF = calculateOffer( PRICE_F, skus.count { it == 'F' } * PRICE_F, 3, 1 ) val totalF = (skus.count { it == 'F' } * PRICE_F) - (offerF.first * PRICE_F) return totalA + (if (totalB <= 0) 0 else totalB) + (skus.count { it == 'C' } * PRICE_C) + (skus.count { it == 'D' } * PRICE_D) + (skus.count { it == 'E' } * PRICE_E) + totalF } private fun calculateOffer( price: Int, total: Int, multiplier: Int, offer: Int ) : Pair<Int, Int> { val leftover = total % (price * multiplier) val reduced = ((total - leftover) / (price * multiplier)) * offer return Pair(reduced, leftover) } }
[ { "class_path": "DPNT-Sourcecode__CHK-dkni01__2955860/solutions/CHK/CheckoutSolution.class", "javap": "Compiled from \"CheckoutSolution.kt\"\npublic final class solutions.CHK.CheckoutSolution {\n public static final solutions.CHK.CheckoutSolution INSTANCE;\n\n private static final java.util.HashMap<java.lang.String, java.lang.Integer> prices;\n\n public static final int PRICE_A;\n\n public static final int PRICE_B;\n\n public static final int PRICE_C;\n\n public static final int PRICE_D;\n\n public static final int PRICE_E;\n\n public static final int PRICE_F;\n\n public static final int A_OFFER3;\n\n public static final int A_OFFER5;\n\n public static final int B_OFFER2;\n\n private solutions.CHK.CheckoutSolution();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final java.util.HashMap<java.lang.String, java.lang.Integer> getPrices();\n Code:\n 0: getstatic #18 // Field prices:Ljava/util/HashMap;\n 3: areturn\n\n public final int checkout(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #22 // String skus\n 3: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #30 // class java/lang/CharSequence\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: iconst_0\n 14: istore 4\n 16: iload 4\n 18: aload_2\n 19: invokeinterface #34, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 24: if_icmpge 141\n 27: aload_2\n 28: iload 4\n 30: invokeinterface #38, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 35: istore 5\n 37: iload 5\n 39: istore 6\n 41: iconst_0\n 42: istore 7\n 44: bipush 6\n 46: anewarray #40 // class java/lang/Character\n 49: astore 8\n 51: aload 8\n 53: iconst_0\n 54: bipush 65\n 56: invokestatic #44 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 59: aastore\n 60: aload 8\n 62: iconst_1\n 63: bipush 66\n 65: invokestatic #44 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 68: aastore\n 69: aload 8\n 71: iconst_2\n 72: bipush 67\n 74: invokestatic #44 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 77: aastore\n 78: aload 8\n 80: iconst_3\n 81: bipush 68\n 83: invokestatic #44 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 86: aastore\n 87: aload 8\n 89: iconst_4\n 90: bipush 69\n 92: invokestatic #44 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 95: aastore\n 96: aload 8\n 98: iconst_5\n 99: bipush 70\n 101: invokestatic #44 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 104: aastore\n 105: aload 8\n 107: invokestatic #50 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 110: iload 6\n 112: invokestatic #44 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 115: invokeinterface #56, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 120: ifne 127\n 123: iconst_1\n 124: goto 128\n 127: iconst_0\n 128: ifeq 135\n 131: iconst_1\n 132: goto 142\n 135: iinc 4, 1\n 138: goto 16\n 141: iconst_0\n 142: ifeq 147\n 145: iconst_m1\n 146: ireturn\n 147: aload_0\n 148: bipush 50\n 150: aload_1\n 151: checkcast #30 // class java/lang/CharSequence\n 154: astore_3\n 155: istore 19\n 157: astore 18\n 159: iconst_0\n 160: istore 4\n 162: iconst_0\n 163: istore 5\n 165: iconst_0\n 166: istore 6\n 168: iload 6\n 170: aload_3\n 171: invokeinterface #34, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 176: if_icmpge 220\n 179: aload_3\n 180: iload 6\n 182: invokeinterface #38, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 187: istore 7\n 189: iload 7\n 191: istore 8\n 193: iconst_0\n 194: istore 9\n 196: iload 8\n 198: bipush 65\n 200: if_icmpne 207\n 203: iconst_1\n 204: goto 208\n 207: iconst_0\n 208: ifeq 214\n 211: iinc 5, 1\n 214: iinc 6, 1\n 217: goto 168\n 220: iload 5\n 222: istore 20\n 224: aload 18\n 226: iload 19\n 228: iload 20\n 230: bipush 50\n 232: imul\n 233: iconst_5\n 234: sipush 200\n 237: invokespecial #60 // Method calculateOffer:(IIII)Lkotlin/Pair;\n 240: astore_2\n 241: aload_0\n 242: bipush 50\n 244: aload_2\n 245: invokevirtual #66 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 248: checkcast #68 // class java/lang/Number\n 251: invokevirtual #71 // Method java/lang/Number.intValue:()I\n 254: iconst_3\n 255: sipush 130\n 258: invokespecial #60 // Method calculateOffer:(IIII)Lkotlin/Pair;\n 261: astore_3\n 262: aload_2\n 263: invokevirtual #74 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 266: checkcast #68 // class java/lang/Number\n 269: invokevirtual #71 // Method java/lang/Number.intValue:()I\n 272: aload_3\n 273: invokevirtual #74 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 276: checkcast #68 // class java/lang/Number\n 279: invokevirtual #71 // Method java/lang/Number.intValue:()I\n 282: iadd\n 283: aload_3\n 284: invokevirtual #66 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 287: checkcast #68 // class java/lang/Number\n 290: invokevirtual #71 // Method java/lang/Number.intValue:()I\n 293: iadd\n 294: istore 4\n 296: aload_0\n 297: bipush 40\n 299: aload_1\n 300: checkcast #30 // class java/lang/CharSequence\n 303: astore 6\n 305: istore 19\n 307: astore 18\n 309: iconst_0\n 310: istore 7\n 312: iconst_0\n 313: istore 8\n 315: iconst_0\n 316: istore 9\n 318: iload 9\n 320: aload 6\n 322: invokeinterface #34, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 327: if_icmpge 372\n 330: aload 6\n 332: iload 9\n 334: invokeinterface #38, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 339: istore 10\n 341: iload 10\n 343: istore 11\n 345: iconst_0\n 346: istore 12\n 348: iload 11\n 350: bipush 69\n 352: if_icmpne 359\n 355: iconst_1\n 356: goto 360\n 359: iconst_0\n 360: ifeq 366\n 363: iinc 8, 1\n 366: iinc 9, 1\n 369: goto 318\n 372: iload 8\n 374: istore 20\n 376: aload 18\n 378: iload 19\n 380: iload 20\n 382: bipush 40\n 384: imul\n 385: iconst_2\n 386: iconst_1\n 387: invokespecial #60 // Method calculateOffer:(IIII)Lkotlin/Pair;\n 390: astore 5\n 392: aload_1\n 393: checkcast #30 // class java/lang/CharSequence\n 396: astore 7\n 398: iconst_0\n 399: istore 8\n 401: iconst_0\n 402: istore 9\n 404: iconst_0\n 405: istore 10\n 407: iload 10\n 409: aload 7\n 411: invokeinterface #34, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 416: if_icmpge 461\n 419: aload 7\n 421: iload 10\n 423: invokeinterface #38, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 428: istore 11\n 430: iload 11\n 432: istore 12\n 434: iconst_0\n 435: istore 13\n 437: iload 12\n 439: bipush 66\n 441: if_icmpne 448\n 444: iconst_1\n 445: goto 449\n 448: iconst_0\n 449: ifeq 455\n 452: iinc 9, 1\n 455: iinc 10, 1\n 458: goto 407\n 461: iload 9\n 463: aload 5\n 465: invokevirtual #74 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 468: checkcast #68 // class java/lang/Number\n 471: invokevirtual #71 // Method java/lang/Number.intValue:()I\n 474: isub\n 475: istore 6\n 477: aload_0\n 478: bipush 30\n 480: iload 6\n 482: bipush 30\n 484: imul\n 485: iconst_2\n 486: bipush 45\n 488: invokespecial #60 // Method calculateOffer:(IIII)Lkotlin/Pair;\n 491: astore 7\n 493: aload 7\n 495: invokevirtual #74 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 498: checkcast #68 // class java/lang/Number\n 501: invokevirtual #71 // Method java/lang/Number.intValue:()I\n 504: aload 7\n 506: invokevirtual #66 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 509: checkcast #68 // class java/lang/Number\n 512: invokevirtual #71 // Method java/lang/Number.intValue:()I\n 515: iadd\n 516: istore 8\n 518: aload_0\n 519: bipush 10\n 521: aload_1\n 522: checkcast #30 // class java/lang/CharSequence\n 525: astore 10\n 527: istore 19\n 529: astore 18\n 531: iconst_0\n 532: istore 11\n 534: iconst_0\n 535: istore 12\n 537: iconst_0\n 538: istore 13\n 540: iload 13\n 542: aload 10\n 544: invokeinterface #34, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 549: if_icmpge 594\n 552: aload 10\n 554: iload 13\n 556: invokeinterface #38, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 561: istore 14\n 563: iload 14\n 565: istore 15\n 567: iconst_0\n 568: istore 16\n 570: iload 15\n 572: bipush 70\n 574: if_icmpne 581\n 577: iconst_1\n 578: goto 582\n 581: iconst_0\n 582: ifeq 588\n 585: iinc 12, 1\n 588: iinc 13, 1\n 591: goto 540\n 594: iload 12\n 596: istore 20\n 598: aload 18\n 600: iload 19\n 602: iload 20\n 604: bipush 10\n 606: imul\n 607: iconst_3\n 608: iconst_1\n 609: invokespecial #60 // Method calculateOffer:(IIII)Lkotlin/Pair;\n 612: astore 9\n 614: aload_1\n 615: checkcast #30 // class java/lang/CharSequence\n 618: astore 11\n 620: iconst_0\n 621: istore 12\n 623: iconst_0\n 624: istore 13\n 626: iconst_0\n 627: istore 14\n 629: iload 14\n 631: aload 11\n 633: invokeinterface #34, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 638: if_icmpge 683\n 641: aload 11\n 643: iload 14\n 645: invokeinterface #38, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 650: istore 15\n 652: iload 15\n 654: istore 16\n 656: iconst_0\n 657: istore 17\n 659: iload 16\n 661: bipush 70\n 663: if_icmpne 670\n 666: iconst_1\n 667: goto 671\n 670: iconst_0\n 671: ifeq 677\n 674: iinc 13, 1\n 677: iinc 14, 1\n 680: goto 629\n 683: iload 13\n 685: bipush 10\n 687: imul\n 688: aload 9\n 690: invokevirtual #74 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 693: checkcast #68 // class java/lang/Number\n 696: invokevirtual #71 // Method java/lang/Number.intValue:()I\n 699: bipush 10\n 701: imul\n 702: isub\n 703: istore 10\n 705: iload 4\n 707: iload 8\n 709: ifgt 716\n 712: iconst_0\n 713: goto 718\n 716: iload 8\n 718: iadd\n 719: aload_1\n 720: checkcast #30 // class java/lang/CharSequence\n 723: astore 11\n 725: istore 18\n 727: iconst_0\n 728: istore 12\n 730: iconst_0\n 731: istore 13\n 733: iconst_0\n 734: istore 14\n 736: iload 14\n 738: aload 11\n 740: invokeinterface #34, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 745: if_icmpge 790\n 748: aload 11\n 750: iload 14\n 752: invokeinterface #38, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 757: istore 15\n 759: iload 15\n 761: istore 16\n 763: iconst_0\n 764: istore 17\n 766: iload 16\n 768: bipush 67\n 770: if_icmpne 777\n 773: iconst_1\n 774: goto 778\n 777: iconst_0\n 778: ifeq 784\n 781: iinc 13, 1\n 784: iinc 14, 1\n 787: goto 736\n 790: iload 13\n 792: istore 19\n 794: iload 18\n 796: iload 19\n 798: bipush 20\n 800: imul\n 801: iadd\n 802: aload_1\n 803: checkcast #30 // class java/lang/CharSequence\n 806: astore 11\n 808: istore 18\n 810: iconst_0\n 811: istore 12\n 813: iconst_0\n 814: istore 13\n 816: iconst_0\n 817: istore 14\n 819: iload 14\n 821: aload 11\n 823: invokeinterface #34, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 828: if_icmpge 873\n 831: aload 11\n 833: iload 14\n 835: invokeinterface #38, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 840: istore 15\n 842: iload 15\n 844: istore 16\n 846: iconst_0\n 847: istore 17\n 849: iload 16\n 851: bipush 68\n 853: if_icmpne 860\n 856: iconst_1\n 857: goto 861\n 860: iconst_0\n 861: ifeq 867\n 864: iinc 13, 1\n 867: iinc 14, 1\n 870: goto 819\n 873: iload 13\n 875: istore 19\n 877: iload 18\n 879: iload 19\n 881: bipush 15\n 883: imul\n 884: iadd\n 885: aload_1\n 886: checkcast #30 // class java/lang/CharSequence\n 889: astore 11\n 891: istore 18\n 893: iconst_0\n 894: istore 12\n 896: iconst_0\n 897: istore 13\n 899: iconst_0\n 900: istore 14\n 902: iload 14\n 904: aload 11\n 906: invokeinterface #34, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 911: if_icmpge 956\n 914: aload 11\n 916: iload 14\n 918: invokeinterface #38, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 923: istore 15\n 925: iload 15\n 927: istore 16\n 929: iconst_0\n 930: istore 17\n 932: iload 16\n 934: bipush 69\n 936: if_icmpne 943\n 939: iconst_1\n 940: goto 944\n 943: iconst_0\n 944: ifeq 950\n 947: iinc 13, 1\n 950: iinc 14, 1\n 953: goto 902\n 956: iload 13\n 958: istore 19\n 960: iload 18\n 962: iload 19\n 964: bipush 40\n 966: imul\n 967: iadd\n 968: iload 10\n 970: iadd\n 971: ireturn\n\n private final kotlin.Pair<java.lang.Integer, java.lang.Integer> calculateOffer(int, int, int, int);\n Code:\n 0: iload_2\n 1: iload_1\n 2: iload_3\n 3: imul\n 4: irem\n 5: istore 5\n 7: iload_2\n 8: iload 5\n 10: isub\n 11: iload_1\n 12: iload_3\n 13: imul\n 14: idiv\n 15: iload 4\n 17: imul\n 18: istore 6\n 20: new #62 // class kotlin/Pair\n 23: dup\n 24: iload 6\n 26: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 29: iload 5\n 31: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 34: invokespecial #117 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 37: areturn\n\n static {};\n Code:\n 0: new #2 // class solutions/CHK/CheckoutSolution\n 3: dup\n 4: invokespecial #125 // Method \"<init>\":()V\n 7: putstatic #128 // Field INSTANCE:Lsolutions/CHK/CheckoutSolution;\n 10: bipush 26\n 12: anewarray #62 // class kotlin/Pair\n 15: astore_0\n 16: aload_0\n 17: iconst_0\n 18: ldc #130 // String A\n 20: bipush 50\n 22: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 25: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 28: aastore\n 29: aload_0\n 30: iconst_1\n 31: ldc #138 // String B\n 33: bipush 30\n 35: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 38: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 41: aastore\n 42: aload_0\n 43: iconst_2\n 44: ldc #139 // String C\n 46: bipush 20\n 48: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 51: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 54: aastore\n 55: aload_0\n 56: iconst_3\n 57: ldc #141 // String D\n 59: bipush 15\n 61: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 64: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 67: aastore\n 68: aload_0\n 69: iconst_4\n 70: ldc #143 // String E\n 72: bipush 40\n 74: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 77: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 80: aastore\n 81: aload_0\n 82: iconst_5\n 83: ldc #145 // String F\n 85: bipush 10\n 87: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 90: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 93: aastore\n 94: aload_0\n 95: bipush 6\n 97: ldc #147 // String G\n 99: bipush 20\n 101: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 104: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 107: aastore\n 108: aload_0\n 109: bipush 7\n 111: ldc #149 // String H\n 113: bipush 10\n 115: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 118: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 121: aastore\n 122: aload_0\n 123: bipush 8\n 125: ldc #150 // String I\n 127: bipush 35\n 129: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 132: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 135: aastore\n 136: aload_0\n 137: bipush 9\n 139: ldc #152 // String J\n 141: bipush 60\n 143: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 146: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 149: aastore\n 150: aload_0\n 151: bipush 10\n 153: ldc #154 // String K\n 155: bipush 80\n 157: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 160: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 163: aastore\n 164: aload_0\n 165: bipush 11\n 167: ldc #156 // String L\n 169: bipush 90\n 171: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 174: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 177: aastore\n 178: aload_0\n 179: bipush 12\n 181: ldc #158 // String M\n 183: bipush 15\n 185: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 188: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 191: aastore\n 192: aload_0\n 193: bipush 13\n 195: ldc #160 // String N\n 197: bipush 40\n 199: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 202: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 205: aastore\n 206: aload_0\n 207: bipush 14\n 209: ldc #162 // String O\n 211: bipush 10\n 213: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 216: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 219: aastore\n 220: aload_0\n 221: bipush 15\n 223: ldc #164 // String P\n 225: bipush 50\n 227: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 230: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 233: aastore\n 234: aload_0\n 235: bipush 16\n 237: ldc #166 // String Q\n 239: bipush 30\n 241: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 244: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 247: aastore\n 248: aload_0\n 249: bipush 17\n 251: ldc #168 // String R\n 253: bipush 50\n 255: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 258: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 261: aastore\n 262: aload_0\n 263: bipush 18\n 265: ldc #170 // String S\n 267: bipush 30\n 269: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 272: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 275: aastore\n 276: aload_0\n 277: bipush 19\n 279: ldc #172 // String T\n 281: bipush 20\n 283: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 286: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 289: aastore\n 290: aload_0\n 291: bipush 20\n 293: ldc #174 // String U\n 295: bipush 40\n 297: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 300: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 303: aastore\n 304: aload_0\n 305: bipush 21\n 307: ldc #176 // String V\n 309: bipush 50\n 311: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 314: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 317: aastore\n 318: aload_0\n 319: bipush 22\n 321: ldc #178 // String W\n 323: bipush 20\n 325: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 328: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 331: aastore\n 332: aload_0\n 333: bipush 23\n 335: ldc #180 // String X\n 337: bipush 90\n 339: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 342: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 345: aastore\n 346: aload_0\n 347: bipush 24\n 349: ldc #182 // String Z\n 351: bipush 50\n 353: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 356: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 359: aastore\n 360: aload_0\n 361: bipush 25\n 363: ldc #184 // String Y\n 365: bipush 10\n 367: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 370: invokestatic #136 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 373: aastore\n 374: aload_0\n 375: invokestatic #190 // Method kotlin/collections/MapsKt.hashMapOf:([Lkotlin/Pair;)Ljava/util/HashMap;\n 378: putstatic #18 // Field prices:Ljava/util/HashMap;\n 381: return\n}\n", "javap_err": "" } ]
schnell18__kotlin-koans__7c1e281/src/iii_conventions/MyDate.kt
package iii_conventions data class RepeatedTimeInterval(val interval: TimeInterval, val repeat : Int = 1) enum class TimeInterval { DAY(), WEEK(), YEAR(); operator fun times(i: Int): RepeatedTimeInterval { return RepeatedTimeInterval(this, i) } } data class MyDate(val year: Int, val month: Int, val dayOfMonth: Int) { operator fun compareTo(date2: MyDate): Int { return when { this.year != date2.year -> this.year.compareTo(date2.year) this.month != date2.month -> this.month.compareTo(date2.month) else -> this.dayOfMonth.compareTo(date2.dayOfMonth) } } fun nextDay(days : Int = 1) : MyDate { var d = this.dayOfMonth var m = this.month var y = this.year val daysOfMonth = when (m) { 1, 3, 5, 7, 8, 10, 12 -> 31 2 -> if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) 29 else 28 else -> 30 } var remainder = 0 when { days <= daysOfMonth - this.dayOfMonth -> d += days days <= daysOfMonth - this.dayOfMonth + 28 -> { d += days - daysOfMonth m += 1 } else -> { remainder = days - 28 - (daysOfMonth - this.dayOfMonth) d = 28 m += 1 } } if (m > 12) { m = 1 y += 1 } val result = MyDate(y, m, d) if (remainder > 0) { return result.nextDay(remainder) } return result } } operator fun MyDate.rangeTo(other: MyDate): DateRange = DateRange(this, other) class DateRange(val start: MyDate, val endInclusive: MyDate) { operator fun contains(d: MyDate) = start <= d && d <= endInclusive operator fun iterator(): Iterator<MyDate> { return object : Iterator<MyDate> { var currentDate = start.copy() override fun hasNext(): Boolean { return currentDate <= endInclusive } override fun next(): MyDate { val retDate = currentDate currentDate = currentDate.nextDay() return retDate } } } }
[ { "class_path": "schnell18__kotlin-koans__7c1e281/iii_conventions/MyDate.class", "javap": "Compiled from \"MyDate.kt\"\npublic final class iii_conventions.MyDate {\n private final int year;\n\n private final int month;\n\n private final int dayOfMonth;\n\n public iii_conventions.MyDate(int, int, int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field year:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field month:I\n 14: aload_0\n 15: iload_3\n 16: putfield #19 // Field dayOfMonth:I\n 19: return\n\n public final int getYear();\n Code:\n 0: aload_0\n 1: getfield #13 // Field year:I\n 4: ireturn\n\n public final int getMonth();\n Code:\n 0: aload_0\n 1: getfield #16 // Field month:I\n 4: ireturn\n\n public final int getDayOfMonth();\n Code:\n 0: aload_0\n 1: getfield #19 // Field dayOfMonth:I\n 4: ireturn\n\n public final int compareTo(iii_conventions.MyDate);\n Code:\n 0: aload_1\n 1: ldc #30 // String date2\n 3: invokestatic #36 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: nop\n 7: aload_0\n 8: getfield #13 // Field year:I\n 11: aload_1\n 12: getfield #13 // Field year:I\n 15: if_icmpeq 32\n 18: aload_0\n 19: getfield #13 // Field year:I\n 22: aload_1\n 23: getfield #13 // Field year:I\n 26: invokestatic #40 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 29: goto 68\n 32: aload_0\n 33: getfield #16 // Field month:I\n 36: aload_1\n 37: getfield #16 // Field month:I\n 40: if_icmpeq 57\n 43: aload_0\n 44: getfield #16 // Field month:I\n 47: aload_1\n 48: getfield #16 // Field month:I\n 51: invokestatic #40 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 54: goto 68\n 57: aload_0\n 58: getfield #19 // Field dayOfMonth:I\n 61: aload_1\n 62: getfield #19 // Field dayOfMonth:I\n 65: invokestatic #40 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 68: ireturn\n\n public final iii_conventions.MyDate nextDay(int);\n Code:\n 0: aload_0\n 1: getfield #19 // Field dayOfMonth:I\n 4: istore_2\n 5: aload_0\n 6: getfield #16 // Field month:I\n 9: istore_3\n 10: aload_0\n 11: getfield #13 // Field year:I\n 14: istore 4\n 16: iload_3\n 17: tableswitch { // 1 to 12\n 1: 80\n 2: 85\n 3: 80\n 4: 125\n 5: 80\n 6: 125\n 7: 80\n 8: 80\n 9: 125\n 10: 80\n 11: 125\n 12: 80\n default: 125\n }\n 80: bipush 31\n 82: goto 127\n 85: aload_0\n 86: getfield #13 // Field year:I\n 89: sipush 400\n 92: irem\n 93: ifeq 115\n 96: aload_0\n 97: getfield #13 // Field year:I\n 100: iconst_4\n 101: irem\n 102: ifne 120\n 105: aload_0\n 106: getfield #13 // Field year:I\n 109: bipush 100\n 111: irem\n 112: ifeq 120\n 115: bipush 29\n 117: goto 127\n 120: bipush 28\n 122: goto 127\n 125: bipush 30\n 127: istore 5\n 129: iconst_0\n 130: istore 6\n 132: nop\n 133: iload_1\n 134: iload 5\n 136: aload_0\n 137: getfield #19 // Field dayOfMonth:I\n 140: isub\n 141: if_icmpgt 151\n 144: iload_2\n 145: iload_1\n 146: iadd\n 147: istore_2\n 148: goto 198\n 151: iload_1\n 152: iload 5\n 154: aload_0\n 155: getfield #19 // Field dayOfMonth:I\n 158: isub\n 159: bipush 28\n 161: iadd\n 162: if_icmpgt 178\n 165: iload_2\n 166: iload_1\n 167: iload 5\n 169: isub\n 170: iadd\n 171: istore_2\n 172: iinc 3, 1\n 175: goto 198\n 178: iload_1\n 179: bipush 28\n 181: isub\n 182: iload 5\n 184: aload_0\n 185: getfield #19 // Field dayOfMonth:I\n 188: isub\n 189: isub\n 190: istore 6\n 192: bipush 28\n 194: istore_2\n 195: iinc 3, 1\n 198: iload_3\n 199: bipush 12\n 201: if_icmple 209\n 204: iconst_1\n 205: istore_3\n 206: iinc 4, 1\n 209: new #2 // class iii_conventions/MyDate\n 212: dup\n 213: iload 4\n 215: iload_3\n 216: iload_2\n 217: invokespecial #44 // Method \"<init>\":(III)V\n 220: astore 7\n 222: iload 6\n 224: ifle 235\n 227: aload 7\n 229: iload 6\n 231: invokevirtual #46 // Method nextDay:(I)Liii_conventions/MyDate;\n 234: areturn\n 235: aload 7\n 237: areturn\n\n public static iii_conventions.MyDate nextDay$default(iii_conventions.MyDate, int, int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 8\n 6: iconst_1\n 7: istore_1\n 8: aload_0\n 9: iload_1\n 10: invokevirtual #46 // Method nextDay:(I)Liii_conventions/MyDate;\n 13: areturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field year:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field month:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #19 // Field dayOfMonth:I\n 4: ireturn\n\n public final iii_conventions.MyDate copy(int, int, int);\n Code:\n 0: new #2 // class iii_conventions/MyDate\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: iload_3\n 7: invokespecial #44 // Method \"<init>\":(III)V\n 10: areturn\n\n public static iii_conventions.MyDate copy$default(iii_conventions.MyDate, int, int, int, int, java.lang.Object);\n Code:\n 0: iload 4\n 2: iconst_1\n 3: iand\n 4: ifeq 12\n 7: aload_0\n 8: getfield #13 // Field year:I\n 11: istore_1\n 12: iload 4\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #16 // Field month:I\n 23: istore_2\n 24: iload 4\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #19 // Field dayOfMonth:I\n 35: istore_3\n 36: aload_0\n 37: iload_1\n 38: iload_2\n 39: iload_3\n 40: invokevirtual #64 // Method copy:(III)Liii_conventions/MyDate;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #68 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #69 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #71 // String MyDate(year=\n 9: invokevirtual #75 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field year:I\n 16: invokevirtual #78 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #80 // String , month=\n 21: invokevirtual #75 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field month:I\n 28: invokevirtual #78 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #82 // String , dayOfMonth=\n 33: invokevirtual #75 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #19 // Field dayOfMonth:I\n 40: invokevirtual #78 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #85 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #87 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 51: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #13 // Field year:I\n 4: invokestatic #93 // Method java/lang/Integer.hashCode:(I)I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #16 // Field month:I\n 16: invokestatic #93 // Method java/lang/Integer.hashCode:(I)I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: bipush 31\n 24: imul\n 25: aload_0\n 26: getfield #19 // Field dayOfMonth:I\n 29: invokestatic #93 // Method java/lang/Integer.hashCode:(I)I\n 32: iadd\n 33: istore_1\n 34: iload_1\n 35: ireturn\n\n public boolean equals(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: if_acmpne 7\n 5: iconst_1\n 6: ireturn\n 7: aload_1\n 8: instanceof #2 // class iii_conventions/MyDate\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class iii_conventions/MyDate\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field year:I\n 25: aload_2\n 26: getfield #13 // Field year:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field month:I\n 38: aload_2\n 39: getfield #16 // Field month:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #19 // Field dayOfMonth:I\n 51: aload_2\n 52: getfield #19 // Field dayOfMonth:I\n 55: if_icmpeq 60\n 58: iconst_0\n 59: ireturn\n 60: iconst_1\n 61: ireturn\n}\n", "javap_err": "" }, { "class_path": "schnell18__kotlin-koans__7c1e281/iii_conventions/MyDateKt.class", "javap": "Compiled from \"MyDate.kt\"\npublic final class iii_conventions.MyDateKt {\n public static final iii_conventions.DateRange rangeTo(iii_conventions.MyDate, iii_conventions.MyDate);\n Code:\n 0: aload_0\n 1: ldc #9 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #17 // String other\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #19 // class iii_conventions/DateRange\n 15: dup\n 16: aload_0\n 17: aload_1\n 18: invokespecial #23 // Method iii_conventions/DateRange.\"<init>\":(Liii_conventions/MyDate;Liii_conventions/MyDate;)V\n 21: areturn\n}\n", "javap_err": "" } ]
aesdeef__advent-of-code-2021__4561bcf/kotlin/day01/sonarSweep.kt
package day01 import java.io.File fun main() { val depths = parseInput() val part1 = countIncreases(depths) val slidingWindows = getSlidingWindows(depths) val part2 = countIncreases(slidingWindows) println(part1) println(part2) } fun parseInput(): List<Int> { return File("../../input/01.txt") .readLines() .map { it.toInt() } } fun countIncreases(measurements: List<Int>): Int { return (measurements.dropLast(1) zip measurements.drop(1)) .count { it.first < it.second } } fun getSlidingWindows(depths: List<Int>): List<Int> { return zipSum( zipSum( depths.dropLast(2), depths.dropLast(1).drop(1) ), depths.drop(2) ) } fun zipSum(first: List<Int>, second: List<Int>): List<Int> { return (first zip second).map{ it.first + it.second } }
[ { "class_path": "aesdeef__advent-of-code-2021__4561bcf/day01/SonarSweepKt.class", "javap": "Compiled from \"sonarSweep.kt\"\npublic final class day01.SonarSweepKt {\n public static final void main();\n Code:\n 0: invokestatic #10 // Method parseInput:()Ljava/util/List;\n 3: astore_0\n 4: aload_0\n 5: invokestatic #14 // Method countIncreases:(Ljava/util/List;)I\n 8: istore_1\n 9: aload_0\n 10: invokestatic #18 // Method getSlidingWindows:(Ljava/util/List;)Ljava/util/List;\n 13: astore_2\n 14: aload_2\n 15: invokestatic #14 // Method countIncreases:(Ljava/util/List;)I\n 18: istore_3\n 19: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 22: iload_1\n 23: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 26: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 29: iload_3\n 30: invokevirtual #30 // Method java/io/PrintStream.println:(I)V\n 33: return\n\n public static final java.util.List<java.lang.Integer> parseInput();\n Code:\n 0: new #40 // class java/io/File\n 3: dup\n 4: ldc #42 // String ../../input/01.txt\n 6: invokespecial #46 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #52 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 15: checkcast #54 // class java/lang/Iterable\n 18: astore_0\n 19: nop\n 20: iconst_0\n 21: istore_1\n 22: aload_0\n 23: astore_2\n 24: new #56 // class java/util/ArrayList\n 27: dup\n 28: aload_0\n 29: bipush 10\n 31: invokestatic #62 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 34: invokespecial #64 // Method java/util/ArrayList.\"<init>\":(I)V\n 37: checkcast #66 // class java/util/Collection\n 40: astore_3\n 41: iconst_0\n 42: istore 4\n 44: aload_2\n 45: invokeinterface #70, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 5\n 52: aload 5\n 54: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 105\n 62: aload 5\n 64: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 6\n 71: aload_3\n 72: aload 6\n 74: checkcast #82 // class java/lang/String\n 77: astore 7\n 79: astore 9\n 81: iconst_0\n 82: istore 8\n 84: aload 7\n 86: invokestatic #88 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 89: nop\n 90: invokestatic #92 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 93: aload 9\n 95: swap\n 96: invokeinterface #96, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 101: pop\n 102: goto 52\n 105: aload_3\n 106: checkcast #98 // class java/util/List\n 109: nop\n 110: areturn\n\n public static final int countIncreases(java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #113 // String measurements\n 3: invokestatic #119 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iconst_1\n 8: invokestatic #123 // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;\n 11: checkcast #54 // class java/lang/Iterable\n 14: aload_0\n 15: checkcast #54 // class java/lang/Iterable\n 18: iconst_1\n 19: invokestatic #127 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 22: checkcast #54 // class java/lang/Iterable\n 25: invokestatic #131 // Method kotlin/collections/CollectionsKt.zip:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;\n 28: checkcast #54 // class java/lang/Iterable\n 31: astore_1\n 32: nop\n 33: iconst_0\n 34: istore_2\n 35: aload_1\n 36: instanceof #66 // class java/util/Collection\n 39: ifeq 58\n 42: aload_1\n 43: checkcast #66 // class java/util/Collection\n 46: invokeinterface #134, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 51: ifeq 58\n 54: iconst_0\n 55: goto 144\n 58: iconst_0\n 59: istore_3\n 60: aload_1\n 61: invokeinterface #70, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 66: astore 4\n 68: aload 4\n 70: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 75: ifeq 143\n 78: aload 4\n 80: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 85: astore 5\n 87: aload 5\n 89: checkcast #136 // class kotlin/Pair\n 92: astore 6\n 94: iconst_0\n 95: istore 7\n 97: aload 6\n 99: invokevirtual #139 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 102: checkcast #141 // class java/lang/Number\n 105: invokevirtual #145 // Method java/lang/Number.intValue:()I\n 108: aload 6\n 110: invokevirtual #148 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 113: checkcast #141 // class java/lang/Number\n 116: invokevirtual #145 // Method java/lang/Number.intValue:()I\n 119: if_icmpge 126\n 122: iconst_1\n 123: goto 127\n 126: iconst_0\n 127: ifeq 68\n 130: iinc 3, 1\n 133: iload_3\n 134: ifge 68\n 137: invokestatic #151 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 140: goto 68\n 143: iload_3\n 144: ireturn\n\n public static final java.util.List<java.lang.Integer> getSlidingWindows(java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #159 // String depths\n 3: invokestatic #119 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iconst_2\n 8: invokestatic #123 // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;\n 11: aload_0\n 12: iconst_1\n 13: invokestatic #123 // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;\n 16: checkcast #54 // class java/lang/Iterable\n 19: iconst_1\n 20: invokestatic #127 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 23: invokestatic #163 // Method zipSum:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 26: aload_0\n 27: checkcast #54 // class java/lang/Iterable\n 30: iconst_2\n 31: invokestatic #127 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 34: invokestatic #163 // Method zipSum:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 37: areturn\n\n public static final java.util.List<java.lang.Integer> zipSum(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #166 // String first\n 3: invokestatic #119 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #168 // String second\n 9: invokestatic #119 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: checkcast #54 // class java/lang/Iterable\n 16: aload_1\n 17: checkcast #54 // class java/lang/Iterable\n 20: invokestatic #131 // Method kotlin/collections/CollectionsKt.zip:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;\n 23: checkcast #54 // class java/lang/Iterable\n 26: astore_2\n 27: iconst_0\n 28: istore_3\n 29: aload_2\n 30: astore 4\n 32: new #56 // class java/util/ArrayList\n 35: dup\n 36: aload_2\n 37: bipush 10\n 39: invokestatic #62 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 42: invokespecial #64 // Method java/util/ArrayList.\"<init>\":(I)V\n 45: checkcast #66 // class java/util/Collection\n 48: astore 5\n 50: iconst_0\n 51: istore 6\n 53: aload 4\n 55: invokeinterface #70, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 60: astore 7\n 62: aload 7\n 64: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 69: ifeq 133\n 72: aload 7\n 74: invokeinterface #80, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 79: astore 8\n 81: aload 5\n 83: aload 8\n 85: checkcast #136 // class kotlin/Pair\n 88: astore 9\n 90: astore 11\n 92: iconst_0\n 93: istore 10\n 95: aload 9\n 97: invokevirtual #139 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 100: checkcast #141 // class java/lang/Number\n 103: invokevirtual #145 // Method java/lang/Number.intValue:()I\n 106: aload 9\n 108: invokevirtual #148 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 111: checkcast #141 // class java/lang/Number\n 114: invokevirtual #145 // Method java/lang/Number.intValue:()I\n 117: iadd\n 118: invokestatic #92 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 121: aload 11\n 123: swap\n 124: invokeinterface #96, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 129: pop\n 130: goto 62\n 133: aload 5\n 135: checkcast #98 // class java/util/List\n 138: nop\n 139: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #172 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
aesdeef__advent-of-code-2021__4561bcf/kotlin/day02/deep.kt
package day02 import java.io.File data class Instruction(val command: String, val value: Int) fun main() { val instructions = parseInput() val part1 = solvePart1(instructions) val part2 = solvePart2(instructions) println(part1) println(part2) } fun parseInput(): List<Instruction> { return File("../../input/02.txt") .readLines() .map { it.split(" ") } .map { Instruction(it[0], it[1].toInt()) } } fun solvePart1(instructions: List<Instruction>): Int { var horizontal = 0 var depth = 0 instructions.forEach { val (command, value) = it when (command) { "forward" -> horizontal += value "down" -> depth += value "up" -> depth -= value } } return horizontal * depth } fun solvePart2(instructions: List<Instruction>): Int { var aim = 0 var horizontal = 0 var depth = 0 instructions.forEach { val (command, value) = it when (command) { "forward" -> { horizontal += value depth += aim * value } "down" -> aim += value "up" -> aim -= value } } return horizontal * depth }
[ { "class_path": "aesdeef__advent-of-code-2021__4561bcf/day02/DeepKt.class", "javap": "Compiled from \"deep.kt\"\npublic final class day02.DeepKt {\n public static final void main();\n Code:\n 0: invokestatic #10 // Method parseInput:()Ljava/util/List;\n 3: astore_0\n 4: aload_0\n 5: invokestatic #14 // Method solvePart1:(Ljava/util/List;)I\n 8: istore_1\n 9: aload_0\n 10: invokestatic #17 // Method solvePart2:(Ljava/util/List;)I\n 13: istore_2\n 14: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 17: iload_1\n 18: invokevirtual #29 // Method java/io/PrintStream.println:(I)V\n 21: getstatic #23 // Field java/lang/System.out:Ljava/io/PrintStream;\n 24: iload_2\n 25: invokevirtual #29 // Method java/io/PrintStream.println:(I)V\n 28: return\n\n public static final java.util.List<day02.Instruction> parseInput();\n Code:\n 0: new #38 // class java/io/File\n 3: dup\n 4: ldc #40 // String ../../input/02.txt\n 6: invokespecial #44 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: aconst_null\n 10: iconst_1\n 11: aconst_null\n 12: invokestatic #50 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 15: checkcast #52 // class java/lang/Iterable\n 18: astore_0\n 19: nop\n 20: iconst_0\n 21: istore_1\n 22: aload_0\n 23: astore_2\n 24: new #54 // class java/util/ArrayList\n 27: dup\n 28: aload_0\n 29: bipush 10\n 31: invokestatic #60 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 34: invokespecial #62 // Method java/util/ArrayList.\"<init>\":(I)V\n 37: checkcast #64 // class java/util/Collection\n 40: astore_3\n 41: iconst_0\n 42: istore 4\n 44: aload_2\n 45: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 5\n 52: aload 5\n 54: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 123\n 62: aload 5\n 64: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 6\n 71: aload_3\n 72: aload 6\n 74: checkcast #80 // class java/lang/String\n 77: astore 7\n 79: astore 10\n 81: iconst_0\n 82: istore 8\n 84: aload 7\n 86: checkcast #82 // class java/lang/CharSequence\n 89: iconst_1\n 90: anewarray #80 // class java/lang/String\n 93: astore 9\n 95: aload 9\n 97: iconst_0\n 98: ldc #84 // String\n 100: aastore\n 101: aload 9\n 103: iconst_0\n 104: iconst_0\n 105: bipush 6\n 107: aconst_null\n 108: invokestatic #90 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 111: aload 10\n 113: swap\n 114: invokeinterface #94, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 119: pop\n 120: goto 52\n 123: aload_3\n 124: checkcast #96 // class java/util/List\n 127: nop\n 128: checkcast #52 // class java/lang/Iterable\n 131: astore_0\n 132: nop\n 133: iconst_0\n 134: istore_1\n 135: aload_0\n 136: astore_2\n 137: new #54 // class java/util/ArrayList\n 140: dup\n 141: aload_0\n 142: bipush 10\n 144: invokestatic #60 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 147: invokespecial #62 // Method java/util/ArrayList.\"<init>\":(I)V\n 150: checkcast #64 // class java/util/Collection\n 153: astore_3\n 154: iconst_0\n 155: istore 4\n 157: aload_2\n 158: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 163: astore 5\n 165: aload 5\n 167: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 172: ifeq 241\n 175: aload 5\n 177: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 182: astore 6\n 184: aload_3\n 185: aload 6\n 187: checkcast #96 // class java/util/List\n 190: astore 7\n 192: astore 10\n 194: iconst_0\n 195: istore 8\n 197: new #98 // class day02/Instruction\n 200: dup\n 201: aload 7\n 203: iconst_0\n 204: invokeinterface #102, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 209: checkcast #80 // class java/lang/String\n 212: aload 7\n 214: iconst_1\n 215: invokeinterface #102, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 220: checkcast #80 // class java/lang/String\n 223: invokestatic #108 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 226: invokespecial #111 // Method day02/Instruction.\"<init>\":(Ljava/lang/String;I)V\n 229: aload 10\n 231: swap\n 232: invokeinterface #94, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 237: pop\n 238: goto 165\n 241: aload_3\n 242: checkcast #96 // class java/util/List\n 245: nop\n 246: areturn\n\n public static final int solvePart1(java.util.List<day02.Instruction>);\n Code:\n 0: aload_0\n 1: ldc #126 // String instructions\n 3: invokestatic #132 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_0\n 11: checkcast #52 // class java/lang/Iterable\n 14: astore_3\n 15: iconst_0\n 16: istore 4\n 18: aload_3\n 19: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 24: astore 5\n 26: aload 5\n 28: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 33: ifeq 177\n 36: aload 5\n 38: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 43: astore 6\n 45: aload 6\n 47: checkcast #98 // class day02/Instruction\n 50: astore 7\n 52: iconst_0\n 53: istore 8\n 55: aload 7\n 57: invokevirtual #136 // Method day02/Instruction.component1:()Ljava/lang/String;\n 60: astore 9\n 62: aload 7\n 64: invokevirtual #140 // Method day02/Instruction.component2:()I\n 67: istore 10\n 69: aload 9\n 71: astore 11\n 73: aload 11\n 75: invokevirtual #143 // Method java/lang/String.hashCode:()I\n 78: lookupswitch { // 3\n -677145915: 112\n 3739: 125\n 3089570: 138\n default: 172\n }\n 112: aload 11\n 114: ldc #145 // String forward\n 116: invokevirtual #148 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 119: ifne 151\n 122: goto 172\n 125: aload 11\n 127: ldc #150 // String up\n 129: invokevirtual #148 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 132: ifne 167\n 135: goto 172\n 138: aload 11\n 140: ldc #152 // String down\n 142: invokevirtual #148 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 145: ifne 159\n 148: goto 172\n 151: iload_1\n 152: iload 10\n 154: iadd\n 155: istore_1\n 156: goto 172\n 159: iload_2\n 160: iload 10\n 162: iadd\n 163: istore_2\n 164: goto 172\n 167: iload_2\n 168: iload 10\n 170: isub\n 171: istore_2\n 172: nop\n 173: nop\n 174: goto 26\n 177: nop\n 178: iload_1\n 179: iload_2\n 180: imul\n 181: ireturn\n\n public static final int solvePart2(java.util.List<day02.Instruction>);\n Code:\n 0: aload_0\n 1: ldc #126 // String instructions\n 3: invokestatic #132 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_1\n 8: iconst_0\n 9: istore_2\n 10: iconst_0\n 11: istore_3\n 12: aload_0\n 13: checkcast #52 // class java/lang/Iterable\n 16: astore 4\n 18: iconst_0\n 19: istore 5\n 21: aload 4\n 23: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 28: astore 6\n 30: aload 6\n 32: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 37: ifeq 188\n 40: aload 6\n 42: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 47: astore 7\n 49: aload 7\n 51: checkcast #98 // class day02/Instruction\n 54: astore 8\n 56: iconst_0\n 57: istore 9\n 59: aload 8\n 61: invokevirtual #136 // Method day02/Instruction.component1:()Ljava/lang/String;\n 64: astore 10\n 66: aload 8\n 68: invokevirtual #140 // Method day02/Instruction.component2:()I\n 71: istore 11\n 73: aload 10\n 75: astore 12\n 77: aload 12\n 79: invokevirtual #143 // Method java/lang/String.hashCode:()I\n 82: lookupswitch { // 3\n -677145915: 116\n 3739: 129\n 3089570: 142\n default: 183\n }\n 116: aload 12\n 118: ldc #145 // String forward\n 120: invokevirtual #148 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 123: ifne 155\n 126: goto 183\n 129: aload 12\n 131: ldc #150 // String up\n 133: invokevirtual #148 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 136: ifne 178\n 139: goto 183\n 142: aload 12\n 144: ldc #152 // String down\n 146: invokevirtual #148 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 149: ifne 170\n 152: goto 183\n 155: iload_2\n 156: iload 11\n 158: iadd\n 159: istore_2\n 160: iload_3\n 161: iload_1\n 162: iload 11\n 164: imul\n 165: iadd\n 166: istore_3\n 167: goto 183\n 170: iload_1\n 171: iload 11\n 173: iadd\n 174: istore_1\n 175: goto 183\n 178: iload_1\n 179: iload 11\n 181: isub\n 182: istore_1\n 183: nop\n 184: nop\n 185: goto 30\n 188: nop\n 189: iload_2\n 190: iload_3\n 191: imul\n 192: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #166 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
joakimgy__tower-defence__0d6915b/src/main/kotlin/utils/AlgorithmAStar.kt
package utils interface Graph { interface Vertex interface Edge<T : Vertex> { val a: T val b: T } } abstract class AlgorithmAStar<V : Graph.Vertex, E : Graph.Edge<V>>( private val edges: List<E> ) : Graph { private val V.neighbors: List<V> get() = edges .asSequence() .filter { it.a == this || it.b == this } .map { listOf(it.a, it.b) } .flatten() .filterNot { it == this } .distinct() .toList() private val E.cost: Double get() = costToMoveThrough(this) private fun findRoute(from: V, to: V): E? { return edges.find { (it.a == from && it.b == to) || (it.a == to && it.b == from) } } private fun findRouteOrElseCreateIt(from: V, to: V): E { return findRoute(from, to) ?: createEdge(from, to) } private fun generatePath(currentPos: V, cameFrom: Map<V, V>): List<V> { val path = mutableListOf(currentPos) var current = currentPos while (cameFrom.containsKey(current)) { current = cameFrom.getValue(current) path.add(0, current) } return path.toList() } abstract fun costToMoveThrough(edge: E): Double abstract fun createEdge(from: V, to: V): E fun findPath(begin: V, end: V): Pair<List<V>, Double> { val cameFrom = mutableMapOf<V, V>() val openVertices = mutableSetOf(begin) val closedVertices = mutableSetOf<V>() val costFromStart = mutableMapOf(begin to 0.0) val estimatedRoute = findRouteOrElseCreateIt(from = begin, to = end) val estimatedTotalCost = mutableMapOf(begin to estimatedRoute.cost) while (openVertices.isNotEmpty()) { val currentPos = openVertices.minByOrNull { estimatedTotalCost.getValue(it) }!! // Check if we have reached the finish if (currentPos == end) { // Backtrack to generate the most efficient path val path = generatePath(currentPos, cameFrom) // First Route to finish will be optimum route return Pair(path, estimatedTotalCost.getValue(end)) } // Mark the current vertex as closed openVertices.remove(currentPos) closedVertices.add(currentPos) (currentPos.neighbors - closedVertices).forEach { neighbour -> val routeCost = findRouteOrElseCreateIt(from = currentPos, to = neighbour).cost val cost: Double = costFromStart.getValue(currentPos) + routeCost if (cost < costFromStart.getOrDefault(neighbour, Double.MAX_VALUE)) { if (!openVertices.contains(neighbour)) { openVertices.add(neighbour) } cameFrom[neighbour] = currentPos costFromStart[neighbour] = cost val estimatedRemainingRouteCost = findRouteOrElseCreateIt(from = neighbour, to = end).cost estimatedTotalCost[neighbour] = cost + estimatedRemainingRouteCost } } } throw IllegalArgumentException("No Path from Start $begin to Finish $end") } }
[ { "class_path": "joakimgy__tower-defence__0d6915b/utils/AlgorithmAStar.class", "javap": "Compiled from \"AlgorithmAStar.kt\"\npublic abstract class utils.AlgorithmAStar<V extends utils.Graph$Vertex, E extends utils.Graph$Edge<V>> implements utils.Graph {\n private final java.util.List<E> edges;\n\n public utils.AlgorithmAStar(java.util.List<? extends E>);\n Code:\n 0: aload_1\n 1: ldc #13 // String edges\n 3: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #22 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #25 // Field edges:Ljava/util/List;\n 15: return\n\n private final java.util.List<V> getNeighbors(V);\n Code:\n 0: aload_0\n 1: getfield #25 // Field edges:Ljava/util/List;\n 4: checkcast #32 // class java/lang/Iterable\n 7: invokestatic #38 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 10: aload_1\n 11: invokedynamic #58, 0 // InvokeDynamic #0:invoke:(Lutils/Graph$Vertex;)Lkotlin/jvm/functions/Function1;\n 16: invokestatic #64 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 19: invokedynamic #73, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 24: invokestatic #76 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 27: invokestatic #80 // Method kotlin/sequences/SequencesKt.flattenSequenceOfIterable:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 30: aload_1\n 31: invokedynamic #88, 0 // InvokeDynamic #2:invoke:(Lutils/Graph$Vertex;)Lkotlin/jvm/functions/Function1;\n 36: invokestatic #91 // Method kotlin/sequences/SequencesKt.filterNot:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 39: invokestatic #94 // Method kotlin/sequences/SequencesKt.distinct:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 42: invokestatic #98 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 45: areturn\n\n private final double getCost(E);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokevirtual #106 // Method costToMoveThrough:(Lutils/Graph$Edge;)D\n 5: dreturn\n\n private final E findRoute(V, V);\n Code:\n 0: aload_0\n 1: getfield #25 // Field edges:Ljava/util/List;\n 4: checkcast #32 // class java/lang/Iterable\n 7: astore_3\n 8: aload_3\n 9: invokeinterface #115, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 14: astore 4\n 16: aload 4\n 18: invokeinterface #121, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 23: ifeq 114\n 26: aload 4\n 28: invokeinterface #125, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 33: astore 5\n 35: aload 5\n 37: checkcast #127 // class utils/Graph$Edge\n 40: astore 6\n 42: iconst_0\n 43: istore 7\n 45: aload 6\n 47: invokeinterface #131, 1 // InterfaceMethod utils/Graph$Edge.getA:()Lutils/Graph$Vertex;\n 52: aload_1\n 53: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 56: ifeq 73\n 59: aload 6\n 61: invokeinterface #138, 1 // InterfaceMethod utils/Graph$Edge.getB:()Lutils/Graph$Vertex;\n 66: aload_2\n 67: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 70: ifne 101\n 73: aload 6\n 75: invokeinterface #131, 1 // InterfaceMethod utils/Graph$Edge.getA:()Lutils/Graph$Vertex;\n 80: aload_2\n 81: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 84: ifeq 105\n 87: aload 6\n 89: invokeinterface #138, 1 // InterfaceMethod utils/Graph$Edge.getB:()Lutils/Graph$Vertex;\n 94: aload_1\n 95: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 98: ifeq 105\n 101: iconst_1\n 102: goto 106\n 105: iconst_0\n 106: ifeq 16\n 109: aload 5\n 111: goto 115\n 114: aconst_null\n 115: checkcast #127 // class utils/Graph$Edge\n 118: areturn\n\n private final E findRouteOrElseCreateIt(V, V);\n Code:\n 0: aload_0\n 1: aload_1\n 2: aload_2\n 3: invokespecial #146 // Method findRoute:(Lutils/Graph$Vertex;Lutils/Graph$Vertex;)Lutils/Graph$Edge;\n 6: dup\n 7: ifnonnull 17\n 10: pop\n 11: aload_0\n 12: aload_1\n 13: aload_2\n 14: invokevirtual #149 // Method createEdge:(Lutils/Graph$Vertex;Lutils/Graph$Vertex;)Lutils/Graph$Edge;\n 17: areturn\n\n private final java.util.List<V> generatePath(V, java.util.Map<V, ? extends V>);\n Code:\n 0: iconst_1\n 1: anewarray #154 // class utils/Graph$Vertex\n 4: astore 4\n 6: aload 4\n 8: iconst_0\n 9: aload_1\n 10: aastore\n 11: aload 4\n 13: invokestatic #158 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 16: astore_3\n 17: aload_1\n 18: astore 4\n 20: aload_2\n 21: aload 4\n 23: invokeinterface #164, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 28: ifeq 54\n 31: aload_2\n 32: aload 4\n 34: invokestatic #170 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 37: checkcast #154 // class utils/Graph$Vertex\n 40: astore 4\n 42: aload_3\n 43: iconst_0\n 44: aload 4\n 46: invokeinterface #176, 3 // InterfaceMethod java/util/List.add:(ILjava/lang/Object;)V\n 51: goto 20\n 54: aload_3\n 55: checkcast #32 // class java/lang/Iterable\n 58: invokestatic #179 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 61: areturn\n\n public abstract double costToMoveThrough(E);\n\n public abstract E createEdge(V, V);\n\n public final kotlin.Pair<java.util.List<V>, java.lang.Double> findPath(V, V);\n Code:\n 0: aload_1\n 1: ldc #189 // String begin\n 3: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #191 // String end\n 9: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #193 // class java/util/LinkedHashMap\n 15: dup\n 16: invokespecial #194 // Method java/util/LinkedHashMap.\"<init>\":()V\n 19: checkcast #160 // class java/util/Map\n 22: astore_3\n 23: iconst_1\n 24: anewarray #154 // class utils/Graph$Vertex\n 27: astore 5\n 29: aload 5\n 31: iconst_0\n 32: aload_1\n 33: aastore\n 34: aload 5\n 36: invokestatic #200 // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;\n 39: astore 4\n 41: new #202 // class java/util/LinkedHashSet\n 44: dup\n 45: invokespecial #203 // Method java/util/LinkedHashSet.\"<init>\":()V\n 48: checkcast #205 // class java/util/Set\n 51: astore 5\n 53: iconst_1\n 54: anewarray #207 // class kotlin/Pair\n 57: astore 7\n 59: aload 7\n 61: iconst_0\n 62: aload_1\n 63: dconst_0\n 64: invokestatic #213 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 67: invokestatic #218 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 70: aastore\n 71: aload 7\n 73: invokestatic #222 // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 76: astore 6\n 78: aload_0\n 79: aload_1\n 80: aload_2\n 81: invokespecial #224 // Method findRouteOrElseCreateIt:(Lutils/Graph$Vertex;Lutils/Graph$Vertex;)Lutils/Graph$Edge;\n 84: astore 7\n 86: iconst_1\n 87: anewarray #207 // class kotlin/Pair\n 90: astore 9\n 92: aload 9\n 94: iconst_0\n 95: aload_1\n 96: aload_0\n 97: aload 7\n 99: invokespecial #226 // Method getCost:(Lutils/Graph$Edge;)D\n 102: invokestatic #213 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 105: invokestatic #218 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 108: aastore\n 109: aload 9\n 111: invokestatic #222 // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 114: astore 8\n 116: aload 4\n 118: checkcast #228 // class java/util/Collection\n 121: invokeinterface #231, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 126: ifne 133\n 129: iconst_1\n 130: goto 134\n 133: iconst_0\n 134: ifeq 560\n 137: aload 4\n 139: checkcast #32 // class java/lang/Iterable\n 142: astore 10\n 144: iconst_0\n 145: istore 11\n 147: aload 10\n 149: invokeinterface #115, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 154: astore 12\n 156: aload 12\n 158: invokeinterface #121, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 163: ifne 170\n 166: aconst_null\n 167: goto 283\n 170: aload 12\n 172: invokeinterface #125, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 177: astore 13\n 179: aload 12\n 181: invokeinterface #121, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 186: ifne 194\n 189: aload 13\n 191: goto 283\n 194: aload 13\n 196: checkcast #154 // class utils/Graph$Vertex\n 199: astore 14\n 201: iconst_0\n 202: istore 16\n 204: aload 8\n 206: aload 14\n 208: invokestatic #170 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 211: checkcast #233 // class java/lang/Number\n 214: invokevirtual #237 // Method java/lang/Number.doubleValue:()D\n 217: dstore 14\n 219: aload 12\n 221: invokeinterface #125, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 226: astore 16\n 228: aload 16\n 230: checkcast #154 // class utils/Graph$Vertex\n 233: astore 17\n 235: iconst_0\n 236: istore 19\n 238: aload 8\n 240: aload 17\n 242: invokestatic #170 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 245: checkcast #233 // class java/lang/Number\n 248: invokevirtual #237 // Method java/lang/Number.doubleValue:()D\n 251: dstore 17\n 253: dload 14\n 255: dload 17\n 257: invokestatic #241 // Method java/lang/Double.compare:(DD)I\n 260: ifle 271\n 263: aload 16\n 265: astore 13\n 267: dload 17\n 269: dstore 14\n 271: aload 12\n 273: invokeinterface #121, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 278: ifne 219\n 281: aload 13\n 283: dup\n 284: invokestatic #245 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 287: checkcast #154 // class utils/Graph$Vertex\n 290: astore 9\n 292: aload 9\n 294: aload_2\n 295: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 298: ifeq 326\n 301: aload_0\n 302: aload 9\n 304: aload_3\n 305: invokespecial #247 // Method generatePath:(Lutils/Graph$Vertex;Ljava/util/Map;)Ljava/util/List;\n 308: astore 10\n 310: new #207 // class kotlin/Pair\n 313: dup\n 314: aload 10\n 316: aload 8\n 318: aload_2\n 319: invokestatic #170 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 322: invokespecial #250 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 325: areturn\n 326: aload 4\n 328: aload 9\n 330: invokeinterface #253, 2 // InterfaceMethod java/util/Set.remove:(Ljava/lang/Object;)Z\n 335: pop\n 336: aload 5\n 338: aload 9\n 340: invokeinterface #255, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 345: pop\n 346: aload_0\n 347: aload 9\n 349: invokespecial #257 // Method getNeighbors:(Lutils/Graph$Vertex;)Ljava/util/List;\n 352: checkcast #32 // class java/lang/Iterable\n 355: aload 5\n 357: checkcast #32 // class java/lang/Iterable\n 360: invokestatic #261 // Method kotlin/collections/CollectionsKt.minus:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;\n 363: checkcast #32 // class java/lang/Iterable\n 366: astore 10\n 368: iconst_0\n 369: istore 11\n 371: aload 10\n 373: invokeinterface #115, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 378: astore 12\n 380: aload 12\n 382: invokeinterface #121, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 387: ifeq 556\n 390: aload 12\n 392: invokeinterface #125, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 397: astore 13\n 399: aload 13\n 401: checkcast #154 // class utils/Graph$Vertex\n 404: astore 14\n 406: iconst_0\n 407: istore 16\n 409: aload_0\n 410: aload_0\n 411: aload 9\n 413: aload 14\n 415: invokespecial #224 // Method findRouteOrElseCreateIt:(Lutils/Graph$Vertex;Lutils/Graph$Vertex;)Lutils/Graph$Edge;\n 418: invokespecial #226 // Method getCost:(Lutils/Graph$Edge;)D\n 421: dstore 17\n 423: aload 6\n 425: aload 9\n 427: invokestatic #170 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 430: checkcast #233 // class java/lang/Number\n 433: invokevirtual #237 // Method java/lang/Number.doubleValue:()D\n 436: dload 17\n 438: dadd\n 439: dstore 20\n 441: dload 20\n 443: aload 6\n 445: aload 14\n 447: ldc2_w #262 // double 1.7976931348623157E308d\n 450: invokestatic #213 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 453: invokeinterface #267, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 458: checkcast #233 // class java/lang/Number\n 461: invokevirtual #237 // Method java/lang/Number.doubleValue:()D\n 464: dcmpg\n 465: ifge 551\n 468: aload 4\n 470: aload 14\n 472: invokeinterface #270, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 477: ifne 490\n 480: aload 4\n 482: aload 14\n 484: invokeinterface #255, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 489: pop\n 490: aload_3\n 491: aload 14\n 493: aload 9\n 495: invokeinterface #273, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 500: pop\n 501: dload 20\n 503: invokestatic #213 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 506: astore 22\n 508: aload 6\n 510: aload 14\n 512: aload 22\n 514: invokeinterface #273, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 519: pop\n 520: aload_0\n 521: aload_0\n 522: aload 14\n 524: aload_2\n 525: invokespecial #224 // Method findRouteOrElseCreateIt:(Lutils/Graph$Vertex;Lutils/Graph$Vertex;)Lutils/Graph$Edge;\n 528: invokespecial #226 // Method getCost:(Lutils/Graph$Edge;)D\n 531: dstore 23\n 533: aload 8\n 535: aload 14\n 537: dload 20\n 539: dload 23\n 541: dadd\n 542: invokestatic #213 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 545: invokeinterface #273, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 550: pop\n 551: nop\n 552: nop\n 553: goto 380\n 556: nop\n 557: goto 116\n 560: new #275 // class java/lang/IllegalArgumentException\n 563: dup\n 564: new #277 // class java/lang/StringBuilder\n 567: dup\n 568: invokespecial #278 // Method java/lang/StringBuilder.\"<init>\":()V\n 571: ldc_w #280 // String No Path from Start\n 574: invokevirtual #284 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 577: aload_1\n 578: invokevirtual #287 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 581: ldc_w #289 // String to Finish\n 584: invokevirtual #284 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 587: aload_2\n 588: invokevirtual #287 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 591: invokevirtual #293 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 594: invokespecial #296 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 597: athrow\n\n private static final boolean _get_neighbors_$lambda$0(utils.Graph$Vertex, utils.Graph$Edge);\n Code:\n 0: aload_1\n 1: ldc_w #323 // String it\n 4: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: invokeinterface #131, 1 // InterfaceMethod utils/Graph$Edge.getA:()Lutils/Graph$Vertex;\n 13: aload_0\n 14: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 17: ifne 33\n 20: aload_1\n 21: invokeinterface #138, 1 // InterfaceMethod utils/Graph$Edge.getB:()Lutils/Graph$Vertex;\n 26: aload_0\n 27: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 30: ifeq 37\n 33: iconst_1\n 34: goto 38\n 37: iconst_0\n 38: ireturn\n\n private static final java.util.List _get_neighbors_$lambda$1(utils.Graph$Edge);\n Code:\n 0: aload_0\n 1: ldc_w #323 // String it\n 4: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: iconst_2\n 8: anewarray #154 // class utils/Graph$Vertex\n 11: astore_1\n 12: aload_1\n 13: iconst_0\n 14: aload_0\n 15: invokeinterface #131, 1 // InterfaceMethod utils/Graph$Edge.getA:()Lutils/Graph$Vertex;\n 20: aastore\n 21: aload_1\n 22: iconst_1\n 23: aload_0\n 24: invokeinterface #138, 1 // InterfaceMethod utils/Graph$Edge.getB:()Lutils/Graph$Vertex;\n 29: aastore\n 30: aload_1\n 31: invokestatic #327 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 34: areturn\n\n private static final boolean _get_neighbors_$lambda$2(utils.Graph$Vertex, utils.Graph$Vertex);\n Code:\n 0: aload_1\n 1: ldc_w #323 // String it\n 4: invokestatic #19 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: aload_0\n 9: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 12: ireturn\n}\n", "javap_err": "" } ]