kt_path
stringlengths
35
167
kt_source
stringlengths
626
28.9k
classes
listlengths
1
17
nerok__Advent-of-code-2021__7553c28/src/main/kotlin/day9.kt
import java.io.File fun main(args: Array<String>) { day9part2() } fun day9part1() { var coordinates = mutableListOf<List<Int>>() val input = File("day9input.txt").bufferedReader().readLines() input.mapIndexed { index, line -> line.split("") .filterNot { it == "" } .map { it.toInt() } .let { coordinates.add(index, it) } } findLocalMinimas(coordinates).map { coordinates[it.first][it.second]+1 }.sum().also { println(it) } } fun day9part2() { var coordinates = mutableListOf<List<Int>>() val input = File("day9input.txt").bufferedReader().readLines() input.mapIndexed { index, line -> line.split("") .filterNot { it == "" } .map { it.toInt() } .let { coordinates.add(index, it) } } val limits = findBasinLimits(coordinates) println("Total size: ${coordinates.size * coordinates.first().size}") println("Nines: ${limits.size}") val score = clusterBaisins(coordinates, limits) .map { it.value.size } .sorted() .also { "Non-nines: ${println(it.sum())}" } .takeLast(3) .reduce { acc: Int, i: Int -> acc * i } println("Score $score") } fun clusterBaisins(map: MutableList<List<Int>>, basinLimits: Set<Pair<Int,Int>>): Map<Int, Set<Pair<Int,Int>>> { var nextCluster = 0 val clusterMap = mutableMapOf<Int, Set<Pair<Int,Int>>>() val clusterIndex = mutableMapOf<Pair<Int,Int>, Int>() map.forEachIndexed { rowIndex, row -> row.forEachIndexed { index, point -> if (point == 9) return@forEachIndexed val columnNeighbours = when (rowIndex) { 0 -> { listOf(rowIndex+1 to index to clusterIndex.getOrDefault(rowIndex+1 to index, -1)) } map.size - 1 -> { listOf(rowIndex-1 to index to clusterIndex.getOrDefault(rowIndex-1 to index, -1)) } else -> { listOf( rowIndex-1 to index to clusterIndex.getOrDefault(rowIndex-1 to index, -1), rowIndex+1 to index to clusterIndex.getOrDefault(rowIndex+1 to index, -1) ) } } val rowNeighbours = when(index) { 0 -> { listOf(rowIndex to index + 1 to clusterIndex.getOrDefault(rowIndex to index + 1, -1)) } row.size - 1 -> { listOf(rowIndex to index - 1 to clusterIndex.getOrDefault(rowIndex to index - 1, -1)) } else -> { listOf( rowIndex to index-1 to clusterIndex.getOrDefault(rowIndex to index-1, -1), rowIndex to index+1 to clusterIndex.getOrDefault(rowIndex to index+1, -1) ) } } val neighbours = columnNeighbours + rowNeighbours if (neighbours.none { it.second != -1 }) { val neighbourhood = (neighbours.map { it.first } + (rowIndex to index)) .filter { map[it.first][it.second] != 9 } .toSet() clusterMap[nextCluster] = neighbourhood neighbourhood.forEach { clusterIndex[it] = nextCluster } nextCluster = nextCluster.inc() } else { val neighbourhood = (neighbours.map { it.first } + (rowIndex to index)) .filter { map[it.first][it.second] != 9 } .toMutableSet() var cluster = -1 neighbourhood.map { if (cluster == -1) { cluster = clusterIndex.getOrDefault(it, -1) } else { val neighbourIndex = clusterIndex[it] if (neighbourIndex != null && cluster != neighbourIndex) { println("Cluster: $cluster, neighbour: ${neighbourIndex}, it: $it") val newCluster = minOf(cluster, neighbourIndex) val neighbourhood1 = clusterMap.getOrDefault(neighbourIndex, emptySet()) clusterMap.remove(neighbourIndex) val neighbourhood2 = clusterMap.getOrDefault(cluster, emptySet()) clusterMap.remove(cluster) val newNeighbourhood = neighbourhood1 + neighbourhood2 newNeighbourhood.forEach { clusterIndex[it] = newCluster } clusterMap[newCluster] = newNeighbourhood } } } neighbourhood.forEach { clusterIndex[it] = cluster } clusterMap[cluster]?.let { neighbourhood.addAll(it) } clusterMap[cluster] = neighbourhood } } } return clusterMap } fun findBasinLimits(map: MutableList<List<Int>>): Set<Pair<Int,Int>> { val limits = mutableSetOf<Pair<Int,Int>>() map.forEachIndexed { rowIndex, row -> row.forEachIndexed { index, point -> if (point == 9) limits.add(rowIndex to index) } } return limits } fun findLocalMinimas(map: MutableList<List<Int>>): List<Pair<Int,Int>> { val minimas = mutableListOf<Pair<Int,Int>>() map.forEachIndexed { rowIndex, row -> row.forEachIndexed { index, point -> val possibleMinima = when (index) { 0 -> { point < row[index+1] } row.size-1 -> { point < row[index-1] } else -> { (point < row[index-1]) && (point < row[index+1]) } } //println("Row $rowIndex, column $index: $possibleMinima") if (!possibleMinima) { return@forEachIndexed } val localMinima = when (rowIndex) { 0 -> { point < map[rowIndex+1][index] } map.size-1 -> { point < map[rowIndex-1][index] } else -> { (point < map[rowIndex-1][index]) && (point < map[rowIndex+1][index]) } } if (localMinima) { minimas.add(rowIndex to index) } } } return minimas }
[ { "class_path": "nerok__Advent-of-code-2021__7553c28/Day9Kt.class", "javap": "Compiled from \"day9.kt\"\npublic final class Day9Kt {\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: invokestatic #19 // Method day9part2:()V\n 9: return\n\n public static final void day9part1();\n Code:\n 0: aconst_null\n 1: astore_0\n 2: new #23 // class java/util/ArrayList\n 5: dup\n 6: invokespecial #26 // Method java/util/ArrayList.\"<init>\":()V\n 9: checkcast #28 // class java/util/List\n 12: astore_0\n 13: new #30 // class java/io/File\n 16: dup\n 17: ldc #32 // String day9input.txt\n 19: invokespecial #35 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 22: astore_2\n 23: getstatic #41 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 26: astore_3\n 27: sipush 8192\n 30: istore 4\n 32: aload_2\n 33: astore 5\n 35: new #43 // class java/io/InputStreamReader\n 38: dup\n 39: new #45 // class java/io/FileInputStream\n 42: dup\n 43: aload 5\n 45: invokespecial #48 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 48: checkcast #50 // class java/io/InputStream\n 51: aload_3\n 52: invokespecial #53 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 55: checkcast #55 // class java/io/Reader\n 58: astore 5\n 60: aload 5\n 62: instanceof #57 // class java/io/BufferedReader\n 65: ifeq 76\n 68: aload 5\n 70: checkcast #57 // class java/io/BufferedReader\n 73: goto 87\n 76: new #57 // class java/io/BufferedReader\n 79: dup\n 80: aload 5\n 82: iload 4\n 84: invokespecial #60 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 87: checkcast #55 // class java/io/Reader\n 90: invokestatic #66 // Method kotlin/io/TextStreamsKt.readLines:(Ljava/io/Reader;)Ljava/util/List;\n 93: astore_1\n 94: aload_1\n 95: checkcast #68 // class java/lang/Iterable\n 98: astore_2\n 99: iconst_0\n 100: istore_3\n 101: aload_2\n 102: astore 4\n 104: new #23 // class java/util/ArrayList\n 107: dup\n 108: aload_2\n 109: bipush 10\n 111: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 114: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 117: checkcast #79 // class java/util/Collection\n 120: astore 5\n 122: iconst_0\n 123: istore 6\n 125: iconst_0\n 126: istore 7\n 128: aload 4\n 130: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 135: astore 8\n 137: aload 8\n 139: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 144: ifeq 446\n 147: aload 8\n 149: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 154: astore 9\n 156: aload 5\n 158: iload 7\n 160: iinc 7, 1\n 163: istore 10\n 165: iload 10\n 167: ifge 173\n 170: invokestatic #96 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 173: iload 10\n 175: aload 9\n 177: checkcast #98 // class java/lang/String\n 180: astore 11\n 182: istore 12\n 184: astore 24\n 186: iconst_0\n 187: istore 13\n 189: aload 11\n 191: checkcast #100 // class java/lang/CharSequence\n 194: iconst_1\n 195: anewarray #98 // class java/lang/String\n 198: astore 14\n 200: aload 14\n 202: iconst_0\n 203: ldc #102 // String\n 205: aastore\n 206: aload 14\n 208: iconst_0\n 209: iconst_0\n 210: bipush 6\n 212: aconst_null\n 213: invokestatic #108 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 216: checkcast #68 // class java/lang/Iterable\n 219: astore 14\n 221: nop\n 222: iconst_0\n 223: istore 15\n 225: aload 14\n 227: astore 16\n 229: new #23 // class java/util/ArrayList\n 232: dup\n 233: invokespecial #26 // Method java/util/ArrayList.\"<init>\":()V\n 236: checkcast #79 // class java/util/Collection\n 239: astore 17\n 241: iconst_0\n 242: istore 18\n 244: aload 16\n 246: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 251: astore 19\n 253: aload 19\n 255: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 260: ifeq 305\n 263: aload 19\n 265: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 270: astore 20\n 272: aload 20\n 274: checkcast #98 // class java/lang/String\n 277: astore 21\n 279: iconst_0\n 280: istore 22\n 282: aload 21\n 284: ldc #102 // String\n 286: invokestatic #112 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 289: ifne 253\n 292: aload 17\n 294: aload 20\n 296: invokeinterface #116, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 301: pop\n 302: goto 253\n 305: aload 17\n 307: checkcast #28 // class java/util/List\n 310: nop\n 311: checkcast #68 // class java/lang/Iterable\n 314: astore 14\n 316: nop\n 317: iconst_0\n 318: istore 15\n 320: aload 14\n 322: astore 16\n 324: new #23 // class java/util/ArrayList\n 327: dup\n 328: aload 14\n 330: bipush 10\n 332: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 335: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 338: checkcast #79 // class java/util/Collection\n 341: astore 17\n 343: iconst_0\n 344: istore 18\n 346: aload 16\n 348: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 353: astore 19\n 355: aload 19\n 357: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 362: ifeq 409\n 365: aload 19\n 367: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 372: astore 20\n 374: aload 17\n 376: aload 20\n 378: checkcast #98 // class java/lang/String\n 381: astore 21\n 383: astore 23\n 385: iconst_0\n 386: istore 22\n 388: aload 21\n 390: invokestatic #122 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 393: nop\n 394: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 397: aload 23\n 399: swap\n 400: invokeinterface #116, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 405: pop\n 406: goto 355\n 409: aload 17\n 411: checkcast #28 // class java/util/List\n 414: nop\n 415: astore 15\n 417: iconst_0\n 418: istore 16\n 420: aload_0\n 421: iload 12\n 423: aload 15\n 425: invokeinterface #129, 3 // InterfaceMethod java/util/List.add:(ILjava/lang/Object;)V\n 430: nop\n 431: nop\n 432: aload 24\n 434: getstatic #135 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 437: invokeinterface #116, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 442: pop\n 443: goto 137\n 446: aload 5\n 448: checkcast #28 // class java/util/List\n 451: nop\n 452: pop\n 453: aload_0\n 454: invokestatic #139 // Method findLocalMinimas:(Ljava/util/List;)Ljava/util/List;\n 457: checkcast #68 // class java/lang/Iterable\n 460: astore_2\n 461: iconst_0\n 462: istore_3\n 463: aload_2\n 464: astore 4\n 466: new #23 // class java/util/ArrayList\n 469: dup\n 470: aload_2\n 471: bipush 10\n 473: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 476: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 479: checkcast #79 // class java/util/Collection\n 482: astore 5\n 484: iconst_0\n 485: istore 6\n 487: aload 4\n 489: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 494: astore 7\n 496: aload 7\n 498: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 503: ifeq 588\n 506: aload 7\n 508: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 513: astore 8\n 515: aload 5\n 517: aload 8\n 519: checkcast #141 // class kotlin/Pair\n 522: astore 9\n 524: astore 24\n 526: iconst_0\n 527: istore 10\n 529: aload_0\n 530: aload 9\n 532: invokevirtual #144 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 535: checkcast #146 // class java/lang/Number\n 538: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 541: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 546: checkcast #28 // class java/util/List\n 549: aload 9\n 551: invokevirtual #157 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 554: checkcast #146 // class java/lang/Number\n 557: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 560: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 565: checkcast #146 // class java/lang/Number\n 568: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 571: iconst_1\n 572: iadd\n 573: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 576: aload 24\n 578: swap\n 579: invokeinterface #116, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 584: pop\n 585: goto 496\n 588: aload 5\n 590: checkcast #28 // class java/util/List\n 593: nop\n 594: checkcast #68 // class java/lang/Iterable\n 597: invokestatic #161 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 600: istore_2\n 601: iload_2\n 602: istore_3\n 603: iconst_0\n 604: istore 4\n 606: getstatic #167 // Field java/lang/System.out:Ljava/io/PrintStream;\n 609: iload_3\n 610: invokevirtual #172 // Method java/io/PrintStream.println:(I)V\n 613: nop\n 614: nop\n 615: return\n\n public static final void day9part2();\n Code:\n 0: aconst_null\n 1: astore_0\n 2: new #23 // class java/util/ArrayList\n 5: dup\n 6: invokespecial #26 // Method java/util/ArrayList.\"<init>\":()V\n 9: checkcast #28 // class java/util/List\n 12: astore_0\n 13: new #30 // class java/io/File\n 16: dup\n 17: ldc #32 // String day9input.txt\n 19: invokespecial #35 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 22: astore_2\n 23: getstatic #41 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 26: astore_3\n 27: sipush 8192\n 30: istore 4\n 32: aload_2\n 33: astore 5\n 35: new #43 // class java/io/InputStreamReader\n 38: dup\n 39: new #45 // class java/io/FileInputStream\n 42: dup\n 43: aload 5\n 45: invokespecial #48 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 48: checkcast #50 // class java/io/InputStream\n 51: aload_3\n 52: invokespecial #53 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 55: checkcast #55 // class java/io/Reader\n 58: astore 5\n 60: aload 5\n 62: instanceof #57 // class java/io/BufferedReader\n 65: ifeq 76\n 68: aload 5\n 70: checkcast #57 // class java/io/BufferedReader\n 73: goto 87\n 76: new #57 // class java/io/BufferedReader\n 79: dup\n 80: aload 5\n 82: iload 4\n 84: invokespecial #60 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 87: checkcast #55 // class java/io/Reader\n 90: invokestatic #66 // Method kotlin/io/TextStreamsKt.readLines:(Ljava/io/Reader;)Ljava/util/List;\n 93: astore_1\n 94: aload_1\n 95: checkcast #68 // class java/lang/Iterable\n 98: astore_2\n 99: iconst_0\n 100: istore_3\n 101: aload_2\n 102: astore 4\n 104: new #23 // class java/util/ArrayList\n 107: dup\n 108: aload_2\n 109: bipush 10\n 111: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 114: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 117: checkcast #79 // class java/util/Collection\n 120: astore 5\n 122: iconst_0\n 123: istore 6\n 125: iconst_0\n 126: istore 7\n 128: aload 4\n 130: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 135: astore 8\n 137: aload 8\n 139: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 144: ifeq 446\n 147: aload 8\n 149: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 154: astore 9\n 156: aload 5\n 158: iload 7\n 160: iinc 7, 1\n 163: istore 10\n 165: iload 10\n 167: ifge 173\n 170: invokestatic #96 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 173: iload 10\n 175: aload 9\n 177: checkcast #98 // class java/lang/String\n 180: astore 11\n 182: istore 12\n 184: astore 24\n 186: iconst_0\n 187: istore 13\n 189: aload 11\n 191: checkcast #100 // class java/lang/CharSequence\n 194: iconst_1\n 195: anewarray #98 // class java/lang/String\n 198: astore 14\n 200: aload 14\n 202: iconst_0\n 203: ldc #102 // String\n 205: aastore\n 206: aload 14\n 208: iconst_0\n 209: iconst_0\n 210: bipush 6\n 212: aconst_null\n 213: invokestatic #108 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 216: checkcast #68 // class java/lang/Iterable\n 219: astore 14\n 221: nop\n 222: iconst_0\n 223: istore 15\n 225: aload 14\n 227: astore 16\n 229: new #23 // class java/util/ArrayList\n 232: dup\n 233: invokespecial #26 // Method java/util/ArrayList.\"<init>\":()V\n 236: checkcast #79 // class java/util/Collection\n 239: astore 17\n 241: iconst_0\n 242: istore 18\n 244: aload 16\n 246: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 251: astore 19\n 253: aload 19\n 255: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 260: ifeq 305\n 263: aload 19\n 265: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 270: astore 20\n 272: aload 20\n 274: checkcast #98 // class java/lang/String\n 277: astore 21\n 279: iconst_0\n 280: istore 22\n 282: aload 21\n 284: ldc #102 // String\n 286: invokestatic #112 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 289: ifne 253\n 292: aload 17\n 294: aload 20\n 296: invokeinterface #116, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 301: pop\n 302: goto 253\n 305: aload 17\n 307: checkcast #28 // class java/util/List\n 310: nop\n 311: checkcast #68 // class java/lang/Iterable\n 314: astore 14\n 316: nop\n 317: iconst_0\n 318: istore 15\n 320: aload 14\n 322: astore 16\n 324: new #23 // class java/util/ArrayList\n 327: dup\n 328: aload 14\n 330: bipush 10\n 332: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 335: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 338: checkcast #79 // class java/util/Collection\n 341: astore 17\n 343: iconst_0\n 344: istore 18\n 346: aload 16\n 348: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 353: astore 19\n 355: aload 19\n 357: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 362: ifeq 409\n 365: aload 19\n 367: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 372: astore 20\n 374: aload 17\n 376: aload 20\n 378: checkcast #98 // class java/lang/String\n 381: astore 21\n 383: astore 23\n 385: iconst_0\n 386: istore 22\n 388: aload 21\n 390: invokestatic #122 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 393: nop\n 394: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 397: aload 23\n 399: swap\n 400: invokeinterface #116, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 405: pop\n 406: goto 355\n 409: aload 17\n 411: checkcast #28 // class java/util/List\n 414: nop\n 415: astore 15\n 417: iconst_0\n 418: istore 16\n 420: aload_0\n 421: iload 12\n 423: aload 15\n 425: invokeinterface #129, 3 // InterfaceMethod java/util/List.add:(ILjava/lang/Object;)V\n 430: nop\n 431: nop\n 432: aload 24\n 434: getstatic #135 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 437: invokeinterface #116, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 442: pop\n 443: goto 137\n 446: aload 5\n 448: checkcast #28 // class java/util/List\n 451: nop\n 452: pop\n 453: aload_0\n 454: invokestatic #212 // Method findBasinLimits:(Ljava/util/List;)Ljava/util/Set;\n 457: astore_2\n 458: new #214 // class java/lang/StringBuilder\n 461: dup\n 462: invokespecial #215 // Method java/lang/StringBuilder.\"<init>\":()V\n 465: ldc #217 // String Total size:\n 467: invokevirtual #221 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 470: aload_0\n 471: invokeinterface #224, 1 // InterfaceMethod java/util/List.size:()I\n 476: aload_0\n 477: invokestatic #228 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 480: checkcast #28 // class java/util/List\n 483: invokeinterface #224, 1 // InterfaceMethod java/util/List.size:()I\n 488: imul\n 489: invokevirtual #231 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 492: invokevirtual #235 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 495: getstatic #167 // Field java/lang/System.out:Ljava/io/PrintStream;\n 498: swap\n 499: invokevirtual #238 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 502: new #214 // class java/lang/StringBuilder\n 505: dup\n 506: invokespecial #215 // Method java/lang/StringBuilder.\"<init>\":()V\n 509: ldc #240 // String Nines:\n 511: invokevirtual #221 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 514: aload_2\n 515: invokeinterface #243, 1 // InterfaceMethod java/util/Set.size:()I\n 520: invokevirtual #231 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 523: invokevirtual #235 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 526: getstatic #167 // Field java/lang/System.out:Ljava/io/PrintStream;\n 529: swap\n 530: invokevirtual #238 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 533: aload_0\n 534: aload_2\n 535: invokestatic #247 // Method clusterBaisins:(Ljava/util/List;Ljava/util/Set;)Ljava/util/Map;\n 538: astore 4\n 540: nop\n 541: iconst_0\n 542: istore 5\n 544: aload 4\n 546: astore 6\n 548: new #23 // class java/util/ArrayList\n 551: dup\n 552: aload 4\n 554: invokeinterface #250, 1 // InterfaceMethod java/util/Map.size:()I\n 559: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 562: checkcast #79 // class java/util/Collection\n 565: astore 7\n 567: iconst_0\n 568: istore 8\n 570: aload 6\n 572: invokeinterface #254, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 577: invokeinterface #255, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 582: astore 9\n 584: aload 9\n 586: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 591: ifeq 647\n 594: aload 9\n 596: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 601: checkcast #257 // class java/util/Map$Entry\n 604: astore 10\n 606: aload 7\n 608: aload 10\n 610: astore 11\n 612: astore 24\n 614: iconst_0\n 615: istore 12\n 617: aload 11\n 619: invokeinterface #260, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 624: checkcast #242 // class java/util/Set\n 627: invokeinterface #243, 1 // InterfaceMethod java/util/Set.size:()I\n 632: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 635: aload 24\n 637: swap\n 638: invokeinterface #116, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 643: pop\n 644: goto 584\n 647: aload 7\n 649: checkcast #28 // class java/util/List\n 652: nop\n 653: checkcast #68 // class java/lang/Iterable\n 656: invokestatic #264 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 659: astore 4\n 661: aload 4\n 663: astore 5\n 665: iconst_0\n 666: istore 6\n 668: new #214 // class java/lang/StringBuilder\n 671: dup\n 672: invokespecial #215 // Method java/lang/StringBuilder.\"<init>\":()V\n 675: ldc_w #266 // String Non-nines:\n 678: invokevirtual #221 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 681: aload 5\n 683: checkcast #68 // class java/lang/Iterable\n 686: invokestatic #161 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 689: istore 7\n 691: getstatic #167 // Field java/lang/System.out:Ljava/io/PrintStream;\n 694: iload 7\n 696: invokevirtual #172 // Method java/io/PrintStream.println:(I)V\n 699: getstatic #135 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 702: invokevirtual #269 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 705: invokevirtual #235 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 708: pop\n 709: aload 4\n 711: iconst_3\n 712: invokestatic #273 // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;\n 715: checkcast #68 // class java/lang/Iterable\n 718: astore 4\n 720: nop\n 721: iconst_0\n 722: istore 5\n 724: aload 4\n 726: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 731: astore 6\n 733: aload 6\n 735: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 740: ifne 754\n 743: new #275 // class java/lang/UnsupportedOperationException\n 746: dup\n 747: ldc_w #277 // String Empty collection can\\'t be reduced.\n 750: invokespecial #278 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 753: athrow\n 754: aload 6\n 756: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 761: astore 7\n 763: aload 6\n 765: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 770: ifeq 814\n 773: aload 7\n 775: aload 6\n 777: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 782: checkcast #146 // class java/lang/Number\n 785: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 788: istore 8\n 790: checkcast #146 // class java/lang/Number\n 793: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 796: istore 9\n 798: iconst_0\n 799: istore 10\n 801: iload 9\n 803: iload 8\n 805: imul\n 806: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 809: astore 7\n 811: goto 763\n 814: aload 7\n 816: checkcast #146 // class java/lang/Number\n 819: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 822: istore_3\n 823: new #214 // class java/lang/StringBuilder\n 826: dup\n 827: invokespecial #215 // Method java/lang/StringBuilder.\"<init>\":()V\n 830: ldc_w #280 // String Score\n 833: invokevirtual #221 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 836: iload_3\n 837: invokevirtual #231 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 840: invokevirtual #235 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 843: getstatic #167 // Field java/lang/System.out:Ljava/io/PrintStream;\n 846: swap\n 847: invokevirtual #238 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 850: return\n\n public static final java.util.Map<java.lang.Integer, java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>>> clusterBaisins(java.util.List<java.util.List<java.lang.Integer>>, java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: ldc_w #302 // String map\n 4: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: ldc_w #304 // String basinLimits\n 11: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: iconst_0\n 15: istore_2\n 16: new #306 // class java/util/LinkedHashMap\n 19: dup\n 20: invokespecial #307 // Method java/util/LinkedHashMap.\"<init>\":()V\n 23: checkcast #249 // class java/util/Map\n 26: astore_3\n 27: new #306 // class java/util/LinkedHashMap\n 30: dup\n 31: invokespecial #307 // Method java/util/LinkedHashMap.\"<init>\":()V\n 34: checkcast #249 // class java/util/Map\n 37: astore 4\n 39: aload_0\n 40: checkcast #68 // class java/lang/Iterable\n 43: astore 5\n 45: iconst_0\n 46: istore 6\n 48: iconst_0\n 49: istore 7\n 51: aload 5\n 53: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 58: astore 8\n 60: aload 8\n 62: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 67: ifeq 1925\n 70: aload 8\n 72: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 77: astore 9\n 79: iload 7\n 81: iinc 7, 1\n 84: istore 10\n 86: iload 10\n 88: ifge 94\n 91: invokestatic #96 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 94: iload 10\n 96: aload 9\n 98: checkcast #28 // class java/util/List\n 101: astore 11\n 103: istore 12\n 105: iconst_0\n 106: istore 13\n 108: aload 11\n 110: checkcast #68 // class java/lang/Iterable\n 113: astore 14\n 115: iconst_0\n 116: istore 15\n 118: iconst_0\n 119: istore 16\n 121: aload 14\n 123: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 128: astore 17\n 130: aload 17\n 132: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 137: ifeq 1919\n 140: aload 17\n 142: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 147: astore 18\n 149: iload 16\n 151: iinc 16, 1\n 154: istore 19\n 156: iload 19\n 158: ifge 164\n 161: invokestatic #96 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 164: iload 19\n 166: aload 18\n 168: checkcast #146 // class java/lang/Number\n 171: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 174: istore 20\n 176: istore 21\n 178: iconst_0\n 179: istore 22\n 181: iload 20\n 183: bipush 9\n 185: if_icmpeq 1915\n 188: iload 12\n 190: istore 23\n 192: iload 23\n 194: ifne 247\n 197: iload 12\n 199: iconst_1\n 200: iadd\n 201: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 204: iload 21\n 206: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 209: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 212: aload 4\n 214: iload 12\n 216: iconst_1\n 217: iadd\n 218: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 221: iload 21\n 223: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 226: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 229: iconst_m1\n 230: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 233: invokeinterface #317, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 238: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 241: invokestatic #321 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 244: goto 417\n 247: iload 23\n 249: aload_0\n 250: invokeinterface #224, 1 // InterfaceMethod java/util/List.size:()I\n 255: iconst_1\n 256: isub\n 257: if_icmpne 310\n 260: iload 12\n 262: iconst_1\n 263: isub\n 264: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 267: iload 21\n 269: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 272: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 275: aload 4\n 277: iload 12\n 279: iconst_1\n 280: isub\n 281: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 284: iload 21\n 286: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 289: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 292: iconst_m1\n 293: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 296: invokeinterface #317, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 301: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 304: invokestatic #321 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 307: goto 417\n 310: iconst_2\n 311: anewarray #141 // class kotlin/Pair\n 314: astore 24\n 316: aload 24\n 318: iconst_0\n 319: iload 12\n 321: iconst_1\n 322: isub\n 323: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 326: iload 21\n 328: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 331: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 334: aload 4\n 336: iload 12\n 338: iconst_1\n 339: isub\n 340: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 343: iload 21\n 345: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 348: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 351: iconst_m1\n 352: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 355: invokeinterface #317, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 360: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 363: aastore\n 364: aload 24\n 366: iconst_1\n 367: iload 12\n 369: iconst_1\n 370: iadd\n 371: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 374: iload 21\n 376: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 379: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 382: aload 4\n 384: iload 12\n 386: iconst_1\n 387: iadd\n 388: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 391: iload 21\n 393: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 396: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 399: iconst_m1\n 400: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 403: invokeinterface #317, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 408: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 411: aastore\n 412: aload 24\n 414: invokestatic #324 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 417: astore 25\n 419: iload 21\n 421: istore 24\n 423: iload 24\n 425: ifne 478\n 428: iload 12\n 430: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 433: iload 21\n 435: iconst_1\n 436: iadd\n 437: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 440: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 443: aload 4\n 445: iload 12\n 447: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 450: iload 21\n 452: iconst_1\n 453: iadd\n 454: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 457: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 460: iconst_m1\n 461: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 464: invokeinterface #317, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 469: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 472: invokestatic #321 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 475: goto 649\n 478: iload 24\n 480: aload 11\n 482: invokeinterface #224, 1 // InterfaceMethod java/util/List.size:()I\n 487: iconst_1\n 488: isub\n 489: if_icmpne 542\n 492: iload 12\n 494: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 497: iload 21\n 499: iconst_1\n 500: isub\n 501: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 504: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 507: aload 4\n 509: iload 12\n 511: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 514: iload 21\n 516: iconst_1\n 517: isub\n 518: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 521: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 524: iconst_m1\n 525: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 528: invokeinterface #317, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 533: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 536: invokestatic #321 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 539: goto 649\n 542: iconst_2\n 543: anewarray #141 // class kotlin/Pair\n 546: astore 26\n 548: aload 26\n 550: iconst_0\n 551: iload 12\n 553: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 556: iload 21\n 558: iconst_1\n 559: isub\n 560: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 563: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 566: aload 4\n 568: iload 12\n 570: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 573: iload 21\n 575: iconst_1\n 576: isub\n 577: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 580: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 583: iconst_m1\n 584: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 587: invokeinterface #317, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 592: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 595: aastore\n 596: aload 26\n 598: iconst_1\n 599: iload 12\n 601: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 604: iload 21\n 606: iconst_1\n 607: iadd\n 608: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 611: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 614: aload 4\n 616: iload 12\n 618: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 621: iload 21\n 623: iconst_1\n 624: iadd\n 625: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 628: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 631: iconst_m1\n 632: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 635: invokeinterface #317, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 640: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 643: aastore\n 644: aload 26\n 646: invokestatic #324 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 649: astore 23\n 651: aload 25\n 653: checkcast #79 // class java/util/Collection\n 656: aload 23\n 658: checkcast #68 // class java/lang/Iterable\n 661: invokestatic #328 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 664: astore 24\n 666: aload 24\n 668: checkcast #68 // class java/lang/Iterable\n 671: astore 26\n 673: iconst_0\n 674: istore 27\n 676: aload 26\n 678: instanceof #79 // class java/util/Collection\n 681: ifeq 701\n 684: aload 26\n 686: checkcast #79 // class java/util/Collection\n 689: invokeinterface #331, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 694: ifeq 701\n 697: iconst_1\n 698: goto 767\n 701: aload 26\n 703: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 708: astore 28\n 710: aload 28\n 712: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 717: ifeq 766\n 720: aload 28\n 722: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 727: astore 29\n 729: aload 29\n 731: checkcast #141 // class kotlin/Pair\n 734: astore 30\n 736: iconst_0\n 737: istore 31\n 739: aload 30\n 741: invokevirtual #157 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 744: checkcast #146 // class java/lang/Number\n 747: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 750: iconst_m1\n 751: if_icmpeq 758\n 754: iconst_1\n 755: goto 759\n 758: iconst_0\n 759: ifeq 710\n 762: iconst_0\n 763: goto 767\n 766: iconst_1\n 767: ifeq 1129\n 770: aload 24\n 772: checkcast #68 // class java/lang/Iterable\n 775: astore 27\n 777: iconst_0\n 778: istore 28\n 780: aload 27\n 782: astore 29\n 784: new #23 // class java/util/ArrayList\n 787: dup\n 788: aload 27\n 790: bipush 10\n 792: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 795: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 798: checkcast #79 // class java/util/Collection\n 801: astore 30\n 803: iconst_0\n 804: istore 31\n 806: aload 29\n 808: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 813: astore 32\n 815: aload 32\n 817: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 822: ifeq 868\n 825: aload 32\n 827: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 832: astore 33\n 834: aload 30\n 836: aload 33\n 838: checkcast #141 // class kotlin/Pair\n 841: astore 34\n 843: astore 35\n 845: iconst_0\n 846: istore 36\n 848: aload 34\n 850: invokevirtual #144 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 853: checkcast #141 // class kotlin/Pair\n 856: aload 35\n 858: swap\n 859: invokeinterface #116, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 864: pop\n 865: goto 815\n 868: aload 30\n 870: checkcast #28 // class java/util/List\n 873: nop\n 874: checkcast #79 // class java/util/Collection\n 877: iload 12\n 879: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 882: iload 21\n 884: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 887: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 890: invokestatic #334 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 893: checkcast #68 // class java/lang/Iterable\n 896: astore 27\n 898: nop\n 899: iconst_0\n 900: istore 28\n 902: aload 27\n 904: astore 29\n 906: new #23 // class java/util/ArrayList\n 909: dup\n 910: invokespecial #26 // Method java/util/ArrayList.\"<init>\":()V\n 913: checkcast #79 // class java/util/Collection\n 916: astore 30\n 918: iconst_0\n 919: istore 31\n 921: aload 29\n 923: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 928: astore 32\n 930: aload 32\n 932: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 937: ifeq 1027\n 940: aload 32\n 942: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 947: astore 33\n 949: aload 33\n 951: checkcast #141 // class kotlin/Pair\n 954: astore 34\n 956: iconst_0\n 957: istore 36\n 959: aload_0\n 960: aload 34\n 962: invokevirtual #144 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 965: checkcast #146 // class java/lang/Number\n 968: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 971: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 976: checkcast #28 // class java/util/List\n 979: aload 34\n 981: invokevirtual #157 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 984: checkcast #146 // class java/lang/Number\n 987: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 990: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 995: checkcast #146 // class java/lang/Number\n 998: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 1001: bipush 9\n 1003: if_icmpeq 1010\n 1006: iconst_1\n 1007: goto 1011\n 1010: iconst_0\n 1011: ifeq 930\n 1014: aload 30\n 1016: aload 33\n 1018: invokeinterface #116, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 1023: pop\n 1024: goto 930\n 1027: aload 30\n 1029: checkcast #28 // class java/util/List\n 1032: nop\n 1033: checkcast #68 // class java/lang/Iterable\n 1036: invokestatic #338 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 1039: astore 26\n 1041: aload_3\n 1042: iload_2\n 1043: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1046: aload 26\n 1048: invokeinterface #341, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 1053: pop\n 1054: aload 26\n 1056: checkcast #68 // class java/lang/Iterable\n 1059: astore 27\n 1061: iconst_0\n 1062: istore 28\n 1064: aload 27\n 1066: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1071: astore 29\n 1073: aload 29\n 1075: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1080: ifeq 1121\n 1083: aload 29\n 1085: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1090: astore 30\n 1092: aload 30\n 1094: checkcast #141 // class kotlin/Pair\n 1097: astore 31\n 1099: iconst_0\n 1100: istore 32\n 1102: aload 4\n 1104: aload 31\n 1106: iload_2\n 1107: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1110: invokeinterface #341, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 1115: pop\n 1116: nop\n 1117: nop\n 1118: goto 1073\n 1121: nop\n 1122: iload_2\n 1123: iconst_1\n 1124: iadd\n 1125: istore_2\n 1126: goto 1914\n 1129: aload 24\n 1131: checkcast #68 // class java/lang/Iterable\n 1134: astore 27\n 1136: iconst_0\n 1137: istore 28\n 1139: aload 27\n 1141: astore 29\n 1143: new #23 // class java/util/ArrayList\n 1146: dup\n 1147: aload 27\n 1149: bipush 10\n 1151: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 1154: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 1157: checkcast #79 // class java/util/Collection\n 1160: astore 30\n 1162: iconst_0\n 1163: istore 31\n 1165: aload 29\n 1167: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1172: astore 32\n 1174: aload 32\n 1176: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1181: ifeq 1227\n 1184: aload 32\n 1186: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1191: astore 33\n 1193: aload 30\n 1195: aload 33\n 1197: checkcast #141 // class kotlin/Pair\n 1200: astore 34\n 1202: astore 35\n 1204: iconst_0\n 1205: istore 36\n 1207: aload 34\n 1209: invokevirtual #144 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 1212: checkcast #141 // class kotlin/Pair\n 1215: aload 35\n 1217: swap\n 1218: invokeinterface #116, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 1223: pop\n 1224: goto 1174\n 1227: aload 30\n 1229: checkcast #28 // class java/util/List\n 1232: nop\n 1233: checkcast #79 // class java/util/Collection\n 1236: iload 12\n 1238: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1241: iload 21\n 1243: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1246: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 1249: invokestatic #334 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 1252: checkcast #68 // class java/lang/Iterable\n 1255: astore 27\n 1257: nop\n 1258: iconst_0\n 1259: istore 28\n 1261: aload 27\n 1263: astore 29\n 1265: new #23 // class java/util/ArrayList\n 1268: dup\n 1269: invokespecial #26 // Method java/util/ArrayList.\"<init>\":()V\n 1272: checkcast #79 // class java/util/Collection\n 1275: astore 30\n 1277: iconst_0\n 1278: istore 31\n 1280: aload 29\n 1282: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1287: astore 32\n 1289: aload 32\n 1291: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1296: ifeq 1386\n 1299: aload 32\n 1301: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1306: astore 33\n 1308: aload 33\n 1310: checkcast #141 // class kotlin/Pair\n 1313: astore 34\n 1315: iconst_0\n 1316: istore 36\n 1318: aload_0\n 1319: aload 34\n 1321: invokevirtual #144 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 1324: checkcast #146 // class java/lang/Number\n 1327: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 1330: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 1335: checkcast #28 // class java/util/List\n 1338: aload 34\n 1340: invokevirtual #157 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 1343: checkcast #146 // class java/lang/Number\n 1346: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 1349: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 1354: checkcast #146 // class java/lang/Number\n 1357: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 1360: bipush 9\n 1362: if_icmpeq 1369\n 1365: iconst_1\n 1366: goto 1370\n 1369: iconst_0\n 1370: ifeq 1289\n 1373: aload 30\n 1375: aload 33\n 1377: invokeinterface #116, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 1382: pop\n 1383: goto 1289\n 1386: aload 30\n 1388: checkcast #28 // class java/util/List\n 1391: nop\n 1392: checkcast #68 // class java/lang/Iterable\n 1395: invokestatic #344 // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 1398: astore 26\n 1400: iconst_0\n 1401: istore 27\n 1403: iconst_m1\n 1404: istore 27\n 1406: aload 26\n 1408: checkcast #68 // class java/lang/Iterable\n 1411: astore 28\n 1413: iconst_0\n 1414: istore 29\n 1416: aload 28\n 1418: astore 30\n 1420: new #23 // class java/util/ArrayList\n 1423: dup\n 1424: aload 28\n 1426: bipush 10\n 1428: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 1431: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 1434: checkcast #79 // class java/util/Collection\n 1437: astore 31\n 1439: iconst_0\n 1440: istore 32\n 1442: aload 30\n 1444: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1449: astore 33\n 1451: aload 33\n 1453: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1458: ifeq 1783\n 1461: aload 33\n 1463: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1468: astore 34\n 1470: aload 31\n 1472: aload 34\n 1474: checkcast #141 // class kotlin/Pair\n 1477: astore 36\n 1479: astore 35\n 1481: iconst_0\n 1482: istore 37\n 1484: iload 27\n 1486: iconst_m1\n 1487: if_icmpne 1514\n 1490: aload 4\n 1492: aload 36\n 1494: iconst_m1\n 1495: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1498: invokeinterface #317, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 1503: checkcast #146 // class java/lang/Number\n 1506: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 1509: istore 27\n 1511: goto 1768\n 1514: aload 4\n 1516: aload 36\n 1518: invokeinterface #347, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 1523: checkcast #118 // class java/lang/Integer\n 1526: astore 38\n 1528: aload 38\n 1530: ifnull 1768\n 1533: iload 27\n 1535: aload 38\n 1537: invokevirtual #348 // Method java/lang/Integer.intValue:()I\n 1540: if_icmpeq 1768\n 1543: new #214 // class java/lang/StringBuilder\n 1546: dup\n 1547: invokespecial #215 // Method java/lang/StringBuilder.\"<init>\":()V\n 1550: ldc_w #350 // String Cluster:\n 1553: invokevirtual #221 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 1556: iload 27\n 1558: invokevirtual #231 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 1561: ldc_w #352 // String , neighbour:\n 1564: invokevirtual #221 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 1567: aload 38\n 1569: invokevirtual #269 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 1572: ldc_w #354 // String , it:\n 1575: invokevirtual #221 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 1578: aload 36\n 1580: invokevirtual #269 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 1583: invokevirtual #235 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 1586: getstatic #167 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1589: swap\n 1590: invokevirtual #238 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 1593: aload 38\n 1595: invokevirtual #348 // Method java/lang/Integer.intValue:()I\n 1598: istore 39\n 1600: iload 27\n 1602: iload 39\n 1604: invokestatic #360 // Method java/lang/Math.min:(II)I\n 1607: istore 40\n 1609: aload_3\n 1610: aload 38\n 1612: invokestatic #365 // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;\n 1615: invokeinterface #317, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 1620: checkcast #242 // class java/util/Set\n 1623: astore 41\n 1625: aload_3\n 1626: aload 38\n 1628: invokeinterface #368, 2 // InterfaceMethod java/util/Map.remove:(Ljava/lang/Object;)Ljava/lang/Object;\n 1633: pop\n 1634: aload_3\n 1635: iload 27\n 1637: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1640: invokestatic #365 // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;\n 1643: invokeinterface #317, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 1648: checkcast #242 // class java/util/Set\n 1651: astore 39\n 1653: aload_3\n 1654: iload 27\n 1656: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1659: invokeinterface #368, 2 // InterfaceMethod java/util/Map.remove:(Ljava/lang/Object;)Ljava/lang/Object;\n 1664: pop\n 1665: aload 41\n 1667: aload 39\n 1669: checkcast #68 // class java/lang/Iterable\n 1672: invokestatic #371 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Iterable;)Ljava/util/Set;\n 1675: astore 42\n 1677: aload 42\n 1679: checkcast #68 // class java/lang/Iterable\n 1682: astore 43\n 1684: iconst_0\n 1685: istore 44\n 1687: aload 43\n 1689: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1694: astore 45\n 1696: aload 45\n 1698: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1703: ifeq 1749\n 1706: aload 45\n 1708: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1713: astore 46\n 1715: aload 46\n 1717: checkcast #141 // class kotlin/Pair\n 1720: astore 47\n 1722: iconst_0\n 1723: istore 48\n 1725: iload 40\n 1727: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1730: astore 49\n 1732: aload 4\n 1734: aload 47\n 1736: aload 49\n 1738: invokeinterface #341, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 1743: pop\n 1744: nop\n 1745: nop\n 1746: goto 1696\n 1749: nop\n 1750: iload 40\n 1752: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1755: astore 44\n 1757: aload_3\n 1758: aload 44\n 1760: aload 42\n 1762: invokeinterface #341, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 1767: pop\n 1768: nop\n 1769: aload 35\n 1771: getstatic #135 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 1774: invokeinterface #116, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 1779: pop\n 1780: goto 1451\n 1783: aload 31\n 1785: checkcast #28 // class java/util/List\n 1788: nop\n 1789: pop\n 1790: aload 26\n 1792: checkcast #68 // class java/lang/Iterable\n 1795: astore 28\n 1797: iconst_0\n 1798: istore 29\n 1800: aload 28\n 1802: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1807: astore 30\n 1809: aload 30\n 1811: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1816: ifeq 1858\n 1819: aload 30\n 1821: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1826: astore 31\n 1828: aload 31\n 1830: checkcast #141 // class kotlin/Pair\n 1833: astore 32\n 1835: iconst_0\n 1836: istore 33\n 1838: aload 4\n 1840: aload 32\n 1842: iload 27\n 1844: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1847: invokeinterface #341, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 1852: pop\n 1853: nop\n 1854: nop\n 1855: goto 1809\n 1858: nop\n 1859: aload_3\n 1860: iload 27\n 1862: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1865: invokeinterface #347, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 1870: checkcast #242 // class java/util/Set\n 1873: dup\n 1874: ifnull 1898\n 1877: astore 30\n 1879: iconst_0\n 1880: istore 31\n 1882: aload 26\n 1884: aload 30\n 1886: checkcast #79 // class java/util/Collection\n 1889: invokeinterface #375, 2 // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z\n 1894: pop\n 1895: goto 1900\n 1898: pop\n 1899: nop\n 1900: aload_3\n 1901: iload 27\n 1903: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1906: aload 26\n 1908: invokeinterface #341, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 1913: pop\n 1914: nop\n 1915: nop\n 1916: goto 130\n 1919: nop\n 1920: nop\n 1921: nop\n 1922: goto 60\n 1925: nop\n 1926: aload_3\n 1927: areturn\n\n public static final java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>> findBasinLimits(java.util.List<java.util.List<java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: ldc_w #302 // String map\n 4: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: new #420 // class java/util/LinkedHashSet\n 10: dup\n 11: invokespecial #421 // Method java/util/LinkedHashSet.\"<init>\":()V\n 14: checkcast #242 // class java/util/Set\n 17: astore_1\n 18: aload_0\n 19: checkcast #68 // class java/lang/Iterable\n 22: astore_2\n 23: iconst_0\n 24: istore_3\n 25: iconst_0\n 26: istore 4\n 28: aload_2\n 29: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 34: astore 5\n 36: aload 5\n 38: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 43: ifeq 195\n 46: aload 5\n 48: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 53: astore 6\n 55: iload 4\n 57: iinc 4, 1\n 60: istore 7\n 62: iload 7\n 64: ifge 70\n 67: invokestatic #96 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 70: iload 7\n 72: aload 6\n 74: checkcast #28 // class java/util/List\n 77: astore 8\n 79: istore 9\n 81: iconst_0\n 82: istore 10\n 84: aload 8\n 86: checkcast #68 // class java/lang/Iterable\n 89: astore 11\n 91: iconst_0\n 92: istore 12\n 94: iconst_0\n 95: istore 13\n 97: aload 11\n 99: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 104: astore 14\n 106: aload 14\n 108: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 113: ifeq 189\n 116: aload 14\n 118: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 123: astore 15\n 125: iload 13\n 127: iinc 13, 1\n 130: istore 16\n 132: iload 16\n 134: ifge 140\n 137: invokestatic #96 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 140: iload 16\n 142: aload 15\n 144: checkcast #146 // class java/lang/Number\n 147: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 150: istore 17\n 152: istore 18\n 154: iconst_0\n 155: istore 19\n 157: iload 17\n 159: bipush 9\n 161: if_icmpne 184\n 164: aload_1\n 165: iload 9\n 167: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 170: iload 18\n 172: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 175: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 178: invokeinterface #422, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 183: pop\n 184: nop\n 185: nop\n 186: goto 106\n 189: nop\n 190: nop\n 191: nop\n 192: goto 36\n 195: nop\n 196: aload_1\n 197: areturn\n\n public static final java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>> findLocalMinimas(java.util.List<java.util.List<java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: ldc_w #302 // String map\n 4: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: new #23 // class java/util/ArrayList\n 10: dup\n 11: invokespecial #26 // Method java/util/ArrayList.\"<init>\":()V\n 14: checkcast #28 // class java/util/List\n 17: astore_1\n 18: aload_0\n 19: checkcast #68 // class java/lang/Iterable\n 22: astore_2\n 23: iconst_0\n 24: istore_3\n 25: iconst_0\n 26: istore 4\n 28: aload_2\n 29: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 34: astore 5\n 36: aload 5\n 38: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 43: ifeq 504\n 46: aload 5\n 48: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 53: astore 6\n 55: iload 4\n 57: iinc 4, 1\n 60: istore 7\n 62: iload 7\n 64: ifge 70\n 67: invokestatic #96 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 70: iload 7\n 72: aload 6\n 74: checkcast #28 // class java/util/List\n 77: astore 8\n 79: istore 9\n 81: iconst_0\n 82: istore 10\n 84: aload 8\n 86: checkcast #68 // class java/lang/Iterable\n 89: astore 11\n 91: iconst_0\n 92: istore 12\n 94: iconst_0\n 95: istore 13\n 97: aload 11\n 99: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 104: astore 14\n 106: aload 14\n 108: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 113: ifeq 498\n 116: aload 14\n 118: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 123: astore 15\n 125: iload 13\n 127: iinc 13, 1\n 130: istore 16\n 132: iload 16\n 134: ifge 140\n 137: invokestatic #96 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 140: iload 16\n 142: aload 15\n 144: checkcast #146 // class java/lang/Number\n 147: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 150: istore 17\n 152: istore 18\n 154: iconst_0\n 155: istore 19\n 157: iload 18\n 159: istore 20\n 161: iload 20\n 163: ifne 196\n 166: iload 17\n 168: aload 8\n 170: iload 18\n 172: iconst_1\n 173: iadd\n 174: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 179: checkcast #146 // class java/lang/Number\n 182: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 185: if_icmpge 192\n 188: iconst_1\n 189: goto 289\n 192: iconst_0\n 193: goto 289\n 196: iload 20\n 198: aload 8\n 200: invokeinterface #224, 1 // InterfaceMethod java/util/List.size:()I\n 205: iconst_1\n 206: isub\n 207: if_icmpne 240\n 210: iload 17\n 212: aload 8\n 214: iload 18\n 216: iconst_1\n 217: isub\n 218: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 223: checkcast #146 // class java/lang/Number\n 226: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 229: if_icmpge 236\n 232: iconst_1\n 233: goto 289\n 236: iconst_0\n 237: goto 289\n 240: iload 17\n 242: aload 8\n 244: iload 18\n 246: iconst_1\n 247: isub\n 248: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 253: checkcast #146 // class java/lang/Number\n 256: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 259: if_icmpge 288\n 262: iload 17\n 264: aload 8\n 266: iload 18\n 268: iconst_1\n 269: iadd\n 270: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 275: checkcast #146 // class java/lang/Number\n 278: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 281: if_icmpge 288\n 284: iconst_1\n 285: goto 289\n 288: iconst_0\n 289: istore 21\n 291: iload 21\n 293: ifne 299\n 296: goto 494\n 299: iload 9\n 301: istore 22\n 303: iload 22\n 305: ifne 347\n 308: iload 17\n 310: aload_0\n 311: iload 9\n 313: iconst_1\n 314: iadd\n 315: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 320: checkcast #28 // class java/util/List\n 323: iload 18\n 325: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 330: checkcast #146 // class java/lang/Number\n 333: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 336: if_icmpge 343\n 339: iconst_1\n 340: goto 466\n 343: iconst_0\n 344: goto 466\n 347: iload 22\n 349: aload_0\n 350: invokeinterface #224, 1 // InterfaceMethod java/util/List.size:()I\n 355: iconst_1\n 356: isub\n 357: if_icmpne 399\n 360: iload 17\n 362: aload_0\n 363: iload 9\n 365: iconst_1\n 366: isub\n 367: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 372: checkcast #28 // class java/util/List\n 375: iload 18\n 377: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 382: checkcast #146 // class java/lang/Number\n 385: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 388: if_icmpge 395\n 391: iconst_1\n 392: goto 466\n 395: iconst_0\n 396: goto 466\n 399: iload 17\n 401: aload_0\n 402: iload 9\n 404: iconst_1\n 405: isub\n 406: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 411: checkcast #28 // class java/util/List\n 414: iload 18\n 416: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 421: checkcast #146 // class java/lang/Number\n 424: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 427: if_icmpge 465\n 430: iload 17\n 432: aload_0\n 433: iload 9\n 435: iconst_1\n 436: iadd\n 437: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 442: checkcast #28 // class java/util/List\n 445: iload 18\n 447: invokeinterface #154, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 452: checkcast #146 // class java/lang/Number\n 455: invokevirtual #150 // Method java/lang/Number.intValue:()I\n 458: if_icmpge 465\n 461: iconst_1\n 462: goto 466\n 465: iconst_0\n 466: istore 20\n 468: iload 20\n 470: ifeq 493\n 473: aload_1\n 474: iload 9\n 476: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 479: iload 18\n 481: invokestatic #126 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 484: invokestatic #313 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 487: invokeinterface #426, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 492: pop\n 493: nop\n 494: nop\n 495: goto 106\n 498: nop\n 499: nop\n 500: nop\n 501: goto 36\n 504: nop\n 505: aload_1\n 506: areturn\n}\n", "javap_err": "" } ]
lhDream__wuziqi__c83c58c/src/test/kotlin/Test.kt
import java.util.* import kotlin.math.abs // 棋盘大小 const val BOARD_SIZE = 15 // 评估函数(简化版本,根据棋局评估得分) // 五子棋中针对当前局面的评估函数 fun evaluate(board: Array<Array<Int>>, player: Int): Int { val opponent = if (player == 2) 1 else 2 var score = 0 // 检查每个位置的行、列、对角线是否存在连续的棋子 for (i in 0 until BOARD_SIZE) { for (j in 0 until BOARD_SIZE) { // 检查水平、垂直和对角线上的棋子情况 val directions = arrayOf( intArrayOf(1, 0), intArrayOf(1, -1), intArrayOf(0, -1), intArrayOf(-1, -1), intArrayOf(-1, 0), intArrayOf(-1, 1), intArrayOf(0, 1), intArrayOf(1, 1) ) for (dir in directions) { var countPlayer = 0 var countOpponent = 0 var association = 0 for (k in 0 until 6) { val r = i + k * dir[0] val c = j + k * dir[1] if (r in 0 until BOARD_SIZE && c in 0 until BOARD_SIZE) { if (board[r][c] == player) { countPlayer++ } else if (board[r][c] == opponent) { countOpponent++ } association = association * 10 + board[r][c] } else { break } } score += when(association){ 22222 -> 50000 // 活五 22220, 22202, 22022, 20222 -> 10000 // 活四 122220, 122202, 122022, 120222, 102222, 22221 -> 5000 // 冲四 222, 2202, 2022, 2220 -> 2000 // 活三 12220, 12202, 12022, 10222, 2221 -> 1000 // 眠三 22, 202, 20 -> 500 // 活二 1220, 1202, 1020, 210, 2120 -> 200 // 眠二 else -> 0 } } } } return score } // Minimax 算法 fun minimax(board: Array<Array<Int>>, depth: Int, player: Int): Int { if (depth == 0) { return evaluate(board,player) } var bestScore = 0 val opponent = if (player == 2) 1 else 2 for (i in 0 until BOARD_SIZE) { for (j in 0 until BOARD_SIZE) { if (board[i][j] == 0) { board[i][j] = opponent val score = minimax(board, depth - 1, opponent) board[i][j] = 0 bestScore = maxOf(bestScore, score) } } } return bestScore } // 寻找最佳下棋位置 fun findBestMove(board: Array<Array<Int>>,player: Int): Pair<Int, Int> { var bestScore = Int.MIN_VALUE var bestMove = Pair(-1, -1) for (i in 0 until BOARD_SIZE) { for (j in 0 until BOARD_SIZE) { if (board[i][j] == 0) { board[i][j] = player // 模拟落子 var score = minimax(board, 3, player) // 这里设定最大搜索深度为3 score = score * major[i][j] + major[i][j] // 位置价值 board[i][j] = 0 // 撤销落子 if (score > bestScore) { bestScore = score // 更新最高分 bestMove = Pair(i, j) // 更新最佳落子位置 } } } } return bestMove } // 初始化位置价值矩阵 fun initMatrix(matrix:Array<Array<Int>>){ val centerX = matrix.size / 2 val centerY = matrix.size / 2 for (i in matrix.indices) { for (j in matrix.indices) { val distance = abs(i - centerX) + abs(j - centerY) matrix[i][j] = matrix.size - distance } } } // 位置价值矩阵 val major = Array(BOARD_SIZE) { Array(BOARD_SIZE) { 0 } } // 主函数 fun main() { initMatrix(major) val board = Array(BOARD_SIZE) { Array(BOARD_SIZE) { 0 } } // 模拟当前棋盘状态 val scan = Scanner(System.`in`) while (true){ // ... val (x,y) = findBestMove(board,2) board[x][y] = 2 println("Best Move: ${x}, $y") for (i in board.indices){ println(board[i].contentToString()) } val p = scan.nextLine().split(",") board[p[0].toInt()][p[1].toInt()] = 1 } }
[ { "class_path": "lhDream__wuziqi__c83c58c/TestKt.class", "javap": "Compiled from \"Test.kt\"\npublic final class TestKt {\n public static final int BOARD_SIZE;\n\n private static final java.lang.Integer[][] major;\n\n public static final int evaluate(java.lang.Integer[][], int);\n Code:\n 0: aload_0\n 1: ldc #9 // String board\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_1\n 7: iconst_2\n 8: if_icmpne 15\n 11: iconst_1\n 12: goto 16\n 15: iconst_2\n 16: istore_2\n 17: iconst_0\n 18: istore_3\n 19: iconst_0\n 20: istore 4\n 22: iload 4\n 24: bipush 15\n 26: if_icmpge 706\n 29: iconst_0\n 30: istore 5\n 32: iload 5\n 34: bipush 15\n 36: if_icmpge 700\n 39: bipush 8\n 41: anewarray #17 // class \"[I\"\n 44: astore 7\n 46: aload 7\n 48: iconst_0\n 49: iconst_2\n 50: newarray int\n 52: astore 8\n 54: aload 8\n 56: iconst_0\n 57: iconst_1\n 58: iastore\n 59: aload 8\n 61: iconst_1\n 62: iconst_0\n 63: iastore\n 64: aload 8\n 66: aastore\n 67: aload 7\n 69: iconst_1\n 70: iconst_2\n 71: newarray int\n 73: astore 8\n 75: aload 8\n 77: iconst_0\n 78: iconst_1\n 79: iastore\n 80: aload 8\n 82: iconst_1\n 83: iconst_m1\n 84: iastore\n 85: aload 8\n 87: aastore\n 88: aload 7\n 90: iconst_2\n 91: iconst_2\n 92: newarray int\n 94: astore 8\n 96: aload 8\n 98: iconst_0\n 99: iconst_0\n 100: iastore\n 101: aload 8\n 103: iconst_1\n 104: iconst_m1\n 105: iastore\n 106: aload 8\n 108: aastore\n 109: aload 7\n 111: iconst_3\n 112: iconst_2\n 113: newarray int\n 115: astore 8\n 117: aload 8\n 119: iconst_0\n 120: iconst_m1\n 121: iastore\n 122: aload 8\n 124: iconst_1\n 125: iconst_m1\n 126: iastore\n 127: aload 8\n 129: aastore\n 130: aload 7\n 132: iconst_4\n 133: iconst_2\n 134: newarray int\n 136: astore 8\n 138: aload 8\n 140: iconst_0\n 141: iconst_m1\n 142: iastore\n 143: aload 8\n 145: iconst_1\n 146: iconst_0\n 147: iastore\n 148: aload 8\n 150: aastore\n 151: aload 7\n 153: iconst_5\n 154: iconst_2\n 155: newarray int\n 157: astore 8\n 159: aload 8\n 161: iconst_0\n 162: iconst_m1\n 163: iastore\n 164: aload 8\n 166: iconst_1\n 167: iconst_1\n 168: iastore\n 169: aload 8\n 171: aastore\n 172: aload 7\n 174: bipush 6\n 176: iconst_2\n 177: newarray int\n 179: astore 8\n 181: aload 8\n 183: iconst_0\n 184: iconst_0\n 185: iastore\n 186: aload 8\n 188: iconst_1\n 189: iconst_1\n 190: iastore\n 191: aload 8\n 193: aastore\n 194: aload 7\n 196: bipush 7\n 198: iconst_2\n 199: newarray int\n 201: astore 8\n 203: aload 8\n 205: iconst_0\n 206: iconst_1\n 207: iastore\n 208: aload 8\n 210: iconst_1\n 211: iconst_1\n 212: iastore\n 213: aload 8\n 215: aastore\n 216: aload 7\n 218: astore 6\n 220: iconst_0\n 221: istore 7\n 223: aload 6\n 225: checkcast #19 // class \"[Ljava/lang/Object;\"\n 228: arraylength\n 229: istore 8\n 231: iload 7\n 233: iload 8\n 235: if_icmpge 694\n 238: aload 6\n 240: iload 7\n 242: aaload\n 243: astore 9\n 245: iconst_0\n 246: istore 10\n 248: iconst_0\n 249: istore 11\n 251: iconst_0\n 252: istore 12\n 254: iconst_0\n 255: istore 13\n 257: iload 13\n 259: bipush 6\n 261: if_icmpge 405\n 264: iload 4\n 266: iload 13\n 268: aload 9\n 270: iconst_0\n 271: iaload\n 272: imul\n 273: iadd\n 274: istore 14\n 276: iload 5\n 278: iload 13\n 280: aload 9\n 282: iconst_1\n 283: iaload\n 284: imul\n 285: iadd\n 286: istore 15\n 288: iconst_0\n 289: iload 14\n 291: if_icmpgt 309\n 294: iload 14\n 296: bipush 15\n 298: if_icmpge 305\n 301: iconst_1\n 302: goto 310\n 305: iconst_0\n 306: goto 310\n 309: iconst_0\n 310: ifeq 396\n 313: iconst_0\n 314: iload 15\n 316: if_icmpgt 334\n 319: iload 15\n 321: bipush 15\n 323: if_icmpge 330\n 326: iconst_1\n 327: goto 335\n 330: iconst_0\n 331: goto 335\n 334: iconst_0\n 335: ifeq 396\n 338: aload_0\n 339: iload 14\n 341: aaload\n 342: iload 15\n 344: aaload\n 345: invokevirtual #25 // Method java/lang/Integer.intValue:()I\n 348: iload_1\n 349: if_icmpne 358\n 352: iinc 10, 1\n 355: goto 375\n 358: aload_0\n 359: iload 14\n 361: aaload\n 362: iload 15\n 364: aaload\n 365: invokevirtual #25 // Method java/lang/Integer.intValue:()I\n 368: iload_2\n 369: if_icmpne 375\n 372: iinc 11, 1\n 375: iload 12\n 377: bipush 10\n 379: imul\n 380: aload_0\n 381: iload 14\n 383: aaload\n 384: iload 15\n 386: aaload\n 387: invokevirtual #25 // Method java/lang/Integer.intValue:()I\n 390: iadd\n 391: istore 12\n 393: goto 399\n 396: goto 405\n 399: iinc 13, 1\n 402: goto 257\n 405: iload_3\n 406: iload 12\n 408: lookupswitch { // 28\n 20: 673\n 22: 673\n 202: 673\n 210: 679\n 222: 661\n 1020: 679\n 1202: 679\n 1220: 679\n 2022: 661\n 2120: 679\n 2202: 661\n 2220: 661\n 2221: 667\n 10222: 667\n 12022: 667\n 12202: 667\n 12220: 667\n 20222: 649\n 22022: 649\n 22202: 649\n 22220: 649\n 22221: 655\n 22222: 644\n 102222: 655\n 120222: 655\n 122022: 655\n 122202: 655\n 122220: 655\n default: 685\n }\n 644: ldc #26 // int 50000\n 646: goto 686\n 649: sipush 10000\n 652: goto 686\n 655: sipush 5000\n 658: goto 686\n 661: sipush 2000\n 664: goto 686\n 667: sipush 1000\n 670: goto 686\n 673: sipush 500\n 676: goto 686\n 679: sipush 200\n 682: goto 686\n 685: iconst_0\n 686: iadd\n 687: istore_3\n 688: iinc 7, 1\n 691: goto 231\n 694: iinc 5, 1\n 697: goto 32\n 700: iinc 4, 1\n 703: goto 22\n 706: iload_3\n 707: ireturn\n\n public static final int minimax(java.lang.Integer[][], int, int);\n Code:\n 0: aload_0\n 1: ldc #9 // String board\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_1\n 7: ifne 16\n 10: aload_0\n 11: iload_2\n 12: invokestatic #48 // Method evaluate:([[Ljava/lang/Integer;I)I\n 15: ireturn\n 16: iconst_0\n 17: istore_3\n 18: iload_2\n 19: iconst_2\n 20: if_icmpne 27\n 23: iconst_1\n 24: goto 28\n 27: iconst_2\n 28: istore 4\n 30: iconst_0\n 31: istore 5\n 33: iload 5\n 35: bipush 15\n 37: if_icmpge 116\n 40: iconst_0\n 41: istore 6\n 43: iload 6\n 45: bipush 15\n 47: if_icmpge 110\n 50: aload_0\n 51: iload 5\n 53: aaload\n 54: iload 6\n 56: aaload\n 57: invokevirtual #25 // Method java/lang/Integer.intValue:()I\n 60: ifne 104\n 63: aload_0\n 64: iload 5\n 66: aaload\n 67: iload 6\n 69: iload 4\n 71: invokestatic #52 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 74: aastore\n 75: aload_0\n 76: iload_1\n 77: iconst_1\n 78: isub\n 79: iload 4\n 81: invokestatic #54 // Method minimax:([[Ljava/lang/Integer;II)I\n 84: istore 7\n 86: aload_0\n 87: iload 5\n 89: aaload\n 90: iload 6\n 92: iconst_0\n 93: invokestatic #52 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 96: aastore\n 97: iload_3\n 98: iload 7\n 100: invokestatic #60 // Method java/lang/Math.max:(II)I\n 103: istore_3\n 104: iinc 6, 1\n 107: goto 43\n 110: iinc 5, 1\n 113: goto 33\n 116: iload_3\n 117: ireturn\n\n public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> findBestMove(java.lang.Integer[][], int);\n Code:\n 0: aload_0\n 1: ldc #9 // String board\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #66 // int -2147483648\n 8: istore_2\n 9: new #68 // class kotlin/Pair\n 12: dup\n 13: iconst_m1\n 14: invokestatic #52 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 17: iconst_m1\n 18: invokestatic #52 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 21: invokespecial #72 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 24: astore_3\n 25: iconst_0\n 26: istore 4\n 28: iload 4\n 30: bipush 15\n 32: if_icmpge 157\n 35: iconst_0\n 36: istore 5\n 38: iload 5\n 40: bipush 15\n 42: if_icmpge 151\n 45: aload_0\n 46: iload 4\n 48: aaload\n 49: iload 5\n 51: aaload\n 52: invokevirtual #25 // Method java/lang/Integer.intValue:()I\n 55: ifne 145\n 58: aload_0\n 59: iload 4\n 61: aaload\n 62: iload 5\n 64: iload_1\n 65: invokestatic #52 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 68: aastore\n 69: aload_0\n 70: iconst_3\n 71: iload_1\n 72: invokestatic #54 // Method minimax:([[Ljava/lang/Integer;II)I\n 75: istore 6\n 77: iload 6\n 79: getstatic #75 // Field major:[[Ljava/lang/Integer;\n 82: iload 4\n 84: aaload\n 85: iload 5\n 87: aaload\n 88: invokevirtual #25 // Method java/lang/Integer.intValue:()I\n 91: imul\n 92: getstatic #75 // Field major:[[Ljava/lang/Integer;\n 95: iload 4\n 97: aaload\n 98: iload 5\n 100: aaload\n 101: invokevirtual #25 // Method java/lang/Integer.intValue:()I\n 104: iadd\n 105: istore 6\n 107: aload_0\n 108: iload 4\n 110: aaload\n 111: iload 5\n 113: iconst_0\n 114: invokestatic #52 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 117: aastore\n 118: iload 6\n 120: iload_2\n 121: if_icmple 145\n 124: iload 6\n 126: istore_2\n 127: new #68 // class kotlin/Pair\n 130: dup\n 131: iload 4\n 133: invokestatic #52 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 136: iload 5\n 138: invokestatic #52 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 141: invokespecial #72 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 144: astore_3\n 145: iinc 5, 1\n 148: goto 38\n 151: iinc 4, 1\n 154: goto 28\n 157: aload_3\n 158: areturn\n\n public static final void initMatrix(java.lang.Integer[][]);\n Code:\n 0: aload_0\n 1: ldc #81 // String matrix\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #19 // class \"[Ljava/lang/Object;\"\n 10: arraylength\n 11: iconst_2\n 12: idiv\n 13: istore_1\n 14: aload_0\n 15: checkcast #19 // class \"[Ljava/lang/Object;\"\n 18: arraylength\n 19: iconst_2\n 20: idiv\n 21: istore_2\n 22: iconst_0\n 23: istore_3\n 24: aload_0\n 25: checkcast #19 // class \"[Ljava/lang/Object;\"\n 28: arraylength\n 29: istore 4\n 31: iload_3\n 32: iload 4\n 34: if_icmpge 99\n 37: iconst_0\n 38: istore 5\n 40: aload_0\n 41: checkcast #19 // class \"[Ljava/lang/Object;\"\n 44: arraylength\n 45: istore 6\n 47: iload 5\n 49: iload 6\n 51: if_icmpge 93\n 54: iload_3\n 55: iload_1\n 56: isub\n 57: invokestatic #85 // Method java/lang/Math.abs:(I)I\n 60: iload 5\n 62: iload_2\n 63: isub\n 64: invokestatic #85 // Method java/lang/Math.abs:(I)I\n 67: iadd\n 68: istore 7\n 70: aload_0\n 71: iload_3\n 72: aaload\n 73: iload 5\n 75: aload_0\n 76: checkcast #19 // class \"[Ljava/lang/Object;\"\n 79: arraylength\n 80: iload 7\n 82: isub\n 83: invokestatic #52 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 86: aastore\n 87: iinc 5, 1\n 90: goto 47\n 93: iinc 3, 1\n 96: goto 31\n 99: return\n\n public static final java.lang.Integer[][] getMajor();\n Code:\n 0: getstatic #75 // Field major:[[Ljava/lang/Integer;\n 3: areturn\n\n public static final void main();\n Code:\n 0: getstatic #75 // Field major:[[Ljava/lang/Integer;\n 3: invokestatic #94 // Method initMatrix:([[Ljava/lang/Integer;)V\n 6: iconst_0\n 7: istore_1\n 8: bipush 15\n 10: anewarray #96 // class \"[Ljava/lang/Integer;\"\n 13: astore_2\n 14: iload_1\n 15: bipush 15\n 17: if_icmpge 77\n 20: iload_1\n 21: istore_3\n 22: aload_2\n 23: iload_3\n 24: iconst_0\n 25: istore 4\n 27: bipush 15\n 29: anewarray #21 // class java/lang/Integer\n 32: astore 5\n 34: istore 9\n 36: astore 8\n 38: iload 4\n 40: bipush 15\n 42: if_icmpge 64\n 45: iload 4\n 47: istore 6\n 49: aload 5\n 51: iload 6\n 53: iconst_0\n 54: invokestatic #52 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 57: aastore\n 58: iinc 4, 1\n 61: goto 38\n 64: aload 8\n 66: iload 9\n 68: aload 5\n 70: aastore\n 71: iinc 1, 1\n 74: goto 14\n 77: aload_2\n 78: astore_0\n 79: new #98 // class java/util/Scanner\n 82: dup\n 83: getstatic #104 // Field java/lang/System.in:Ljava/io/InputStream;\n 86: invokespecial #107 // Method java/util/Scanner.\"<init>\":(Ljava/io/InputStream;)V\n 89: astore_1\n 90: nop\n 91: aload_0\n 92: iconst_2\n 93: invokestatic #109 // Method findBestMove:([[Ljava/lang/Integer;I)Lkotlin/Pair;\n 96: astore_2\n 97: aload_2\n 98: invokevirtual #113 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 101: checkcast #115 // class java/lang/Number\n 104: invokevirtual #116 // Method java/lang/Number.intValue:()I\n 107: istore_3\n 108: aload_2\n 109: invokevirtual #119 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 112: checkcast #115 // class java/lang/Number\n 115: invokevirtual #116 // Method java/lang/Number.intValue:()I\n 118: istore 4\n 120: aload_0\n 121: iload_3\n 122: aaload\n 123: iload 4\n 125: iconst_2\n 126: invokestatic #52 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 129: aastore\n 130: new #121 // class java/lang/StringBuilder\n 133: dup\n 134: invokespecial #123 // Method java/lang/StringBuilder.\"<init>\":()V\n 137: ldc #125 // String Best Move:\n 139: invokevirtual #129 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 142: iload_3\n 143: invokevirtual #132 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 146: ldc #134 // String ,\n 148: invokevirtual #129 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 151: iload 4\n 153: invokevirtual #132 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 156: invokevirtual #138 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 159: getstatic #142 // Field java/lang/System.out:Ljava/io/PrintStream;\n 162: swap\n 163: invokevirtual #148 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 166: iconst_0\n 167: istore 5\n 169: aload_0\n 170: checkcast #19 // class \"[Ljava/lang/Object;\"\n 173: arraylength\n 174: istore 6\n 176: iload 5\n 178: iload 6\n 180: if_icmpge 212\n 183: aload_0\n 184: iload 5\n 186: aaload\n 187: invokestatic #153 // Method java/util/Arrays.toString:([Ljava/lang/Object;)Ljava/lang/String;\n 190: dup\n 191: ldc #155 // String toString(...)\n 193: invokestatic #158 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 196: astore 7\n 198: getstatic #142 // Field java/lang/System.out:Ljava/io/PrintStream;\n 201: aload 7\n 203: invokevirtual #148 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 206: iinc 5, 1\n 209: goto 176\n 212: aload_1\n 213: invokevirtual #161 // Method java/util/Scanner.nextLine:()Ljava/lang/String;\n 216: dup\n 217: ldc #163 // String nextLine(...)\n 219: invokestatic #158 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 222: checkcast #165 // class java/lang/CharSequence\n 225: iconst_1\n 226: anewarray #167 // class java/lang/String\n 229: astore 6\n 231: aload 6\n 233: iconst_0\n 234: ldc #169 // String ,\n 236: aastore\n 237: aload 6\n 239: iconst_0\n 240: iconst_0\n 241: bipush 6\n 243: aconst_null\n 244: invokestatic #175 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 247: astore 5\n 249: aload_0\n 250: aload 5\n 252: iconst_0\n 253: invokeinterface #181, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 258: checkcast #167 // class java/lang/String\n 261: invokestatic #185 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 264: aaload\n 265: aload 5\n 267: iconst_1\n 268: invokeinterface #181, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 273: checkcast #167 // class java/lang/String\n 276: invokestatic #185 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 279: iconst_1\n 280: invokestatic #52 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 283: aastore\n 284: goto 90\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #194 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: iconst_0\n 1: istore_0\n 2: bipush 15\n 4: anewarray #96 // class \"[Ljava/lang/Integer;\"\n 7: astore_1\n 8: iload_0\n 9: bipush 15\n 11: if_icmpge 68\n 14: iload_0\n 15: istore_2\n 16: aload_1\n 17: iload_2\n 18: iconst_0\n 19: istore_3\n 20: bipush 15\n 22: anewarray #21 // class java/lang/Integer\n 25: astore 4\n 27: istore 7\n 29: astore 6\n 31: iload_3\n 32: bipush 15\n 34: if_icmpge 55\n 37: iload_3\n 38: istore 5\n 40: aload 4\n 42: iload 5\n 44: iconst_0\n 45: invokestatic #52 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 48: aastore\n 49: iinc 3, 1\n 52: goto 31\n 55: aload 6\n 57: iload 7\n 59: aload 4\n 61: aastore\n 62: iinc 0, 1\n 65: goto 8\n 68: aload_1\n 69: putstatic #75 // Field major:[[Ljava/lang/Integer;\n 72: return\n}\n", "javap_err": "" } ]
alexiscrack3__algorithms-kotlin__a201986/src/main/kotlin/SubArray.kt
class SubArray { fun getLengthOfLongestContiguousSubarray(array: Array<Int>): Int { var maxLength = 1 for (i in 0 until array.size - 1) { var minimum = array[i] var maximum = array[i] for (j in i + 1 until array.size) { minimum = Math.min(minimum, array[j]) maximum = Math.max(maximum, array[j]) if (maximum - minimum == j - i) { maxLength = Math.max(maxLength, maximum - minimum + 1) } } } return maxLength } fun getSmallestPositiveNumber(array: Array<Int>): Int { var result = 1 var i = 0 while (i < array.size && array[i] <= result) { result += array[i] i++ } return result } fun getSmallestSubarrayWithSumGreaterThanValue(array: Array<Int>, value: Int): Int { var minLength = array.size + 1 for (start in 0 until array.size) { // Initialize sum starting with current start var sum = array[start] // If first element itself is greater if (sum > value) { return 1 } for (end in start + 1 until array.size) { sum += array[end] // If sum becomes more than x and length of // this subarray is smaller than current smallest // length, update the smallest length (or result) val length = end - start + 1 if (sum > value && length < minLength) { minLength = length } } } return minLength } }
[ { "class_path": "alexiscrack3__algorithms-kotlin__a201986/SubArray.class", "javap": "Compiled from \"SubArray.kt\"\npublic final class SubArray {\n public SubArray();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int getLengthOfLongestContiguousSubarray(java.lang.Integer[]);\n Code:\n 0: aload_1\n 1: ldc #15 // String array\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_1\n 7: istore_2\n 8: iconst_0\n 9: istore_3\n 10: aload_1\n 11: arraylength\n 12: iconst_1\n 13: isub\n 14: istore 4\n 16: iload_3\n 17: iload 4\n 19: if_icmpge 118\n 22: aload_1\n 23: iload_3\n 24: aaload\n 25: invokevirtual #27 // Method java/lang/Integer.intValue:()I\n 28: istore 5\n 30: aload_1\n 31: iload_3\n 32: aaload\n 33: invokevirtual #27 // Method java/lang/Integer.intValue:()I\n 36: istore 6\n 38: iload_3\n 39: iconst_1\n 40: iadd\n 41: istore 7\n 43: aload_1\n 44: arraylength\n 45: istore 8\n 47: iload 7\n 49: iload 8\n 51: if_icmpge 112\n 54: iload 5\n 56: aload_1\n 57: iload 7\n 59: aaload\n 60: invokevirtual #27 // Method java/lang/Integer.intValue:()I\n 63: invokestatic #33 // Method java/lang/Math.min:(II)I\n 66: istore 5\n 68: iload 6\n 70: aload_1\n 71: iload 7\n 73: aaload\n 74: invokevirtual #27 // Method java/lang/Integer.intValue:()I\n 77: invokestatic #36 // Method java/lang/Math.max:(II)I\n 80: istore 6\n 82: iload 6\n 84: iload 5\n 86: isub\n 87: iload 7\n 89: iload_3\n 90: isub\n 91: if_icmpne 106\n 94: iload_2\n 95: iload 6\n 97: iload 5\n 99: isub\n 100: iconst_1\n 101: iadd\n 102: invokestatic #36 // Method java/lang/Math.max:(II)I\n 105: istore_2\n 106: iinc 7, 1\n 109: goto 47\n 112: iinc 3, 1\n 115: goto 16\n 118: iload_2\n 119: ireturn\n\n public final int getSmallestPositiveNumber(java.lang.Integer[]);\n Code:\n 0: aload_1\n 1: ldc #15 // String array\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_1\n 7: istore_2\n 8: iconst_0\n 9: istore_3\n 10: iload_3\n 11: aload_1\n 12: arraylength\n 13: if_icmpge 41\n 16: aload_1\n 17: iload_3\n 18: aaload\n 19: invokevirtual #27 // Method java/lang/Integer.intValue:()I\n 22: iload_2\n 23: if_icmpgt 41\n 26: iload_2\n 27: aload_1\n 28: iload_3\n 29: aaload\n 30: invokevirtual #27 // Method java/lang/Integer.intValue:()I\n 33: iadd\n 34: istore_2\n 35: iinc 3, 1\n 38: goto 10\n 41: iload_2\n 42: ireturn\n\n public final int getSmallestSubarrayWithSumGreaterThanValue(java.lang.Integer[], int);\n Code:\n 0: aload_1\n 1: ldc #15 // String array\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: arraylength\n 8: iconst_1\n 9: iadd\n 10: istore_3\n 11: iconst_0\n 12: istore 4\n 14: aload_1\n 15: arraylength\n 16: istore 5\n 18: iload 4\n 20: iload 5\n 22: if_icmpge 107\n 25: aload_1\n 26: iload 4\n 28: aaload\n 29: invokevirtual #27 // Method java/lang/Integer.intValue:()I\n 32: istore 6\n 34: iload 6\n 36: iload_2\n 37: if_icmple 42\n 40: iconst_1\n 41: ireturn\n 42: iload 4\n 44: iconst_1\n 45: iadd\n 46: istore 7\n 48: aload_1\n 49: arraylength\n 50: istore 8\n 52: iload 7\n 54: iload 8\n 56: if_icmpge 101\n 59: iload 6\n 61: aload_1\n 62: iload 7\n 64: aaload\n 65: invokevirtual #27 // Method java/lang/Integer.intValue:()I\n 68: iadd\n 69: istore 6\n 71: iload 7\n 73: iload 4\n 75: isub\n 76: iconst_1\n 77: iadd\n 78: istore 9\n 80: iload 6\n 82: iload_2\n 83: if_icmple 95\n 86: iload 9\n 88: iload_3\n 89: if_icmpge 95\n 92: iload 9\n 94: istore_3\n 95: iinc 7, 1\n 98: goto 52\n 101: iinc 4, 1\n 104: goto 18\n 107: iload_3\n 108: ireturn\n}\n", "javap_err": "" } ]
goetz-markgraf__battleship_2024__ebd9504/src/main/kotlin/Main.kt
import java.lang.Integer.max import java.lang.Integer.min import kotlin.math.abs enum class Function { CHECK, PLACE } enum class Player { PLAYER1, PLAYER2 } data class Position( val col: Int, val row: Int ) data class Ship( var parts: List<Position> ) typealias Field = Array<Array<Int>> data class GameState( val field1: Field, val field2: Field, val ships1: List<Ship>, val ships2: List<Ship> ) fun main() { var gameState = createGameState() showField(gameState, Player.PLAYER1) while (true) { print("Enter ship coordinates: ") gameState = place(gameState, Player.PLAYER1) showField(gameState, Player.PLAYER1) } } fun createGameState(): GameState { val field1 = Array(10) { Array(10) { 0 } } val field2 = Array(10) { Array(10) { 0 } } return GameState(field1, field2, emptyList(), emptyList()) } fun showField(gameState: GameState, player: Player) { for (row in '0'..'9') { print("\t $row") } println() val tabVertLine = "\t${9474.toChar()}" val ships = if (player == Player.PLAYER1) gameState.ships1 else gameState.ships2 for (col in 0 until 10) { print(" " + (col + 65).toChar() + tabVertLine) for (row in 0 until 10) { var shipFound = false ships.forEach { it.parts.forEach { if (it.row == row && it.col == col) { shipFound = true } } } if (shipFound) { print("██") } print(tabVertLine) } println() } } fun place(gameState: GameState, player: Player): GameState { val location = readln().lowercase() println("inside place") val ships = (if (player == Player.PLAYER1) gameState.ships1 else gameState.ships2).toMutableList() if (inputIsValid(Function.PLACE, location)) { val coordinates = convertPair(location) val firstPos = Pair(min(coordinates.first.row, coordinates.second.row), min(coordinates.first.col, coordinates.second.col)) val lastPos = Pair(max(coordinates.first.row, coordinates.second.row), max(coordinates.first.col, coordinates.second.col)) println(coordinates) val n = mutableListOf<Position>() for (row in firstPos.first..lastPos.first) { for (col in firstPos.second..lastPos.second) { if (isCellOccupied(gameState, player, Position(col, row))) { println("This cell is occupied") return gameState } else { println("set at $row,$col") n.add(Position(col, row)) } } } ships.addLast(Ship(n)) } return if (player == Player.PLAYER1) { gameState.copy(ships1 = ships) } else { gameState.copy(ships2 = ships) } } fun isCellOccupied(gameState: GameState, player: Player, position: Position): Boolean { val ships = if (player == Player.PLAYER1) gameState.ships1 else gameState.ships2 return ships.any { ship -> ship.parts.any { it == position } } } fun convertPair(input: String): Pair<Position, Position> { println("in convertPair $input") return Pair(convert(input.substring(0, 2)), convert(input.substring(2, 4))) } fun convert(input: String): Position { println("in convert $input") val rowChar = input[0] val columnChar = input[1] val row = rowChar - 'a' val column = columnChar.toString().toInt() return Position(row, column) } fun check() { val pos = readln().lowercase() if (inputIsValid(Function.CHECK, pos)) { } } fun inputIsValid(function: Function, input: String): Boolean { println(function) when (function) { Function.CHECK -> { if (input.length == 2 && input[0] in 'a'..'j' && input[1] in '0'..'9') { return true } else { println("Enter the cell index in format \"letternumber\", for example \"a0a3\"") return false } } Function.PLACE -> { if (input.length == 4 && input[0] in 'a'..'j' && input[1] in '0'..'9' && input[2] in 'a'..'j' && input[3] in '0'..'9' && (input[0] == input[2] || input[1] == input[3]) && abs(input[0] - input[2]) <= 3 && abs(input[1] - input[3]) <= 3 ) { return true } else { println("Enter the cell indexes in format \"letternumberletternumber\" for placing ship, for example \"a0b0\"") return false } } } }
[ { "class_path": "goetz-markgraf__battleship_2024__ebd9504/MainKt$WhenMappings.class", "javap": "Compiled from \"Main.kt\"\npublic final class MainKt$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method Function.values:()[LFunction;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field Function.CHECK:LFunction;\n 12: invokevirtual #22 // Method Function.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 Function.PLACE:LFunction;\n 26: invokevirtual #22 // Method Function.ordinal:()I\n 29: iconst_2\n 30: iastore\n 31: goto 35\n 34: astore_1\n 35: aload_0\n 36: putstatic #29 // Field $EnumSwitchMapping$0:[I\n 39: 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}\n", "javap_err": "" }, { "class_path": "goetz-markgraf__battleship_2024__ebd9504/MainKt.class", "javap": "Compiled from \"Main.kt\"\npublic final class MainKt {\n public static final void main();\n Code:\n 0: invokestatic #10 // Method createGameState:()LGameState;\n 3: astore_0\n 4: aload_0\n 5: getstatic #16 // Field Player.PLAYER1:LPlayer;\n 8: invokestatic #20 // Method showField:(LGameState;LPlayer;)V\n 11: nop\n 12: ldc #22 // String Enter ship coordinates:\n 14: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 17: swap\n 18: invokevirtual #34 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 21: aload_0\n 22: getstatic #16 // Field Player.PLAYER1:LPlayer;\n 25: invokestatic #38 // Method place:(LGameState;LPlayer;)LGameState;\n 28: astore_0\n 29: aload_0\n 30: getstatic #16 // Field Player.PLAYER1:LPlayer;\n 33: invokestatic #20 // Method showField:(LGameState;LPlayer;)V\n 36: goto 11\n\n public static final GameState createGameState();\n Code:\n 0: iconst_0\n 1: istore_1\n 2: bipush 10\n 4: anewarray #45 // class \"[Ljava/lang/Integer;\"\n 7: astore_2\n 8: iload_1\n 9: bipush 10\n 11: if_icmpge 71\n 14: iload_1\n 15: istore_3\n 16: aload_2\n 17: iload_3\n 18: iconst_0\n 19: istore 4\n 21: bipush 10\n 23: anewarray #47 // class java/lang/Integer\n 26: astore 5\n 28: istore 9\n 30: astore 8\n 32: iload 4\n 34: bipush 10\n 36: if_icmpge 58\n 39: iload 4\n 41: istore 6\n 43: aload 5\n 45: iload 6\n 47: iconst_0\n 48: invokestatic #51 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 51: aastore\n 52: iinc 4, 1\n 55: goto 32\n 58: aload 8\n 60: iload 9\n 62: aload 5\n 64: aastore\n 65: iinc 1, 1\n 68: goto 8\n 71: aload_2\n 72: astore_0\n 73: iconst_0\n 74: istore_2\n 75: bipush 10\n 77: anewarray #45 // class \"[Ljava/lang/Integer;\"\n 80: astore_3\n 81: iload_2\n 82: bipush 10\n 84: if_icmpge 146\n 87: iload_2\n 88: istore 4\n 90: aload_3\n 91: iload 4\n 93: iconst_0\n 94: istore 5\n 96: bipush 10\n 98: anewarray #47 // class java/lang/Integer\n 101: astore 6\n 103: istore 9\n 105: astore 8\n 107: iload 5\n 109: bipush 10\n 111: if_icmpge 133\n 114: iload 5\n 116: istore 7\n 118: aload 6\n 120: iload 7\n 122: iconst_0\n 123: invokestatic #51 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 126: aastore\n 127: iinc 5, 1\n 130: goto 107\n 133: aload 8\n 135: iload 9\n 137: aload 6\n 139: aastore\n 140: iinc 2, 1\n 143: goto 81\n 146: aload_3\n 147: astore_1\n 148: new #42 // class GameState\n 151: dup\n 152: aload_0\n 153: aload_1\n 154: invokestatic #57 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 157: invokestatic #57 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 160: invokespecial #61 // Method GameState.\"<init>\":([[Ljava/lang/Integer;[[Ljava/lang/Integer;Ljava/util/List;Ljava/util/List;)V\n 163: areturn\n\n public static final void showField(GameState, Player);\n Code:\n 0: aload_0\n 1: ldc #66 // String gameState\n 3: invokestatic #72 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #74 // String player\n 9: invokestatic #72 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: bipush 48\n 14: istore_2\n 15: iload_2\n 16: bipush 58\n 18: if_icmpge 55\n 21: new #76 // class java/lang/StringBuilder\n 24: dup\n 25: invokespecial #78 // Method java/lang/StringBuilder.\"<init>\":()V\n 28: ldc #80 // String \\t\n 30: invokevirtual #84 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 33: iload_2\n 34: invokevirtual #87 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 37: invokevirtual #91 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 40: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 43: swap\n 44: invokevirtual #34 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 47: iload_2\n 48: iconst_1\n 49: iadd\n 50: i2c\n 51: istore_2\n 52: goto 15\n 55: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 58: invokevirtual #94 // Method java/io/PrintStream.println:()V\n 61: ldc #96 // String \\t│\n 63: astore_2\n 64: aload_1\n 65: getstatic #16 // Field Player.PLAYER1:LPlayer;\n 68: if_acmpne 78\n 71: aload_0\n 72: invokevirtual #99 // Method GameState.getShips1:()Ljava/util/List;\n 75: goto 82\n 78: aload_0\n 79: invokevirtual #102 // Method GameState.getShips2:()Ljava/util/List;\n 82: astore_3\n 83: iconst_0\n 84: istore 4\n 86: iload 4\n 88: bipush 10\n 90: if_icmpge 313\n 93: new #76 // class java/lang/StringBuilder\n 96: dup\n 97: invokespecial #78 // Method java/lang/StringBuilder.\"<init>\":()V\n 100: bipush 32\n 102: invokevirtual #87 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 105: iload 4\n 107: bipush 65\n 109: iadd\n 110: i2c\n 111: invokevirtual #87 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 114: aload_2\n 115: invokevirtual #84 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 118: invokevirtual #91 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 121: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 124: swap\n 125: invokevirtual #34 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 128: iconst_0\n 129: istore 5\n 131: iload 5\n 133: bipush 10\n 135: if_icmpge 301\n 138: iconst_0\n 139: istore 6\n 141: aload_3\n 142: checkcast #104 // class java/lang/Iterable\n 145: astore 7\n 147: iconst_0\n 148: istore 8\n 150: aload 7\n 152: invokeinterface #108, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 157: astore 9\n 159: aload 9\n 161: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 166: ifeq 273\n 169: aload 9\n 171: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 176: astore 10\n 178: aload 10\n 180: checkcast #120 // class Ship\n 183: astore 11\n 185: iconst_0\n 186: istore 12\n 188: aload 11\n 190: invokevirtual #123 // Method Ship.getParts:()Ljava/util/List;\n 193: checkcast #104 // class java/lang/Iterable\n 196: astore 13\n 198: iconst_0\n 199: istore 14\n 201: aload 13\n 203: invokeinterface #108, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 208: astore 15\n 210: aload 15\n 212: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 217: ifeq 267\n 220: aload 15\n 222: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 227: astore 16\n 229: aload 16\n 231: checkcast #125 // class Position\n 234: astore 17\n 236: iconst_0\n 237: istore 18\n 239: aload 17\n 241: invokevirtual #129 // Method Position.getRow:()I\n 244: iload 5\n 246: if_icmpne 262\n 249: aload 17\n 251: invokevirtual #132 // Method Position.getCol:()I\n 254: iload 4\n 256: if_icmpne 262\n 259: iconst_1\n 260: istore 6\n 262: nop\n 263: nop\n 264: goto 210\n 267: nop\n 268: nop\n 269: nop\n 270: goto 159\n 273: nop\n 274: iload 6\n 276: ifeq 288\n 279: ldc #134 // String ██\n 281: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 284: swap\n 285: invokevirtual #34 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 288: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 291: aload_2\n 292: invokevirtual #34 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 295: iinc 5, 1\n 298: goto 131\n 301: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 304: invokevirtual #94 // Method java/io/PrintStream.println:()V\n 307: iinc 4, 1\n 310: goto 86\n 313: return\n\n public static final GameState place(GameState, Player);\n Code:\n 0: aload_0\n 1: ldc #66 // String gameState\n 3: invokestatic #72 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #74 // String player\n 9: invokestatic #72 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: invokestatic #163 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;\n 15: getstatic #169 // Field java/util/Locale.ROOT:Ljava/util/Locale;\n 18: invokevirtual #173 // Method java/lang/String.toLowerCase:(Ljava/util/Locale;)Ljava/lang/String;\n 21: dup\n 22: ldc #175 // String toLowerCase(...)\n 24: invokestatic #178 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 27: astore_2\n 28: ldc #180 // String inside place\n 30: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 33: swap\n 34: invokevirtual #182 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 37: aload_1\n 38: getstatic #16 // Field Player.PLAYER1:LPlayer;\n 41: if_acmpne 51\n 44: aload_0\n 45: invokevirtual #99 // Method GameState.getShips1:()Ljava/util/List;\n 48: goto 55\n 51: aload_0\n 52: invokevirtual #102 // Method GameState.getShips2:()Ljava/util/List;\n 55: checkcast #184 // class java/util/Collection\n 58: invokestatic #188 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 61: astore_3\n 62: getstatic #194 // Field Function.PLACE:LFunction;\n 65: aload_2\n 66: invokestatic #198 // Method inputIsValid:(LFunction;Ljava/lang/String;)Z\n 69: ifeq 421\n 72: aload_2\n 73: invokestatic #202 // Method convertPair:(Ljava/lang/String;)Lkotlin/Pair;\n 76: astore 4\n 78: new #204 // class kotlin/Pair\n 81: dup\n 82: aload 4\n 84: invokevirtual #207 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 87: checkcast #125 // class Position\n 90: invokevirtual #129 // Method Position.getRow:()I\n 93: aload 4\n 95: invokevirtual #210 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 98: checkcast #125 // class Position\n 101: invokevirtual #129 // Method Position.getRow:()I\n 104: invokestatic #214 // Method java/lang/Integer.min:(II)I\n 107: invokestatic #51 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 110: aload 4\n 112: invokevirtual #207 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 115: checkcast #125 // class Position\n 118: invokevirtual #132 // Method Position.getCol:()I\n 121: aload 4\n 123: invokevirtual #210 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 126: checkcast #125 // class Position\n 129: invokevirtual #132 // Method Position.getCol:()I\n 132: invokestatic #214 // Method java/lang/Integer.min:(II)I\n 135: invokestatic #51 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 138: invokespecial #217 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 141: astore 5\n 143: new #204 // class kotlin/Pair\n 146: dup\n 147: aload 4\n 149: invokevirtual #207 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 152: checkcast #125 // class Position\n 155: invokevirtual #129 // Method Position.getRow:()I\n 158: aload 4\n 160: invokevirtual #210 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 163: checkcast #125 // class Position\n 166: invokevirtual #129 // Method Position.getRow:()I\n 169: invokestatic #220 // Method java/lang/Integer.max:(II)I\n 172: invokestatic #51 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 175: aload 4\n 177: invokevirtual #207 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 180: checkcast #125 // class Position\n 183: invokevirtual #132 // Method Position.getCol:()I\n 186: aload 4\n 188: invokevirtual #210 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 191: checkcast #125 // class Position\n 194: invokevirtual #132 // Method Position.getCol:()I\n 197: invokestatic #220 // Method java/lang/Integer.max:(II)I\n 200: invokestatic #51 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 203: invokespecial #217 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 206: astore 6\n 208: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 211: aload 4\n 213: invokevirtual #182 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 216: new #222 // class java/util/ArrayList\n 219: dup\n 220: invokespecial #223 // Method java/util/ArrayList.\"<init>\":()V\n 223: checkcast #158 // class java/util/List\n 226: astore 7\n 228: aload 5\n 230: invokevirtual #207 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 233: checkcast #225 // class java/lang/Number\n 236: invokevirtual #228 // Method java/lang/Number.intValue:()I\n 239: istore 8\n 241: aload 6\n 243: invokevirtual #207 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 246: checkcast #225 // class java/lang/Number\n 249: invokevirtual #228 // Method java/lang/Number.intValue:()I\n 252: istore 9\n 254: iload 8\n 256: iload 9\n 258: if_icmpgt 406\n 261: aload 5\n 263: invokevirtual #210 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 266: checkcast #225 // class java/lang/Number\n 269: invokevirtual #228 // Method java/lang/Number.intValue:()I\n 272: istore 10\n 274: aload 6\n 276: invokevirtual #210 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 279: checkcast #225 // class java/lang/Number\n 282: invokevirtual #228 // Method java/lang/Number.intValue:()I\n 285: istore 11\n 287: iload 10\n 289: iload 11\n 291: if_icmpgt 393\n 294: aload_0\n 295: aload_1\n 296: new #125 // class Position\n 299: dup\n 300: iload 10\n 302: iload 8\n 304: invokespecial #231 // Method Position.\"<init>\":(II)V\n 307: invokestatic #235 // Method isCellOccupied:(LGameState;LPlayer;LPosition;)Z\n 310: ifeq 324\n 313: ldc #237 // String This cell is occupied\n 315: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 318: swap\n 319: invokevirtual #182 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 322: aload_0\n 323: areturn\n 324: new #76 // class java/lang/StringBuilder\n 327: dup\n 328: invokespecial #78 // Method java/lang/StringBuilder.\"<init>\":()V\n 331: ldc #239 // String set at\n 333: invokevirtual #84 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 336: iload 8\n 338: invokevirtual #242 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 341: bipush 44\n 343: invokevirtual #87 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 346: iload 10\n 348: invokevirtual #242 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 351: invokevirtual #91 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 354: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 357: swap\n 358: invokevirtual #182 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 361: aload 7\n 363: new #125 // class Position\n 366: dup\n 367: iload 10\n 369: iload 8\n 371: invokespecial #231 // Method Position.\"<init>\":(II)V\n 374: invokeinterface #246, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 379: pop\n 380: iload 10\n 382: iload 11\n 384: if_icmpeq 393\n 387: iinc 10, 1\n 390: goto 294\n 393: iload 8\n 395: iload 9\n 397: if_icmpeq 406\n 400: iinc 8, 1\n 403: goto 261\n 406: aload_3\n 407: new #120 // class Ship\n 410: dup\n 411: aload 7\n 413: invokespecial #249 // Method Ship.\"<init>\":(Ljava/util/List;)V\n 416: invokeinterface #252, 2 // InterfaceMethod java/util/List.addLast:(Ljava/lang/Object;)V\n 421: aload_1\n 422: getstatic #16 // Field Player.PLAYER1:LPlayer;\n 425: if_acmpne 442\n 428: aload_0\n 429: aconst_null\n 430: aconst_null\n 431: aload_3\n 432: aconst_null\n 433: bipush 11\n 435: aconst_null\n 436: invokestatic #256 // Method GameState.copy$default:(LGameState;[[Ljava/lang/Integer;[[Ljava/lang/Integer;Ljava/util/List;Ljava/util/List;ILjava/lang/Object;)LGameState;\n 439: goto 453\n 442: aload_0\n 443: aconst_null\n 444: aconst_null\n 445: aconst_null\n 446: aload_3\n 447: bipush 7\n 449: aconst_null\n 450: invokestatic #256 // Method GameState.copy$default:(LGameState;[[Ljava/lang/Integer;[[Ljava/lang/Integer;Ljava/util/List;Ljava/util/List;ILjava/lang/Object;)LGameState;\n 453: areturn\n\n public static final boolean isCellOccupied(GameState, Player, Position);\n Code:\n 0: aload_0\n 1: ldc #66 // String gameState\n 3: invokestatic #72 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #74 // String player\n 9: invokestatic #72 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_2\n 13: ldc_w #264 // String position\n 16: invokestatic #72 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 19: aload_1\n 20: getstatic #16 // Field Player.PLAYER1:LPlayer;\n 23: if_acmpne 33\n 26: aload_0\n 27: invokevirtual #99 // Method GameState.getShips1:()Ljava/util/List;\n 30: goto 37\n 33: aload_0\n 34: invokevirtual #102 // Method GameState.getShips2:()Ljava/util/List;\n 37: astore_3\n 38: aload_3\n 39: checkcast #104 // class java/lang/Iterable\n 42: astore 4\n 44: iconst_0\n 45: istore 5\n 47: aload 4\n 49: instanceof #184 // class java/util/Collection\n 52: ifeq 72\n 55: aload 4\n 57: checkcast #184 // class java/util/Collection\n 60: invokeinterface #267, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 65: ifeq 72\n 68: iconst_0\n 69: goto 209\n 72: aload 4\n 74: invokeinterface #108, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 79: astore 6\n 81: aload 6\n 83: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 88: ifeq 208\n 91: aload 6\n 93: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 98: astore 7\n 100: aload 7\n 102: checkcast #120 // class Ship\n 105: astore 8\n 107: iconst_0\n 108: istore 9\n 110: aload 8\n 112: invokevirtual #123 // Method Ship.getParts:()Ljava/util/List;\n 115: checkcast #104 // class java/lang/Iterable\n 118: astore 10\n 120: iconst_0\n 121: istore 11\n 123: aload 10\n 125: instanceof #184 // class java/util/Collection\n 128: ifeq 148\n 131: aload 10\n 133: checkcast #184 // class java/util/Collection\n 136: invokeinterface #267, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 141: ifeq 148\n 144: iconst_0\n 145: goto 200\n 148: aload 10\n 150: invokeinterface #108, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 155: astore 12\n 157: aload 12\n 159: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 164: ifeq 199\n 167: aload 12\n 169: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 174: astore 13\n 176: aload 13\n 178: checkcast #125 // class Position\n 181: astore 14\n 183: iconst_0\n 184: istore 15\n 186: aload 14\n 188: aload_2\n 189: invokestatic #271 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 192: ifeq 157\n 195: iconst_1\n 196: goto 200\n 199: iconst_0\n 200: nop\n 201: ifeq 81\n 204: iconst_1\n 205: goto 209\n 208: iconst_0\n 209: ireturn\n\n public static final kotlin.Pair<Position, Position> convertPair(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #279 // String input\n 4: invokestatic #72 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: new #76 // class java/lang/StringBuilder\n 10: dup\n 11: invokespecial #78 // Method java/lang/StringBuilder.\"<init>\":()V\n 14: ldc_w #281 // String in convertPair\n 17: invokevirtual #84 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: aload_0\n 21: invokevirtual #84 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: invokevirtual #91 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 27: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 30: swap\n 31: invokevirtual #182 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 34: new #204 // class kotlin/Pair\n 37: dup\n 38: aload_0\n 39: iconst_0\n 40: iconst_2\n 41: invokevirtual #285 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 44: dup\n 45: ldc_w #287 // String substring(...)\n 48: invokestatic #178 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 51: invokestatic #291 // Method convert:(Ljava/lang/String;)LPosition;\n 54: aload_0\n 55: iconst_2\n 56: iconst_4\n 57: invokevirtual #285 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 60: dup\n 61: ldc_w #287 // String substring(...)\n 64: invokestatic #178 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 67: invokestatic #291 // Method convert:(Ljava/lang/String;)LPosition;\n 70: invokespecial #217 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 73: areturn\n\n public static final Position convert(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #279 // String input\n 4: invokestatic #72 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: new #76 // class java/lang/StringBuilder\n 10: dup\n 11: invokespecial #78 // Method java/lang/StringBuilder.\"<init>\":()V\n 14: ldc_w #293 // String in convert\n 17: invokevirtual #84 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: aload_0\n 21: invokevirtual #84 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: invokevirtual #91 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 27: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 30: swap\n 31: invokevirtual #182 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 34: aload_0\n 35: iconst_0\n 36: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 39: istore_1\n 40: aload_0\n 41: iconst_1\n 42: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 45: istore_2\n 46: iload_1\n 47: bipush 97\n 49: isub\n 50: istore_3\n 51: iload_2\n 52: invokestatic #300 // Method java/lang/String.valueOf:(C)Ljava/lang/String;\n 55: invokestatic #304 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 58: istore 4\n 60: new #125 // class Position\n 63: dup\n 64: iload_3\n 65: iload 4\n 67: invokespecial #231 // Method Position.\"<init>\":(II)V\n 70: areturn\n\n public static final void check();\n Code:\n 0: invokestatic #163 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;\n 3: getstatic #169 // Field java/util/Locale.ROOT:Ljava/util/Locale;\n 6: invokevirtual #173 // Method java/lang/String.toLowerCase:(Ljava/util/Locale;)Ljava/lang/String;\n 9: dup\n 10: ldc #175 // String toLowerCase(...)\n 12: invokestatic #178 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 15: astore_0\n 16: getstatic #311 // Field Function.CHECK:LFunction;\n 19: aload_0\n 20: invokestatic #198 // Method inputIsValid:(LFunction;Ljava/lang/String;)Z\n 23: ifeq 26\n 26: return\n\n public static final boolean inputIsValid(Function, java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #314 // String function\n 4: invokestatic #72 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: ldc_w #279 // String input\n 11: invokestatic #72 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 17: aload_0\n 18: invokevirtual #182 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 21: aload_0\n 22: getstatic #320 // Field MainKt$WhenMappings.$EnumSwitchMapping$0:[I\n 25: swap\n 26: invokevirtual #323 // Method Function.ordinal:()I\n 29: iaload\n 30: tableswitch { // 1 to 2\n 1: 52\n 2: 134\n default: 338\n }\n 52: aload_1\n 53: invokevirtual #326 // Method java/lang/String.length:()I\n 56: iconst_2\n 57: if_icmpne 122\n 60: aload_1\n 61: iconst_0\n 62: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 65: istore_2\n 66: bipush 97\n 68: iload_2\n 69: if_icmpgt 86\n 72: iload_2\n 73: bipush 107\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 122\n 90: aload_1\n 91: iconst_1\n 92: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 95: istore_2\n 96: bipush 48\n 98: iload_2\n 99: if_icmpgt 116\n 102: iload_2\n 103: bipush 58\n 105: if_icmpge 112\n 108: iconst_1\n 109: goto 117\n 112: iconst_0\n 113: goto 117\n 116: iconst_0\n 117: ifeq 122\n 120: iconst_1\n 121: ireturn\n 122: ldc_w #328 // String Enter the cell index in format \\\"letternumber\\\", for example \\\"a0a3\\\"\n 125: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 128: swap\n 129: invokevirtual #182 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 132: iconst_0\n 133: ireturn\n 134: aload_1\n 135: invokevirtual #326 // Method java/lang/String.length:()I\n 138: iconst_4\n 139: if_icmpne 326\n 142: aload_1\n 143: iconst_0\n 144: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 147: istore_2\n 148: bipush 97\n 150: iload_2\n 151: if_icmpgt 168\n 154: iload_2\n 155: bipush 107\n 157: if_icmpge 164\n 160: iconst_1\n 161: goto 169\n 164: iconst_0\n 165: goto 169\n 168: iconst_0\n 169: ifeq 326\n 172: aload_1\n 173: iconst_1\n 174: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 177: istore_2\n 178: bipush 48\n 180: iload_2\n 181: if_icmpgt 198\n 184: iload_2\n 185: bipush 58\n 187: if_icmpge 194\n 190: iconst_1\n 191: goto 199\n 194: iconst_0\n 195: goto 199\n 198: iconst_0\n 199: ifeq 326\n 202: aload_1\n 203: iconst_2\n 204: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 207: istore_2\n 208: bipush 97\n 210: iload_2\n 211: if_icmpgt 228\n 214: iload_2\n 215: bipush 107\n 217: if_icmpge 224\n 220: iconst_1\n 221: goto 229\n 224: iconst_0\n 225: goto 229\n 228: iconst_0\n 229: ifeq 326\n 232: aload_1\n 233: iconst_3\n 234: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 237: istore_2\n 238: bipush 48\n 240: iload_2\n 241: if_icmpgt 258\n 244: iload_2\n 245: bipush 58\n 247: if_icmpge 254\n 250: iconst_1\n 251: goto 259\n 254: iconst_0\n 255: goto 259\n 258: iconst_0\n 259: ifeq 326\n 262: aload_1\n 263: iconst_0\n 264: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 267: aload_1\n 268: iconst_2\n 269: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 272: if_icmpeq 288\n 275: aload_1\n 276: iconst_1\n 277: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 280: aload_1\n 281: iconst_3\n 282: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 285: if_icmpne 326\n 288: aload_1\n 289: iconst_0\n 290: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 293: aload_1\n 294: iconst_2\n 295: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 298: isub\n 299: invokestatic #334 // Method java/lang/Math.abs:(I)I\n 302: iconst_3\n 303: if_icmpgt 326\n 306: aload_1\n 307: iconst_1\n 308: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 311: aload_1\n 312: iconst_3\n 313: invokevirtual #297 // Method java/lang/String.charAt:(I)C\n 316: isub\n 317: invokestatic #334 // Method java/lang/Math.abs:(I)I\n 320: iconst_3\n 321: if_icmpgt 326\n 324: iconst_1\n 325: ireturn\n 326: ldc_w #336 // String Enter the cell indexes in format \\\"letternumberletternumber\\\" for placing ship, for example \\\"a0b0\\\"\n 329: getstatic #28 // Field java/lang/System.out:Ljava/io/PrintStream;\n 332: swap\n 333: invokevirtual #182 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 336: iconst_0\n 337: ireturn\n 338: new #338 // class kotlin/NoWhenBranchMatchedException\n 341: dup\n 342: invokespecial #339 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 345: athrow\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #342 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
jomartigcal__kotlin-heroes__ad16779/practice-4/src/practice4e.kt
// Special Permutation // https://codeforces.com/contest/1347/problem/E private fun readLn() = readLine()!! private fun readInt() = readLn().toInt() private fun readStrings() = readLn().split(" ") private fun readInts() = readStrings().map { it.toInt() } fun main() { val lines = readInt() for (line in 1..lines) { val number = readInt() if (number < 4) { println("-1") } else { println(getPermutation(number).joinToString(" ")) } } } fun getPermutation(number: Int): List<Int> { val permutations = mutableSetOf<Int>() val numbers = (1..number).map { it } as MutableList val evens = numbers.filter { it % 2 == 0} permutations.addAll(evens) val odds = numbers.filter { it % 2 != 0}.reversed() permutations.add(evens.last()-3) permutations.addAll(odds) return permutations.toList() }
[ { "class_path": "jomartigcal__kotlin-heroes__ad16779/Practice4eKt.class", "javap": "Compiled from \"practice4e.kt\"\npublic final class Practice4eKt {\n private static final java.lang.String readLn();\n Code:\n 0: invokestatic #11 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 3: dup\n 4: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 7: areturn\n\n private static final int readInt();\n Code:\n 0: invokestatic #21 // Method readLn:()Ljava/lang/String;\n 3: invokestatic #27 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 6: ireturn\n\n private static final java.util.List<java.lang.String> readStrings();\n Code:\n 0: invokestatic #21 // Method readLn:()Ljava/lang/String;\n 3: checkcast #32 // class java/lang/CharSequence\n 6: iconst_1\n 7: anewarray #34 // class java/lang/String\n 10: astore_0\n 11: aload_0\n 12: iconst_0\n 13: ldc #36 // String\n 15: aastore\n 16: aload_0\n 17: iconst_0\n 18: iconst_0\n 19: bipush 6\n 21: aconst_null\n 22: invokestatic #42 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 25: areturn\n\n private static final java.util.List<java.lang.Integer> readInts();\n Code:\n 0: invokestatic #46 // Method readStrings:()Ljava/util/List;\n 3: checkcast #48 // 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 #50 // class java/util/ArrayList\n 14: dup\n 15: aload_0\n 16: bipush 10\n 18: invokestatic #56 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 21: invokespecial #60 // Method java/util/ArrayList.\"<init>\":(I)V\n 24: checkcast #62 // class java/util/Collection\n 27: astore_3\n 28: iconst_0\n 29: istore 4\n 31: aload_2\n 32: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore 5\n 39: aload 5\n 41: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 92\n 49: aload 5\n 51: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 56: astore 6\n 58: aload_3\n 59: aload 6\n 61: checkcast #34 // class java/lang/String\n 64: astore 7\n 66: astore 9\n 68: iconst_0\n 69: istore 8\n 71: aload 7\n 73: invokestatic #27 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 76: nop\n 77: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 80: aload 9\n 82: swap\n 83: invokeinterface #84, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 88: pop\n 89: goto 39\n 92: aload_3\n 93: checkcast #86 // class java/util/List\n 96: nop\n 97: areturn\n\n public static final void main();\n Code:\n 0: invokestatic #103 // Method readInt:()I\n 3: istore_0\n 4: iconst_1\n 5: istore_1\n 6: iload_1\n 7: iload_0\n 8: if_icmpgt 73\n 11: invokestatic #103 // Method readInt:()I\n 14: istore_2\n 15: iload_2\n 16: iconst_4\n 17: if_icmpge 32\n 20: ldc #105 // String -1\n 22: getstatic #111 // Field java/lang/System.out:Ljava/io/PrintStream;\n 25: swap\n 26: invokevirtual #116 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 29: goto 62\n 32: iload_2\n 33: invokestatic #120 // Method getPermutation:(I)Ljava/util/List;\n 36: checkcast #48 // class java/lang/Iterable\n 39: ldc #36 // String\n 41: checkcast #32 // class java/lang/CharSequence\n 44: aconst_null\n 45: aconst_null\n 46: iconst_0\n 47: aconst_null\n 48: aconst_null\n 49: bipush 62\n 51: aconst_null\n 52: invokestatic #124 // 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 55: getstatic #111 // Field java/lang/System.out:Ljava/io/PrintStream;\n 58: swap\n 59: invokevirtual #116 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 62: iload_1\n 63: iload_0\n 64: if_icmpeq 73\n 67: iinc 1, 1\n 70: goto 11\n 73: return\n\n public static final java.util.List<java.lang.Integer> getPermutation(int);\n Code:\n 0: new #131 // class java/util/LinkedHashSet\n 3: dup\n 4: invokespecial #133 // Method java/util/LinkedHashSet.\"<init>\":()V\n 7: checkcast #135 // class java/util/Set\n 10: astore_1\n 11: new #137 // class kotlin/ranges/IntRange\n 14: dup\n 15: iconst_1\n 16: iload_0\n 17: invokespecial #140 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 20: checkcast #48 // class java/lang/Iterable\n 23: astore 4\n 25: iconst_0\n 26: istore 5\n 28: aload 4\n 30: astore 6\n 32: new #50 // class java/util/ArrayList\n 35: dup\n 36: aload 4\n 38: bipush 10\n 40: invokestatic #56 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 43: invokespecial #60 // Method java/util/ArrayList.\"<init>\":(I)V\n 46: checkcast #62 // class java/util/Collection\n 49: astore 7\n 51: iconst_0\n 52: istore 8\n 54: aload 6\n 56: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 61: astore 9\n 63: aload 9\n 65: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 70: ifeq 111\n 73: aload 9\n 75: checkcast #142 // class kotlin/collections/IntIterator\n 78: invokevirtual #145 // Method kotlin/collections/IntIterator.nextInt:()I\n 81: istore 10\n 83: aload 7\n 85: iload 10\n 87: istore 11\n 89: astore 14\n 91: iconst_0\n 92: istore 12\n 94: iload 11\n 96: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 99: aload 14\n 101: swap\n 102: invokeinterface #84, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 107: pop\n 108: goto 63\n 111: aload 7\n 113: checkcast #86 // class java/util/List\n 116: nop\n 117: invokestatic #151 // Method kotlin/jvm/internal/TypeIntrinsics.asMutableList:(Ljava/lang/Object;)Ljava/util/List;\n 120: astore_2\n 121: aload_2\n 122: checkcast #48 // class java/lang/Iterable\n 125: astore 4\n 127: iconst_0\n 128: istore 5\n 130: aload 4\n 132: astore 6\n 134: new #50 // class java/util/ArrayList\n 137: dup\n 138: invokespecial #152 // Method java/util/ArrayList.\"<init>\":()V\n 141: checkcast #62 // class java/util/Collection\n 144: astore 7\n 146: iconst_0\n 147: istore 8\n 149: aload 6\n 151: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 156: astore 9\n 158: aload 9\n 160: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 165: ifeq 218\n 168: aload 9\n 170: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 175: astore 10\n 177: aload 10\n 179: checkcast #154 // class java/lang/Number\n 182: invokevirtual #157 // Method java/lang/Number.intValue:()I\n 185: istore 11\n 187: iconst_0\n 188: istore 12\n 190: iload 11\n 192: iconst_2\n 193: irem\n 194: ifne 201\n 197: iconst_1\n 198: goto 202\n 201: iconst_0\n 202: ifeq 158\n 205: aload 7\n 207: aload 10\n 209: invokeinterface #84, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 214: pop\n 215: goto 158\n 218: aload 7\n 220: checkcast #86 // class java/util/List\n 223: nop\n 224: astore_3\n 225: aload_1\n 226: aload_3\n 227: checkcast #62 // class java/util/Collection\n 230: invokeinterface #161, 2 // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z\n 235: pop\n 236: aload_2\n 237: checkcast #48 // class java/lang/Iterable\n 240: astore 5\n 242: iconst_0\n 243: istore 6\n 245: aload 5\n 247: astore 7\n 249: new #50 // class java/util/ArrayList\n 252: dup\n 253: invokespecial #152 // Method java/util/ArrayList.\"<init>\":()V\n 256: checkcast #62 // class java/util/Collection\n 259: astore 8\n 261: iconst_0\n 262: istore 9\n 264: aload 7\n 266: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 271: astore 10\n 273: aload 10\n 275: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 280: ifeq 333\n 283: aload 10\n 285: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 290: astore 11\n 292: aload 11\n 294: checkcast #154 // class java/lang/Number\n 297: invokevirtual #157 // Method java/lang/Number.intValue:()I\n 300: istore 12\n 302: iconst_0\n 303: istore 13\n 305: iload 12\n 307: iconst_2\n 308: irem\n 309: ifeq 316\n 312: iconst_1\n 313: goto 317\n 316: iconst_0\n 317: ifeq 273\n 320: aload 8\n 322: aload 11\n 324: invokeinterface #84, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 329: pop\n 330: goto 273\n 333: aload 8\n 335: checkcast #86 // class java/util/List\n 338: nop\n 339: checkcast #48 // class java/lang/Iterable\n 342: invokestatic #165 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 345: astore 4\n 347: aload_1\n 348: aload_3\n 349: invokestatic #169 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 352: checkcast #154 // class java/lang/Number\n 355: invokevirtual #157 // Method java/lang/Number.intValue:()I\n 358: iconst_3\n 359: isub\n 360: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 363: invokeinterface #170, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 368: pop\n 369: aload_1\n 370: aload 4\n 372: checkcast #62 // class java/util/Collection\n 375: invokeinterface #161, 2 // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z\n 380: pop\n 381: aload_1\n 382: checkcast #48 // class java/lang/Iterable\n 385: invokestatic #173 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 388: areturn\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": "" } ]
andrewrlee__adventOfCode2021__aace0fc/src/main/kotlin/Day15.kt
import java.io.File import java.nio.charset.Charset.defaultCharset import kotlin.streams.toList typealias ChitonGrid = Map<Pair<Int, Int>, Day15.Square> object Day15 { private fun toCoordinates(row: Int, line: String) = line.chars() .map(Character::getNumericValue) .toList() .mapIndexed { col, value -> (col to row) to Square((col to row), value) } private fun draw(coordinates: Collection<Square>) { println("\n") val maxCols = coordinates.maxOf { it.coord.first } val maxRows = coordinates.maxOf { it.coord.second } (0..maxRows).forEach { row -> (0..maxCols).forEach { col -> print(coordinates.find { it.coord == Pair(col, row) }?.let { it.risk } ?: ".") } println() } } data class Square( var coord: Pair<Int, Int>, var risk: Int, var distance: Int = Int.MAX_VALUE, var parent: Square? = null ): Comparable<Square> { fun getNeighbours( validCells: ChitonGrid, remaining: Collection<Square>, deltas: List<Pair<Int, Int>> = listOf( -1 to 0, 0 to -1, 1 to 0, 0 to 1, ) ) = deltas.asSequence() .map { (x2, y2) -> coord.first + x2 to coord.second + y2 } .mapNotNull { validCells[it] } .filter { remaining.contains(it) } override fun compareTo(other: Square): Int { return this.distance.compareTo(other.distance) } } object Part1 { val chitonGrid = { File("day15/input-real.txt") .readLines(defaultCharset()) .mapIndexed(::toCoordinates) .flatten() .associate { it } } fun run() { val grid = chitonGrid() grid.values.first().distance = 0 val queue = grid.values.toMutableList() while (queue.isNotEmpty()) { val next = queue.minOrNull()!! queue.remove(next) val neighbours = next.getNeighbours(grid, queue) neighbours.forEach { if (next.distance + next.risk < it.distance) { it.distance = next.distance + next.risk it.parent = next } } } var end = grid.values.last() val parents = mutableListOf(end) while(end.parent != null) { end = end.parent!! parents.add(end) } draw(parents) parents.reversed().forEach { println("${it.coord} ${it.risk} ${it.distance}") } parents.sumOf { it.risk }.also { println(it - grid.values.first().risk) } } } object Part2 { private fun toCoordinates(row: Int, line: List<Int>) = line .mapIndexed { col, value -> (col to row) to Square((col to row), value) } fun run() { val grid = File("day15/input-real.txt") .readLines(defaultCharset()) .map { it.map (Character::getNumericValue) } .map { vals -> (0..4).flatMap{ i -> vals.map { round(it, i) }}}.let{ grid -> (0..4).flatMap{ i -> grid.map { row -> row.map { round(it, i) } }} }.mapIndexed { i, it -> toCoordinates(i, it) } .flatten() .associate { it } grid.values.first().distance = 0 val queue = grid.values.toMutableList() val total = queue.size var count = 0 while (queue.isNotEmpty()) { if (count++ % 500 == 0) { println("$count/$total (${queue.size})") } val next = queue.minOrNull()!! queue.remove(next) val neighbours = next.getNeighbours(grid, queue) neighbours.forEach { if (next.distance + next.risk < it.distance) { it.distance = next.distance + next.risk it.parent = next } } } var end = grid.values.last() val parents = mutableListOf(end) while(end.parent != null) { end = end.parent!! parents.add(end) } draw(parents) parents.reversed().forEach { println("${it.coord} ${it.risk} ${it.distance}") } parents.sumOf { it.risk }.also { println(it - grid.values.first().risk) } } } private fun round(it: Int, i: Int): Int { val x = it + i val y = x - 9 return if (y > 0) y else x } } fun main() { Day15.Part1.run() Day15.Part2.run() // 21 mins! }
[ { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day15.class", "javap": "Compiled from \"Day15.kt\"\npublic final class Day15 {\n public static final Day15 INSTANCE;\n\n private Day15();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final java.util.List<kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day15$Square>> toCoordinates(int, java.lang.String);\n Code:\n 0: aload_2\n 1: invokevirtual #19 // Method java/lang/String.chars:()Ljava/util/stream/IntStream;\n 4: invokedynamic #38, 0 // InvokeDynamic #0:applyAsInt:()Ljava/util/function/IntUnaryOperator;\n 9: invokeinterface #44, 2 // InterfaceMethod java/util/stream/IntStream.map:(Ljava/util/function/IntUnaryOperator;)Ljava/util/stream/IntStream;\n 14: dup\n 15: ldc #46 // String map(...)\n 17: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 20: invokestatic #58 // Method kotlin/streams/jdk8/StreamsKt.toList:(Ljava/util/stream/IntStream;)Ljava/util/List;\n 23: checkcast #60 // class java/lang/Iterable\n 26: astore_3\n 27: nop\n 28: iconst_0\n 29: istore 4\n 31: aload_3\n 32: astore 5\n 34: new #62 // class java/util/ArrayList\n 37: dup\n 38: aload_3\n 39: bipush 10\n 41: invokestatic #68 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 44: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 47: checkcast #73 // class java/util/Collection\n 50: astore 6\n 52: iconst_0\n 53: istore 7\n 55: iconst_0\n 56: istore 8\n 58: aload 5\n 60: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 65: astore 9\n 67: aload 9\n 69: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 74: ifeq 175\n 77: aload 9\n 79: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 84: astore 10\n 86: aload 6\n 88: iload 8\n 90: iinc 8, 1\n 93: istore 11\n 95: iload 11\n 97: ifge 103\n 100: invokestatic #90 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 103: iload 11\n 105: aload 10\n 107: checkcast #92 // class java/lang/Number\n 110: invokevirtual #96 // Method java/lang/Number.intValue:()I\n 113: istore 12\n 115: istore 13\n 117: astore 15\n 119: iconst_0\n 120: istore 14\n 122: iload 13\n 124: invokestatic #102 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 127: iload_1\n 128: invokestatic #102 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 131: invokestatic #108 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 134: new #110 // class Day15$Square\n 137: dup\n 138: iload 13\n 140: invokestatic #102 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 143: iload_1\n 144: invokestatic #102 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 147: invokestatic #108 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 150: iload 12\n 152: iconst_0\n 153: aconst_null\n 154: bipush 12\n 156: aconst_null\n 157: invokespecial #113 // Method Day15$Square.\"<init>\":(Lkotlin/Pair;IILDay15$Square;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 160: invokestatic #108 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 163: aload 15\n 165: swap\n 166: invokeinterface #117, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 171: pop\n 172: goto 67\n 175: aload 6\n 177: checkcast #119 // class java/util/List\n 180: nop\n 181: areturn\n\n private final void draw(java.util.Collection<Day15$Square>);\n Code:\n 0: ldc #141 // String \\n\n 2: getstatic #147 // Field java/lang/System.out:Ljava/io/PrintStream;\n 5: swap\n 6: invokevirtual #153 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 9: aload_1\n 10: checkcast #60 // class java/lang/Iterable\n 13: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 18: astore 4\n 20: aload 4\n 22: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 27: ifne 38\n 30: new #155 // class java/util/NoSuchElementException\n 33: dup\n 34: invokespecial #156 // Method java/util/NoSuchElementException.\"<init>\":()V\n 37: athrow\n 38: aload 4\n 40: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 45: checkcast #110 // class Day15$Square\n 48: astore 5\n 50: iconst_0\n 51: istore 6\n 53: aload 5\n 55: invokevirtual #160 // Method Day15$Square.getCoord:()Lkotlin/Pair;\n 58: invokevirtual #165 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 61: checkcast #92 // class java/lang/Number\n 64: invokevirtual #96 // Method java/lang/Number.intValue:()I\n 67: istore 5\n 69: aload 4\n 71: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 76: ifeq 124\n 79: aload 4\n 81: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: checkcast #110 // class Day15$Square\n 89: astore 6\n 91: iconst_0\n 92: istore 7\n 94: aload 6\n 96: invokevirtual #160 // Method Day15$Square.getCoord:()Lkotlin/Pair;\n 99: invokevirtual #165 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 102: checkcast #92 // class java/lang/Number\n 105: invokevirtual #96 // Method java/lang/Number.intValue:()I\n 108: istore 6\n 110: iload 5\n 112: iload 6\n 114: if_icmpge 69\n 117: iload 6\n 119: istore 5\n 121: goto 69\n 124: iload 5\n 126: istore_2\n 127: aload_1\n 128: checkcast #60 // class java/lang/Iterable\n 131: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 136: astore 5\n 138: aload 5\n 140: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 145: ifne 156\n 148: new #155 // class java/util/NoSuchElementException\n 151: dup\n 152: invokespecial #156 // Method java/util/NoSuchElementException.\"<init>\":()V\n 155: athrow\n 156: aload 5\n 158: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 163: checkcast #110 // class Day15$Square\n 166: astore 6\n 168: iconst_0\n 169: istore 7\n 171: aload 6\n 173: invokevirtual #160 // Method Day15$Square.getCoord:()Lkotlin/Pair;\n 176: invokevirtual #168 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 179: checkcast #92 // class java/lang/Number\n 182: invokevirtual #96 // Method java/lang/Number.intValue:()I\n 185: istore 6\n 187: aload 5\n 189: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 194: ifeq 242\n 197: aload 5\n 199: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 204: checkcast #110 // class Day15$Square\n 207: astore 7\n 209: iconst_0\n 210: istore 8\n 212: aload 7\n 214: invokevirtual #160 // Method Day15$Square.getCoord:()Lkotlin/Pair;\n 217: invokevirtual #168 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 220: checkcast #92 // class java/lang/Number\n 223: invokevirtual #96 // Method java/lang/Number.intValue:()I\n 226: istore 7\n 228: iload 6\n 230: iload 7\n 232: if_icmpge 187\n 235: iload 7\n 237: istore 6\n 239: goto 187\n 242: iload 6\n 244: istore_3\n 245: new #170 // class kotlin/ranges/IntRange\n 248: dup\n 249: iconst_0\n 250: iload_3\n 251: invokespecial #173 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 254: checkcast #60 // class java/lang/Iterable\n 257: astore 4\n 259: iconst_0\n 260: istore 5\n 262: aload 4\n 264: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 269: astore 6\n 271: aload 6\n 273: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 278: ifeq 480\n 281: aload 6\n 283: checkcast #175 // class kotlin/collections/IntIterator\n 286: invokevirtual #178 // Method kotlin/collections/IntIterator.nextInt:()I\n 289: istore 7\n 291: iload 7\n 293: istore 8\n 295: iconst_0\n 296: istore 9\n 298: new #170 // class kotlin/ranges/IntRange\n 301: dup\n 302: iconst_0\n 303: iload_2\n 304: invokespecial #173 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 307: checkcast #60 // class java/lang/Iterable\n 310: astore 10\n 312: iconst_0\n 313: istore 11\n 315: aload 10\n 317: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 322: astore 12\n 324: aload 12\n 326: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 331: ifeq 468\n 334: aload 12\n 336: checkcast #175 // class kotlin/collections/IntIterator\n 339: invokevirtual #178 // Method kotlin/collections/IntIterator.nextInt:()I\n 342: istore 13\n 344: iload 13\n 346: istore 14\n 348: iconst_0\n 349: istore 15\n 351: aload_1\n 352: checkcast #60 // class java/lang/Iterable\n 355: astore 16\n 357: aload 16\n 359: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 364: astore 17\n 366: aload 17\n 368: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 373: ifeq 428\n 376: aload 17\n 378: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 383: astore 18\n 385: aload 18\n 387: checkcast #110 // class Day15$Square\n 390: astore 19\n 392: iconst_0\n 393: istore 20\n 395: aload 19\n 397: invokevirtual #160 // Method Day15$Square.getCoord:()Lkotlin/Pair;\n 400: new #162 // class kotlin/Pair\n 403: dup\n 404: iload 14\n 406: invokestatic #102 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 409: iload 8\n 411: invokestatic #102 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 414: invokespecial #181 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 417: invokestatic #185 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 420: ifeq 366\n 423: aload 18\n 425: goto 429\n 428: aconst_null\n 429: checkcast #110 // class Day15$Square\n 432: dup\n 433: ifnull 453\n 436: astore 17\n 438: iconst_0\n 439: istore 18\n 441: aload 17\n 443: invokevirtual #188 // Method Day15$Square.getRisk:()I\n 446: nop\n 447: invokestatic #102 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 450: goto 456\n 453: pop\n 454: ldc #190 // String .\n 456: getstatic #147 // Field java/lang/System.out:Ljava/io/PrintStream;\n 459: swap\n 460: invokevirtual #193 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 463: nop\n 464: nop\n 465: goto 324\n 468: nop\n 469: getstatic #147 // Field java/lang/System.out:Ljava/io/PrintStream;\n 472: invokevirtual #195 // Method java/io/PrintStream.println:()V\n 475: nop\n 476: nop\n 477: goto 271\n 480: nop\n 481: return\n\n private final int round(int, int);\n Code:\n 0: iload_1\n 1: iload_2\n 2: iadd\n 3: istore_3\n 4: iload_3\n 5: bipush 9\n 7: isub\n 8: istore 4\n 10: iload 4\n 12: ifle 20\n 15: iload 4\n 17: goto 21\n 20: iload_3\n 21: ireturn\n\n public static final void access$draw(Day15, java.util.Collection);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #218 // Method draw:(Ljava/util/Collection;)V\n 5: return\n\n public static final java.util.List access$toCoordinates(Day15, int, java.lang.String);\n Code:\n 0: aload_0\n 1: iload_1\n 2: aload_2\n 3: invokespecial #223 // Method toCoordinates:(ILjava/lang/String;)Ljava/util/List;\n 6: areturn\n\n public static final int access$round(Day15, int, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: iload_2\n 3: invokespecial #227 // Method round:(II)I\n 6: ireturn\n\n static {};\n Code:\n 0: new #2 // class Day15\n 3: dup\n 4: invokespecial #229 // Method \"<init>\":()V\n 7: putstatic #232 // Field INSTANCE:LDay15;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day15Kt.class", "javap": "Compiled from \"Day15.kt\"\npublic final class Day15Kt {\n public static final void main();\n Code:\n 0: getstatic #12 // Field Day15$Part1.INSTANCE:LDay15$Part1;\n 3: invokevirtual #15 // Method Day15$Part1.run:()V\n 6: getstatic #20 // Field Day15$Part2.INSTANCE:LDay15$Part2;\n 9: invokevirtual #21 // Method Day15$Part2.run:()V\n 12: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #24 // Method main:()V\n 3: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day15$Square.class", "javap": "Compiled from \"Day15.kt\"\npublic final class Day15$Square implements java.lang.Comparable<Day15$Square> {\n private kotlin.Pair<java.lang.Integer, java.lang.Integer> coord;\n\n private int risk;\n\n private int distance;\n\n private Day15$Square parent;\n\n public Day15$Square(kotlin.Pair<java.lang.Integer, java.lang.Integer>, int, int, Day15$Square);\n Code:\n 0: aload_1\n 1: ldc #14 // String coord\n 3: invokestatic #20 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #23 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #26 // Field coord:Lkotlin/Pair;\n 15: aload_0\n 16: iload_2\n 17: putfield #30 // Field risk:I\n 20: aload_0\n 21: iload_3\n 22: putfield #33 // Field distance:I\n 25: aload_0\n 26: aload 4\n 28: putfield #37 // Field parent:LDay15$Square;\n 31: return\n\n public Day15$Square(kotlin.Pair, int, int, Day15$Square, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload 5\n 2: iconst_4\n 3: iand\n 4: ifeq 10\n 7: ldc #40 // int 2147483647\n 9: istore_3\n 10: iload 5\n 12: bipush 8\n 14: iand\n 15: ifeq 21\n 18: aconst_null\n 19: astore 4\n 21: aload_0\n 22: aload_1\n 23: iload_2\n 24: iload_3\n 25: aload 4\n 27: invokespecial #42 // Method \"<init>\":(Lkotlin/Pair;IILDay15$Square;)V\n 30: return\n\n public final kotlin.Pair<java.lang.Integer, java.lang.Integer> getCoord();\n Code:\n 0: aload_0\n 1: getfield #26 // Field coord:Lkotlin/Pair;\n 4: areturn\n\n public final void setCoord(kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_1\n 1: ldc #50 // String <set-?>\n 3: invokestatic #20 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: putfield #26 // Field coord:Lkotlin/Pair;\n 11: return\n\n public final int getRisk();\n Code:\n 0: aload_0\n 1: getfield #30 // Field risk:I\n 4: ireturn\n\n public final void setRisk(int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #30 // Field risk:I\n 5: return\n\n public final int getDistance();\n Code:\n 0: aload_0\n 1: getfield #33 // Field distance:I\n 4: ireturn\n\n public final void setDistance(int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #33 // Field distance:I\n 5: return\n\n public final Day15$Square getParent();\n Code:\n 0: aload_0\n 1: getfield #37 // Field parent:LDay15$Square;\n 4: areturn\n\n public final void setParent(Day15$Square);\n Code:\n 0: aload_0\n 1: aload_1\n 2: putfield #37 // Field parent:LDay15$Square;\n 5: return\n\n public final kotlin.sequences.Sequence<Day15$Square> getNeighbours(java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day15$Square>, java.util.Collection<Day15$Square>, java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>>);\n Code:\n 0: aload_1\n 1: ldc #65 // String validCells\n 3: invokestatic #20 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #67 // String remaining\n 9: invokestatic #20 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_3\n 13: ldc #69 // String deltas\n 15: invokestatic #20 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_3\n 19: checkcast #71 // class java/lang/Iterable\n 22: invokestatic #77 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 25: aload_0\n 26: invokedynamic #97, 0 // InvokeDynamic #0:invoke:(LDay15$Square;)Lkotlin/jvm/functions/Function1;\n 31: invokestatic #103 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 34: aload_1\n 35: invokedynamic #113, 0 // InvokeDynamic #1:invoke:(Ljava/util/Map;)Lkotlin/jvm/functions/Function1;\n 40: invokestatic #116 // Method kotlin/sequences/SequencesKt.mapNotNull:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 43: aload_2\n 44: invokedynamic #126, 0 // InvokeDynamic #2:invoke:(Ljava/util/Collection;)Lkotlin/jvm/functions/Function1;\n 49: invokestatic #129 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 52: areturn\n\n public static kotlin.sequences.Sequence getNeighbours$default(Day15$Square, java.util.Map, java.util.Collection, java.util.List, int, java.lang.Object);\n Code:\n 0: iload 4\n 2: iconst_4\n 3: iand\n 4: ifeq 79\n 7: iconst_4\n 8: anewarray #136 // class kotlin/Pair\n 11: astore 6\n 13: aload 6\n 15: iconst_0\n 16: iconst_m1\n 17: invokestatic #142 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 20: iconst_0\n 21: invokestatic #142 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 24: invokestatic #148 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 27: aastore\n 28: aload 6\n 30: iconst_1\n 31: iconst_0\n 32: invokestatic #142 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: iconst_m1\n 36: invokestatic #142 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 39: invokestatic #148 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 42: aastore\n 43: aload 6\n 45: iconst_2\n 46: iconst_1\n 47: invokestatic #142 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 50: iconst_0\n 51: invokestatic #142 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 54: invokestatic #148 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 57: aastore\n 58: aload 6\n 60: iconst_3\n 61: iconst_0\n 62: invokestatic #142 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 65: iconst_1\n 66: invokestatic #142 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 69: invokestatic #148 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 72: aastore\n 73: aload 6\n 75: invokestatic #152 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 78: astore_3\n 79: aload_0\n 80: aload_1\n 81: aload_2\n 82: aload_3\n 83: invokevirtual #154 // Method getNeighbours:(Ljava/util/Map;Ljava/util/Collection;Ljava/util/List;)Lkotlin/sequences/Sequence;\n 86: areturn\n\n public int compareTo(Day15$Square);\n Code:\n 0: aload_1\n 1: ldc #158 // String other\n 3: invokestatic #20 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #33 // Field distance:I\n 10: aload_1\n 11: getfield #33 // Field distance:I\n 14: invokestatic #162 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 17: ireturn\n\n public final kotlin.Pair<java.lang.Integer, java.lang.Integer> component1();\n Code:\n 0: aload_0\n 1: getfield #26 // Field coord:Lkotlin/Pair;\n 4: areturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #30 // Field risk:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #33 // Field distance:I\n 4: ireturn\n\n public final Day15$Square component4();\n Code:\n 0: aload_0\n 1: getfield #37 // Field parent:LDay15$Square;\n 4: areturn\n\n public final Day15$Square copy(kotlin.Pair<java.lang.Integer, java.lang.Integer>, int, int, Day15$Square);\n Code:\n 0: aload_1\n 1: ldc #14 // String coord\n 3: invokestatic #20 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day15$Square\n 9: dup\n 10: aload_1\n 11: iload_2\n 12: iload_3\n 13: aload 4\n 15: invokespecial #42 // Method \"<init>\":(Lkotlin/Pair;IILDay15$Square;)V\n 18: areturn\n\n public static Day15$Square copy$default(Day15$Square, kotlin.Pair, int, int, Day15$Square, int, java.lang.Object);\n Code:\n 0: iload 5\n 2: iconst_1\n 3: iand\n 4: ifeq 12\n 7: aload_0\n 8: getfield #26 // Field coord:Lkotlin/Pair;\n 11: astore_1\n 12: iload 5\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #30 // Field risk:I\n 23: istore_2\n 24: iload 5\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #33 // Field distance:I\n 35: istore_3\n 36: iload 5\n 38: bipush 8\n 40: iand\n 41: ifeq 50\n 44: aload_0\n 45: getfield #37 // Field parent:LDay15$Square;\n 48: astore 4\n 50: aload_0\n 51: aload_1\n 52: iload_2\n 53: iload_3\n 54: aload 4\n 56: invokevirtual #173 // Method copy:(Lkotlin/Pair;IILDay15$Square;)LDay15$Square;\n 59: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #177 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #178 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #180 // String Square(coord=\n 9: invokevirtual #184 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #26 // Field coord:Lkotlin/Pair;\n 16: invokevirtual #187 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #189 // String , risk=\n 21: invokevirtual #184 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #30 // Field risk:I\n 28: invokevirtual #192 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #194 // String , distance=\n 33: invokevirtual #184 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #33 // Field distance:I\n 40: invokevirtual #192 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 43: ldc #196 // String , parent=\n 45: invokevirtual #184 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: aload_0\n 49: getfield #37 // Field parent:LDay15$Square;\n 52: invokevirtual #187 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 55: bipush 41\n 57: invokevirtual #199 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 60: invokevirtual #201 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 63: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #26 // Field coord:Lkotlin/Pair;\n 4: invokevirtual #204 // Method kotlin/Pair.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #30 // Field risk:I\n 16: invokestatic #207 // 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 #33 // Field distance:I\n 29: invokestatic #207 // Method java/lang/Integer.hashCode:(I)I\n 32: iadd\n 33: istore_1\n 34: iload_1\n 35: bipush 31\n 37: imul\n 38: aload_0\n 39: getfield #37 // Field parent:LDay15$Square;\n 42: ifnonnull 49\n 45: iconst_0\n 46: goto 56\n 49: aload_0\n 50: getfield #37 // Field parent:LDay15$Square;\n 53: invokevirtual #208 // Method hashCode:()I\n 56: iadd\n 57: istore_1\n 58: iload_1\n 59: 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 Day15$Square\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day15$Square\n 20: astore_2\n 21: aload_0\n 22: getfield #26 // Field coord:Lkotlin/Pair;\n 25: aload_2\n 26: getfield #26 // Field coord:Lkotlin/Pair;\n 29: invokestatic #215 // 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 #30 // Field risk:I\n 41: aload_2\n 42: getfield #30 // Field risk:I\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: aload_0\n 51: getfield #33 // Field distance:I\n 54: aload_2\n 55: getfield #33 // Field distance:I\n 58: if_icmpeq 63\n 61: iconst_0\n 62: ireturn\n 63: aload_0\n 64: getfield #37 // Field parent:LDay15$Square;\n 67: aload_2\n 68: getfield #37 // Field parent:LDay15$Square;\n 71: invokestatic #215 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 74: ifne 79\n 77: iconst_0\n 78: ireturn\n 79: iconst_1\n 80: ireturn\n\n private static final kotlin.Pair getNeighbours$lambda$0(Day15$Square, kotlin.Pair);\n Code:\n 0: aload_1\n 1: ldc #218 // String <destruct>\n 3: invokestatic #20 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokevirtual #221 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 10: checkcast #223 // class java/lang/Number\n 13: invokevirtual #226 // Method java/lang/Number.intValue:()I\n 16: istore_2\n 17: aload_1\n 18: invokevirtual #228 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 21: checkcast #223 // class java/lang/Number\n 24: invokevirtual #226 // Method java/lang/Number.intValue:()I\n 27: istore_3\n 28: aload_0\n 29: getfield #26 // Field coord:Lkotlin/Pair;\n 32: invokevirtual #231 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 35: checkcast #223 // class java/lang/Number\n 38: invokevirtual #226 // Method java/lang/Number.intValue:()I\n 41: iload_2\n 42: iadd\n 43: invokestatic #142 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 46: aload_0\n 47: getfield #26 // Field coord:Lkotlin/Pair;\n 50: invokevirtual #234 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 53: checkcast #223 // class java/lang/Number\n 56: invokevirtual #226 // Method java/lang/Number.intValue:()I\n 59: iload_3\n 60: iadd\n 61: invokestatic #142 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 64: invokestatic #148 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 67: areturn\n\n private static final Day15$Square getNeighbours$lambda$1(java.util.Map, kotlin.Pair);\n Code:\n 0: aload_1\n 1: ldc #239 // String it\n 3: invokestatic #20 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokeinterface #244, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 13: checkcast #2 // class Day15$Square\n 16: areturn\n\n private static final boolean getNeighbours$lambda$2(java.util.Collection, Day15$Square);\n Code:\n 0: aload_1\n 1: ldc #239 // String it\n 3: invokestatic #20 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokeinterface #250, 2 // InterfaceMethod java/util/Collection.contains:(Ljava/lang/Object;)Z\n 13: ireturn\n\n public int compareTo(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #2 // class Day15$Square\n 5: invokevirtual #254 // Method compareTo:(LDay15$Square;)I\n 8: ireturn\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day15$Part1.class", "javap": "Compiled from \"Day15.kt\"\npublic final class Day15$Part1 {\n public static final Day15$Part1 INSTANCE;\n\n private static final kotlin.jvm.functions.Function0<java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day15$Square>> chitonGrid;\n\n private Day15$Part1();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final kotlin.jvm.functions.Function0<java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day15$Square>> getChitonGrid();\n Code:\n 0: getstatic #18 // Field chitonGrid:Lkotlin/jvm/functions/Function0;\n 3: areturn\n\n public final void run();\n Code:\n 0: getstatic #18 // Field chitonGrid:Lkotlin/jvm/functions/Function0;\n 3: invokeinterface #25, 1 // InterfaceMethod kotlin/jvm/functions/Function0.invoke:()Ljava/lang/Object;\n 8: checkcast #27 // class java/util/Map\n 11: astore_1\n 12: aload_1\n 13: invokeinterface #31, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 18: checkcast #33 // class java/lang/Iterable\n 21: invokestatic #39 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 24: checkcast #41 // class Day15$Square\n 27: iconst_0\n 28: invokevirtual #45 // Method Day15$Square.setDistance:(I)V\n 31: aload_1\n 32: invokeinterface #31, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 37: invokestatic #49 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 40: astore_2\n 41: aload_2\n 42: checkcast #51 // class java/util/Collection\n 45: invokeinterface #55, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 50: ifne 57\n 53: iconst_1\n 54: goto 58\n 57: iconst_0\n 58: ifeq 189\n 61: aload_2\n 62: checkcast #33 // class java/lang/Iterable\n 65: invokestatic #59 // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 68: dup\n 69: invokestatic #65 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 72: checkcast #41 // class Day15$Square\n 75: astore_3\n 76: aload_2\n 77: aload_3\n 78: invokeinterface #71, 2 // InterfaceMethod java/util/List.remove:(Ljava/lang/Object;)Z\n 83: pop\n 84: aload_3\n 85: aload_1\n 86: aload_2\n 87: checkcast #51 // class java/util/Collection\n 90: aconst_null\n 91: iconst_4\n 92: aconst_null\n 93: invokestatic #75 // Method Day15$Square.getNeighbours$default:(LDay15$Square;Ljava/util/Map;Ljava/util/Collection;Ljava/util/List;ILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 96: astore 4\n 98: aload 4\n 100: astore 5\n 102: iconst_0\n 103: istore 6\n 105: aload 5\n 107: invokeinterface #81, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 112: astore 7\n 114: aload 7\n 116: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 121: ifeq 185\n 124: aload 7\n 126: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 131: astore 8\n 133: aload 8\n 135: checkcast #41 // class Day15$Square\n 138: astore 9\n 140: iconst_0\n 141: istore 10\n 143: aload_3\n 144: invokevirtual #93 // Method Day15$Square.getDistance:()I\n 147: aload_3\n 148: invokevirtual #96 // Method Day15$Square.getRisk:()I\n 151: iadd\n 152: aload 9\n 154: invokevirtual #93 // Method Day15$Square.getDistance:()I\n 157: if_icmpge 180\n 160: aload 9\n 162: aload_3\n 163: invokevirtual #93 // Method Day15$Square.getDistance:()I\n 166: aload_3\n 167: invokevirtual #96 // Method Day15$Square.getRisk:()I\n 170: iadd\n 171: invokevirtual #45 // Method Day15$Square.setDistance:(I)V\n 174: aload 9\n 176: aload_3\n 177: invokevirtual #100 // Method Day15$Square.setParent:(LDay15$Square;)V\n 180: nop\n 181: nop\n 182: goto 114\n 185: nop\n 186: goto 41\n 189: aload_1\n 190: invokeinterface #31, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 195: checkcast #33 // class java/lang/Iterable\n 198: invokestatic #103 // Method kotlin/collections/CollectionsKt.last:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 201: checkcast #41 // class Day15$Square\n 204: astore_3\n 205: iconst_1\n 206: anewarray #41 // class Day15$Square\n 209: astore 5\n 211: aload 5\n 213: iconst_0\n 214: aload_3\n 215: aastore\n 216: aload 5\n 218: invokestatic #107 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 221: astore 4\n 223: aload_3\n 224: invokevirtual #111 // Method Day15$Square.getParent:()LDay15$Square;\n 227: ifnull 251\n 230: aload_3\n 231: invokevirtual #111 // Method Day15$Square.getParent:()LDay15$Square;\n 234: dup\n 235: invokestatic #65 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 238: astore_3\n 239: aload 4\n 241: aload_3\n 242: invokeinterface #114, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 247: pop\n 248: goto 223\n 251: getstatic #120 // Field Day15.INSTANCE:LDay15;\n 254: aload 4\n 256: checkcast #51 // class java/util/Collection\n 259: invokestatic #124 // Method Day15.access$draw:(LDay15;Ljava/util/Collection;)V\n 262: aload 4\n 264: checkcast #33 // class java/lang/Iterable\n 267: invokestatic #128 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 270: checkcast #33 // class java/lang/Iterable\n 273: astore 5\n 275: iconst_0\n 276: istore 6\n 278: aload 5\n 280: invokeinterface #129, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 285: astore 7\n 287: aload 7\n 289: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 294: ifeq 372\n 297: aload 7\n 299: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 304: astore 8\n 306: aload 8\n 308: checkcast #41 // class Day15$Square\n 311: astore 9\n 313: iconst_0\n 314: istore 10\n 316: new #131 // class java/lang/StringBuilder\n 319: dup\n 320: invokespecial #132 // Method java/lang/StringBuilder.\"<init>\":()V\n 323: aload 9\n 325: invokevirtual #136 // Method Day15$Square.getCoord:()Lkotlin/Pair;\n 328: invokevirtual #140 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 331: bipush 32\n 333: invokevirtual #143 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 336: aload 9\n 338: invokevirtual #96 // Method Day15$Square.getRisk:()I\n 341: invokevirtual #146 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 344: ldc #148 // String\n 346: invokevirtual #151 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 349: aload 9\n 351: invokevirtual #93 // Method Day15$Square.getDistance:()I\n 354: invokevirtual #146 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 357: invokevirtual #155 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 360: getstatic #161 // Field java/lang/System.out:Ljava/io/PrintStream;\n 363: swap\n 364: invokevirtual #166 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 367: nop\n 368: nop\n 369: goto 287\n 372: nop\n 373: aload 4\n 375: checkcast #33 // class java/lang/Iterable\n 378: astore 5\n 380: iconst_0\n 381: istore 6\n 383: aload 5\n 385: invokeinterface #129, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 390: astore 7\n 392: aload 7\n 394: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 399: ifeq 442\n 402: aload 7\n 404: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 409: astore 8\n 411: iload 6\n 413: aload 8\n 415: checkcast #41 // class Day15$Square\n 418: astore 9\n 420: istore 11\n 422: iconst_0\n 423: istore 10\n 425: aload 9\n 427: invokevirtual #96 // Method Day15$Square.getRisk:()I\n 430: istore 12\n 432: iload 11\n 434: iload 12\n 436: iadd\n 437: istore 6\n 439: goto 392\n 442: iload 6\n 444: istore 5\n 446: iload 5\n 448: istore 6\n 450: iconst_0\n 451: istore 7\n 453: iload 6\n 455: aload_1\n 456: invokeinterface #31, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 461: checkcast #33 // class java/lang/Iterable\n 464: invokestatic #39 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 467: checkcast #41 // class Day15$Square\n 470: invokevirtual #96 // Method Day15$Square.getRisk:()I\n 473: isub\n 474: istore 8\n 476: getstatic #161 // Field java/lang/System.out:Ljava/io/PrintStream;\n 479: iload 8\n 481: invokevirtual #168 // Method java/io/PrintStream.println:(I)V\n 484: nop\n 485: nop\n 486: return\n\n private static final java.util.Map chitonGrid$lambda$1();\n Code:\n 0: new #194 // class java/io/File\n 3: dup\n 4: ldc #196 // String day15/input-real.txt\n 6: invokespecial #199 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: invokestatic #205 // Method java/nio/charset/Charset.defaultCharset:()Ljava/nio/charset/Charset;\n 12: dup\n 13: ldc #207 // String defaultCharset(...)\n 15: invokestatic #211 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: invokestatic #217 // Method kotlin/io/FilesKt.readLines:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/util/List;\n 21: checkcast #33 // class java/lang/Iterable\n 24: astore_0\n 25: getstatic #120 // Field Day15.INSTANCE:LDay15;\n 28: astore_1\n 29: iconst_0\n 30: istore_2\n 31: aload_0\n 32: astore_3\n 33: new #219 // class java/util/ArrayList\n 36: dup\n 37: aload_0\n 38: bipush 10\n 40: invokestatic #223 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 43: invokespecial #225 // Method java/util/ArrayList.\"<init>\":(I)V\n 46: checkcast #51 // class java/util/Collection\n 49: astore 4\n 51: iconst_0\n 52: istore 5\n 54: iconst_0\n 55: istore 6\n 57: aload_3\n 58: invokeinterface #129, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 63: astore 7\n 65: aload 7\n 67: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 72: ifeq 137\n 75: aload 7\n 77: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 82: astore 8\n 84: aload 4\n 86: iload 6\n 88: iinc 6, 1\n 91: istore 9\n 93: iload 9\n 95: ifge 101\n 98: invokestatic #228 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 101: iload 9\n 103: aload 8\n 105: checkcast #230 // class java/lang/String\n 108: astore 10\n 110: istore 11\n 112: astore 13\n 114: iconst_0\n 115: istore 12\n 117: aload_1\n 118: iload 11\n 120: aload 10\n 122: invokestatic #234 // Method Day15.access$toCoordinates:(LDay15;ILjava/lang/String;)Ljava/util/List;\n 125: aload 13\n 127: swap\n 128: invokeinterface #235, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 133: pop\n 134: goto 65\n 137: aload 4\n 139: checkcast #67 // class java/util/List\n 142: nop\n 143: checkcast #33 // class java/lang/Iterable\n 146: invokestatic #238 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 149: checkcast #33 // class java/lang/Iterable\n 152: astore_0\n 153: nop\n 154: iconst_0\n 155: istore_1\n 156: aload_0\n 157: bipush 10\n 159: invokestatic #223 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 162: invokestatic #244 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 165: bipush 16\n 167: invokestatic #250 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 170: istore_2\n 171: aload_0\n 172: astore_3\n 173: new #252 // class java/util/LinkedHashMap\n 176: dup\n 177: iload_2\n 178: invokespecial #253 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 181: checkcast #27 // class java/util/Map\n 184: astore 4\n 186: iconst_0\n 187: istore 5\n 189: aload_3\n 190: invokeinterface #129, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 195: astore 6\n 197: aload 6\n 199: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 204: ifeq 255\n 207: aload 6\n 209: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 214: astore 7\n 216: aload 4\n 218: astore 8\n 220: aload 7\n 222: checkcast #255 // class kotlin/Pair\n 225: astore 9\n 227: iconst_0\n 228: istore 10\n 230: aload 9\n 232: astore 9\n 234: aload 8\n 236: aload 9\n 238: invokevirtual #258 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 241: aload 9\n 243: invokevirtual #261 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 246: invokeinterface #265, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 251: pop\n 252: goto 197\n 255: aload 4\n 257: nop\n 258: areturn\n\n static {};\n Code:\n 0: new #2 // class Day15$Part1\n 3: dup\n 4: invokespecial #287 // Method \"<init>\":()V\n 7: putstatic #289 // Field INSTANCE:LDay15$Part1;\n 10: invokedynamic #303, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function0;\n 15: putstatic #18 // Field chitonGrid:Lkotlin/jvm/functions/Function0;\n 18: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day15$Part2.class", "javap": "Compiled from \"Day15.kt\"\npublic final class Day15$Part2 {\n public static final Day15$Part2 INSTANCE;\n\n private Day15$Part2();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final java.util.List<kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day15$Square>> toCoordinates(int, java.util.List<java.lang.Integer>);\n Code:\n 0: aload_2\n 1: checkcast #15 // class java/lang/Iterable\n 4: astore_3\n 5: nop\n 6: iconst_0\n 7: istore 4\n 9: aload_3\n 10: astore 5\n 12: new #17 // class java/util/ArrayList\n 15: dup\n 16: aload_3\n 17: bipush 10\n 19: invokestatic #23 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 22: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 25: checkcast #28 // class java/util/Collection\n 28: astore 6\n 30: iconst_0\n 31: istore 7\n 33: iconst_0\n 34: istore 8\n 36: aload 5\n 38: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 43: astore 9\n 45: aload 9\n 47: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 52: ifeq 153\n 55: aload 9\n 57: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 62: astore 10\n 64: aload 6\n 66: iload 8\n 68: iinc 8, 1\n 71: istore 11\n 73: iload 11\n 75: ifge 81\n 78: invokestatic #45 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 81: iload 11\n 83: aload 10\n 85: checkcast #47 // class java/lang/Number\n 88: invokevirtual #51 // Method java/lang/Number.intValue:()I\n 91: istore 12\n 93: istore 13\n 95: astore 15\n 97: iconst_0\n 98: istore 14\n 100: iload 13\n 102: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 105: iload_1\n 106: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 109: invokestatic #63 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 112: new #65 // class Day15$Square\n 115: dup\n 116: iload 13\n 118: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 121: iload_1\n 122: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 125: invokestatic #63 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 128: iload 12\n 130: iconst_0\n 131: aconst_null\n 132: bipush 12\n 134: aconst_null\n 135: invokespecial #68 // Method Day15$Square.\"<init>\":(Lkotlin/Pair;IILDay15$Square;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 138: invokestatic #63 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 141: aload 15\n 143: swap\n 144: invokeinterface #72, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 149: pop\n 150: goto 45\n 153: aload 6\n 155: checkcast #74 // class java/util/List\n 158: nop\n 159: areturn\n\n public final void run();\n Code:\n 0: new #94 // class java/io/File\n 3: dup\n 4: ldc #96 // String day15/input-real.txt\n 6: invokespecial #99 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: invokestatic #105 // Method java/nio/charset/Charset.defaultCharset:()Ljava/nio/charset/Charset;\n 12: dup\n 13: ldc #107 // String defaultCharset(...)\n 15: invokestatic #113 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: invokestatic #119 // Method kotlin/io/FilesKt.readLines:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/util/List;\n 21: checkcast #15 // class java/lang/Iterable\n 24: astore_2\n 25: nop\n 26: iconst_0\n 27: istore_3\n 28: aload_2\n 29: astore 4\n 31: new #17 // class java/util/ArrayList\n 34: dup\n 35: aload_2\n 36: bipush 10\n 38: invokestatic #23 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 41: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 44: checkcast #28 // class java/util/Collection\n 47: astore 5\n 49: iconst_0\n 50: istore 6\n 52: aload 4\n 54: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 59: astore 7\n 61: aload 7\n 63: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 68: ifeq 209\n 71: aload 7\n 73: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 78: astore 8\n 80: aload 5\n 82: aload 8\n 84: checkcast #121 // class java/lang/String\n 87: astore 9\n 89: astore 34\n 91: iconst_0\n 92: istore 10\n 94: aload 9\n 96: checkcast #123 // class java/lang/CharSequence\n 99: astore 11\n 101: iconst_0\n 102: istore 12\n 104: aload 11\n 106: astore 13\n 108: new #17 // class java/util/ArrayList\n 111: dup\n 112: aload 11\n 114: invokeinterface #126, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 119: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 122: checkcast #28 // class java/util/Collection\n 125: astore 14\n 127: iconst_0\n 128: istore 15\n 130: iconst_0\n 131: istore 16\n 133: iload 16\n 135: aload 13\n 137: invokeinterface #126, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 142: if_icmpge 190\n 145: aload 13\n 147: iload 16\n 149: invokeinterface #130, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 154: istore 17\n 156: aload 14\n 158: iload 17\n 160: istore 18\n 162: astore 19\n 164: iconst_0\n 165: istore 20\n 167: iload 18\n 169: invokestatic #136 // Method java/lang/Character.getNumericValue:(C)I\n 172: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 175: aload 19\n 177: swap\n 178: invokeinterface #72, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 183: pop\n 184: iinc 16, 1\n 187: goto 133\n 190: aload 14\n 192: checkcast #74 // class java/util/List\n 195: nop\n 196: nop\n 197: aload 34\n 199: swap\n 200: invokeinterface #72, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 205: pop\n 206: goto 61\n 209: aload 5\n 211: checkcast #74 // class java/util/List\n 214: nop\n 215: checkcast #15 // class java/lang/Iterable\n 218: astore_2\n 219: nop\n 220: iconst_0\n 221: istore_3\n 222: aload_2\n 223: astore 4\n 225: new #17 // class java/util/ArrayList\n 228: dup\n 229: aload_2\n 230: bipush 10\n 232: invokestatic #23 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 235: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 238: checkcast #28 // class java/util/Collection\n 241: astore 5\n 243: iconst_0\n 244: istore 6\n 246: aload 4\n 248: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 253: astore 7\n 255: aload 7\n 257: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 262: ifeq 508\n 265: aload 7\n 267: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 272: astore 8\n 274: aload 5\n 276: aload 8\n 278: checkcast #74 // class java/util/List\n 281: astore 9\n 283: astore 34\n 285: iconst_0\n 286: istore 10\n 288: new #138 // class kotlin/ranges/IntRange\n 291: dup\n 292: iconst_0\n 293: iconst_4\n 294: invokespecial #141 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 297: checkcast #15 // class java/lang/Iterable\n 300: astore 11\n 302: iconst_0\n 303: istore 12\n 305: aload 11\n 307: astore 13\n 309: new #17 // class java/util/ArrayList\n 312: dup\n 313: invokespecial #142 // Method java/util/ArrayList.\"<init>\":()V\n 316: checkcast #28 // class java/util/Collection\n 319: astore 14\n 321: iconst_0\n 322: istore 15\n 324: aload 13\n 326: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 331: astore 16\n 333: aload 16\n 335: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 340: ifeq 489\n 343: aload 16\n 345: checkcast #144 // class kotlin/collections/IntIterator\n 348: invokevirtual #147 // Method kotlin/collections/IntIterator.nextInt:()I\n 351: istore 17\n 353: iload 17\n 355: istore 18\n 357: iconst_0\n 358: istore 19\n 360: aload 9\n 362: checkcast #15 // class java/lang/Iterable\n 365: astore 20\n 367: iconst_0\n 368: istore 21\n 370: aload 20\n 372: astore 22\n 374: new #17 // class java/util/ArrayList\n 377: dup\n 378: aload 20\n 380: bipush 10\n 382: invokestatic #23 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 385: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 388: checkcast #28 // class java/util/Collection\n 391: astore 23\n 393: iconst_0\n 394: istore 24\n 396: aload 22\n 398: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 403: astore 25\n 405: aload 25\n 407: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 412: ifeq 466\n 415: aload 25\n 417: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 422: astore 26\n 424: aload 23\n 426: aload 26\n 428: checkcast #47 // class java/lang/Number\n 431: invokevirtual #51 // Method java/lang/Number.intValue:()I\n 434: istore 27\n 436: astore 28\n 438: iconst_0\n 439: istore 29\n 441: getstatic #153 // Field Day15.INSTANCE:LDay15;\n 444: iload 27\n 446: iload 18\n 448: invokestatic #157 // Method Day15.access$round:(LDay15;II)I\n 451: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 454: aload 28\n 456: swap\n 457: invokeinterface #72, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 462: pop\n 463: goto 405\n 466: aload 23\n 468: checkcast #74 // class java/util/List\n 471: nop\n 472: checkcast #15 // class java/lang/Iterable\n 475: nop\n 476: astore 18\n 478: aload 14\n 480: aload 18\n 482: invokestatic #161 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 485: pop\n 486: goto 333\n 489: aload 14\n 491: checkcast #74 // class java/util/List\n 494: nop\n 495: nop\n 496: aload 34\n 498: swap\n 499: invokeinterface #72, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 504: pop\n 505: goto 255\n 508: aload 5\n 510: checkcast #74 // class java/util/List\n 513: nop\n 514: astore_3\n 515: iconst_0\n 516: istore 4\n 518: new #138 // class kotlin/ranges/IntRange\n 521: dup\n 522: iconst_0\n 523: iconst_4\n 524: invokespecial #141 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 527: checkcast #15 // class java/lang/Iterable\n 530: astore 5\n 532: iconst_0\n 533: istore 6\n 535: aload 5\n 537: astore 7\n 539: new #17 // class java/util/ArrayList\n 542: dup\n 543: invokespecial #142 // Method java/util/ArrayList.\"<init>\":()V\n 546: checkcast #28 // class java/util/Collection\n 549: astore 8\n 551: iconst_0\n 552: istore 9\n 554: aload 7\n 556: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 561: astore 10\n 563: aload 10\n 565: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 570: ifeq 815\n 573: aload 10\n 575: checkcast #144 // class kotlin/collections/IntIterator\n 578: invokevirtual #147 // Method kotlin/collections/IntIterator.nextInt:()I\n 581: istore 11\n 583: iload 11\n 585: istore 12\n 587: iconst_0\n 588: istore 13\n 590: aload_3\n 591: checkcast #15 // class java/lang/Iterable\n 594: astore 14\n 596: iconst_0\n 597: istore 15\n 599: aload 14\n 601: astore 16\n 603: new #17 // class java/util/ArrayList\n 606: dup\n 607: aload 14\n 609: bipush 10\n 611: invokestatic #23 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 614: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 617: checkcast #28 // class java/util/Collection\n 620: astore 17\n 622: iconst_0\n 623: istore 18\n 625: aload 16\n 627: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 632: astore 19\n 634: aload 19\n 636: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 641: ifeq 792\n 644: aload 19\n 646: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 651: astore 20\n 653: aload 17\n 655: aload 20\n 657: checkcast #74 // class java/util/List\n 660: astore 21\n 662: astore 22\n 664: iconst_0\n 665: istore 23\n 667: aload 21\n 669: checkcast #15 // class java/lang/Iterable\n 672: astore 24\n 674: iconst_0\n 675: istore 25\n 677: aload 24\n 679: astore 26\n 681: new #17 // class java/util/ArrayList\n 684: dup\n 685: aload 24\n 687: bipush 10\n 689: invokestatic #23 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 692: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 695: checkcast #28 // class java/util/Collection\n 698: astore 27\n 700: iconst_0\n 701: istore 28\n 703: aload 26\n 705: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 710: astore 29\n 712: aload 29\n 714: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 719: ifeq 773\n 722: aload 29\n 724: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 729: astore 30\n 731: aload 27\n 733: aload 30\n 735: checkcast #47 // class java/lang/Number\n 738: invokevirtual #51 // Method java/lang/Number.intValue:()I\n 741: istore 31\n 743: astore 32\n 745: iconst_0\n 746: istore 33\n 748: getstatic #153 // Field Day15.INSTANCE:LDay15;\n 751: iload 31\n 753: iload 12\n 755: invokestatic #157 // Method Day15.access$round:(LDay15;II)I\n 758: invokestatic #57 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 761: aload 32\n 763: swap\n 764: invokeinterface #72, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 769: pop\n 770: goto 712\n 773: aload 27\n 775: checkcast #74 // class java/util/List\n 778: nop\n 779: nop\n 780: aload 22\n 782: swap\n 783: invokeinterface #72, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 788: pop\n 789: goto 634\n 792: aload 17\n 794: checkcast #74 // class java/util/List\n 797: nop\n 798: checkcast #15 // class java/lang/Iterable\n 801: nop\n 802: astore 12\n 804: aload 8\n 806: aload 12\n 808: invokestatic #161 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 811: pop\n 812: goto 563\n 815: aload 8\n 817: checkcast #74 // class java/util/List\n 820: nop\n 821: nop\n 822: checkcast #15 // class java/lang/Iterable\n 825: astore_2\n 826: nop\n 827: iconst_0\n 828: istore_3\n 829: aload_2\n 830: astore 4\n 832: new #17 // class java/util/ArrayList\n 835: dup\n 836: aload_2\n 837: bipush 10\n 839: invokestatic #23 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 842: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 845: checkcast #28 // class java/util/Collection\n 848: astore 5\n 850: iconst_0\n 851: istore 6\n 853: iconst_0\n 854: istore 7\n 856: aload 4\n 858: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 863: astore 8\n 865: aload 8\n 867: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 872: ifeq 939\n 875: aload 8\n 877: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 882: astore 9\n 884: aload 5\n 886: iload 7\n 888: iinc 7, 1\n 891: istore 10\n 893: iload 10\n 895: ifge 901\n 898: invokestatic #45 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 901: iload 10\n 903: aload 9\n 905: checkcast #74 // class java/util/List\n 908: astore 11\n 910: istore 12\n 912: astore 34\n 914: iconst_0\n 915: istore 13\n 917: getstatic #163 // Field INSTANCE:LDay15$Part2;\n 920: iload 12\n 922: aload 11\n 924: invokespecial #165 // Method toCoordinates:(ILjava/util/List;)Ljava/util/List;\n 927: aload 34\n 929: swap\n 930: invokeinterface #72, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 935: pop\n 936: goto 865\n 939: aload 5\n 941: checkcast #74 // class java/util/List\n 944: nop\n 945: checkcast #15 // class java/lang/Iterable\n 948: invokestatic #169 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 951: checkcast #15 // class java/lang/Iterable\n 954: astore_2\n 955: nop\n 956: iconst_0\n 957: istore_3\n 958: aload_2\n 959: bipush 10\n 961: invokestatic #23 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 964: invokestatic #175 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 967: bipush 16\n 969: invokestatic #181 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 972: istore 4\n 974: aload_2\n 975: astore 5\n 977: new #183 // class java/util/LinkedHashMap\n 980: dup\n 981: iload 4\n 983: invokespecial #184 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 986: checkcast #186 // class java/util/Map\n 989: astore 6\n 991: iconst_0\n 992: istore 7\n 994: aload 5\n 996: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1001: astore 8\n 1003: aload 8\n 1005: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1010: ifeq 1061\n 1013: aload 8\n 1015: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1020: astore 9\n 1022: aload 6\n 1024: astore 10\n 1026: aload 9\n 1028: checkcast #188 // class kotlin/Pair\n 1031: astore 11\n 1033: iconst_0\n 1034: istore 12\n 1036: aload 11\n 1038: astore 11\n 1040: aload 10\n 1042: aload 11\n 1044: invokevirtual #191 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 1047: aload 11\n 1049: invokevirtual #194 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 1052: invokeinterface #198, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 1057: pop\n 1058: goto 1003\n 1061: aload 6\n 1063: nop\n 1064: astore_1\n 1065: aload_1\n 1066: invokeinterface #202, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 1071: checkcast #15 // class java/lang/Iterable\n 1074: invokestatic #206 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 1077: checkcast #65 // class Day15$Square\n 1080: iconst_0\n 1081: invokevirtual #209 // Method Day15$Square.setDistance:(I)V\n 1084: aload_1\n 1085: invokeinterface #202, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 1090: invokestatic #213 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 1093: astore_2\n 1094: aload_2\n 1095: invokeinterface #216, 1 // InterfaceMethod java/util/List.size:()I\n 1100: istore_3\n 1101: iconst_0\n 1102: istore 4\n 1104: aload_2\n 1105: checkcast #28 // class java/util/Collection\n 1108: invokeinterface #219, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 1113: ifne 1120\n 1116: iconst_1\n 1117: goto 1121\n 1120: iconst_0\n 1121: ifeq 1322\n 1124: iload 4\n 1126: iinc 4, 1\n 1129: sipush 500\n 1132: irem\n 1133: ifne 1186\n 1136: new #221 // class java/lang/StringBuilder\n 1139: dup\n 1140: invokespecial #222 // Method java/lang/StringBuilder.\"<init>\":()V\n 1143: iload 4\n 1145: invokevirtual #226 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 1148: bipush 47\n 1150: invokevirtual #229 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 1153: iload_3\n 1154: invokevirtual #226 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 1157: ldc #231 // String (\n 1159: invokevirtual #234 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 1162: aload_2\n 1163: invokeinterface #216, 1 // InterfaceMethod java/util/List.size:()I\n 1168: invokevirtual #226 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 1171: bipush 41\n 1173: invokevirtual #229 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 1176: invokevirtual #238 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 1179: getstatic #244 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1182: swap\n 1183: invokevirtual #250 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 1186: aload_2\n 1187: checkcast #15 // class java/lang/Iterable\n 1190: invokestatic #254 // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 1193: dup\n 1194: invokestatic #257 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 1197: checkcast #65 // class Day15$Square\n 1200: astore 5\n 1202: aload_2\n 1203: aload 5\n 1205: invokeinterface #260, 2 // InterfaceMethod java/util/List.remove:(Ljava/lang/Object;)Z\n 1210: pop\n 1211: aload 5\n 1213: aload_1\n 1214: aload_2\n 1215: checkcast #28 // class java/util/Collection\n 1218: aconst_null\n 1219: iconst_4\n 1220: aconst_null\n 1221: invokestatic #264 // Method Day15$Square.getNeighbours$default:(LDay15$Square;Ljava/util/Map;Ljava/util/Collection;Ljava/util/List;ILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 1224: astore 6\n 1226: aload 6\n 1228: astore 7\n 1230: iconst_0\n 1231: istore 8\n 1233: aload 7\n 1235: invokeinterface #267, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 1240: astore 9\n 1242: aload 9\n 1244: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1249: ifeq 1318\n 1252: aload 9\n 1254: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1259: astore 10\n 1261: aload 10\n 1263: checkcast #65 // class Day15$Square\n 1266: astore 11\n 1268: iconst_0\n 1269: istore 12\n 1271: aload 5\n 1273: invokevirtual #270 // Method Day15$Square.getDistance:()I\n 1276: aload 5\n 1278: invokevirtual #273 // Method Day15$Square.getRisk:()I\n 1281: iadd\n 1282: aload 11\n 1284: invokevirtual #270 // Method Day15$Square.getDistance:()I\n 1287: if_icmpge 1313\n 1290: aload 11\n 1292: aload 5\n 1294: invokevirtual #270 // Method Day15$Square.getDistance:()I\n 1297: aload 5\n 1299: invokevirtual #273 // Method Day15$Square.getRisk:()I\n 1302: iadd\n 1303: invokevirtual #209 // Method Day15$Square.setDistance:(I)V\n 1306: aload 11\n 1308: aload 5\n 1310: invokevirtual #277 // Method Day15$Square.setParent:(LDay15$Square;)V\n 1313: nop\n 1314: nop\n 1315: goto 1242\n 1318: nop\n 1319: goto 1104\n 1322: aload_1\n 1323: invokeinterface #202, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 1328: checkcast #15 // class java/lang/Iterable\n 1331: invokestatic #280 // Method kotlin/collections/CollectionsKt.last:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 1334: checkcast #65 // class Day15$Square\n 1337: astore 5\n 1339: iconst_1\n 1340: anewarray #65 // class Day15$Square\n 1343: astore 7\n 1345: aload 7\n 1347: iconst_0\n 1348: aload 5\n 1350: aastore\n 1351: aload 7\n 1353: invokestatic #284 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 1356: astore 6\n 1358: aload 5\n 1360: invokevirtual #288 // Method Day15$Square.getParent:()LDay15$Square;\n 1363: ifnull 1390\n 1366: aload 5\n 1368: invokevirtual #288 // Method Day15$Square.getParent:()LDay15$Square;\n 1371: dup\n 1372: invokestatic #257 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 1375: astore 5\n 1377: aload 6\n 1379: aload 5\n 1381: invokeinterface #289, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 1386: pop\n 1387: goto 1358\n 1390: getstatic #153 // Field Day15.INSTANCE:LDay15;\n 1393: aload 6\n 1395: checkcast #28 // class java/util/Collection\n 1398: invokestatic #293 // Method Day15.access$draw:(LDay15;Ljava/util/Collection;)V\n 1401: aload 6\n 1403: checkcast #15 // class java/lang/Iterable\n 1406: invokestatic #296 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 1409: checkcast #15 // class java/lang/Iterable\n 1412: astore 7\n 1414: iconst_0\n 1415: istore 8\n 1417: aload 7\n 1419: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1424: astore 9\n 1426: aload 9\n 1428: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1433: ifeq 1512\n 1436: aload 9\n 1438: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1443: astore 10\n 1445: aload 10\n 1447: checkcast #65 // class Day15$Square\n 1450: astore 11\n 1452: iconst_0\n 1453: istore 12\n 1455: new #221 // class java/lang/StringBuilder\n 1458: dup\n 1459: invokespecial #222 // Method java/lang/StringBuilder.\"<init>\":()V\n 1462: aload 11\n 1464: invokevirtual #300 // Method Day15$Square.getCoord:()Lkotlin/Pair;\n 1467: invokevirtual #303 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 1470: bipush 32\n 1472: invokevirtual #229 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 1475: aload 11\n 1477: invokevirtual #273 // Method Day15$Square.getRisk:()I\n 1480: invokevirtual #226 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 1483: ldc_w #305 // String\n 1486: invokevirtual #234 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 1489: aload 11\n 1491: invokevirtual #270 // Method Day15$Square.getDistance:()I\n 1494: invokevirtual #226 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 1497: invokevirtual #238 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 1500: getstatic #244 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1503: swap\n 1504: invokevirtual #250 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 1507: nop\n 1508: nop\n 1509: goto 1426\n 1512: nop\n 1513: aload 6\n 1515: checkcast #15 // class java/lang/Iterable\n 1518: astore 7\n 1520: iconst_0\n 1521: istore 8\n 1523: aload 7\n 1525: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1530: astore 9\n 1532: aload 9\n 1534: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1539: ifeq 1582\n 1542: aload 9\n 1544: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1549: astore 10\n 1551: iload 8\n 1553: aload 10\n 1555: checkcast #65 // class Day15$Square\n 1558: astore 11\n 1560: istore 34\n 1562: iconst_0\n 1563: istore 12\n 1565: aload 11\n 1567: invokevirtual #273 // Method Day15$Square.getRisk:()I\n 1570: istore 35\n 1572: iload 34\n 1574: iload 35\n 1576: iadd\n 1577: istore 8\n 1579: goto 1532\n 1582: iload 8\n 1584: istore 7\n 1586: iload 7\n 1588: istore 8\n 1590: iconst_0\n 1591: istore 9\n 1593: iload 8\n 1595: aload_1\n 1596: invokeinterface #202, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 1601: checkcast #15 // class java/lang/Iterable\n 1604: invokestatic #206 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 1607: checkcast #65 // class Day15$Square\n 1610: invokevirtual #273 // Method Day15$Square.getRisk:()I\n 1613: isub\n 1614: istore 10\n 1616: getstatic #244 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1619: iload 10\n 1621: invokevirtual #307 // Method java/io/PrintStream.println:(I)V\n 1624: nop\n 1625: nop\n 1626: return\n\n static {};\n Code:\n 0: new #2 // class Day15$Part2\n 3: dup\n 4: invokespecial #362 // Method \"<init>\":()V\n 7: putstatic #163 // Field INSTANCE:LDay15$Part2;\n 10: return\n}\n", "javap_err": "" } ]
andrewrlee__adventOfCode2021__aace0fc/src/main/kotlin/Day14.kt
import java.io.File import java.nio.charset.StandardCharsets.UTF_8 import kotlin.collections.Map.Entry object Day14 { object Part1 { private fun toRule(s: String): Pair<List<Char>, Char> { val (pair, value) = s.split(" -> ") return pair.toCharArray().let { listOf(it[0], it[1]) } to value[0] } private fun step( input: List<Char>, rules: Map<List<Char>, Char> ) = input.windowed(2, 1) .flatMap { p -> rules[p]?.let { listOf(p[0], it) } ?: listOf(p[0]) } + input.last() fun run() { val lines = File("day14/input-real.txt").readLines(UTF_8) val input = lines.first().toCharArray().toList() val rules = lines.drop(2).associate(::toRule) val result = generateSequence(input) { step(it, rules) }.drop(10).first() val freqs = result.groupingBy { it }.eachCount().entries val max = freqs.maxOf { it.value } val min = freqs.minOf { it.value } println(max - min) } } object Part2 { private fun toRule(s: String): Pair<List<Char>, Char> { val (pair, value) = s.split(" -> ") return pair.toCharArray().let { listOf(it[0], it[1]) } to value[0] } private fun toTransitions() = { (k, v): Entry<List<Char>, Char> -> (k[0] to k[1]) to listOf(k[0] to v, v to k[1]) } private fun step( values: MutableMap<Pair<Char, Char>, Long>, transitions: Map<Pair<Char, Char>, List<Pair<Char, Char>>> ): MutableMap<Pair<Char, Char>, Long> { val newValues = values.flatMap { (k, v) -> val new = transitions[k]!! new.map { it to v } }.groupBy({ it.first }, { it.second }).mapValues { it.value.sum() } return newValues.toMutableMap(); } fun run() { val lines = File("day14/input-real.txt").readLines(UTF_8) val input = lines.first().toCharArray().toList() val rules = lines.drop(2).associate(::toRule) val transitions = rules.map(toTransitions()).toMap() val initialFreqs = input .windowed(2, 1) .map { it[0] to it[1] } .groupingBy { it } .eachCount() .mapValues { it.value.toLong() } .toMutableMap() val result = generateSequence(initialFreqs) { step(it, transitions) }.drop(40).first() val freqs = result.entries .groupBy({ it.key.first }, { it.value }) .mapValues { it.value.sum() } .toMutableMap().also { // Add single last character in it[input.last()] = 1L + it[input.last()]!! } val max = freqs.maxOf { it.value } val min = freqs.minOf { it.value } println(max - min) } } } fun main() { Day14.Part1.run() Day14.Part2.run() }
[ { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day14Kt.class", "javap": "Compiled from \"Day14.kt\"\npublic final class Day14Kt {\n public static final void main();\n Code:\n 0: getstatic #12 // Field Day14$Part1.INSTANCE:LDay14$Part1;\n 3: invokevirtual #15 // Method Day14$Part1.run:()V\n 6: getstatic #20 // Field Day14$Part2.INSTANCE:LDay14$Part2;\n 9: invokevirtual #21 // Method Day14$Part2.run:()V\n 12: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #24 // Method main:()V\n 3: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day14$Part1.class", "javap": "Compiled from \"Day14.kt\"\npublic final class Day14$Part1 {\n public static final Day14$Part1 INSTANCE;\n\n private Day14$Part1();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final kotlin.Pair<java.util.List<java.lang.Character>, java.lang.Character> toRule(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #15 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #17 // class java/lang/String\n 8: astore_3\n 9: aload_3\n 10: iconst_0\n 11: ldc #19 // 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 #25 // 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 #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 31: checkcast #17 // class java/lang/String\n 34: astore_3\n 35: aload_2\n 36: iconst_1\n 37: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 42: checkcast #17 // class java/lang/String\n 45: astore 4\n 47: aload_3\n 48: invokevirtual #35 // Method java/lang/String.toCharArray:()[C\n 51: dup\n 52: ldc #37 // String toCharArray(...)\n 54: invokestatic #43 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 57: astore 5\n 59: iconst_0\n 60: istore 6\n 62: iconst_2\n 63: anewarray #45 // class java/lang/Character\n 66: astore 7\n 68: aload 7\n 70: iconst_0\n 71: aload 5\n 73: iconst_0\n 74: caload\n 75: invokestatic #49 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 78: aastore\n 79: aload 7\n 81: iconst_1\n 82: aload 5\n 84: iconst_1\n 85: caload\n 86: invokestatic #49 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 89: aastore\n 90: aload 7\n 92: invokestatic #55 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 95: nop\n 96: aload 4\n 98: iconst_0\n 99: invokevirtual #59 // Method java/lang/String.charAt:(I)C\n 102: invokestatic #49 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 105: invokestatic #65 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 108: areturn\n\n private final java.util.List<java.lang.Character> step(java.util.List<java.lang.Character>, java.util.Map<java.util.List<java.lang.Character>, java.lang.Character>);\n Code:\n 0: aload_1\n 1: checkcast #78 // class java/lang/Iterable\n 4: iconst_2\n 5: iconst_1\n 6: iconst_0\n 7: iconst_4\n 8: aconst_null\n 9: invokestatic #82 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;\n 12: checkcast #78 // class java/lang/Iterable\n 15: astore_3\n 16: nop\n 17: iconst_0\n 18: istore 4\n 20: aload_3\n 21: astore 5\n 23: new #84 // class java/util/ArrayList\n 26: dup\n 27: invokespecial #85 // Method java/util/ArrayList.\"<init>\":()V\n 30: checkcast #87 // class java/util/Collection\n 33: astore 6\n 35: iconst_0\n 36: istore 7\n 38: aload 5\n 40: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 8\n 47: aload 8\n 49: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 164\n 57: aload 8\n 59: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 9\n 66: aload 9\n 68: checkcast #27 // class java/util/List\n 71: astore 10\n 73: iconst_0\n 74: istore 11\n 76: aload_2\n 77: aload 10\n 79: invokeinterface #106, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 84: checkcast #45 // class java/lang/Character\n 87: dup\n 88: ifnull 136\n 91: invokevirtual #110 // Method java/lang/Character.charValue:()C\n 94: istore 12\n 96: iconst_0\n 97: istore 13\n 99: iconst_2\n 100: anewarray #45 // class java/lang/Character\n 103: astore 14\n 105: aload 14\n 107: iconst_0\n 108: aload 10\n 110: iconst_0\n 111: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 116: aastore\n 117: aload 14\n 119: iconst_1\n 120: iload 12\n 122: invokestatic #49 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 125: aastore\n 126: aload 14\n 128: invokestatic #55 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 131: nop\n 132: dup\n 133: ifnonnull 148\n 136: pop\n 137: aload 10\n 139: iconst_0\n 140: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 145: invokestatic #113 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 148: checkcast #78 // class java/lang/Iterable\n 151: astore 10\n 153: aload 6\n 155: aload 10\n 157: invokestatic #117 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 160: pop\n 161: goto 47\n 164: aload 6\n 166: checkcast #27 // class java/util/List\n 169: nop\n 170: checkcast #87 // class java/util/Collection\n 173: aload_1\n 174: invokestatic #121 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 177: invokestatic #125 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 180: areturn\n\n public final void run();\n Code:\n 0: new #146 // class java/io/File\n 3: dup\n 4: ldc #148 // String day14/input-real.txt\n 6: invokespecial #151 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: getstatic #157 // Field java/nio/charset/StandardCharsets.UTF_8:Ljava/nio/charset/Charset;\n 12: dup\n 13: ldc #158 // String UTF_8\n 15: invokestatic #43 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: invokestatic #164 // Method kotlin/io/FilesKt.readLines:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/util/List;\n 21: astore_1\n 22: aload_1\n 23: invokestatic #167 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 26: checkcast #17 // class java/lang/String\n 29: invokevirtual #35 // Method java/lang/String.toCharArray:()[C\n 32: dup\n 33: ldc #37 // String toCharArray(...)\n 35: invokestatic #43 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 38: invokestatic #173 // Method kotlin/collections/ArraysKt.toList:([C)Ljava/util/List;\n 41: astore_2\n 42: aload_1\n 43: checkcast #78 // class java/lang/Iterable\n 46: iconst_2\n 47: invokestatic #177 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 50: checkcast #78 // class java/lang/Iterable\n 53: astore 4\n 55: iconst_0\n 56: istore 5\n 58: aload 4\n 60: bipush 10\n 62: invokestatic #181 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 65: invokestatic #187 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 68: bipush 16\n 70: invokestatic #193 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 73: istore 6\n 75: aload 4\n 77: astore 7\n 79: new #195 // class java/util/LinkedHashMap\n 82: dup\n 83: iload 6\n 85: invokespecial #198 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 88: checkcast #103 // class java/util/Map\n 91: astore 8\n 93: iconst_0\n 94: istore 9\n 96: aload 7\n 98: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 103: astore 10\n 105: aload 10\n 107: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 112: ifeq 167\n 115: aload 10\n 117: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 122: astore 11\n 124: aload 8\n 126: astore 12\n 128: aload 11\n 130: checkcast #17 // class java/lang/String\n 133: astore 13\n 135: iconst_0\n 136: istore 14\n 138: aload_0\n 139: aload 13\n 141: invokespecial #200 // Method toRule:(Ljava/lang/String;)Lkotlin/Pair;\n 144: astore 13\n 146: aload 12\n 148: aload 13\n 150: invokevirtual #205 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 153: aload 13\n 155: invokevirtual #208 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 158: invokeinterface #212, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 163: pop\n 164: goto 105\n 167: aload 8\n 169: nop\n 170: astore_3\n 171: aload_2\n 172: aload_3\n 173: invokedynamic #231, 0 // InvokeDynamic #0:invoke:(Ljava/util/Map;)Lkotlin/jvm/functions/Function1;\n 178: invokestatic #237 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 181: bipush 10\n 183: invokestatic #240 // Method kotlin/sequences/SequencesKt.drop:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;\n 186: invokestatic #243 // Method kotlin/sequences/SequencesKt.first:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;\n 189: checkcast #27 // class java/util/List\n 192: astore 4\n 194: aload 4\n 196: checkcast #78 // class java/lang/Iterable\n 199: astore 6\n 201: iconst_0\n 202: istore 7\n 204: new #245 // class Day14$Part1$run$$inlined$groupingBy$1\n 207: dup\n 208: aload 6\n 210: invokespecial #248 // Method Day14$Part1$run$$inlined$groupingBy$1.\"<init>\":(Ljava/lang/Iterable;)V\n 213: checkcast #250 // class kotlin/collections/Grouping\n 216: invokestatic #256 // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;\n 219: invokeinterface #260, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 224: astore 5\n 226: aload 5\n 228: checkcast #78 // class java/lang/Iterable\n 231: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 236: astore 8\n 238: aload 8\n 240: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 245: ifne 256\n 248: new #262 // class java/util/NoSuchElementException\n 251: dup\n 252: invokespecial #263 // Method java/util/NoSuchElementException.\"<init>\":()V\n 255: athrow\n 256: aload 8\n 258: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 263: checkcast #265 // class java/util/Map$Entry\n 266: astore 9\n 268: iconst_0\n 269: istore 10\n 271: aload 9\n 273: invokeinterface #268, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 278: checkcast #270 // class java/lang/Number\n 281: invokevirtual #274 // Method java/lang/Number.intValue:()I\n 284: istore 9\n 286: aload 8\n 288: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 293: ifeq 340\n 296: aload 8\n 298: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 303: checkcast #265 // class java/util/Map$Entry\n 306: astore 10\n 308: iconst_0\n 309: istore 11\n 311: aload 10\n 313: invokeinterface #268, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 318: checkcast #270 // class java/lang/Number\n 321: invokevirtual #274 // Method java/lang/Number.intValue:()I\n 324: istore 10\n 326: iload 9\n 328: iload 10\n 330: if_icmpge 286\n 333: iload 10\n 335: istore 9\n 337: goto 286\n 340: iload 9\n 342: istore 6\n 344: aload 5\n 346: checkcast #78 // class java/lang/Iterable\n 349: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 354: astore 9\n 356: aload 9\n 358: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 363: ifne 374\n 366: new #262 // class java/util/NoSuchElementException\n 369: dup\n 370: invokespecial #263 // Method java/util/NoSuchElementException.\"<init>\":()V\n 373: athrow\n 374: aload 9\n 376: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 381: checkcast #265 // class java/util/Map$Entry\n 384: astore 10\n 386: iconst_0\n 387: istore 11\n 389: aload 10\n 391: invokeinterface #268, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 396: checkcast #270 // class java/lang/Number\n 399: invokevirtual #274 // Method java/lang/Number.intValue:()I\n 402: istore 10\n 404: aload 9\n 406: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 411: ifeq 458\n 414: aload 9\n 416: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 421: checkcast #265 // class java/util/Map$Entry\n 424: astore 11\n 426: iconst_0\n 427: istore 12\n 429: aload 11\n 431: invokeinterface #268, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 436: checkcast #270 // class java/lang/Number\n 439: invokevirtual #274 // Method java/lang/Number.intValue:()I\n 442: istore 11\n 444: iload 10\n 446: iload 11\n 448: if_icmple 404\n 451: iload 11\n 453: istore 10\n 455: goto 404\n 458: iload 10\n 460: istore 7\n 462: iload 6\n 464: iload 7\n 466: isub\n 467: istore 8\n 469: getstatic #280 // Field java/lang/System.out:Ljava/io/PrintStream;\n 472: iload 8\n 474: invokevirtual #285 // Method java/io/PrintStream.println:(I)V\n 477: return\n\n private static final java.util.List run$lambda$3(java.util.Map, java.util.List);\n Code:\n 0: aload_1\n 1: ldc_w #306 // String it\n 4: invokestatic #309 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: getstatic #312 // Field INSTANCE:LDay14$Part1;\n 10: aload_1\n 11: aload_0\n 12: invokespecial #314 // Method step:(Ljava/util/List;Ljava/util/Map;)Ljava/util/List;\n 15: areturn\n\n static {};\n Code:\n 0: new #2 // class Day14$Part1\n 3: dup\n 4: invokespecial #317 // Method \"<init>\":()V\n 7: putstatic #312 // Field INSTANCE:LDay14$Part1;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day14.class", "javap": "Compiled from \"Day14.kt\"\npublic final class Day14 {\n public static final Day14 INSTANCE;\n\n private Day14();\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 Day14\n 3: dup\n 4: invokespecial #12 // Method \"<init>\":()V\n 7: putstatic #15 // Field INSTANCE:LDay14;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day14$Part2.class", "javap": "Compiled from \"Day14.kt\"\npublic final class Day14$Part2 {\n public static final Day14$Part2 INSTANCE;\n\n private Day14$Part2();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final kotlin.Pair<java.util.List<java.lang.Character>, java.lang.Character> toRule(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #15 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #17 // class java/lang/String\n 8: astore_3\n 9: aload_3\n 10: iconst_0\n 11: ldc #19 // 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 #25 // 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 #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 31: checkcast #17 // class java/lang/String\n 34: astore_3\n 35: aload_2\n 36: iconst_1\n 37: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 42: checkcast #17 // class java/lang/String\n 45: astore 4\n 47: aload_3\n 48: invokevirtual #35 // Method java/lang/String.toCharArray:()[C\n 51: dup\n 52: ldc #37 // String toCharArray(...)\n 54: invokestatic #43 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 57: astore 5\n 59: iconst_0\n 60: istore 6\n 62: iconst_2\n 63: anewarray #45 // class java/lang/Character\n 66: astore 7\n 68: aload 7\n 70: iconst_0\n 71: aload 5\n 73: iconst_0\n 74: caload\n 75: invokestatic #49 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 78: aastore\n 79: aload 7\n 81: iconst_1\n 82: aload 5\n 84: iconst_1\n 85: caload\n 86: invokestatic #49 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 89: aastore\n 90: aload 7\n 92: invokestatic #55 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 95: nop\n 96: aload 4\n 98: iconst_0\n 99: invokevirtual #59 // Method java/lang/String.charAt:(I)C\n 102: invokestatic #49 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 105: invokestatic #65 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 108: areturn\n\n private final kotlin.jvm.functions.Function1<java.util.Map$Entry<? extends java.util.List<java.lang.Character>, java.lang.Character>, kotlin.Pair<kotlin.Pair<java.lang.Character, java.lang.Character>, java.util.List<kotlin.Pair<java.lang.Character, java.lang.Character>>>> toTransitions();\n Code:\n 0: invokedynamic #94, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 5: areturn\n\n private final java.util.Map<kotlin.Pair<java.lang.Character, java.lang.Character>, java.lang.Long> step(java.util.Map<kotlin.Pair<java.lang.Character, java.lang.Character>, java.lang.Long>, java.util.Map<kotlin.Pair<java.lang.Character, java.lang.Character>, ? extends java.util.List<kotlin.Pair<java.lang.Character, java.lang.Character>>>);\n Code:\n 0: aload_1\n 1: astore 4\n 3: iconst_0\n 4: istore 5\n 6: aload 4\n 8: astore 6\n 10: new #99 // class java/util/ArrayList\n 13: dup\n 14: invokespecial #100 // Method java/util/ArrayList.\"<init>\":()V\n 17: checkcast #102 // class java/util/Collection\n 20: astore 7\n 22: iconst_0\n 23: istore 8\n 25: aload 6\n 27: invokeinterface #108, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 32: invokeinterface #114, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 37: astore 9\n 39: aload 9\n 41: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 235\n 49: aload 9\n 51: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 56: checkcast #126 // class java/util/Map$Entry\n 59: astore 10\n 61: aload 10\n 63: astore 11\n 65: iconst_0\n 66: istore 12\n 68: aload 11\n 70: invokeinterface #129, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 75: checkcast #131 // class kotlin/Pair\n 78: astore 13\n 80: aload 11\n 82: invokeinterface #134, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 87: checkcast #136 // class java/lang/Number\n 90: invokevirtual #140 // Method java/lang/Number.longValue:()J\n 93: lstore 14\n 95: aload_2\n 96: aload 13\n 98: invokeinterface #142, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 103: dup\n 104: invokestatic #146 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 107: checkcast #27 // class java/util/List\n 110: astore 16\n 112: aload 16\n 114: checkcast #148 // class java/lang/Iterable\n 117: astore 17\n 119: iconst_0\n 120: istore 18\n 122: aload 17\n 124: astore 19\n 126: new #99 // class java/util/ArrayList\n 129: dup\n 130: aload 17\n 132: bipush 10\n 134: invokestatic #152 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 137: invokespecial #155 // Method java/util/ArrayList.\"<init>\":(I)V\n 140: checkcast #102 // class java/util/Collection\n 143: astore 20\n 145: iconst_0\n 146: istore 21\n 148: aload 19\n 150: invokeinterface #156, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 155: astore 22\n 157: aload 22\n 159: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 164: ifeq 212\n 167: aload 22\n 169: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 174: astore 23\n 176: aload 20\n 178: aload 23\n 180: checkcast #131 // class kotlin/Pair\n 183: astore 24\n 185: astore 25\n 187: iconst_0\n 188: istore 26\n 190: aload 24\n 192: lload 14\n 194: invokestatic #161 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 197: invokestatic #65 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 200: aload 25\n 202: swap\n 203: invokeinterface #165, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 208: pop\n 209: goto 157\n 212: aload 20\n 214: checkcast #27 // class java/util/List\n 217: nop\n 218: checkcast #148 // class java/lang/Iterable\n 221: nop\n 222: astore 11\n 224: aload 7\n 226: aload 11\n 228: invokestatic #169 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 231: pop\n 232: goto 39\n 235: aload 7\n 237: checkcast #27 // class java/util/List\n 240: nop\n 241: checkcast #148 // class java/lang/Iterable\n 244: astore 4\n 246: nop\n 247: iconst_0\n 248: istore 5\n 250: aload 4\n 252: astore 6\n 254: new #171 // class java/util/LinkedHashMap\n 257: dup\n 258: invokespecial #172 // Method java/util/LinkedHashMap.\"<init>\":()V\n 261: checkcast #104 // class java/util/Map\n 264: astore 7\n 266: iconst_0\n 267: istore 8\n 269: aload 6\n 271: invokeinterface #156, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 276: astore 9\n 278: aload 9\n 280: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 285: ifeq 420\n 288: aload 9\n 290: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 295: astore 10\n 297: aload 10\n 299: checkcast #131 // class kotlin/Pair\n 302: astore 11\n 304: iconst_0\n 305: istore 12\n 307: aload 11\n 309: invokevirtual #175 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 312: checkcast #131 // class kotlin/Pair\n 315: astore 13\n 317: aload 7\n 319: astore 14\n 321: iconst_0\n 322: istore 15\n 324: aload 14\n 326: aload 13\n 328: invokeinterface #142, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 333: astore 16\n 335: aload 16\n 337: ifnonnull 372\n 340: iconst_0\n 341: istore 17\n 343: new #99 // class java/util/ArrayList\n 346: dup\n 347: invokespecial #100 // Method java/util/ArrayList.\"<init>\":()V\n 350: checkcast #27 // class java/util/List\n 353: astore 17\n 355: aload 14\n 357: aload 13\n 359: aload 17\n 361: invokeinterface #179, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 366: pop\n 367: aload 17\n 369: goto 374\n 372: aload 16\n 374: nop\n 375: checkcast #27 // class java/util/List\n 378: astore 11\n 380: aload 11\n 382: aload 10\n 384: checkcast #131 // class kotlin/Pair\n 387: astore 12\n 389: astore 27\n 391: iconst_0\n 392: istore 18\n 394: aload 12\n 396: invokevirtual #182 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 399: checkcast #136 // class java/lang/Number\n 402: invokevirtual #140 // Method java/lang/Number.longValue:()J\n 405: invokestatic #161 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 408: aload 27\n 410: swap\n 411: invokeinterface #183, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 416: pop\n 417: goto 278\n 420: aload 7\n 422: nop\n 423: astore 4\n 425: nop\n 426: iconst_0\n 427: istore 5\n 429: aload 4\n 431: astore 6\n 433: new #171 // class java/util/LinkedHashMap\n 436: dup\n 437: aload 4\n 439: invokeinterface #187, 1 // InterfaceMethod java/util/Map.size:()I\n 444: invokestatic #193 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 447: invokespecial #194 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 450: checkcast #104 // class java/util/Map\n 453: astore 7\n 455: iconst_0\n 456: istore 8\n 458: aload 6\n 460: invokeinterface #108, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 465: checkcast #148 // class java/lang/Iterable\n 468: astore 9\n 470: iconst_0\n 471: istore 10\n 473: aload 9\n 475: invokeinterface #156, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 480: astore 11\n 482: aload 11\n 484: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 489: ifeq 572\n 492: aload 11\n 494: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 499: astore 12\n 501: aload 7\n 503: aload 12\n 505: checkcast #126 // class java/util/Map$Entry\n 508: astore 13\n 510: astore 14\n 512: iconst_0\n 513: istore 15\n 515: aload 13\n 517: invokeinterface #129, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 522: aload 14\n 524: swap\n 525: aload 12\n 527: checkcast #126 // class java/util/Map$Entry\n 530: astore 16\n 532: astore 28\n 534: astore 27\n 536: iconst_0\n 537: istore 17\n 539: aload 16\n 541: invokeinterface #134, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 546: checkcast #148 // class java/lang/Iterable\n 549: invokestatic #198 // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J\n 552: invokestatic #161 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 555: astore 29\n 557: aload 27\n 559: aload 28\n 561: aload 29\n 563: invokeinterface #179, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 568: pop\n 569: goto 482\n 572: aload 7\n 574: nop\n 575: nop\n 576: astore_3\n 577: aload_3\n 578: invokestatic #202 // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;\n 581: areturn\n\n public final void run();\n Code:\n 0: new #255 // class java/io/File\n 3: dup\n 4: ldc_w #257 // String day14/input-real.txt\n 7: invokespecial #260 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 10: getstatic #266 // Field java/nio/charset/StandardCharsets.UTF_8:Ljava/nio/charset/Charset;\n 13: dup\n 14: ldc_w #267 // String UTF_8\n 17: invokestatic #43 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 20: invokestatic #273 // Method kotlin/io/FilesKt.readLines:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/util/List;\n 23: astore_1\n 24: aload_1\n 25: invokestatic #277 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 28: checkcast #17 // class java/lang/String\n 31: invokevirtual #35 // Method java/lang/String.toCharArray:()[C\n 34: dup\n 35: ldc #37 // String toCharArray(...)\n 37: invokestatic #43 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 40: invokestatic #283 // Method kotlin/collections/ArraysKt.toList:([C)Ljava/util/List;\n 43: astore_2\n 44: aload_1\n 45: checkcast #148 // class java/lang/Iterable\n 48: iconst_2\n 49: invokestatic #287 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 52: checkcast #148 // class java/lang/Iterable\n 55: astore 4\n 57: iconst_0\n 58: istore 5\n 60: aload 4\n 62: bipush 10\n 64: invokestatic #152 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 67: invokestatic #193 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 70: bipush 16\n 72: invokestatic #293 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 75: istore 6\n 77: aload 4\n 79: astore 7\n 81: new #171 // class java/util/LinkedHashMap\n 84: dup\n 85: iload 6\n 87: invokespecial #194 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 90: checkcast #104 // class java/util/Map\n 93: astore 8\n 95: iconst_0\n 96: istore 9\n 98: aload 7\n 100: invokeinterface #156, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 105: astore 10\n 107: aload 10\n 109: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 114: ifeq 169\n 117: aload 10\n 119: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 124: astore 11\n 126: aload 8\n 128: astore 12\n 130: aload 11\n 132: checkcast #17 // class java/lang/String\n 135: astore 14\n 137: iconst_0\n 138: istore 16\n 140: aload_0\n 141: aload 14\n 143: invokespecial #295 // Method toRule:(Ljava/lang/String;)Lkotlin/Pair;\n 146: astore 14\n 148: aload 12\n 150: aload 14\n 152: invokevirtual #175 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 155: aload 14\n 157: invokevirtual #182 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 160: invokeinterface #179, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 165: pop\n 166: goto 107\n 169: aload 8\n 171: nop\n 172: astore_3\n 173: aload_3\n 174: astore 5\n 176: aload_0\n 177: invokespecial #297 // Method toTransitions:()Lkotlin/jvm/functions/Function1;\n 180: astore 6\n 182: iconst_0\n 183: istore 7\n 185: aload 5\n 187: astore 8\n 189: new #99 // class java/util/ArrayList\n 192: dup\n 193: aload 5\n 195: invokeinterface #187, 1 // InterfaceMethod java/util/Map.size:()I\n 200: invokespecial #155 // Method java/util/ArrayList.\"<init>\":(I)V\n 203: checkcast #102 // class java/util/Collection\n 206: astore 9\n 208: iconst_0\n 209: istore 10\n 211: aload 8\n 213: invokeinterface #108, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 218: invokeinterface #114, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 223: astore 11\n 225: aload 11\n 227: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 232: ifeq 267\n 235: aload 11\n 237: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 242: checkcast #126 // class java/util/Map$Entry\n 245: astore 12\n 247: aload 9\n 249: aload 6\n 251: aload 12\n 253: invokeinterface #301, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 258: invokeinterface #165, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 263: pop\n 264: goto 225\n 267: aload 9\n 269: checkcast #27 // class java/util/List\n 272: nop\n 273: checkcast #148 // class java/lang/Iterable\n 276: invokestatic #305 // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;\n 279: astore 4\n 281: aload_2\n 282: checkcast #148 // class java/lang/Iterable\n 285: iconst_2\n 286: iconst_1\n 287: iconst_0\n 288: iconst_4\n 289: aconst_null\n 290: invokestatic #309 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;\n 293: checkcast #148 // class java/lang/Iterable\n 296: astore 6\n 298: nop\n 299: iconst_0\n 300: istore 7\n 302: aload 6\n 304: astore 8\n 306: new #99 // class java/util/ArrayList\n 309: dup\n 310: aload 6\n 312: bipush 10\n 314: invokestatic #152 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 317: invokespecial #155 // Method java/util/ArrayList.\"<init>\":(I)V\n 320: checkcast #102 // class java/util/Collection\n 323: astore 9\n 325: iconst_0\n 326: istore 10\n 328: aload 8\n 330: invokeinterface #156, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 335: astore 11\n 337: aload 11\n 339: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 344: ifeq 401\n 347: aload 11\n 349: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 354: astore 12\n 356: aload 9\n 358: aload 12\n 360: checkcast #27 // class java/util/List\n 363: astore 14\n 365: astore 27\n 367: iconst_0\n 368: istore 16\n 370: aload 14\n 372: iconst_0\n 373: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 378: aload 14\n 380: iconst_1\n 381: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 386: invokestatic #65 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 389: aload 27\n 391: swap\n 392: invokeinterface #165, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 397: pop\n 398: goto 337\n 401: aload 9\n 403: checkcast #27 // class java/util/List\n 406: nop\n 407: checkcast #148 // class java/lang/Iterable\n 410: astore 6\n 412: nop\n 413: iconst_0\n 414: istore 7\n 416: new #311 // class Day14$Part2$run$$inlined$groupingBy$1\n 419: dup\n 420: aload 6\n 422: invokespecial #314 // Method Day14$Part2$run$$inlined$groupingBy$1.\"<init>\":(Ljava/lang/Iterable;)V\n 425: checkcast #316 // class kotlin/collections/Grouping\n 428: invokestatic #322 // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;\n 431: astore 6\n 433: nop\n 434: iconst_0\n 435: istore 7\n 437: aload 6\n 439: astore 8\n 441: new #171 // class java/util/LinkedHashMap\n 444: dup\n 445: aload 6\n 447: invokeinterface #187, 1 // InterfaceMethod java/util/Map.size:()I\n 452: invokestatic #193 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 455: invokespecial #194 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 458: checkcast #104 // class java/util/Map\n 461: astore 9\n 463: iconst_0\n 464: istore 10\n 466: aload 8\n 468: invokeinterface #108, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 473: checkcast #148 // class java/lang/Iterable\n 476: astore 11\n 478: iconst_0\n 479: istore 12\n 481: aload 11\n 483: invokeinterface #156, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 488: astore 14\n 490: aload 14\n 492: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 497: ifeq 581\n 500: aload 14\n 502: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 507: astore 16\n 509: aload 9\n 511: aload 16\n 513: checkcast #126 // class java/util/Map$Entry\n 516: astore 18\n 518: astore 20\n 520: iconst_0\n 521: istore 21\n 523: aload 18\n 525: invokeinterface #129, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 530: aload 20\n 532: swap\n 533: aload 16\n 535: checkcast #126 // class java/util/Map$Entry\n 538: astore 22\n 540: astore 28\n 542: astore 27\n 544: iconst_0\n 545: istore 23\n 547: aload 22\n 549: invokeinterface #134, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 554: checkcast #136 // class java/lang/Number\n 557: invokevirtual #325 // Method java/lang/Number.intValue:()I\n 560: i2l\n 561: invokestatic #161 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 564: astore 29\n 566: aload 27\n 568: aload 28\n 570: aload 29\n 572: invokeinterface #179, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 577: pop\n 578: goto 490\n 581: aload 9\n 583: nop\n 584: nop\n 585: invokestatic #202 // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;\n 588: astore 5\n 590: aload 5\n 592: aload 4\n 594: invokedynamic #333, 0 // InvokeDynamic #1:invoke:(Ljava/util/Map;)Lkotlin/jvm/functions/Function1;\n 599: invokestatic #339 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 602: bipush 40\n 604: invokestatic #342 // Method kotlin/sequences/SequencesKt.drop:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;\n 607: invokestatic #345 // Method kotlin/sequences/SequencesKt.first:(Lkotlin/sequences/Sequence;)Ljava/lang/Object;\n 610: checkcast #104 // class java/util/Map\n 613: astore 6\n 615: aload 6\n 617: invokeinterface #108, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 622: checkcast #148 // class java/lang/Iterable\n 625: astore 8\n 627: nop\n 628: iconst_0\n 629: istore 9\n 631: aload 8\n 633: astore 10\n 635: new #171 // class java/util/LinkedHashMap\n 638: dup\n 639: invokespecial #172 // Method java/util/LinkedHashMap.\"<init>\":()V\n 642: checkcast #104 // class java/util/Map\n 645: astore 11\n 647: iconst_0\n 648: istore 12\n 650: aload 10\n 652: invokeinterface #156, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 657: astore 14\n 659: aload 14\n 661: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 666: ifeq 817\n 669: aload 14\n 671: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 676: astore 16\n 678: aload 16\n 680: checkcast #126 // class java/util/Map$Entry\n 683: astore 18\n 685: iconst_0\n 686: istore 20\n 688: aload 18\n 690: invokeinterface #129, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 695: checkcast #131 // class kotlin/Pair\n 698: invokevirtual #175 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 701: checkcast #45 // class java/lang/Character\n 704: invokevirtual #349 // Method java/lang/Character.charValue:()C\n 707: invokestatic #49 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 710: astore 21\n 712: aload 11\n 714: astore 22\n 716: iconst_0\n 717: istore 23\n 719: aload 22\n 721: aload 21\n 723: invokeinterface #142, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 728: astore 24\n 730: aload 24\n 732: ifnonnull 767\n 735: iconst_0\n 736: istore 25\n 738: new #99 // class java/util/ArrayList\n 741: dup\n 742: invokespecial #100 // Method java/util/ArrayList.\"<init>\":()V\n 745: checkcast #27 // class java/util/List\n 748: astore 25\n 750: aload 22\n 752: aload 21\n 754: aload 25\n 756: invokeinterface #179, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 761: pop\n 762: aload 25\n 764: goto 769\n 767: aload 24\n 769: nop\n 770: checkcast #27 // class java/util/List\n 773: astore 18\n 775: aload 18\n 777: aload 16\n 779: checkcast #126 // class java/util/Map$Entry\n 782: astore 20\n 784: astore 27\n 786: iconst_0\n 787: istore 26\n 789: aload 20\n 791: invokeinterface #134, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 796: checkcast #136 // class java/lang/Number\n 799: invokevirtual #140 // Method java/lang/Number.longValue:()J\n 802: invokestatic #161 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 805: aload 27\n 807: swap\n 808: invokeinterface #183, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 813: pop\n 814: goto 659\n 817: aload 11\n 819: nop\n 820: astore 8\n 822: nop\n 823: iconst_0\n 824: istore 9\n 826: aload 8\n 828: astore 10\n 830: new #171 // class java/util/LinkedHashMap\n 833: dup\n 834: aload 8\n 836: invokeinterface #187, 1 // InterfaceMethod java/util/Map.size:()I\n 841: invokestatic #193 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 844: invokespecial #194 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 847: checkcast #104 // class java/util/Map\n 850: astore 11\n 852: iconst_0\n 853: istore 12\n 855: aload 10\n 857: invokeinterface #108, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 862: checkcast #148 // class java/lang/Iterable\n 865: astore 14\n 867: iconst_0\n 868: istore 16\n 870: aload 14\n 872: invokeinterface #156, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 877: astore 18\n 879: aload 18\n 881: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 886: ifeq 969\n 889: aload 18\n 891: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 896: astore 20\n 898: aload 11\n 900: aload 20\n 902: checkcast #126 // class java/util/Map$Entry\n 905: astore 21\n 907: astore 22\n 909: iconst_0\n 910: istore 23\n 912: aload 21\n 914: invokeinterface #129, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 919: aload 22\n 921: swap\n 922: aload 20\n 924: checkcast #126 // class java/util/Map$Entry\n 927: astore 24\n 929: astore 28\n 931: astore 27\n 933: iconst_0\n 934: istore 25\n 936: aload 24\n 938: invokeinterface #134, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 943: checkcast #148 // class java/lang/Iterable\n 946: invokestatic #198 // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J\n 949: invokestatic #161 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 952: astore 29\n 954: aload 27\n 956: aload 28\n 958: aload 29\n 960: invokeinterface #179, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 965: pop\n 966: goto 879\n 969: aload 11\n 971: nop\n 972: nop\n 973: invokestatic #202 // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;\n 976: astore 8\n 978: aload 8\n 980: astore 9\n 982: iconst_0\n 983: istore 10\n 985: aload 9\n 987: aload_2\n 988: invokestatic #352 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 991: lconst_1\n 992: aload 9\n 994: aload_2\n 995: invokestatic #352 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 998: invokeinterface #142, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 1003: dup\n 1004: invokestatic #146 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 1007: checkcast #136 // class java/lang/Number\n 1010: invokevirtual #140 // Method java/lang/Number.longValue:()J\n 1013: ladd\n 1014: invokestatic #161 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 1017: invokeinterface #179, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 1022: pop\n 1023: nop\n 1024: aload 8\n 1026: astore 7\n 1028: aload 7\n 1030: invokeinterface #108, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 1035: checkcast #148 // class java/lang/Iterable\n 1038: invokeinterface #156, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1043: astore 11\n 1045: aload 11\n 1047: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1052: ifne 1063\n 1055: new #354 // class java/util/NoSuchElementException\n 1058: dup\n 1059: invokespecial #355 // Method java/util/NoSuchElementException.\"<init>\":()V\n 1062: athrow\n 1063: aload 11\n 1065: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1070: checkcast #126 // class java/util/Map$Entry\n 1073: astore 12\n 1075: iconst_0\n 1076: istore 14\n 1078: aload 12\n 1080: invokeinterface #134, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 1085: checkcast #136 // class java/lang/Number\n 1088: invokevirtual #140 // Method java/lang/Number.longValue:()J\n 1091: lstore 12\n 1093: aload 11\n 1095: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1100: ifeq 1148\n 1103: aload 11\n 1105: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1110: checkcast #126 // class java/util/Map$Entry\n 1113: astore 14\n 1115: iconst_0\n 1116: istore 16\n 1118: aload 14\n 1120: invokeinterface #134, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 1125: checkcast #136 // class java/lang/Number\n 1128: invokevirtual #140 // Method java/lang/Number.longValue:()J\n 1131: lstore 14\n 1133: lload 12\n 1135: lload 14\n 1137: lcmp\n 1138: ifge 1093\n 1141: lload 14\n 1143: lstore 12\n 1145: goto 1093\n 1148: lload 12\n 1150: lstore 8\n 1152: aload 7\n 1154: invokeinterface #108, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 1159: checkcast #148 // class java/lang/Iterable\n 1162: invokeinterface #156, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1167: astore 14\n 1169: aload 14\n 1171: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1176: ifne 1187\n 1179: new #354 // class java/util/NoSuchElementException\n 1182: dup\n 1183: invokespecial #355 // Method java/util/NoSuchElementException.\"<init>\":()V\n 1186: athrow\n 1187: aload 14\n 1189: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1194: checkcast #126 // class java/util/Map$Entry\n 1197: astore 16\n 1199: iconst_0\n 1200: istore 18\n 1202: aload 16\n 1204: invokeinterface #134, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 1209: checkcast #136 // class java/lang/Number\n 1212: invokevirtual #140 // Method java/lang/Number.longValue:()J\n 1215: lstore 16\n 1217: aload 14\n 1219: invokeinterface #120, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1224: ifeq 1272\n 1227: aload 14\n 1229: invokeinterface #124, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1234: checkcast #126 // class java/util/Map$Entry\n 1237: astore 18\n 1239: iconst_0\n 1240: istore 20\n 1242: aload 18\n 1244: invokeinterface #134, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 1249: checkcast #136 // class java/lang/Number\n 1252: invokevirtual #140 // Method java/lang/Number.longValue:()J\n 1255: lstore 18\n 1257: lload 16\n 1259: lload 18\n 1261: lcmp\n 1262: ifle 1217\n 1265: lload 18\n 1267: lstore 16\n 1269: goto 1217\n 1272: lload 16\n 1274: lstore 10\n 1276: lload 8\n 1278: lload 10\n 1280: lsub\n 1281: lstore 12\n 1283: getstatic #361 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1286: lload 12\n 1288: invokevirtual #367 // Method java/io/PrintStream.println:(J)V\n 1291: return\n\n private static final kotlin.Pair toTransitions$lambda$1(java.util.Map$Entry);\n Code:\n 0: aload_0\n 1: ldc_w #396 // String <destruct>\n 4: invokestatic #399 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokeinterface #129, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 13: checkcast #27 // class java/util/List\n 16: astore_1\n 17: aload_0\n 18: invokeinterface #134, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 23: checkcast #45 // class java/lang/Character\n 26: invokevirtual #349 // Method java/lang/Character.charValue:()C\n 29: istore_2\n 30: aload_1\n 31: iconst_0\n 32: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 37: aload_1\n 38: iconst_1\n 39: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 44: invokestatic #65 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 47: iconst_2\n 48: anewarray #131 // class kotlin/Pair\n 51: astore_3\n 52: aload_3\n 53: iconst_0\n 54: aload_1\n 55: iconst_0\n 56: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 61: iload_2\n 62: invokestatic #49 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 65: invokestatic #65 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 68: aastore\n 69: aload_3\n 70: iconst_1\n 71: iload_2\n 72: invokestatic #49 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 75: aload_1\n 76: iconst_1\n 77: invokeinterface #31, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 82: invokestatic #65 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 85: aastore\n 86: aload_3\n 87: invokestatic #55 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 90: invokestatic #65 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 93: areturn\n\n private static final java.util.Map run$lambda$10(java.util.Map, java.util.Map);\n Code:\n 0: aload_1\n 1: ldc_w #401 // String it\n 4: invokestatic #399 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: getstatic #404 // Field INSTANCE:LDay14$Part2;\n 10: aload_1\n 11: aload_0\n 12: invokespecial #406 // Method step:(Ljava/util/Map;Ljava/util/Map;)Ljava/util/Map;\n 15: areturn\n\n static {};\n Code:\n 0: new #2 // class Day14$Part2\n 3: dup\n 4: invokespecial #409 // Method \"<init>\":()V\n 7: putstatic #404 // Field INSTANCE:LDay14$Part2;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day14$Part2$run$$inlined$groupingBy$1.class", "javap": "Compiled from \"_Collections.kt\"\npublic final class Day14$Part2$run$$inlined$groupingBy$1 implements kotlin.collections.Grouping<kotlin.Pair<? extends java.lang.Character, ? extends java.lang.Character>, kotlin.Pair<? extends java.lang.Character, ? extends java.lang.Character>> {\n final java.lang.Iterable $this_groupingBy;\n\n public Day14$Part2$run$$inlined$groupingBy$1(java.lang.Iterable);\n Code:\n 0: aload_0\n 1: aload_1\n 2: putfield #18 // Field $this_groupingBy:Ljava/lang/Iterable;\n 5: aload_0\n 6: invokespecial #21 // Method java/lang/Object.\"<init>\":()V\n 9: return\n\n public java.util.Iterator<kotlin.Pair<? extends java.lang.Character, ? extends java.lang.Character>> sourceIterator();\n Code:\n 0: aload_0\n 1: getfield #18 // Field $this_groupingBy:Ljava/lang/Iterable;\n 4: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 9: areturn\n\n public kotlin.Pair<? extends java.lang.Character, ? extends java.lang.Character> keyOf(kotlin.Pair<? extends java.lang.Character, ? extends java.lang.Character>);\n Code:\n 0: aload_1\n 1: checkcast #37 // class kotlin/Pair\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: areturn\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day14$Part1$run$$inlined$groupingBy$1.class", "javap": "Compiled from \"_Collections.kt\"\npublic final class Day14$Part1$run$$inlined$groupingBy$1 implements kotlin.collections.Grouping<java.lang.Character, java.lang.Character> {\n final java.lang.Iterable $this_groupingBy;\n\n public Day14$Part1$run$$inlined$groupingBy$1(java.lang.Iterable);\n Code:\n 0: aload_0\n 1: aload_1\n 2: putfield #18 // Field $this_groupingBy:Ljava/lang/Iterable;\n 5: aload_0\n 6: invokespecial #21 // Method java/lang/Object.\"<init>\":()V\n 9: return\n\n public java.util.Iterator<java.lang.Character> sourceIterator();\n Code:\n 0: aload_0\n 1: getfield #18 // Field $this_groupingBy:Ljava/lang/Iterable;\n 4: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 9: areturn\n\n public java.lang.Character keyOf(java.lang.Character);\n Code:\n 0: aload_1\n 1: checkcast #37 // class java/lang/Character\n 4: invokevirtual #41 // Method java/lang/Character.charValue:()C\n 7: istore_2\n 8: iconst_0\n 9: istore_3\n 10: iload_2\n 11: invokestatic #45 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 14: areturn\n}\n", "javap_err": "" } ]
andrewrlee__adventOfCode2021__aace0fc/src/main/kotlin/Day16.kt
import Day16.Type.EQUAL_TO import Day16.Type.G_THAN import Day16.Type.LITERAL import Day16.Type.L_THAN import Day16.Type.MAX import Day16.Type.MIN import Day16.Type.PRODUCT import Day16.Type.SUM import java.io.File import java.math.BigInteger import java.nio.charset.Charset.defaultCharset object Day16 { enum class Type(val code: Int) { SUM(0), PRODUCT(1), MIN(2), MAX(3), LITERAL(4), G_THAN(5), L_THAN(6), EQUAL_TO(7); companion object { fun fromCode(code: Int) = values().first { it.code == code } } } private fun String.toBinary() = BigInteger(this, 16).toString(2).let { String.format("%4s", it).replace(" ", "0").toCharArray().toList() } sealed class Packet( open val version: Int, open val type: Type, ) { abstract fun getTotalVersion(): Int abstract fun evaluate(): Long } data class Literal( override val version: Int, val literal: Long ) : Packet(version, LITERAL) { override fun getTotalVersion() = version override fun evaluate(): Long = literal } data class Operator( override val version: Int, override val type: Type, val payload: List<Packet> ) : Packet(version, type) { override fun getTotalVersion() = version + (payload.sumOf { it.getTotalVersion() }) override fun evaluate() = when (type) { SUM -> payload.sumOf { it.evaluate() } PRODUCT -> payload.fold(1L) { acc, i -> acc * i.evaluate() } MIN -> payload.minOf { it.evaluate() } MAX -> payload.maxOf { it.evaluate() } G_THAN -> if (payload[0].evaluate() > payload[1].evaluate()) 1 else 0 L_THAN -> if (payload[0].evaluate() < payload[1].evaluate()) 1 else 0 EQUAL_TO -> if (payload[0].evaluate() == payload[1].evaluate()) 1 else 0 else -> throw RuntimeException("unexpected type") } } data class BinaryString(var input: List<Char>) { fun isNotEmpty() = input.isNotEmpty() && input.size > 3 fun readString(length: Int): String { val chars = mutableListOf<Char>() var index = 0 var realCount = 0 do { when (val c = input[index]) { '%' -> {} else -> { chars.add(c) realCount++ } } index++ } while (realCount != length) input = input.subList(index, input.size) return chars.joinToString("") } fun readSection(length: Int): BinaryString { val chars = mutableListOf<Char>() var index = 0 var realCount = 0 do { val c = input[index] when (c) { '%' -> {} else -> { realCount++ } } chars.add(c) index++ } while (realCount != length) input = input.subList(index, input.size) return BinaryString(chars) } fun readInt(length: Int): Int { val string = readString(length) return Integer.parseInt(string, 2) } } private fun readPackets(input: BinaryString): MutableList<Packet> { val packets = mutableListOf<Packet>() while (input.isNotEmpty()) { packets.add(input.readPacket()) } return packets } private fun BinaryString.readPacket(): Packet { val version = this.readInt(3) return when (val type = Type.fromCode(this.readInt(3))) { LITERAL -> readLiteral(version, this) else -> readOperator(version, type, this) } } private fun readOperator(version: Int, type: Type, input: BinaryString): Packet { val packets = when (input.readString(1)) { "0" -> { val size = input.readInt(15) readPackets(input.readSection(size)) } "1" -> { val numberOfPackets = input.readInt(11) (0 until numberOfPackets).map { input.readPacket() } } else -> throw RuntimeException("unexpected val") } return Operator(version, type, packets) } private fun readLiteral(version: Int, input: BinaryString): Packet { val parts = mutableListOf<Char>() var finish: Boolean do { val (a, b, c, d, e) = input.readString(5).toList() parts.addAll(listOf(b, c, d, e)) finish = a == '0' } while (!finish) val value = BigInteger(parts.joinToString(""), 2).longValueExact() return Literal(version, value) } val input = { File("day16/input-real.txt") .readText(defaultCharset()) .map { it.toString().toBinary() } .flatMap { it + '%' } .let { BinaryString(it) } } object Part1 { fun run() = println(input().readPacket().getTotalVersion()) } object Part2 { fun run() = println(input().readPacket().evaluate()) } } fun main() { Day16.Part1.run() Day16.Part2.run() }
[ { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day16$Packet.class", "javap": "Compiled from \"Day16.kt\"\npublic abstract class Day16$Packet {\n private final int version;\n\n private final Day16$Type type;\n\n private Day16$Packet(int, Day16$Type);\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 version:I\n 9: aload_0\n 10: aload_2\n 11: putfield #17 // Field type:LDay16$Type;\n 14: return\n\n public int getVersion();\n Code:\n 0: aload_0\n 1: getfield #13 // Field version:I\n 4: ireturn\n\n public Day16$Type getType();\n Code:\n 0: aload_0\n 1: getfield #17 // Field type:LDay16$Type;\n 4: areturn\n\n public abstract int getTotalVersion();\n\n public abstract long evaluate();\n\n public Day16$Packet(int, Day16$Type, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: iload_1\n 2: aload_2\n 3: invokespecial #30 // Method \"<init>\":(ILDay16$Type;)V\n 6: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day16$Operator.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16$Operator extends Day16$Packet {\n private final int version;\n\n private final Day16$Type type;\n\n private final java.util.List<Day16$Packet> payload;\n\n public Day16$Operator(int, Day16$Type, java.util.List<? extends Day16$Packet>);\n Code:\n 0: aload_2\n 1: ldc #10 // String type\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_3\n 7: ldc #18 // String payload\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: iload_1\n 14: aload_2\n 15: aconst_null\n 16: invokespecial #21 // Method Day16$Packet.\"<init>\":(ILDay16$Type;Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 19: aload_0\n 20: iload_1\n 21: putfield #25 // Field version:I\n 24: aload_0\n 25: aload_2\n 26: putfield #28 // Field type:LDay16$Type;\n 29: aload_0\n 30: aload_3\n 31: putfield #31 // Field payload:Ljava/util/List;\n 34: return\n\n public int getVersion();\n Code:\n 0: aload_0\n 1: getfield #25 // Field version:I\n 4: ireturn\n\n public Day16$Type getType();\n Code:\n 0: aload_0\n 1: getfield #28 // Field type:LDay16$Type;\n 4: areturn\n\n public final java.util.List<Day16$Packet> getPayload();\n Code:\n 0: aload_0\n 1: getfield #31 // Field payload:Ljava/util/List;\n 4: areturn\n\n public int getTotalVersion();\n Code:\n 0: aload_0\n 1: invokevirtual #43 // Method getVersion:()I\n 4: aload_0\n 5: getfield #31 // Field payload:Ljava/util/List;\n 8: checkcast #45 // class java/lang/Iterable\n 11: astore_1\n 12: istore 7\n 14: iconst_0\n 15: istore_2\n 16: aload_1\n 17: invokeinterface #49, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 22: astore_3\n 23: aload_3\n 24: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifeq 69\n 32: aload_3\n 33: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 38: astore 4\n 40: iload_2\n 41: aload 4\n 43: checkcast #4 // class Day16$Packet\n 46: astore 5\n 48: istore 8\n 50: iconst_0\n 51: istore 6\n 53: aload 5\n 55: invokevirtual #61 // Method Day16$Packet.getTotalVersion:()I\n 58: istore 9\n 60: iload 8\n 62: iload 9\n 64: iadd\n 65: istore_2\n 66: goto 23\n 69: iload_2\n 70: istore 8\n 72: iload 7\n 74: iload 8\n 76: iadd\n 77: ireturn\n\n public long evaluate();\n Code:\n 0: aload_0\n 1: invokevirtual #68 // Method getType:()LDay16$Type;\n 4: getstatic #74 // Field Day16$Operator$WhenMappings.$EnumSwitchMapping$0:[I\n 7: swap\n 8: invokevirtual #79 // Method Day16$Type.ordinal:()I\n 11: iaload\n 12: tableswitch { // 1 to 7\n 1: 56\n 2: 126\n 3: 201\n 4: 302\n 5: 403\n 6: 447\n 7: 491\n default: 535\n }\n 56: aload_0\n 57: getfield #31 // Field payload:Ljava/util/List;\n 60: checkcast #45 // class java/lang/Iterable\n 63: astore_1\n 64: lconst_0\n 65: lstore_2\n 66: aload_1\n 67: invokeinterface #49, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 72: astore 6\n 74: aload 6\n 76: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 81: ifeq 122\n 84: aload 6\n 86: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 91: astore 8\n 93: lload_2\n 94: aload 8\n 96: checkcast #4 // class Day16$Packet\n 99: astore 9\n 101: lstore 14\n 103: iconst_0\n 104: istore 10\n 106: aload 9\n 108: invokevirtual #81 // Method Day16$Packet.evaluate:()J\n 111: lstore 16\n 113: lload 14\n 115: lload 16\n 117: ladd\n 118: lstore_2\n 119: goto 74\n 122: lload_2\n 123: goto 545\n 126: aload_0\n 127: getfield #31 // Field payload:Ljava/util/List;\n 130: checkcast #45 // class java/lang/Iterable\n 133: astore_1\n 134: lconst_1\n 135: lstore_2\n 136: iconst_0\n 137: istore 4\n 139: lload_2\n 140: lstore 6\n 142: aload_1\n 143: invokeinterface #49, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 148: astore 8\n 150: aload 8\n 152: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 157: ifeq 196\n 160: aload 8\n 162: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 167: astore 9\n 169: lload 6\n 171: aload 9\n 173: checkcast #4 // class Day16$Packet\n 176: astore 10\n 178: lstore 11\n 180: iconst_0\n 181: istore 13\n 183: lload 11\n 185: aload 10\n 187: invokevirtual #81 // Method Day16$Packet.evaluate:()J\n 190: lmul\n 191: lstore 6\n 193: goto 150\n 196: lload 6\n 198: goto 545\n 201: aload_0\n 202: getfield #31 // Field payload:Ljava/util/List;\n 205: checkcast #45 // class java/lang/Iterable\n 208: invokeinterface #49, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 213: astore_2\n 214: aload_2\n 215: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 220: ifne 231\n 223: new #83 // class java/util/NoSuchElementException\n 226: dup\n 227: invokespecial #86 // Method java/util/NoSuchElementException.\"<init>\":()V\n 230: athrow\n 231: aload_2\n 232: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 237: checkcast #4 // class Day16$Packet\n 240: astore 4\n 242: iconst_0\n 243: istore 6\n 245: aload 4\n 247: invokevirtual #81 // Method Day16$Packet.evaluate:()J\n 250: lstore 4\n 252: aload_2\n 253: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 258: ifeq 297\n 261: aload_2\n 262: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 267: checkcast #4 // class Day16$Packet\n 270: astore 6\n 272: iconst_0\n 273: istore 8\n 275: aload 6\n 277: invokevirtual #81 // Method Day16$Packet.evaluate:()J\n 280: lstore 6\n 282: lload 4\n 284: lload 6\n 286: lcmp\n 287: ifle 252\n 290: lload 6\n 292: lstore 4\n 294: goto 252\n 297: lload 4\n 299: goto 545\n 302: aload_0\n 303: getfield #31 // Field payload:Ljava/util/List;\n 306: checkcast #45 // class java/lang/Iterable\n 309: invokeinterface #49, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 314: astore_2\n 315: aload_2\n 316: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 321: ifne 332\n 324: new #83 // class java/util/NoSuchElementException\n 327: dup\n 328: invokespecial #86 // Method java/util/NoSuchElementException.\"<init>\":()V\n 331: athrow\n 332: aload_2\n 333: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 338: checkcast #4 // class Day16$Packet\n 341: astore 4\n 343: iconst_0\n 344: istore 6\n 346: aload 4\n 348: invokevirtual #81 // Method Day16$Packet.evaluate:()J\n 351: lstore 4\n 353: aload_2\n 354: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 359: ifeq 398\n 362: aload_2\n 363: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 368: checkcast #4 // class Day16$Packet\n 371: astore 6\n 373: iconst_0\n 374: istore 8\n 376: aload 6\n 378: invokevirtual #81 // Method Day16$Packet.evaluate:()J\n 381: lstore 6\n 383: lload 4\n 385: lload 6\n 387: lcmp\n 388: ifge 353\n 391: lload 6\n 393: lstore 4\n 395: goto 353\n 398: lload 4\n 400: goto 545\n 403: aload_0\n 404: getfield #31 // Field payload:Ljava/util/List;\n 407: iconst_0\n 408: invokeinterface #92, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 413: checkcast #4 // class Day16$Packet\n 416: invokevirtual #81 // Method Day16$Packet.evaluate:()J\n 419: aload_0\n 420: getfield #31 // Field payload:Ljava/util/List;\n 423: iconst_1\n 424: invokeinterface #92, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 429: checkcast #4 // class Day16$Packet\n 432: invokevirtual #81 // Method Day16$Packet.evaluate:()J\n 435: lcmp\n 436: ifle 443\n 439: lconst_1\n 440: goto 545\n 443: lconst_0\n 444: goto 545\n 447: aload_0\n 448: getfield #31 // Field payload:Ljava/util/List;\n 451: iconst_0\n 452: invokeinterface #92, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 457: checkcast #4 // class Day16$Packet\n 460: invokevirtual #81 // Method Day16$Packet.evaluate:()J\n 463: aload_0\n 464: getfield #31 // Field payload:Ljava/util/List;\n 467: iconst_1\n 468: invokeinterface #92, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 473: checkcast #4 // class Day16$Packet\n 476: invokevirtual #81 // Method Day16$Packet.evaluate:()J\n 479: lcmp\n 480: ifge 487\n 483: lconst_1\n 484: goto 545\n 487: lconst_0\n 488: goto 545\n 491: aload_0\n 492: getfield #31 // Field payload:Ljava/util/List;\n 495: iconst_0\n 496: invokeinterface #92, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 501: checkcast #4 // class Day16$Packet\n 504: invokevirtual #81 // Method Day16$Packet.evaluate:()J\n 507: aload_0\n 508: getfield #31 // Field payload:Ljava/util/List;\n 511: iconst_1\n 512: invokeinterface #92, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 517: checkcast #4 // class Day16$Packet\n 520: invokevirtual #81 // Method Day16$Packet.evaluate:()J\n 523: lcmp\n 524: ifne 531\n 527: lconst_1\n 528: goto 545\n 531: lconst_0\n 532: goto 545\n 535: new #94 // class java/lang/RuntimeException\n 538: dup\n 539: ldc #96 // String unexpected type\n 541: invokespecial #99 // Method java/lang/RuntimeException.\"<init>\":(Ljava/lang/String;)V\n 544: athrow\n 545: lreturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #25 // Field version:I\n 4: ireturn\n\n public final Day16$Type component2();\n Code:\n 0: aload_0\n 1: getfield #28 // Field type:LDay16$Type;\n 4: areturn\n\n public final java.util.List<Day16$Packet> component3();\n Code:\n 0: aload_0\n 1: getfield #31 // Field payload:Ljava/util/List;\n 4: areturn\n\n public final Day16$Operator copy(int, Day16$Type, java.util.List<? extends Day16$Packet>);\n Code:\n 0: aload_2\n 1: ldc #10 // String type\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_3\n 7: ldc #18 // String payload\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class Day16$Operator\n 15: dup\n 16: iload_1\n 17: aload_2\n 18: aload_3\n 19: invokespecial #121 // Method \"<init>\":(ILDay16$Type;Ljava/util/List;)V\n 22: areturn\n\n public static Day16$Operator copy$default(Day16$Operator, int, Day16$Type, java.util.List, 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 #25 // Field version: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 #28 // Field type:LDay16$Type;\n 23: astore_2\n 24: iload 4\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #31 // Field payload:Ljava/util/List;\n 35: astore_3\n 36: aload_0\n 37: iload_1\n 38: aload_2\n 39: aload_3\n 40: invokevirtual #125 // Method copy:(ILDay16$Type;Ljava/util/List;)LDay16$Operator;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #129 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #130 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #132 // String Operator(version=\n 9: invokevirtual #136 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #25 // Field version:I\n 16: invokevirtual #139 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #141 // String , type=\n 21: invokevirtual #136 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #28 // Field type:LDay16$Type;\n 28: invokevirtual #144 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: ldc #146 // String , payload=\n 33: invokevirtual #136 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #31 // Field payload:Ljava/util/List;\n 40: invokevirtual #144 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #149 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #151 // 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 #25 // Field version:I\n 4: invokestatic #157 // 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 #28 // Field type:LDay16$Type;\n 16: invokevirtual #159 // Method Day16$Type.hashCode:()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 #31 // Field payload:Ljava/util/List;\n 29: invokevirtual #162 // Method java/lang/Object.hashCode:()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 Day16$Operator\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day16$Operator\n 20: astore_2\n 21: aload_0\n 22: getfield #25 // Field version:I\n 25: aload_2\n 26: getfield #25 // Field version:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #28 // Field type:LDay16$Type;\n 38: aload_2\n 39: getfield #28 // Field type:LDay16$Type;\n 42: if_acmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #31 // Field payload:Ljava/util/List;\n 51: aload_2\n 52: getfield #31 // Field payload:Ljava/util/List;\n 55: invokestatic #170 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 58: ifne 63\n 61: iconst_0\n 62: ireturn\n 63: iconst_1\n 64: ireturn\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day16$Type$Companion.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16$Type$Companion {\n private Day16$Type$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final Day16$Type fromCode(int);\n Code:\n 0: invokestatic #19 // Method Day16$Type.values:()[LDay16$Type;\n 3: astore_2\n 4: iconst_0\n 5: istore_3\n 6: iconst_0\n 7: istore 4\n 9: aload_2\n 10: arraylength\n 11: istore 5\n 13: iload 4\n 15: iload 5\n 17: if_icmpge 61\n 20: aload_2\n 21: iload 4\n 23: aaload\n 24: astore 6\n 26: aload 6\n 28: astore 7\n 30: iconst_0\n 31: istore 8\n 33: aload 7\n 35: invokevirtual #23 // Method Day16$Type.getCode:()I\n 38: iload_1\n 39: if_icmpne 46\n 42: iconst_1\n 43: goto 47\n 46: iconst_0\n 47: ifeq 55\n 50: aload 6\n 52: goto 71\n 55: iinc 4, 1\n 58: goto 13\n 61: new #25 // class java/util/NoSuchElementException\n 64: dup\n 65: ldc #27 // String Array contains no element matching the predicate.\n 67: invokespecial #30 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 70: athrow\n 71: areturn\n\n public Day16$Type$Companion(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #44 // Method \"<init>\":()V\n 4: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day16.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16 {\n public static final Day16 INSTANCE;\n\n private static final kotlin.jvm.functions.Function0<Day16$BinaryString> input;\n\n private Day16();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final java.util.List<java.lang.Character> toBinary(java.lang.String);\n Code:\n 0: new #15 // class java/math/BigInteger\n 3: dup\n 4: aload_1\n 5: bipush 16\n 7: invokespecial #18 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;I)V\n 10: iconst_2\n 11: invokevirtual #22 // Method java/math/BigInteger.toString:(I)Ljava/lang/String;\n 14: astore_2\n 15: iconst_0\n 16: istore_3\n 17: getstatic #28 // Field kotlin/jvm/internal/StringCompanionObject.INSTANCE:Lkotlin/jvm/internal/StringCompanionObject;\n 20: pop\n 21: ldc #30 // String %4s\n 23: astore 4\n 25: iconst_1\n 26: anewarray #4 // class java/lang/Object\n 29: astore 5\n 31: aload 5\n 33: iconst_0\n 34: aload_2\n 35: aastore\n 36: aload 5\n 38: astore 5\n 40: aload 4\n 42: aload 5\n 44: aload 5\n 46: arraylength\n 47: invokestatic #36 // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;\n 50: invokestatic #42 // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;\n 53: dup\n 54: ldc #44 // String format(...)\n 56: invokestatic #50 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 59: ldc #52 // String\n 61: ldc #54 // String 0\n 63: iconst_0\n 64: iconst_4\n 65: aconst_null\n 66: invokestatic #60 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 69: invokevirtual #64 // Method java/lang/String.toCharArray:()[C\n 72: dup\n 73: ldc #66 // String toCharArray(...)\n 75: invokestatic #50 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 78: invokestatic #72 // Method kotlin/collections/ArraysKt.toList:([C)Ljava/util/List;\n 81: nop\n 82: areturn\n\n private final java.util.List<Day16$Packet> readPackets(Day16$BinaryString);\n Code:\n 0: new #82 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #83 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #85 // class java/util/List\n 10: astore_2\n 11: aload_1\n 12: invokevirtual #91 // Method Day16$BinaryString.isNotEmpty:()Z\n 15: ifeq 33\n 18: aload_2\n 19: aload_0\n 20: aload_1\n 21: invokespecial #95 // Method readPacket:(LDay16$BinaryString;)LDay16$Packet;\n 24: invokeinterface #99, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 29: pop\n 30: goto 11\n 33: aload_2\n 34: areturn\n\n private final Day16$Packet readPacket(Day16$BinaryString);\n Code:\n 0: aload_1\n 1: iconst_3\n 2: invokevirtual #107 // Method Day16$BinaryString.readInt:(I)I\n 5: istore_2\n 6: getstatic #113 // Field Day16$Type.Companion:LDay16$Type$Companion;\n 9: aload_1\n 10: iconst_3\n 11: invokevirtual #107 // Method Day16$BinaryString.readInt:(I)I\n 14: invokevirtual #119 // Method Day16$Type$Companion.fromCode:(I)LDay16$Type;\n 17: astore_3\n 18: getstatic #125 // Field Day16$WhenMappings.$EnumSwitchMapping$0:[I\n 21: aload_3\n 22: invokevirtual #129 // Method Day16$Type.ordinal:()I\n 25: iaload\n 26: iconst_1\n 27: if_icmpne 39\n 30: aload_0\n 31: iload_2\n 32: aload_1\n 33: invokespecial #133 // Method readLiteral:(ILDay16$BinaryString;)LDay16$Packet;\n 36: goto 46\n 39: aload_0\n 40: iload_2\n 41: aload_3\n 42: aload_1\n 43: invokespecial #137 // Method readOperator:(ILDay16$Type;LDay16$BinaryString;)LDay16$Packet;\n 46: areturn\n\n private final Day16$Packet readOperator(int, Day16$Type, Day16$BinaryString);\n Code:\n 0: aload_3\n 1: iconst_1\n 2: invokevirtual #146 // Method Day16$BinaryString.readString:(I)Ljava/lang/String;\n 5: astore 5\n 7: aload 5\n 9: ldc #54 // String 0\n 11: invokestatic #150 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 14: ifeq 38\n 17: aload_3\n 18: bipush 15\n 20: invokevirtual #107 // Method Day16$BinaryString.readInt:(I)I\n 23: istore 6\n 25: aload_0\n 26: aload_3\n 27: iload 6\n 29: invokevirtual #154 // Method Day16$BinaryString.readSection:(I)LDay16$BinaryString;\n 32: invokespecial #156 // Method readPackets:(LDay16$BinaryString;)Ljava/util/List;\n 35: goto 174\n 38: aload 5\n 40: ldc #158 // String 1\n 42: invokestatic #150 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 45: ifeq 164\n 48: aload_3\n 49: bipush 11\n 51: invokevirtual #107 // Method Day16$BinaryString.readInt:(I)I\n 54: istore 6\n 56: iconst_0\n 57: iload 6\n 59: invokestatic #164 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 62: checkcast #166 // class java/lang/Iterable\n 65: astore 7\n 67: iconst_0\n 68: istore 8\n 70: aload 7\n 72: astore 9\n 74: new #82 // class java/util/ArrayList\n 77: dup\n 78: aload 7\n 80: bipush 10\n 82: invokestatic #172 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 85: invokespecial #175 // Method java/util/ArrayList.\"<init>\":(I)V\n 88: checkcast #177 // class java/util/Collection\n 91: astore 10\n 93: iconst_0\n 94: istore 11\n 96: aload 9\n 98: invokeinterface #181, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 103: astore 12\n 105: aload 12\n 107: invokeinterface #186, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 112: ifeq 155\n 115: aload 12\n 117: checkcast #188 // class kotlin/collections/IntIterator\n 120: invokevirtual #191 // Method kotlin/collections/IntIterator.nextInt:()I\n 123: istore 13\n 125: aload 10\n 127: iload 13\n 129: istore 14\n 131: astore 16\n 133: iconst_0\n 134: istore 15\n 136: getstatic #193 // Field INSTANCE:LDay16;\n 139: aload_3\n 140: invokespecial #95 // Method readPacket:(LDay16$BinaryString;)LDay16$Packet;\n 143: aload 16\n 145: swap\n 146: invokeinterface #194, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 151: pop\n 152: goto 105\n 155: aload 10\n 157: checkcast #85 // class java/util/List\n 160: nop\n 161: goto 174\n 164: new #196 // class java/lang/RuntimeException\n 167: dup\n 168: ldc #198 // String unexpected val\n 170: invokespecial #201 // Method java/lang/RuntimeException.\"<init>\":(Ljava/lang/String;)V\n 173: athrow\n 174: astore 4\n 176: new #203 // class Day16$Operator\n 179: dup\n 180: iload_1\n 181: aload_2\n 182: aload 4\n 184: invokespecial #206 // Method Day16$Operator.\"<init>\":(ILDay16$Type;Ljava/util/List;)V\n 187: checkcast #143 // class Day16$Packet\n 190: areturn\n\n private final Day16$Packet readLiteral(int, Day16$BinaryString);\n Code:\n 0: new #82 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #83 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #85 // class java/util/List\n 10: astore_3\n 11: iconst_0\n 12: istore 4\n 14: aload_2\n 15: iconst_5\n 16: invokevirtual #146 // Method Day16$BinaryString.readString:(I)Ljava/lang/String;\n 19: checkcast #219 // class java/lang/CharSequence\n 22: invokestatic #222 // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;\n 25: astore 5\n 27: aload 5\n 29: iconst_0\n 30: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 35: checkcast #228 // class java/lang/Character\n 38: invokevirtual #232 // Method java/lang/Character.charValue:()C\n 41: istore 6\n 43: aload 5\n 45: iconst_1\n 46: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 51: checkcast #228 // class java/lang/Character\n 54: invokevirtual #232 // Method java/lang/Character.charValue:()C\n 57: istore 7\n 59: aload 5\n 61: iconst_2\n 62: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 67: checkcast #228 // class java/lang/Character\n 70: invokevirtual #232 // Method java/lang/Character.charValue:()C\n 73: istore 8\n 75: aload 5\n 77: iconst_3\n 78: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 83: checkcast #228 // class java/lang/Character\n 86: invokevirtual #232 // Method java/lang/Character.charValue:()C\n 89: istore 9\n 91: aload 5\n 93: iconst_4\n 94: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 99: checkcast #228 // class java/lang/Character\n 102: invokevirtual #232 // Method java/lang/Character.charValue:()C\n 105: istore 10\n 107: aload_3\n 108: iconst_4\n 109: anewarray #228 // class java/lang/Character\n 112: astore 11\n 114: aload 11\n 116: iconst_0\n 117: iload 7\n 119: invokestatic #236 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 122: aastore\n 123: aload 11\n 125: iconst_1\n 126: iload 8\n 128: invokestatic #236 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 131: aastore\n 132: aload 11\n 134: iconst_2\n 135: iload 9\n 137: invokestatic #236 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 140: aastore\n 141: aload 11\n 143: iconst_3\n 144: iload 10\n 146: invokestatic #236 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 149: aastore\n 150: aload 11\n 152: invokestatic #240 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 155: checkcast #177 // class java/util/Collection\n 158: invokeinterface #244, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 163: pop\n 164: iload 6\n 166: bipush 48\n 168: if_icmpne 175\n 171: iconst_1\n 172: goto 176\n 175: iconst_0\n 176: istore 4\n 178: iload 4\n 180: ifeq 14\n 183: new #15 // class java/math/BigInteger\n 186: dup\n 187: aload_3\n 188: checkcast #166 // class java/lang/Iterable\n 191: ldc #246 // String\n 193: checkcast #219 // class java/lang/CharSequence\n 196: aconst_null\n 197: aconst_null\n 198: iconst_0\n 199: aconst_null\n 200: aconst_null\n 201: bipush 62\n 203: aconst_null\n 204: invokestatic #250 // 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 207: iconst_2\n 208: invokespecial #18 // Method java/math/BigInteger.\"<init>\":(Ljava/lang/String;I)V\n 211: invokevirtual #254 // Method java/math/BigInteger.longValueExact:()J\n 214: lstore 5\n 216: new #256 // class Day16$Literal\n 219: dup\n 220: iload_1\n 221: lload 5\n 223: invokespecial #259 // Method Day16$Literal.\"<init>\":(IJ)V\n 226: checkcast #143 // class Day16$Packet\n 229: areturn\n\n public final kotlin.jvm.functions.Function0<Day16$BinaryString> getInput();\n Code:\n 0: getstatic #279 // Field input:Lkotlin/jvm/functions/Function0;\n 3: areturn\n\n private static final Day16$BinaryString input$lambda$5();\n Code:\n 0: new #283 // class java/io/File\n 3: dup\n 4: ldc_w #285 // String day16/input-real.txt\n 7: invokespecial #286 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 10: invokestatic #292 // Method java/nio/charset/Charset.defaultCharset:()Ljava/nio/charset/Charset;\n 13: dup\n 14: ldc_w #294 // String defaultCharset(...)\n 17: invokestatic #50 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 20: invokestatic #300 // Method kotlin/io/FilesKt.readText:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/lang/String;\n 23: checkcast #219 // class java/lang/CharSequence\n 26: astore_0\n 27: nop\n 28: iconst_0\n 29: istore_1\n 30: aload_0\n 31: astore_2\n 32: new #82 // class java/util/ArrayList\n 35: dup\n 36: aload_0\n 37: invokeinterface #303, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 42: invokespecial #175 // Method java/util/ArrayList.\"<init>\":(I)V\n 45: checkcast #177 // class java/util/Collection\n 48: astore_3\n 49: iconst_0\n 50: istore 4\n 52: iconst_0\n 53: istore 5\n 55: iload 5\n 57: aload_2\n 58: invokeinterface #303, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 63: if_icmpge 112\n 66: aload_2\n 67: iload 5\n 69: invokeinterface #307, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 74: istore 6\n 76: aload_3\n 77: iload 6\n 79: istore 7\n 81: astore 9\n 83: iconst_0\n 84: istore 8\n 86: getstatic #193 // Field INSTANCE:LDay16;\n 89: iload 7\n 91: invokestatic #310 // Method java/lang/String.valueOf:(C)Ljava/lang/String;\n 94: invokespecial #312 // Method toBinary:(Ljava/lang/String;)Ljava/util/List;\n 97: aload 9\n 99: swap\n 100: invokeinterface #194, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 105: pop\n 106: iinc 5, 1\n 109: goto 55\n 112: aload_3\n 113: checkcast #85 // class java/util/List\n 116: nop\n 117: checkcast #166 // class java/lang/Iterable\n 120: astore_0\n 121: nop\n 122: iconst_0\n 123: istore_1\n 124: aload_0\n 125: astore_2\n 126: new #82 // class java/util/ArrayList\n 129: dup\n 130: invokespecial #83 // Method java/util/ArrayList.\"<init>\":()V\n 133: checkcast #177 // class java/util/Collection\n 136: astore_3\n 137: iconst_0\n 138: istore 4\n 140: aload_2\n 141: invokeinterface #181, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 146: astore 5\n 148: aload 5\n 150: invokeinterface #186, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 155: ifeq 205\n 158: aload 5\n 160: invokeinterface #316, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 165: astore 6\n 167: aload 6\n 169: checkcast #85 // class java/util/List\n 172: astore 7\n 174: iconst_0\n 175: istore 8\n 177: aload 7\n 179: checkcast #177 // class java/util/Collection\n 182: bipush 37\n 184: invokestatic #236 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 187: invokestatic #320 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 190: checkcast #166 // class java/lang/Iterable\n 193: astore 7\n 195: aload_3\n 196: aload 7\n 198: invokestatic #323 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 201: pop\n 202: goto 148\n 205: aload_3\n 206: checkcast #85 // class java/util/List\n 209: nop\n 210: astore_1\n 211: iconst_0\n 212: istore_2\n 213: new #87 // class Day16$BinaryString\n 216: dup\n 217: aload_1\n 218: invokespecial #326 // Method Day16$BinaryString.\"<init>\":(Ljava/util/List;)V\n 221: nop\n 222: areturn\n\n public static final Day16$Packet access$readPacket(Day16, Day16$BinaryString);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #95 // Method readPacket:(LDay16$BinaryString;)LDay16$Packet;\n 5: areturn\n\n static {};\n Code:\n 0: new #2 // class Day16\n 3: dup\n 4: invokespecial #343 // Method \"<init>\":()V\n 7: putstatic #193 // Field INSTANCE:LDay16;\n 10: invokedynamic #358, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function0;\n 15: putstatic #279 // Field input:Lkotlin/jvm/functions/Function0;\n 18: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day16Kt.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16Kt {\n public static final void main();\n Code:\n 0: getstatic #12 // Field Day16$Part1.INSTANCE:LDay16$Part1;\n 3: invokevirtual #15 // Method Day16$Part1.run:()V\n 6: getstatic #20 // Field Day16$Part2.INSTANCE:LDay16$Part2;\n 9: invokevirtual #21 // Method Day16$Part2.run:()V\n 12: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #24 // Method main:()V\n 3: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day16$Type.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16$Type extends java.lang.Enum<Day16$Type> {\n public static final Day16$Type$Companion Companion;\n\n private final int code;\n\n public static final Day16$Type SUM;\n\n public static final Day16$Type PRODUCT;\n\n public static final Day16$Type MIN;\n\n public static final Day16$Type MAX;\n\n public static final Day16$Type LITERAL;\n\n public static final Day16$Type G_THAN;\n\n public static final Day16$Type L_THAN;\n\n public static final Day16$Type EQUAL_TO;\n\n private static final Day16$Type[] $VALUES;\n\n private static final kotlin.enums.EnumEntries $ENTRIES;\n\n private Day16$Type(int);\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: invokespecial #11 // Method java/lang/Enum.\"<init>\":(Ljava/lang/String;I)V\n 6: aload_0\n 7: iload_3\n 8: putfield #15 // Field code:I\n 11: return\n\n public final int getCode();\n Code:\n 0: aload_0\n 1: getfield #15 // Field code:I\n 4: ireturn\n\n public static Day16$Type[] values();\n Code:\n 0: getstatic #28 // Field $VALUES:[LDay16$Type;\n 3: invokevirtual #34 // Method java/lang/Object.clone:()Ljava/lang/Object;\n 6: checkcast #35 // class \"[LDay16$Type;\"\n 9: areturn\n\n public static Day16$Type valueOf(java.lang.String);\n Code:\n 0: ldc #2 // class Day16$Type\n 2: aload_0\n 3: invokestatic #40 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;\n 6: checkcast #2 // class Day16$Type\n 9: areturn\n\n public static kotlin.enums.EnumEntries<Day16$Type> getEntries();\n Code:\n 0: getstatic #49 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 3: areturn\n\n private static final Day16$Type[] $values();\n Code:\n 0: bipush 8\n 2: anewarray #2 // class Day16$Type\n 5: astore_0\n 6: aload_0\n 7: iconst_0\n 8: getstatic #53 // Field SUM:LDay16$Type;\n 11: aastore\n 12: aload_0\n 13: iconst_1\n 14: getstatic #56 // Field PRODUCT:LDay16$Type;\n 17: aastore\n 18: aload_0\n 19: iconst_2\n 20: getstatic #59 // Field MIN:LDay16$Type;\n 23: aastore\n 24: aload_0\n 25: iconst_3\n 26: getstatic #62 // Field MAX:LDay16$Type;\n 29: aastore\n 30: aload_0\n 31: iconst_4\n 32: getstatic #65 // Field LITERAL:LDay16$Type;\n 35: aastore\n 36: aload_0\n 37: iconst_5\n 38: getstatic #68 // Field G_THAN:LDay16$Type;\n 41: aastore\n 42: aload_0\n 43: bipush 6\n 45: getstatic #71 // Field L_THAN:LDay16$Type;\n 48: aastore\n 49: aload_0\n 50: bipush 7\n 52: getstatic #74 // Field EQUAL_TO:LDay16$Type;\n 55: aastore\n 56: aload_0\n 57: areturn\n\n static {};\n Code:\n 0: new #2 // class Day16$Type\n 3: dup\n 4: ldc #77 // String SUM\n 6: iconst_0\n 7: iconst_0\n 8: invokespecial #79 // Method \"<init>\":(Ljava/lang/String;II)V\n 11: putstatic #53 // Field SUM:LDay16$Type;\n 14: new #2 // class Day16$Type\n 17: dup\n 18: ldc #80 // String PRODUCT\n 20: iconst_1\n 21: iconst_1\n 22: invokespecial #79 // Method \"<init>\":(Ljava/lang/String;II)V\n 25: putstatic #56 // Field PRODUCT:LDay16$Type;\n 28: new #2 // class Day16$Type\n 31: dup\n 32: ldc #81 // String MIN\n 34: iconst_2\n 35: iconst_2\n 36: invokespecial #79 // Method \"<init>\":(Ljava/lang/String;II)V\n 39: putstatic #59 // Field MIN:LDay16$Type;\n 42: new #2 // class Day16$Type\n 45: dup\n 46: ldc #82 // String MAX\n 48: iconst_3\n 49: iconst_3\n 50: invokespecial #79 // Method \"<init>\":(Ljava/lang/String;II)V\n 53: putstatic #62 // Field MAX:LDay16$Type;\n 56: new #2 // class Day16$Type\n 59: dup\n 60: ldc #83 // String LITERAL\n 62: iconst_4\n 63: iconst_4\n 64: invokespecial #79 // Method \"<init>\":(Ljava/lang/String;II)V\n 67: putstatic #65 // Field LITERAL:LDay16$Type;\n 70: new #2 // class Day16$Type\n 73: dup\n 74: ldc #84 // String G_THAN\n 76: iconst_5\n 77: iconst_5\n 78: invokespecial #79 // Method \"<init>\":(Ljava/lang/String;II)V\n 81: putstatic #68 // Field G_THAN:LDay16$Type;\n 84: new #2 // class Day16$Type\n 87: dup\n 88: ldc #85 // String L_THAN\n 90: bipush 6\n 92: bipush 6\n 94: invokespecial #79 // Method \"<init>\":(Ljava/lang/String;II)V\n 97: putstatic #71 // Field L_THAN:LDay16$Type;\n 100: new #2 // class Day16$Type\n 103: dup\n 104: ldc #86 // String EQUAL_TO\n 106: bipush 7\n 108: bipush 7\n 110: invokespecial #79 // Method \"<init>\":(Ljava/lang/String;II)V\n 113: putstatic #74 // Field EQUAL_TO:LDay16$Type;\n 116: invokestatic #88 // Method $values:()[LDay16$Type;\n 119: putstatic #28 // Field $VALUES:[LDay16$Type;\n 122: getstatic #28 // Field $VALUES:[LDay16$Type;\n 125: checkcast #90 // class \"[Ljava/lang/Enum;\"\n 128: invokestatic #96 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;\n 131: putstatic #49 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 134: new #98 // class Day16$Type$Companion\n 137: dup\n 138: aconst_null\n 139: invokespecial #101 // Method Day16$Type$Companion.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 142: putstatic #105 // Field Companion:LDay16$Type$Companion;\n 145: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day16$Part2.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16$Part2 {\n public static final Day16$Part2 INSTANCE;\n\n private Day16$Part2();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final void run();\n Code:\n 0: getstatic #17 // Field Day16.INSTANCE:LDay16;\n 3: getstatic #17 // Field Day16.INSTANCE:LDay16;\n 6: invokevirtual #21 // Method Day16.getInput:()Lkotlin/jvm/functions/Function0;\n 9: invokeinterface #27, 1 // InterfaceMethod kotlin/jvm/functions/Function0.invoke:()Ljava/lang/Object;\n 14: checkcast #29 // class Day16$BinaryString\n 17: invokestatic #33 // Method Day16.access$readPacket:(LDay16;LDay16$BinaryString;)LDay16$Packet;\n 20: invokevirtual #39 // Method Day16$Packet.evaluate:()J\n 23: lstore_1\n 24: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 27: lload_1\n 28: invokevirtual #51 // Method java/io/PrintStream.println:(J)V\n 31: return\n\n static {};\n Code:\n 0: new #2 // class Day16$Part2\n 3: dup\n 4: invokespecial #53 // Method \"<init>\":()V\n 7: putstatic #55 // Field INSTANCE:LDay16$Part2;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day16$Literal.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16$Literal extends Day16$Packet {\n private final int version;\n\n private final long literal;\n\n public Day16$Literal(int, long);\n Code:\n 0: aload_0\n 1: iload_1\n 2: getstatic #12 // Field Day16$Type.LITERAL:LDay16$Type;\n 5: aconst_null\n 6: invokespecial #15 // Method Day16$Packet.\"<init>\":(ILDay16$Type;Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 9: aload_0\n 10: iload_1\n 11: putfield #19 // Field version:I\n 14: aload_0\n 15: lload_2\n 16: putfield #23 // Field literal:J\n 19: return\n\n public int getVersion();\n Code:\n 0: aload_0\n 1: getfield #19 // Field version:I\n 4: ireturn\n\n public final long getLiteral();\n Code:\n 0: aload_0\n 1: getfield #23 // Field literal:J\n 4: lreturn\n\n public int getTotalVersion();\n Code:\n 0: aload_0\n 1: invokevirtual #32 // Method getVersion:()I\n 4: ireturn\n\n public long evaluate();\n Code:\n 0: aload_0\n 1: getfield #23 // Field literal:J\n 4: lreturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #19 // Field version:I\n 4: ireturn\n\n public final long component2();\n Code:\n 0: aload_0\n 1: getfield #23 // Field literal:J\n 4: lreturn\n\n public final Day16$Literal copy(int, long);\n Code:\n 0: new #2 // class Day16$Literal\n 3: dup\n 4: iload_1\n 5: lload_2\n 6: invokespecial #40 // Method \"<init>\":(IJ)V\n 9: areturn\n\n public static Day16$Literal copy$default(Day16$Literal, int, long, 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 #19 // Field version: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 #23 // Field literal:J\n 23: lstore_2\n 24: aload_0\n 25: iload_1\n 26: lload_2\n 27: invokevirtual #44 // Method copy:(IJ)LDay16$Literal;\n 30: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #48 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #51 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #53 // String Literal(version=\n 9: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #19 // Field version:I\n 16: invokevirtual #60 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #62 // String , literal=\n 21: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #23 // Field literal:J\n 28: invokevirtual #65 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #68 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #70 // 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 #19 // Field version:I\n 4: invokestatic #76 // 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 #23 // Field literal:J\n 16: invokestatic #81 // Method java/lang/Long.hashCode:(J)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 Day16$Literal\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day16$Literal\n 20: astore_2\n 21: aload_0\n 22: getfield #19 // Field version:I\n 25: aload_2\n 26: getfield #19 // Field version:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #23 // Field literal:J\n 38: aload_2\n 39: getfield #23 // Field literal:J\n 42: lcmp\n 43: ifeq 48\n 46: iconst_0\n 47: ireturn\n 48: iconst_1\n 49: ireturn\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day16$BinaryString.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16$BinaryString {\n private java.util.List<java.lang.Character> input;\n\n public Day16$BinaryString(java.util.List<java.lang.Character>);\n Code:\n 0: aload_1\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: invokespecial #19 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #22 // Field input:Ljava/util/List;\n 15: return\n\n public final java.util.List<java.lang.Character> getInput();\n Code:\n 0: aload_0\n 1: getfield #22 // Field input:Ljava/util/List;\n 4: areturn\n\n public final void setInput(java.util.List<java.lang.Character>);\n Code:\n 0: aload_1\n 1: ldc #30 // 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: aload_1\n 8: putfield #22 // Field input:Ljava/util/List;\n 11: return\n\n public final boolean isNotEmpty();\n Code:\n 0: aload_0\n 1: getfield #22 // Field input:Ljava/util/List;\n 4: checkcast #34 // class java/util/Collection\n 7: invokeinterface #37, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 12: ifne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifeq 40\n 23: aload_0\n 24: getfield #22 // Field input:Ljava/util/List;\n 27: invokeinterface #43, 1 // InterfaceMethod java/util/List.size:()I\n 32: iconst_3\n 33: if_icmple 40\n 36: iconst_1\n 37: goto 41\n 40: iconst_0\n 41: ireturn\n\n public final java.lang.String readString(int);\n Code:\n 0: new #47 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #48 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #39 // class java/util/List\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: iconst_0\n 14: istore 4\n 16: aload_0\n 17: getfield #22 // Field input:Ljava/util/List;\n 20: iload_3\n 21: invokeinterface #52, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 26: checkcast #54 // class java/lang/Character\n 29: invokevirtual #58 // Method java/lang/Character.charValue:()C\n 32: istore 5\n 34: iload 5\n 36: bipush 37\n 38: if_icmpeq 59\n 41: aload_2\n 42: iload 5\n 44: invokestatic #62 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 47: invokeinterface #66, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 52: pop\n 53: iload 4\n 55: iinc 4, 1\n 58: pop\n 59: iinc 3, 1\n 62: iload 4\n 64: iload_1\n 65: if_icmpne 16\n 68: aload_0\n 69: aload_0\n 70: getfield #22 // Field input:Ljava/util/List;\n 73: iload_3\n 74: aload_0\n 75: getfield #22 // Field input:Ljava/util/List;\n 78: invokeinterface #43, 1 // InterfaceMethod java/util/List.size:()I\n 83: invokeinterface #70, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 88: putfield #22 // Field input:Ljava/util/List;\n 91: aload_2\n 92: checkcast #72 // class java/lang/Iterable\n 95: ldc #74 // String\n 97: checkcast #76 // class java/lang/CharSequence\n 100: aconst_null\n 101: aconst_null\n 102: iconst_0\n 103: aconst_null\n 104: aconst_null\n 105: bipush 62\n 107: aconst_null\n 108: invokestatic #82 // 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 111: areturn\n\n public final Day16$BinaryString readSection(int);\n Code:\n 0: new #47 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #48 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #39 // class java/util/List\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: iconst_0\n 14: istore 4\n 16: aload_0\n 17: getfield #22 // Field input:Ljava/util/List;\n 20: iload_3\n 21: invokeinterface #52, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 26: checkcast #54 // class java/lang/Character\n 29: invokevirtual #58 // Method java/lang/Character.charValue:()C\n 32: istore 5\n 34: iload 5\n 36: bipush 37\n 38: if_icmpeq 47\n 41: iload 4\n 43: iinc 4, 1\n 46: pop\n 47: aload_2\n 48: iload 5\n 50: invokestatic #62 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 53: invokeinterface #66, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 58: pop\n 59: iinc 3, 1\n 62: iload 4\n 64: iload_1\n 65: if_icmpne 16\n 68: aload_0\n 69: aload_0\n 70: getfield #22 // Field input:Ljava/util/List;\n 73: iload_3\n 74: aload_0\n 75: getfield #22 // Field input:Ljava/util/List;\n 78: invokeinterface #43, 1 // InterfaceMethod java/util/List.size:()I\n 83: invokeinterface #70, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 88: putfield #22 // Field input:Ljava/util/List;\n 91: new #2 // class Day16$BinaryString\n 94: dup\n 95: aload_2\n 96: invokespecial #93 // Method \"<init>\":(Ljava/util/List;)V\n 99: areturn\n\n public final int readInt(int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: invokevirtual #97 // Method readString:(I)Ljava/lang/String;\n 5: astore_2\n 6: aload_2\n 7: iconst_2\n 8: invokestatic #103 // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I\n 11: ireturn\n\n public final java.util.List<java.lang.Character> component1();\n Code:\n 0: aload_0\n 1: getfield #22 // Field input:Ljava/util/List;\n 4: areturn\n\n public final Day16$BinaryString copy(java.util.List<java.lang.Character>);\n Code:\n 0: aload_1\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 #2 // class Day16$BinaryString\n 9: dup\n 10: aload_1\n 11: invokespecial #93 // Method \"<init>\":(Ljava/util/List;)V\n 14: areturn\n\n public static Day16$BinaryString copy$default(Day16$BinaryString, java.util.List, int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #22 // Field input:Ljava/util/List;\n 10: astore_1\n 11: aload_0\n 12: aload_1\n 13: invokevirtual #113 // Method copy:(Ljava/util/List;)LDay16$BinaryString;\n 16: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #117 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #118 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #120 // String BinaryString(input=\n 9: invokevirtual #124 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #22 // Field input:Ljava/util/List;\n 16: invokevirtual #127 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: bipush 41\n 21: invokevirtual #130 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 24: invokevirtual #132 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 27: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #22 // Field input:Ljava/util/List;\n 4: invokevirtual #135 // Method java/lang/Object.hashCode:()I\n 7: 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 Day16$BinaryString\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day16$BinaryString\n 20: astore_2\n 21: aload_0\n 22: getfield #22 // Field input:Ljava/util/List;\n 25: aload_2\n 26: getfield #22 // Field input:Ljava/util/List;\n 29: invokestatic #141 // 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: iconst_1\n 38: ireturn\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day16$Part1.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16$Part1 {\n public static final Day16$Part1 INSTANCE;\n\n private Day16$Part1();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final void run();\n Code:\n 0: getstatic #17 // Field Day16.INSTANCE:LDay16;\n 3: getstatic #17 // Field Day16.INSTANCE:LDay16;\n 6: invokevirtual #21 // Method Day16.getInput:()Lkotlin/jvm/functions/Function0;\n 9: invokeinterface #27, 1 // InterfaceMethod kotlin/jvm/functions/Function0.invoke:()Ljava/lang/Object;\n 14: checkcast #29 // class Day16$BinaryString\n 17: invokestatic #33 // Method Day16.access$readPacket:(LDay16;LDay16$BinaryString;)LDay16$Packet;\n 20: invokevirtual #39 // Method Day16$Packet.getTotalVersion:()I\n 23: istore_1\n 24: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 27: iload_1\n 28: invokevirtual #51 // Method java/io/PrintStream.println:(I)V\n 31: return\n\n static {};\n Code:\n 0: new #2 // class Day16$Part1\n 3: dup\n 4: invokespecial #53 // Method \"<init>\":()V\n 7: putstatic #55 // Field INSTANCE:LDay16$Part1;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day16$WhenMappings.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method Day16$Type.values:()[LDay16$Type;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field Day16$Type.LITERAL:LDay16$Type;\n 12: invokevirtual #22 // Method Day16$Type.ordinal:()I\n 15: iconst_1\n 16: iastore\n 17: goto 21\n 20: astore_1\n 21: aload_0\n 22: putstatic #26 // Field $EnumSwitchMapping$0:[I\n 25: return\n Exception table:\n from to target type\n 7 17 20 Class java/lang/NoSuchFieldError\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day16$Operator$WhenMappings.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16$Operator$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method Day16$Type.values:()[LDay16$Type;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field Day16$Type.SUM:LDay16$Type;\n 12: invokevirtual #22 // Method Day16$Type.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 Day16$Type.PRODUCT:LDay16$Type;\n 26: invokevirtual #22 // Method Day16$Type.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 Day16$Type.MIN:LDay16$Type;\n 40: invokevirtual #22 // Method Day16$Type.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 Day16$Type.MAX:LDay16$Type;\n 54: invokevirtual #22 // Method Day16$Type.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 Day16$Type.G_THAN:LDay16$Type;\n 68: invokevirtual #22 // Method Day16$Type.ordinal:()I\n 71: iconst_5\n 72: iastore\n 73: goto 77\n 76: astore_1\n 77: nop\n 78: aload_0\n 79: getstatic #37 // Field Day16$Type.L_THAN:LDay16$Type;\n 82: invokevirtual #22 // Method Day16$Type.ordinal:()I\n 85: bipush 6\n 87: iastore\n 88: goto 92\n 91: astore_1\n 92: nop\n 93: aload_0\n 94: getstatic #40 // Field Day16$Type.EQUAL_TO:LDay16$Type;\n 97: invokevirtual #22 // Method Day16$Type.ordinal:()I\n 100: bipush 7\n 102: iastore\n 103: goto 107\n 106: astore_1\n 107: aload_0\n 108: putstatic #44 // Field $EnumSwitchMapping$0:[I\n 111: 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 77 88 91 Class java/lang/NoSuchFieldError\n 92 103 106 Class java/lang/NoSuchFieldError\n}\n", "javap_err": "" } ]
andrewrlee__adventOfCode2021__aace0fc/src/main/kotlin/Day10.kt
import Day10.Type.CLOSE import Day10.Type.OPEN import java.io.File import java.nio.charset.Charset.defaultCharset import java.util.Stack object Day10 { data class Bracket(val bracketType: BracketType, val type: Type) enum class Type { OPEN, CLOSE } enum class BracketType(val open: Char, val close: Char, val points: Int, val autoCompleteScore: Int) { SQUARE('[', ']', 57, 2), ROUND('(', ')', 3, 1), BRACE('{', '}', 1197, 3), ANGLE('<', '>', 25137, 4); fun match(c: Char): Type? = when (c) { open -> OPEN close -> CLOSE else -> null } } fun String.toBrackets() = this.map { c -> BracketType.values().firstNotNullOf { b -> b.match(c)?.let { Bracket(b, it) } } } object Part1 { private fun findInvalid(brackets: List<Bracket>): BracketType? { val stack = Stack<Bracket>() brackets.forEach { if (it.type == CLOSE) { val opening = stack.pop() if (it.bracketType != opening.bracketType) { return it.bracketType } } else { stack.push(it) } } return null } fun run() { File("day10/input-real.txt") .readLines(defaultCharset()) .mapNotNull { findInvalid(it.toBrackets()) } .map { it.points } .reduce(Int::plus) .also { println(it) } } } object Part2 { private fun complete(brackets: List<Bracket>): Long? { val stack = Stack<Bracket>() brackets.forEach { if (it.type == CLOSE) { val opening = stack.pop() if (it.bracketType != opening.bracketType) { return null } } else { stack.push(it) } } if (stack.isEmpty()) { return null } return stack.reversed().fold(0L) { acc, b -> (acc * 5) + b.bracketType.autoCompleteScore } } fun run() { File("day10/input-real.txt").readLines(defaultCharset()) .mapNotNull { complete(it.toBrackets()) } .sorted() .also { println(it[it.size/2]) } } } } fun main() { Day10.Part1.run() Day10.Part2.run() }
[ { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day10$BracketType.class", "javap": "Compiled from \"Day10.kt\"\npublic final class Day10$BracketType extends java.lang.Enum<Day10$BracketType> {\n private final char open;\n\n private final char close;\n\n private final int points;\n\n private final int autoCompleteScore;\n\n public static final Day10$BracketType SQUARE;\n\n public static final Day10$BracketType ROUND;\n\n public static final Day10$BracketType BRACE;\n\n public static final Day10$BracketType ANGLE;\n\n private static final Day10$BracketType[] $VALUES;\n\n private static final kotlin.enums.EnumEntries $ENTRIES;\n\n private Day10$BracketType(char, char, int, int);\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: invokespecial #11 // Method java/lang/Enum.\"<init>\":(Ljava/lang/String;I)V\n 6: aload_0\n 7: iload_3\n 8: putfield #15 // Field open:C\n 11: aload_0\n 12: iload 4\n 14: putfield #18 // Field close:C\n 17: aload_0\n 18: iload 5\n 20: putfield #22 // Field points:I\n 23: aload_0\n 24: iload 6\n 26: putfield #25 // Field autoCompleteScore:I\n 29: return\n\n public final char getOpen();\n Code:\n 0: aload_0\n 1: getfield #15 // Field open:C\n 4: ireturn\n\n public final char getClose();\n Code:\n 0: aload_0\n 1: getfield #18 // Field close:C\n 4: ireturn\n\n public final int getPoints();\n Code:\n 0: aload_0\n 1: getfield #22 // Field points:I\n 4: ireturn\n\n public final int getAutoCompleteScore();\n Code:\n 0: aload_0\n 1: getfield #25 // Field autoCompleteScore:I\n 4: ireturn\n\n public final Day10$Type match(char);\n Code:\n 0: iload_1\n 1: istore_2\n 2: iload_2\n 3: aload_0\n 4: getfield #15 // Field open:C\n 7: if_icmpne 16\n 10: getstatic #45 // Field Day10$Type.OPEN:LDay10$Type;\n 13: goto 31\n 16: iload_2\n 17: aload_0\n 18: getfield #18 // Field close:C\n 21: if_icmpne 30\n 24: getstatic #48 // Field Day10$Type.CLOSE:LDay10$Type;\n 27: goto 31\n 30: aconst_null\n 31: areturn\n\n public static Day10$BracketType[] values();\n Code:\n 0: getstatic #55 // Field $VALUES:[LDay10$BracketType;\n 3: invokevirtual #61 // Method java/lang/Object.clone:()Ljava/lang/Object;\n 6: checkcast #62 // class \"[LDay10$BracketType;\"\n 9: areturn\n\n public static Day10$BracketType valueOf(java.lang.String);\n Code:\n 0: ldc #2 // class Day10$BracketType\n 2: aload_0\n 3: invokestatic #67 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;\n 6: checkcast #2 // class Day10$BracketType\n 9: areturn\n\n public static kotlin.enums.EnumEntries<Day10$BracketType> getEntries();\n Code:\n 0: getstatic #76 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 3: areturn\n\n private static final Day10$BracketType[] $values();\n Code:\n 0: iconst_4\n 1: anewarray #2 // class Day10$BracketType\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: getstatic #80 // Field SQUARE:LDay10$BracketType;\n 10: aastore\n 11: aload_0\n 12: iconst_1\n 13: getstatic #83 // Field ROUND:LDay10$BracketType;\n 16: aastore\n 17: aload_0\n 18: iconst_2\n 19: getstatic #86 // Field BRACE:LDay10$BracketType;\n 22: aastore\n 23: aload_0\n 24: iconst_3\n 25: getstatic #89 // Field ANGLE:LDay10$BracketType;\n 28: aastore\n 29: aload_0\n 30: areturn\n\n static {};\n Code:\n 0: new #2 // class Day10$BracketType\n 3: dup\n 4: ldc #92 // String SQUARE\n 6: iconst_0\n 7: bipush 91\n 9: bipush 93\n 11: bipush 57\n 13: iconst_2\n 14: invokespecial #94 // Method \"<init>\":(Ljava/lang/String;ICCII)V\n 17: putstatic #80 // Field SQUARE:LDay10$BracketType;\n 20: new #2 // class Day10$BracketType\n 23: dup\n 24: ldc #95 // String ROUND\n 26: iconst_1\n 27: bipush 40\n 29: bipush 41\n 31: iconst_3\n 32: iconst_1\n 33: invokespecial #94 // Method \"<init>\":(Ljava/lang/String;ICCII)V\n 36: putstatic #83 // Field ROUND:LDay10$BracketType;\n 39: new #2 // class Day10$BracketType\n 42: dup\n 43: ldc #96 // String BRACE\n 45: iconst_2\n 46: bipush 123\n 48: bipush 125\n 50: sipush 1197\n 53: iconst_3\n 54: invokespecial #94 // Method \"<init>\":(Ljava/lang/String;ICCII)V\n 57: putstatic #86 // Field BRACE:LDay10$BracketType;\n 60: new #2 // class Day10$BracketType\n 63: dup\n 64: ldc #97 // String ANGLE\n 66: iconst_3\n 67: bipush 60\n 69: bipush 62\n 71: sipush 25137\n 74: iconst_4\n 75: invokespecial #94 // Method \"<init>\":(Ljava/lang/String;ICCII)V\n 78: putstatic #89 // Field ANGLE:LDay10$BracketType;\n 81: invokestatic #99 // Method $values:()[LDay10$BracketType;\n 84: putstatic #55 // Field $VALUES:[LDay10$BracketType;\n 87: getstatic #55 // Field $VALUES:[LDay10$BracketType;\n 90: checkcast #101 // class \"[Ljava/lang/Enum;\"\n 93: invokestatic #107 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;\n 96: putstatic #76 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 99: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day10$Bracket.class", "javap": "Compiled from \"Day10.kt\"\npublic final class Day10$Bracket {\n private final Day10$BracketType bracketType;\n\n private final Day10$Type type;\n\n public Day10$Bracket(Day10$BracketType, Day10$Type);\n Code:\n 0: aload_1\n 1: ldc #9 // String bracketType\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 type\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 bracketType:LDay10$BracketType;\n 21: aload_0\n 22: aload_2\n 23: putfield #26 // Field type:LDay10$Type;\n 26: return\n\n public final Day10$BracketType getBracketType();\n Code:\n 0: aload_0\n 1: getfield #23 // Field bracketType:LDay10$BracketType;\n 4: areturn\n\n public final Day10$Type getType();\n Code:\n 0: aload_0\n 1: getfield #26 // Field type:LDay10$Type;\n 4: areturn\n\n public final Day10$BracketType component1();\n Code:\n 0: aload_0\n 1: getfield #23 // Field bracketType:LDay10$BracketType;\n 4: areturn\n\n public final Day10$Type component2();\n Code:\n 0: aload_0\n 1: getfield #26 // Field type:LDay10$Type;\n 4: areturn\n\n public final Day10$Bracket copy(Day10$BracketType, Day10$Type);\n Code:\n 0: aload_1\n 1: ldc #9 // String bracketType\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 type\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class Day10$Bracket\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: invokespecial #38 // Method \"<init>\":(LDay10$BracketType;LDay10$Type;)V\n 21: areturn\n\n public static Day10$Bracket copy$default(Day10$Bracket, Day10$BracketType, Day10$Type, 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 bracketType:LDay10$BracketType;\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 type:LDay10$Type;\n 21: astore_2\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokevirtual #42 // Method copy:(LDay10$BracketType;LDay10$Type;)LDay10$Bracket;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #46 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #47 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #49 // String Bracket(bracketType=\n 9: invokevirtual #53 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #23 // Field bracketType:LDay10$BracketType;\n 16: invokevirtual #56 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #58 // String , type=\n 21: invokevirtual #53 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #26 // Field type:LDay10$Type;\n 28: invokevirtual #56 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #61 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #63 // 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 bracketType:LDay10$BracketType;\n 4: invokevirtual #69 // Method Day10$BracketType.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 type:LDay10$Type;\n 16: invokevirtual #72 // Method Day10$Type.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 Day10$Bracket\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day10$Bracket\n 20: astore_2\n 21: aload_0\n 22: getfield #23 // Field bracketType:LDay10$BracketType;\n 25: aload_2\n 26: getfield #23 // Field bracketType:LDay10$BracketType;\n 29: if_acmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #26 // Field type:LDay10$Type;\n 38: aload_2\n 39: getfield #26 // Field type:LDay10$Type;\n 42: if_acmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: iconst_1\n 48: ireturn\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day10.class", "javap": "Compiled from \"Day10.kt\"\npublic final class Day10 {\n public static final Day10 INSTANCE;\n\n private Day10();\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.List<Day10$Bracket> toBrackets(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_1\n 7: checkcast #24 // class java/lang/CharSequence\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: astore 4\n 16: new #26 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: invokeinterface #30, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 26: invokespecial #33 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #35 // 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: iload 7\n 42: aload 4\n 44: invokeinterface #30, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 49: if_icmpge 179\n 52: aload 4\n 54: iload 7\n 56: invokeinterface #39, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 61: istore 8\n 63: aload 5\n 65: iload 8\n 67: istore 9\n 69: astore 18\n 71: iconst_0\n 72: istore 10\n 74: invokestatic #45 // Method Day10$BracketType.values:()[LDay10$BracketType;\n 77: astore 11\n 79: iconst_0\n 80: istore 12\n 82: aload 11\n 84: arraylength\n 85: istore 13\n 87: iload 12\n 89: iload 13\n 91: if_icmpge 147\n 94: aload 11\n 96: iload 12\n 98: aaload\n 99: astore 14\n 101: iconst_0\n 102: istore 15\n 104: aload 14\n 106: iload 9\n 108: invokevirtual #49 // Method Day10$BracketType.match:(C)LDay10$Type;\n 111: dup\n 112: ifnull 134\n 115: astore 16\n 117: iconst_0\n 118: istore 17\n 120: new #51 // class Day10$Bracket\n 123: dup\n 124: aload 14\n 126: aload 16\n 128: invokespecial #54 // Method Day10$Bracket.\"<init>\":(LDay10$BracketType;LDay10$Type;)V\n 131: goto 136\n 134: pop\n 135: aconst_null\n 136: dup\n 137: ifnonnull 148\n 140: pop\n 141: iinc 12, 1\n 144: goto 87\n 147: aconst_null\n 148: dup\n 149: ifnonnull 163\n 152: pop\n 153: new #56 // class java/util/NoSuchElementException\n 156: dup\n 157: ldc #58 // String No element of the array was transformed to a non-null value.\n 159: invokespecial #61 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 162: athrow\n 163: nop\n 164: aload 18\n 166: swap\n 167: invokeinterface #65, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 172: pop\n 173: iinc 7, 1\n 176: goto 40\n 179: aload 5\n 181: checkcast #67 // class java/util/List\n 184: nop\n 185: areturn\n\n static {};\n Code:\n 0: new #2 // class Day10\n 3: dup\n 4: invokespecial #95 // Method \"<init>\":()V\n 7: putstatic #98 // Field INSTANCE:LDay10;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day10$Part1.class", "javap": "Compiled from \"Day10.kt\"\npublic final class Day10$Part1 {\n public static final Day10$Part1 INSTANCE;\n\n private Day10$Part1();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final Day10$BracketType findInvalid(java.util.List<Day10$Bracket>);\n Code:\n 0: new #15 // class java/util/Stack\n 3: dup\n 4: invokespecial #16 // Method java/util/Stack.\"<init>\":()V\n 7: astore_2\n 8: aload_1\n 9: checkcast #18 // class java/lang/Iterable\n 12: astore_3\n 13: iconst_0\n 14: istore 4\n 16: aload_3\n 17: invokeinterface #22, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 22: astore 5\n 24: aload 5\n 26: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 31: ifeq 104\n 34: aload 5\n 36: invokeinterface #32, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 41: astore 6\n 43: aload 6\n 45: checkcast #34 // class Day10$Bracket\n 48: astore 7\n 50: iconst_0\n 51: istore 8\n 53: aload 7\n 55: invokevirtual #38 // Method Day10$Bracket.getType:()LDay10$Type;\n 58: getstatic #44 // Field Day10$Type.CLOSE:LDay10$Type;\n 61: if_acmpne 92\n 64: aload_2\n 65: invokevirtual #47 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 68: checkcast #34 // class Day10$Bracket\n 71: astore 9\n 73: aload 7\n 75: invokevirtual #51 // Method Day10$Bracket.getBracketType:()LDay10$BracketType;\n 78: aload 9\n 80: invokevirtual #51 // Method Day10$Bracket.getBracketType:()LDay10$BracketType;\n 83: if_acmpeq 99\n 86: aload 7\n 88: invokevirtual #51 // Method Day10$Bracket.getBracketType:()LDay10$BracketType;\n 91: areturn\n 92: aload_2\n 93: aload 7\n 95: invokevirtual #55 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 98: pop\n 99: nop\n 100: nop\n 101: goto 24\n 104: nop\n 105: aconst_null\n 106: areturn\n\n public final void run();\n Code:\n 0: new #74 // class java/io/File\n 3: dup\n 4: ldc #76 // String day10/input-real.txt\n 6: invokespecial #79 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: invokestatic #85 // Method java/nio/charset/Charset.defaultCharset:()Ljava/nio/charset/Charset;\n 12: dup\n 13: ldc #87 // String defaultCharset(...)\n 15: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: invokestatic #99 // Method kotlin/io/FilesKt.readLines:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/util/List;\n 21: checkcast #18 // class java/lang/Iterable\n 24: astore_1\n 25: nop\n 26: iconst_0\n 27: istore_2\n 28: aload_1\n 29: astore_3\n 30: new #101 // class java/util/ArrayList\n 33: dup\n 34: invokespecial #102 // Method java/util/ArrayList.\"<init>\":()V\n 37: checkcast #104 // class java/util/Collection\n 40: astore 4\n 42: iconst_0\n 43: istore 5\n 45: aload_3\n 46: astore 6\n 48: iconst_0\n 49: istore 7\n 51: aload 6\n 53: invokeinterface #22, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 58: astore 8\n 60: aload 8\n 62: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 67: ifeq 137\n 70: aload 8\n 72: invokeinterface #32, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 77: astore 9\n 79: aload 9\n 81: astore 10\n 83: iconst_0\n 84: istore 11\n 86: aload 10\n 88: checkcast #106 // class java/lang/String\n 91: astore 12\n 93: iconst_0\n 94: istore 13\n 96: getstatic #109 // Field INSTANCE:LDay10$Part1;\n 99: getstatic #114 // Field Day10.INSTANCE:LDay10;\n 102: aload 12\n 104: invokevirtual #118 // Method Day10.toBrackets:(Ljava/lang/String;)Ljava/util/List;\n 107: invokespecial #120 // Method findInvalid:(Ljava/util/List;)LDay10$BracketType;\n 110: dup\n 111: ifnull 132\n 114: astore 14\n 116: iconst_0\n 117: istore 15\n 119: aload 4\n 121: aload 14\n 123: invokeinterface #124, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 128: pop\n 129: goto 133\n 132: pop\n 133: nop\n 134: goto 60\n 137: nop\n 138: aload 4\n 140: checkcast #71 // class java/util/List\n 143: nop\n 144: checkcast #18 // class java/lang/Iterable\n 147: astore_1\n 148: nop\n 149: iconst_0\n 150: istore_2\n 151: aload_1\n 152: astore_3\n 153: new #101 // class java/util/ArrayList\n 156: dup\n 157: aload_1\n 158: bipush 10\n 160: invokestatic #130 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 163: invokespecial #133 // Method java/util/ArrayList.\"<init>\":(I)V\n 166: checkcast #104 // class java/util/Collection\n 169: astore 4\n 171: iconst_0\n 172: istore 5\n 174: aload_3\n 175: invokeinterface #22, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 180: astore 6\n 182: aload 6\n 184: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 189: ifeq 235\n 192: aload 6\n 194: invokeinterface #32, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 199: astore 7\n 201: aload 4\n 203: aload 7\n 205: checkcast #135 // class Day10$BracketType\n 208: astore 8\n 210: astore 16\n 212: iconst_0\n 213: istore 9\n 215: aload 8\n 217: invokevirtual #139 // Method Day10$BracketType.getPoints:()I\n 220: invokestatic #145 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 223: aload 16\n 225: swap\n 226: invokeinterface #124, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 231: pop\n 232: goto 182\n 235: aload 4\n 237: checkcast #71 // class java/util/List\n 240: nop\n 241: checkcast #18 // class java/lang/Iterable\n 244: astore_1\n 245: nop\n 246: iconst_0\n 247: istore_2\n 248: aload_1\n 249: invokeinterface #22, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 254: astore_3\n 255: aload_3\n 256: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 261: ifne 274\n 264: new #147 // class java/lang/UnsupportedOperationException\n 267: dup\n 268: ldc #149 // String Empty collection can\\'t be reduced.\n 270: invokespecial #150 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 273: athrow\n 274: aload_3\n 275: invokeinterface #32, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 280: astore 4\n 282: aload_3\n 283: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 288: ifeq 331\n 291: aload 4\n 293: aload_3\n 294: invokeinterface #32, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 299: checkcast #152 // class java/lang/Number\n 302: invokevirtual #155 // Method java/lang/Number.intValue:()I\n 305: istore 5\n 307: checkcast #152 // class java/lang/Number\n 310: invokevirtual #155 // Method java/lang/Number.intValue:()I\n 313: istore 6\n 315: iconst_0\n 316: istore 7\n 318: iload 6\n 320: iload 5\n 322: iadd\n 323: invokestatic #145 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 326: astore 4\n 328: goto 282\n 331: aload 4\n 333: astore_1\n 334: aload_1\n 335: checkcast #152 // class java/lang/Number\n 338: invokevirtual #155 // Method java/lang/Number.intValue:()I\n 341: istore_2\n 342: iconst_0\n 343: istore_3\n 344: getstatic #161 // Field java/lang/System.out:Ljava/io/PrintStream;\n 347: iload_2\n 348: invokevirtual #166 // Method java/io/PrintStream.println:(I)V\n 351: nop\n 352: nop\n 353: return\n\n static {};\n Code:\n 0: new #2 // class Day10$Part1\n 3: dup\n 4: invokespecial #198 // Method \"<init>\":()V\n 7: putstatic #109 // Field INSTANCE:LDay10$Part1;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day10$Type.class", "javap": "Compiled from \"Day10.kt\"\npublic final class Day10$Type extends java.lang.Enum<Day10$Type> {\n public static final Day10$Type OPEN;\n\n public static final Day10$Type CLOSE;\n\n private static final Day10$Type[] $VALUES;\n\n private static final kotlin.enums.EnumEntries $ENTRIES;\n\n private Day10$Type();\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: invokespecial #10 // Method java/lang/Enum.\"<init>\":(Ljava/lang/String;I)V\n 6: return\n\n public static Day10$Type[] values();\n Code:\n 0: getstatic #22 // Field $VALUES:[LDay10$Type;\n 3: invokevirtual #28 // Method java/lang/Object.clone:()Ljava/lang/Object;\n 6: checkcast #29 // class \"[LDay10$Type;\"\n 9: areturn\n\n public static Day10$Type valueOf(java.lang.String);\n Code:\n 0: ldc #2 // class Day10$Type\n 2: aload_0\n 3: invokestatic #34 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;\n 6: checkcast #2 // class Day10$Type\n 9: areturn\n\n public static kotlin.enums.EnumEntries<Day10$Type> getEntries();\n Code:\n 0: getstatic #43 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 3: areturn\n\n private static final Day10$Type[] $values();\n Code:\n 0: iconst_2\n 1: anewarray #2 // class Day10$Type\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: getstatic #47 // Field OPEN:LDay10$Type;\n 10: aastore\n 11: aload_0\n 12: iconst_1\n 13: getstatic #50 // Field CLOSE:LDay10$Type;\n 16: aastore\n 17: aload_0\n 18: areturn\n\n static {};\n Code:\n 0: new #2 // class Day10$Type\n 3: dup\n 4: ldc #52 // String OPEN\n 6: iconst_0\n 7: invokespecial #53 // Method \"<init>\":(Ljava/lang/String;I)V\n 10: putstatic #47 // Field OPEN:LDay10$Type;\n 13: new #2 // class Day10$Type\n 16: dup\n 17: ldc #54 // String CLOSE\n 19: iconst_1\n 20: invokespecial #53 // Method \"<init>\":(Ljava/lang/String;I)V\n 23: putstatic #50 // Field CLOSE:LDay10$Type;\n 26: invokestatic #56 // Method $values:()[LDay10$Type;\n 29: putstatic #22 // Field $VALUES:[LDay10$Type;\n 32: getstatic #22 // Field $VALUES:[LDay10$Type;\n 35: checkcast #58 // class \"[Ljava/lang/Enum;\"\n 38: invokestatic #64 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;\n 41: putstatic #43 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 44: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day10Kt.class", "javap": "Compiled from \"Day10.kt\"\npublic final class Day10Kt {\n public static final void main();\n Code:\n 0: getstatic #12 // Field Day10$Part1.INSTANCE:LDay10$Part1;\n 3: invokevirtual #15 // Method Day10$Part1.run:()V\n 6: getstatic #20 // Field Day10$Part2.INSTANCE:LDay10$Part2;\n 9: invokevirtual #21 // Method Day10$Part2.run:()V\n 12: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #24 // Method main:()V\n 3: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day10$Part2.class", "javap": "Compiled from \"Day10.kt\"\npublic final class Day10$Part2 {\n public static final Day10$Part2 INSTANCE;\n\n private Day10$Part2();\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.Long complete(java.util.List<Day10$Bracket>);\n Code:\n 0: new #15 // class java/util/Stack\n 3: dup\n 4: invokespecial #16 // Method java/util/Stack.\"<init>\":()V\n 7: astore_2\n 8: aload_1\n 9: checkcast #18 // class java/lang/Iterable\n 12: astore_3\n 13: iconst_0\n 14: istore 4\n 16: aload_3\n 17: invokeinterface #22, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 22: astore 5\n 24: aload 5\n 26: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 31: ifeq 100\n 34: aload 5\n 36: invokeinterface #32, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 41: astore 6\n 43: aload 6\n 45: checkcast #34 // class Day10$Bracket\n 48: astore 7\n 50: iconst_0\n 51: istore 8\n 53: aload 7\n 55: invokevirtual #38 // Method Day10$Bracket.getType:()LDay10$Type;\n 58: getstatic #44 // Field Day10$Type.CLOSE:LDay10$Type;\n 61: if_acmpne 88\n 64: aload_2\n 65: invokevirtual #47 // Method java/util/Stack.pop:()Ljava/lang/Object;\n 68: checkcast #34 // class Day10$Bracket\n 71: astore 9\n 73: aload 7\n 75: invokevirtual #51 // Method Day10$Bracket.getBracketType:()LDay10$BracketType;\n 78: aload 9\n 80: invokevirtual #51 // Method Day10$Bracket.getBracketType:()LDay10$BracketType;\n 83: if_acmpeq 95\n 86: aconst_null\n 87: areturn\n 88: aload_2\n 89: aload 7\n 91: invokevirtual #55 // Method java/util/Stack.push:(Ljava/lang/Object;)Ljava/lang/Object;\n 94: pop\n 95: nop\n 96: nop\n 97: goto 24\n 100: nop\n 101: aload_2\n 102: invokevirtual #58 // Method java/util/Stack.isEmpty:()Z\n 105: ifeq 110\n 108: aconst_null\n 109: areturn\n 110: aload_2\n 111: checkcast #18 // class java/lang/Iterable\n 114: invokestatic #64 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 117: checkcast #18 // class java/lang/Iterable\n 120: astore_3\n 121: lconst_0\n 122: invokestatic #70 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 125: astore 4\n 127: iconst_0\n 128: istore 5\n 130: aload 4\n 132: astore 6\n 134: aload_3\n 135: invokeinterface #22, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 140: astore 7\n 142: aload 7\n 144: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 149: ifeq 204\n 152: aload 7\n 154: invokeinterface #32, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 159: astore 8\n 161: aload 6\n 163: aload 8\n 165: checkcast #34 // class Day10$Bracket\n 168: astore 9\n 170: checkcast #72 // class java/lang/Number\n 173: invokevirtual #76 // Method java/lang/Number.longValue:()J\n 176: lstore 10\n 178: iconst_0\n 179: istore 12\n 181: lload 10\n 183: iconst_5\n 184: i2l\n 185: lmul\n 186: aload 9\n 188: invokevirtual #51 // Method Day10$Bracket.getBracketType:()LDay10$BracketType;\n 191: invokevirtual #82 // Method Day10$BracketType.getAutoCompleteScore:()I\n 194: i2l\n 195: ladd\n 196: invokestatic #70 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 199: astore 6\n 201: goto 142\n 204: aload 6\n 206: areturn\n\n public final void run();\n Code:\n 0: new #109 // class java/io/File\n 3: dup\n 4: ldc #111 // String day10/input-real.txt\n 6: invokespecial #114 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: invokestatic #120 // Method java/nio/charset/Charset.defaultCharset:()Ljava/nio/charset/Charset;\n 12: dup\n 13: ldc #122 // String defaultCharset(...)\n 15: invokestatic #128 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: invokestatic #134 // Method kotlin/io/FilesKt.readLines:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/util/List;\n 21: checkcast #18 // class java/lang/Iterable\n 24: astore_1\n 25: nop\n 26: iconst_0\n 27: istore_2\n 28: aload_1\n 29: astore_3\n 30: new #136 // class java/util/ArrayList\n 33: dup\n 34: invokespecial #137 // Method java/util/ArrayList.\"<init>\":()V\n 37: checkcast #139 // class java/util/Collection\n 40: astore 4\n 42: iconst_0\n 43: istore 5\n 45: aload_3\n 46: astore 6\n 48: iconst_0\n 49: istore 7\n 51: aload 6\n 53: invokeinterface #22, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 58: astore 8\n 60: aload 8\n 62: invokeinterface #28, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 67: ifeq 137\n 70: aload 8\n 72: invokeinterface #32, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 77: astore 9\n 79: aload 9\n 81: astore 10\n 83: iconst_0\n 84: istore 11\n 86: aload 10\n 88: checkcast #141 // class java/lang/String\n 91: astore 12\n 93: iconst_0\n 94: istore 13\n 96: getstatic #144 // Field INSTANCE:LDay10$Part2;\n 99: getstatic #149 // Field Day10.INSTANCE:LDay10;\n 102: aload 12\n 104: invokevirtual #153 // Method Day10.toBrackets:(Ljava/lang/String;)Ljava/util/List;\n 107: invokespecial #155 // Method complete:(Ljava/util/List;)Ljava/lang/Long;\n 110: dup\n 111: ifnull 132\n 114: astore 14\n 116: iconst_0\n 117: istore 15\n 119: aload 4\n 121: aload 14\n 123: invokeinterface #159, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 128: pop\n 129: goto 133\n 132: pop\n 133: nop\n 134: goto 60\n 137: nop\n 138: aload 4\n 140: checkcast #106 // class java/util/List\n 143: nop\n 144: checkcast #18 // class java/lang/Iterable\n 147: invokestatic #162 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 150: astore_1\n 151: aload_1\n 152: astore_2\n 153: iconst_0\n 154: istore_3\n 155: aload_2\n 156: aload_2\n 157: invokeinterface #165, 1 // InterfaceMethod java/util/List.size:()I\n 162: iconst_2\n 163: idiv\n 164: invokeinterface #169, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 169: checkcast #72 // class java/lang/Number\n 172: invokevirtual #76 // Method java/lang/Number.longValue:()J\n 175: lstore 4\n 177: getstatic #175 // Field java/lang/System.out:Ljava/io/PrintStream;\n 180: lload 4\n 182: invokevirtual #181 // Method java/io/PrintStream.println:(J)V\n 185: nop\n 186: nop\n 187: return\n\n static {};\n Code:\n 0: new #2 // class Day10$Part2\n 3: dup\n 4: invokespecial #198 // Method \"<init>\":()V\n 7: putstatic #144 // Field INSTANCE:LDay10$Part2;\n 10: return\n}\n", "javap_err": "" } ]
andrewrlee__adventOfCode2021__aace0fc/src/main/kotlin/Day17.kt
object Day17 { // val targetArea = 20..30 to -10..-5 val targetArea = 248..285 to -85..-56 data class Coord(val x: Int, val y: Int) { constructor(coord: Pair<Int, Int>) : this(coord.first, coord.second) } private fun Pair<IntRange, IntRange>.toCoords(): List<Coord> { val (xs, ys) = this return xs.flatMap { row -> ys.map { col -> Coord(row, col) } } } private fun Pair<IntRange, IntRange>.draw(path: List<Coord>) { val targetArea = this.toCoords() println("\n") val maxCols = (path + targetArea).maxOf { it.x } + 2 val maxRows = (path + targetArea).maxOf { it.y } + 2 val minRows = (path + targetArea).minOf { it.y } - 2 (minRows..maxRows).reversed().forEach { row -> print(row.toString().padStart(3, ' ') + " ") (0..maxCols).forEach { col -> print( when { path.contains(Coord(col, row)) -> "#" targetArea.contains(Coord(col, row)) -> "T" else -> "." } ) } println() } } private fun Pair<IntRange, IntRange>.outOfBounds(point: Coord): Boolean { val (xs, ys) = this val (x, y) = point return x > xs.last || y < ys.first } fun Pair<IntRange, IntRange>.within(point: Coord): Boolean { val (xs, ys) = this val (x, y) = point return xs.contains(x) && ys.contains(y) } private fun fire(x: Int, y: Int): List<Coord> { val velocity = generateSequence(x to y) { (x, y) -> (when { x > 0 -> x - 1 x < 0 -> x + 1 else -> 0 }) to y - 1 }.iterator() return generateSequence(Coord(0 to 0)) { (x, y) -> val (x2, y2) = velocity.next() Coord((x + x2) to (y + y2)) } .takeWhile { targetArea.within(it) || !targetArea.outOfBounds(it) } .toList() } object Part1 { fun run() { val paths = (0..100).flatMap { x -> (0..100).map { y -> (x to y) to fire(x, y) } } .filter { (_, path) -> targetArea.within(path.last()) } .sortedBy { (_, path) -> path.maxByOrNull { it.y }!!.y } println(paths.maxOf { (_, path) -> path.maxOf{ it.y } }) targetArea.draw(fire(23, 84)) } } object Part2 { fun run() { val paths = (20..300).flatMap { x -> (-100..100).map { y -> (x to y) to fire(x, y) } } .filter { (_, path) -> targetArea.within(path.last()) } .map {(velocity, _) -> velocity} println(paths.size) } } } fun main() { Day17.Part1.run() Day17.Part2.run() }
[ { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day17.class", "javap": "Compiled from \"Day17.kt\"\npublic final class Day17 {\n public static final Day17 INSTANCE;\n\n private static final kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange> targetArea;\n\n private Day17();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange> getTargetArea();\n Code:\n 0: getstatic #18 // Field targetArea:Lkotlin/Pair;\n 3: areturn\n\n private final java.util.List<Day17$Coord> toCoords(kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange>);\n Code:\n 0: aload_1\n 1: invokevirtual #27 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 4: checkcast #29 // class kotlin/ranges/IntRange\n 7: astore_2\n 8: aload_1\n 9: invokevirtual #32 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 12: checkcast #29 // class kotlin/ranges/IntRange\n 15: astore_3\n 16: aload_2\n 17: checkcast #34 // class java/lang/Iterable\n 20: astore 4\n 22: iconst_0\n 23: istore 5\n 25: aload 4\n 27: astore 6\n 29: new #36 // class java/util/ArrayList\n 32: dup\n 33: invokespecial #37 // Method java/util/ArrayList.\"<init>\":()V\n 36: checkcast #39 // class java/util/Collection\n 39: astore 7\n 41: iconst_0\n 42: istore 8\n 44: aload 6\n 46: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 51: astore 9\n 53: aload 9\n 55: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 60: ifeq 201\n 63: aload 9\n 65: checkcast #51 // class kotlin/collections/IntIterator\n 68: invokevirtual #55 // Method kotlin/collections/IntIterator.nextInt:()I\n 71: istore 10\n 73: iload 10\n 75: istore 11\n 77: iconst_0\n 78: istore 12\n 80: aload_3\n 81: checkcast #34 // class java/lang/Iterable\n 84: astore 13\n 86: iconst_0\n 87: istore 14\n 89: aload 13\n 91: astore 15\n 93: new #36 // class java/util/ArrayList\n 96: dup\n 97: aload 13\n 99: bipush 10\n 101: invokestatic #61 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 104: invokespecial #64 // Method java/util/ArrayList.\"<init>\":(I)V\n 107: checkcast #39 // class java/util/Collection\n 110: astore 16\n 112: iconst_0\n 113: istore 17\n 115: aload 15\n 117: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 122: astore 18\n 124: aload 18\n 126: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 131: ifeq 178\n 134: aload 18\n 136: checkcast #51 // class kotlin/collections/IntIterator\n 139: invokevirtual #55 // Method kotlin/collections/IntIterator.nextInt:()I\n 142: istore 19\n 144: aload 16\n 146: iload 19\n 148: istore 20\n 150: astore 21\n 152: iconst_0\n 153: istore 22\n 155: new #66 // class Day17$Coord\n 158: dup\n 159: iload 11\n 161: iload 20\n 163: invokespecial #69 // Method Day17$Coord.\"<init>\":(II)V\n 166: aload 21\n 168: swap\n 169: invokeinterface #73, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 174: pop\n 175: goto 124\n 178: aload 16\n 180: checkcast #75 // class java/util/List\n 183: nop\n 184: checkcast #34 // class java/lang/Iterable\n 187: nop\n 188: astore 11\n 190: aload 7\n 192: aload 11\n 194: invokestatic #79 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 197: pop\n 198: goto 53\n 201: aload 7\n 203: checkcast #75 // class java/util/List\n 206: nop\n 207: areturn\n\n private final void draw(kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange>, java.util.List<Day17$Coord>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #107 // Method toCoords:(Lkotlin/Pair;)Ljava/util/List;\n 5: astore_3\n 6: ldc #109 // String \\n\n 8: getstatic #115 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: swap\n 12: invokevirtual #121 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 15: aload_2\n 16: checkcast #39 // class java/util/Collection\n 19: aload_3\n 20: checkcast #34 // class java/lang/Iterable\n 23: invokestatic #125 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 26: checkcast #34 // class java/lang/Iterable\n 29: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 34: astore 6\n 36: aload 6\n 38: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 43: ifne 54\n 46: new #127 // class java/util/NoSuchElementException\n 49: dup\n 50: invokespecial #128 // Method java/util/NoSuchElementException.\"<init>\":()V\n 53: athrow\n 54: aload 6\n 56: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: checkcast #66 // class Day17$Coord\n 64: astore 7\n 66: iconst_0\n 67: istore 8\n 69: aload 7\n 71: invokevirtual #134 // Method Day17$Coord.getX:()I\n 74: istore 7\n 76: aload 6\n 78: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 83: ifeq 122\n 86: aload 6\n 88: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 93: checkcast #66 // class Day17$Coord\n 96: astore 8\n 98: iconst_0\n 99: istore 9\n 101: aload 8\n 103: invokevirtual #134 // Method Day17$Coord.getX:()I\n 106: istore 8\n 108: iload 7\n 110: iload 8\n 112: if_icmpge 76\n 115: iload 8\n 117: istore 7\n 119: goto 76\n 122: iload 7\n 124: iconst_2\n 125: iadd\n 126: istore 4\n 128: aload_2\n 129: checkcast #39 // class java/util/Collection\n 132: aload_3\n 133: checkcast #34 // class java/lang/Iterable\n 136: invokestatic #125 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 139: checkcast #34 // class java/lang/Iterable\n 142: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 147: astore 7\n 149: aload 7\n 151: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 156: ifne 167\n 159: new #127 // class java/util/NoSuchElementException\n 162: dup\n 163: invokespecial #128 // Method java/util/NoSuchElementException.\"<init>\":()V\n 166: athrow\n 167: aload 7\n 169: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 174: checkcast #66 // class Day17$Coord\n 177: astore 8\n 179: iconst_0\n 180: istore 9\n 182: aload 8\n 184: invokevirtual #137 // Method Day17$Coord.getY:()I\n 187: istore 8\n 189: aload 7\n 191: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 196: ifeq 235\n 199: aload 7\n 201: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 206: checkcast #66 // class Day17$Coord\n 209: astore 9\n 211: iconst_0\n 212: istore 10\n 214: aload 9\n 216: invokevirtual #137 // Method Day17$Coord.getY:()I\n 219: istore 9\n 221: iload 8\n 223: iload 9\n 225: if_icmpge 189\n 228: iload 9\n 230: istore 8\n 232: goto 189\n 235: iload 8\n 237: iconst_2\n 238: iadd\n 239: istore 5\n 241: aload_2\n 242: checkcast #39 // class java/util/Collection\n 245: aload_3\n 246: checkcast #34 // class java/lang/Iterable\n 249: invokestatic #125 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 252: checkcast #34 // class java/lang/Iterable\n 255: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 260: astore 8\n 262: aload 8\n 264: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 269: ifne 280\n 272: new #127 // class java/util/NoSuchElementException\n 275: dup\n 276: invokespecial #128 // Method java/util/NoSuchElementException.\"<init>\":()V\n 279: athrow\n 280: aload 8\n 282: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 287: checkcast #66 // class Day17$Coord\n 290: astore 9\n 292: iconst_0\n 293: istore 10\n 295: aload 9\n 297: invokevirtual #137 // Method Day17$Coord.getY:()I\n 300: istore 9\n 302: aload 8\n 304: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 309: ifeq 348\n 312: aload 8\n 314: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 319: checkcast #66 // class Day17$Coord\n 322: astore 10\n 324: iconst_0\n 325: istore 11\n 327: aload 10\n 329: invokevirtual #137 // Method Day17$Coord.getY:()I\n 332: istore 10\n 334: iload 9\n 336: iload 10\n 338: if_icmple 302\n 341: iload 10\n 343: istore 9\n 345: goto 302\n 348: iload 9\n 350: iconst_2\n 351: isub\n 352: istore 6\n 354: new #29 // class kotlin/ranges/IntRange\n 357: dup\n 358: iload 6\n 360: iload 5\n 362: invokespecial #138 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 365: checkcast #140 // class kotlin/ranges/IntProgression\n 368: invokestatic #146 // Method kotlin/ranges/RangesKt.reversed:(Lkotlin/ranges/IntProgression;)Lkotlin/ranges/IntProgression;\n 371: checkcast #34 // class java/lang/Iterable\n 374: astore 7\n 376: iconst_0\n 377: istore 8\n 379: aload 7\n 381: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 386: astore 9\n 388: aload 9\n 390: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 395: ifeq 585\n 398: aload 9\n 400: checkcast #51 // class kotlin/collections/IntIterator\n 403: invokevirtual #55 // Method kotlin/collections/IntIterator.nextInt:()I\n 406: istore 10\n 408: iload 10\n 410: istore 11\n 412: iconst_0\n 413: istore 12\n 415: new #148 // class java/lang/StringBuilder\n 418: dup\n 419: invokespecial #149 // Method java/lang/StringBuilder.\"<init>\":()V\n 422: iload 11\n 424: invokestatic #155 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 427: iconst_3\n 428: bipush 32\n 430: invokestatic #161 // Method kotlin/text/StringsKt.padStart:(Ljava/lang/String;IC)Ljava/lang/String;\n 433: invokevirtual #165 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 436: ldc #167 // String\n 438: invokevirtual #165 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 441: invokevirtual #171 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 444: getstatic #115 // Field java/lang/System.out:Ljava/io/PrintStream;\n 447: swap\n 448: invokevirtual #174 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 451: new #29 // class kotlin/ranges/IntRange\n 454: dup\n 455: iconst_0\n 456: iload 4\n 458: invokespecial #138 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 461: checkcast #34 // class java/lang/Iterable\n 464: astore 13\n 466: iconst_0\n 467: istore 14\n 469: aload 13\n 471: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 476: astore 15\n 478: aload 15\n 480: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 485: ifeq 573\n 488: aload 15\n 490: checkcast #51 // class kotlin/collections/IntIterator\n 493: invokevirtual #55 // Method kotlin/collections/IntIterator.nextInt:()I\n 496: istore 16\n 498: iload 16\n 500: istore 17\n 502: iconst_0\n 503: istore 18\n 505: nop\n 506: aload_2\n 507: new #66 // class Day17$Coord\n 510: dup\n 511: iload 17\n 513: iload 11\n 515: invokespecial #69 // Method Day17$Coord.\"<init>\":(II)V\n 518: invokeinterface #177, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 523: ifeq 531\n 526: ldc #179 // String #\n 528: goto 558\n 531: aload_3\n 532: new #66 // class Day17$Coord\n 535: dup\n 536: iload 17\n 538: iload 11\n 540: invokespecial #69 // Method Day17$Coord.\"<init>\":(II)V\n 543: invokeinterface #177, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 548: ifeq 556\n 551: ldc #181 // String T\n 553: goto 558\n 556: ldc #183 // String .\n 558: astore 19\n 560: getstatic #115 // Field java/lang/System.out:Ljava/io/PrintStream;\n 563: aload 19\n 565: invokevirtual #174 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 568: nop\n 569: nop\n 570: goto 478\n 573: nop\n 574: getstatic #115 // Field java/lang/System.out:Ljava/io/PrintStream;\n 577: invokevirtual #185 // Method java/io/PrintStream.println:()V\n 580: nop\n 581: nop\n 582: goto 388\n 585: nop\n 586: return\n\n private final boolean outOfBounds(kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange>, Day17$Coord);\n Code:\n 0: aload_1\n 1: invokevirtual #27 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 4: checkcast #29 // class kotlin/ranges/IntRange\n 7: astore_3\n 8: aload_1\n 9: invokevirtual #32 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 12: checkcast #29 // class kotlin/ranges/IntRange\n 15: astore 4\n 17: aload_2\n 18: invokevirtual #206 // Method Day17$Coord.component1:()I\n 21: istore 5\n 23: aload_2\n 24: invokevirtual #208 // Method Day17$Coord.component2:()I\n 27: istore 6\n 29: iload 5\n 31: aload_3\n 32: invokevirtual #211 // Method kotlin/ranges/IntRange.getLast:()I\n 35: if_icmpgt 48\n 38: iload 6\n 40: aload 4\n 42: invokevirtual #214 // Method kotlin/ranges/IntRange.getFirst:()I\n 45: if_icmpge 52\n 48: iconst_1\n 49: goto 53\n 52: iconst_0\n 53: ireturn\n\n public final boolean within(kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange>, Day17$Coord);\n Code:\n 0: aload_1\n 1: ldc #221 // String <this>\n 3: invokestatic #227 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #228 // String point\n 9: invokestatic #227 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: invokevirtual #27 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 16: checkcast #29 // class kotlin/ranges/IntRange\n 19: astore_3\n 20: aload_1\n 21: invokevirtual #32 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 24: checkcast #29 // class kotlin/ranges/IntRange\n 27: astore 4\n 29: aload_2\n 30: invokevirtual #206 // Method Day17$Coord.component1:()I\n 33: istore 5\n 35: aload_2\n 36: invokevirtual #208 // Method Day17$Coord.component2:()I\n 39: istore 6\n 41: aload_3\n 42: iload 5\n 44: invokevirtual #231 // Method kotlin/ranges/IntRange.contains:(I)Z\n 47: ifeq 64\n 50: aload 4\n 52: iload 6\n 54: invokevirtual #231 // Method kotlin/ranges/IntRange.contains:(I)Z\n 57: ifeq 64\n 60: iconst_1\n 61: goto 65\n 64: iconst_0\n 65: ireturn\n\n private final java.util.List<Day17$Coord> fire(int, int);\n Code:\n 0: iload_1\n 1: invokestatic #240 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 4: iload_2\n 5: invokestatic #240 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 8: invokestatic #246 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 11: invokedynamic #265, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 16: invokestatic #271 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 19: invokeinterface #274, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 24: astore_3\n 25: new #66 // class Day17$Coord\n 28: dup\n 29: iconst_0\n 30: invokestatic #240 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 33: iconst_0\n 34: invokestatic #240 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 37: invokestatic #246 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 40: invokespecial #277 // Method Day17$Coord.\"<init>\":(Lkotlin/Pair;)V\n 43: aload_3\n 44: invokedynamic #287, 0 // InvokeDynamic #1:invoke:(Ljava/util/Iterator;)Lkotlin/jvm/functions/Function1;\n 49: invokestatic #271 // Method kotlin/sequences/SequencesKt.generateSequence:(Ljava/lang/Object;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 52: invokedynamic #295, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;\n 57: invokestatic #299 // Method kotlin/sequences/SequencesKt.takeWhile:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 60: invokestatic #303 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 63: areturn\n\n private static final kotlin.Pair fire$lambda$7(kotlin.Pair);\n Code:\n 0: aload_0\n 1: ldc_w #307 // String <destruct>\n 4: invokestatic #227 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokevirtual #27 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 11: checkcast #309 // class java/lang/Number\n 14: invokevirtual #312 // Method java/lang/Number.intValue:()I\n 17: istore_1\n 18: aload_0\n 19: invokevirtual #32 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 22: checkcast #309 // class java/lang/Number\n 25: invokevirtual #312 // Method java/lang/Number.intValue:()I\n 28: istore_2\n 29: nop\n 30: iload_1\n 31: ifle 40\n 34: iload_1\n 35: iconst_1\n 36: isub\n 37: goto 51\n 40: iload_1\n 41: ifge 50\n 44: iload_1\n 45: iconst_1\n 46: iadd\n 47: goto 51\n 50: iconst_0\n 51: invokestatic #240 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 54: iload_2\n 55: iconst_1\n 56: isub\n 57: invokestatic #240 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 60: invokestatic #246 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 63: areturn\n\n private static final Day17$Coord fire$lambda$8(java.util.Iterator, Day17$Coord);\n Code:\n 0: aload_1\n 1: ldc_w #307 // String <destruct>\n 4: invokestatic #227 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: invokevirtual #206 // Method Day17$Coord.component1:()I\n 11: istore_2\n 12: aload_1\n 13: invokevirtual #208 // Method Day17$Coord.component2:()I\n 16: istore_3\n 17: aload_0\n 18: invokeinterface #131, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 23: checkcast #23 // class kotlin/Pair\n 26: astore 4\n 28: aload 4\n 30: invokevirtual #27 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 33: checkcast #309 // class java/lang/Number\n 36: invokevirtual #312 // Method java/lang/Number.intValue:()I\n 39: istore 5\n 41: aload 4\n 43: invokevirtual #32 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 46: checkcast #309 // class java/lang/Number\n 49: invokevirtual #312 // Method java/lang/Number.intValue:()I\n 52: istore 6\n 54: new #66 // class Day17$Coord\n 57: dup\n 58: iload_2\n 59: iload 5\n 61: iadd\n 62: invokestatic #240 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 65: iload_3\n 66: iload 6\n 68: iadd\n 69: invokestatic #240 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 72: invokestatic #246 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 75: invokespecial #277 // Method Day17$Coord.\"<init>\":(Lkotlin/Pair;)V\n 78: areturn\n\n private static final boolean fire$lambda$9(Day17$Coord);\n Code:\n 0: aload_0\n 1: ldc_w #316 // String it\n 4: invokestatic #227 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: getstatic #319 // Field INSTANCE:LDay17;\n 10: getstatic #319 // Field INSTANCE:LDay17;\n 13: pop\n 14: getstatic #18 // Field targetArea:Lkotlin/Pair;\n 17: aload_0\n 18: invokevirtual #321 // Method within:(Lkotlin/Pair;LDay17$Coord;)Z\n 21: ifne 41\n 24: getstatic #319 // Field INSTANCE:LDay17;\n 27: getstatic #319 // Field INSTANCE:LDay17;\n 30: pop\n 31: getstatic #18 // Field targetArea:Lkotlin/Pair;\n 34: aload_0\n 35: invokespecial #323 // Method outOfBounds:(Lkotlin/Pair;LDay17$Coord;)Z\n 38: ifne 45\n 41: iconst_1\n 42: goto 46\n 45: iconst_0\n 46: ireturn\n\n public static final void access$draw(Day17, kotlin.Pair, java.util.List);\n Code:\n 0: aload_0\n 1: aload_1\n 2: aload_2\n 3: invokespecial #327 // Method draw:(Lkotlin/Pair;Ljava/util/List;)V\n 6: return\n\n public static final java.util.List access$fire(Day17, int, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: iload_2\n 3: invokespecial #333 // Method fire:(II)Ljava/util/List;\n 6: areturn\n\n static {};\n Code:\n 0: new #2 // class Day17\n 3: dup\n 4: invokespecial #335 // Method \"<init>\":()V\n 7: putstatic #319 // Field INSTANCE:LDay17;\n 10: new #29 // class kotlin/ranges/IntRange\n 13: dup\n 14: sipush 248\n 17: sipush 285\n 20: invokespecial #138 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 23: new #29 // class kotlin/ranges/IntRange\n 26: dup\n 27: bipush -85\n 29: bipush -56\n 31: invokespecial #138 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 34: invokestatic #246 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 37: putstatic #18 // Field targetArea:Lkotlin/Pair;\n 40: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day17$Part2.class", "javap": "Compiled from \"Day17.kt\"\npublic final class Day17$Part2 {\n public static final Day17$Part2 INSTANCE;\n\n private Day17$Part2();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final void run();\n Code:\n 0: new #13 // class kotlin/ranges/IntRange\n 3: dup\n 4: bipush 20\n 6: sipush 300\n 9: invokespecial #16 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 12: checkcast #18 // 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 #20 // class java/util/ArrayList\n 24: dup\n 25: invokespecial #21 // Method java/util/ArrayList.\"<init>\":()V\n 28: checkcast #23 // class java/util/Collection\n 31: astore 5\n 33: iconst_0\n 34: istore 6\n 36: aload 4\n 38: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 43: astore 7\n 45: aload 7\n 47: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 52: ifeq 218\n 55: aload 7\n 57: checkcast #35 // class kotlin/collections/IntIterator\n 60: invokevirtual #39 // Method kotlin/collections/IntIterator.nextInt:()I\n 63: istore 8\n 65: iload 8\n 67: istore 9\n 69: iconst_0\n 70: istore 10\n 72: new #13 // class kotlin/ranges/IntRange\n 75: dup\n 76: bipush -100\n 78: bipush 100\n 80: invokespecial #16 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 83: checkcast #18 // class java/lang/Iterable\n 86: astore 11\n 88: iconst_0\n 89: istore 12\n 91: aload 11\n 93: astore 13\n 95: new #20 // class java/util/ArrayList\n 98: dup\n 99: aload 11\n 101: bipush 10\n 103: invokestatic #45 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 106: invokespecial #48 // Method java/util/ArrayList.\"<init>\":(I)V\n 109: checkcast #23 // class java/util/Collection\n 112: astore 14\n 114: iconst_0\n 115: istore 15\n 117: aload 13\n 119: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 124: astore 16\n 126: aload 16\n 128: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 133: ifeq 195\n 136: aload 16\n 138: checkcast #35 // class kotlin/collections/IntIterator\n 141: invokevirtual #39 // Method kotlin/collections/IntIterator.nextInt:()I\n 144: istore 17\n 146: aload 14\n 148: iload 17\n 150: istore 18\n 152: astore 19\n 154: iconst_0\n 155: istore 20\n 157: iload 9\n 159: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 162: iload 18\n 164: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 167: invokestatic #60 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 170: getstatic #66 // Field Day17.INSTANCE:LDay17;\n 173: iload 9\n 175: iload 18\n 177: invokestatic #70 // Method Day17.access$fire:(LDay17;II)Ljava/util/List;\n 180: invokestatic #60 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 183: aload 19\n 185: swap\n 186: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 191: pop\n 192: goto 126\n 195: aload 14\n 197: checkcast #76 // class java/util/List\n 200: nop\n 201: checkcast #18 // class java/lang/Iterable\n 204: nop\n 205: astore 9\n 207: aload 5\n 209: aload 9\n 211: invokestatic #80 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 214: pop\n 215: goto 45\n 218: aload 5\n 220: checkcast #76 // class java/util/List\n 223: nop\n 224: checkcast #18 // class java/lang/Iterable\n 227: astore_2\n 228: nop\n 229: iconst_0\n 230: istore_3\n 231: aload_2\n 232: astore 4\n 234: new #20 // class java/util/ArrayList\n 237: dup\n 238: invokespecial #21 // Method java/util/ArrayList.\"<init>\":()V\n 241: checkcast #23 // class java/util/Collection\n 244: astore 5\n 246: iconst_0\n 247: istore 6\n 249: aload 4\n 251: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 256: astore 7\n 258: aload 7\n 260: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 265: ifeq 333\n 268: aload 7\n 270: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 275: astore 8\n 277: aload 8\n 279: checkcast #86 // class kotlin/Pair\n 282: astore 9\n 284: iconst_0\n 285: istore 10\n 287: aload 9\n 289: invokevirtual #89 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 292: checkcast #76 // class java/util/List\n 295: astore 11\n 297: getstatic #66 // Field Day17.INSTANCE:LDay17;\n 300: getstatic #66 // Field Day17.INSTANCE:LDay17;\n 303: invokevirtual #93 // Method Day17.getTargetArea:()Lkotlin/Pair;\n 306: aload 11\n 308: invokestatic #97 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 311: checkcast #99 // class Day17$Coord\n 314: invokevirtual #103 // Method Day17.within:(Lkotlin/Pair;LDay17$Coord;)Z\n 317: ifeq 258\n 320: aload 5\n 322: aload 8\n 324: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 329: pop\n 330: goto 258\n 333: aload 5\n 335: checkcast #76 // class java/util/List\n 338: nop\n 339: checkcast #18 // class java/lang/Iterable\n 342: astore_2\n 343: nop\n 344: iconst_0\n 345: istore_3\n 346: aload_2\n 347: astore 4\n 349: new #20 // class java/util/ArrayList\n 352: dup\n 353: aload_2\n 354: bipush 10\n 356: invokestatic #45 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 359: invokespecial #48 // Method java/util/ArrayList.\"<init>\":(I)V\n 362: checkcast #23 // class java/util/Collection\n 365: astore 5\n 367: iconst_0\n 368: istore 6\n 370: aload 4\n 372: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 377: astore 7\n 379: aload 7\n 381: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 386: ifeq 436\n 389: aload 7\n 391: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 396: astore 8\n 398: aload 5\n 400: aload 8\n 402: checkcast #86 // class kotlin/Pair\n 405: astore 9\n 407: astore 21\n 409: iconst_0\n 410: istore 10\n 412: aload 9\n 414: invokevirtual #106 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 417: checkcast #86 // class kotlin/Pair\n 420: astore 11\n 422: aload 11\n 424: aload 21\n 426: swap\n 427: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 432: pop\n 433: goto 379\n 436: aload 5\n 438: checkcast #76 // class java/util/List\n 441: nop\n 442: astore_1\n 443: aload_1\n 444: invokeinterface #109, 1 // InterfaceMethod java/util/List.size:()I\n 449: istore_2\n 450: getstatic #115 // Field java/lang/System.out:Ljava/io/PrintStream;\n 453: iload_2\n 454: invokevirtual #120 // Method java/io/PrintStream.println:(I)V\n 457: return\n\n static {};\n Code:\n 0: new #2 // class Day17$Part2\n 3: dup\n 4: invokespecial #153 // Method \"<init>\":()V\n 7: putstatic #155 // Field INSTANCE:LDay17$Part2;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day17$Coord.class", "javap": "Compiled from \"Day17.kt\"\npublic final class Day17$Coord {\n private final int x;\n\n private final int y;\n\n public Day17$Coord(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 x:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field y:I\n 14: return\n\n public final int getX();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int getY();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public Day17$Coord(kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_1\n 1: ldc #26 // String coord\n 3: invokestatic #32 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokevirtual #38 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 11: checkcast #40 // class java/lang/Number\n 14: invokevirtual #43 // Method java/lang/Number.intValue:()I\n 17: aload_1\n 18: invokevirtual #46 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 21: checkcast #40 // class java/lang/Number\n 24: invokevirtual #43 // Method java/lang/Number.intValue:()I\n 27: invokespecial #48 // Method \"<init>\":(II)V\n 30: return\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public final Day17$Coord copy(int, int);\n Code:\n 0: new #2 // class Day17$Coord\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: invokespecial #48 // Method \"<init>\":(II)V\n 9: areturn\n\n public static Day17$Coord copy$default(Day17$Coord, int, int, 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 #13 // Field x:I\n 10: istore_1\n 11: iload_3\n 12: iconst_2\n 13: iand\n 14: ifeq 22\n 17: aload_0\n 18: getfield #16 // Field y:I\n 21: istore_2\n 22: aload_0\n 23: iload_1\n 24: iload_2\n 25: invokevirtual #57 // Method copy:(II)LDay17$Coord;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #61 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #62 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #64 // String Coord(x=\n 9: invokevirtual #68 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field x:I\n 16: invokevirtual #71 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #73 // String , y=\n 21: invokevirtual #68 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field y:I\n 28: invokevirtual #71 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #76 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #78 // 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 #13 // Field x:I\n 4: invokestatic #84 // 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 y:I\n 16: invokestatic #84 // Method java/lang/Integer.hashCode:(I)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 Day17$Coord\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day17$Coord\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field x:I\n 25: aload_2\n 26: getfield #13 // Field x:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field y:I\n 38: aload_2\n 39: getfield #16 // Field y:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: iconst_1\n 48: ireturn\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day17$Part1$run$$inlined$sortedBy$1.class", "javap": "Compiled from \"Comparisons.kt\"\npublic final class Day17$Part1$run$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public Day17$Part1$run$$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/util/List\n 15: astore 5\n 17: aload 5\n 19: checkcast #31 // class java/lang/Iterable\n 22: astore 6\n 24: iconst_0\n 25: istore 7\n 27: aload 6\n 29: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 34: astore 8\n 36: aload 8\n 38: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 43: ifne 50\n 46: aconst_null\n 47: goto 144\n 50: aload 8\n 52: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 9\n 59: aload 8\n 61: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 66: ifne 74\n 69: aload 9\n 71: goto 144\n 74: aload 9\n 76: checkcast #46 // class Day17$Coord\n 79: astore 10\n 81: iconst_0\n 82: istore 11\n 84: aload 10\n 86: invokevirtual #50 // Method Day17$Coord.getY:()I\n 89: istore 10\n 91: aload 8\n 93: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 98: astore 11\n 100: aload 11\n 102: checkcast #46 // class Day17$Coord\n 105: astore 12\n 107: iconst_0\n 108: istore 13\n 110: aload 12\n 112: invokevirtual #50 // Method Day17$Coord.getY:()I\n 115: istore 12\n 117: iload 10\n 119: iload 12\n 121: if_icmpge 132\n 124: aload 11\n 126: astore 9\n 128: iload 12\n 130: istore 10\n 132: aload 8\n 134: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 139: ifne 91\n 142: aload 9\n 144: dup\n 145: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 148: checkcast #46 // class Day17$Coord\n 151: invokevirtual #50 // Method Day17$Coord.getY:()I\n 154: invokestatic #62 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 157: checkcast #64 // class java/lang/Comparable\n 160: aload_2\n 161: checkcast #23 // class kotlin/Pair\n 164: astore_3\n 165: astore 14\n 167: iconst_0\n 168: istore 4\n 170: aload_3\n 171: invokevirtual #27 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 174: checkcast #29 // class java/util/List\n 177: astore 5\n 179: aload 5\n 181: checkcast #31 // class java/lang/Iterable\n 184: astore 6\n 186: iconst_0\n 187: istore 7\n 189: aload 6\n 191: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 196: astore 8\n 198: aload 8\n 200: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 205: ifne 212\n 208: aconst_null\n 209: goto 306\n 212: aload 8\n 214: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 219: astore 9\n 221: aload 8\n 223: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 228: ifne 236\n 231: aload 9\n 233: goto 306\n 236: aload 9\n 238: checkcast #46 // class Day17$Coord\n 241: astore 10\n 243: iconst_0\n 244: istore 11\n 246: aload 10\n 248: invokevirtual #50 // Method Day17$Coord.getY:()I\n 251: istore 10\n 253: aload 8\n 255: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 260: astore 11\n 262: aload 11\n 264: checkcast #46 // class Day17$Coord\n 267: astore 12\n 269: iconst_0\n 270: istore 13\n 272: aload 12\n 274: invokevirtual #50 // Method Day17$Coord.getY:()I\n 277: istore 12\n 279: iload 10\n 281: iload 12\n 283: if_icmpge 294\n 286: aload 11\n 288: astore 9\n 290: iload 12\n 292: istore 10\n 294: aload 8\n 296: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 301: ifne 253\n 304: aload 9\n 306: dup\n 307: invokestatic #56 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 310: checkcast #46 // class Day17$Coord\n 313: invokevirtual #50 // Method Day17$Coord.getY:()I\n 316: invokestatic #62 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 319: aload 14\n 321: swap\n 322: checkcast #64 // class java/lang/Comparable\n 325: invokestatic #70 // Method kotlin/comparisons/ComparisonsKt.compareValues:(Ljava/lang/Comparable;Ljava/lang/Comparable;)I\n 328: ireturn\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day17Kt.class", "javap": "Compiled from \"Day17.kt\"\npublic final class Day17Kt {\n public static final void main();\n Code:\n 0: getstatic #12 // Field Day17$Part1.INSTANCE:LDay17$Part1;\n 3: invokevirtual #15 // Method Day17$Part1.run:()V\n 6: getstatic #20 // Field Day17$Part2.INSTANCE:LDay17$Part2;\n 9: invokevirtual #21 // Method Day17$Part2.run:()V\n 12: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #24 // Method main:()V\n 3: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day17$Part1.class", "javap": "Compiled from \"Day17.kt\"\npublic final class Day17$Part1 {\n public static final Day17$Part1 INSTANCE;\n\n private Day17$Part1();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final void run();\n Code:\n 0: new #13 // class kotlin/ranges/IntRange\n 3: dup\n 4: iconst_0\n 5: bipush 100\n 7: invokespecial #16 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 10: checkcast #18 // class java/lang/Iterable\n 13: astore_2\n 14: iconst_0\n 15: istore_3\n 16: aload_2\n 17: astore 4\n 19: new #20 // class java/util/ArrayList\n 22: dup\n 23: invokespecial #21 // Method java/util/ArrayList.\"<init>\":()V\n 26: checkcast #23 // class java/util/Collection\n 29: astore 5\n 31: iconst_0\n 32: istore 6\n 34: aload 4\n 36: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 41: astore 7\n 43: aload 7\n 45: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 50: ifeq 215\n 53: aload 7\n 55: checkcast #35 // class kotlin/collections/IntIterator\n 58: invokevirtual #39 // Method kotlin/collections/IntIterator.nextInt:()I\n 61: istore 8\n 63: iload 8\n 65: istore 9\n 67: iconst_0\n 68: istore 10\n 70: new #13 // class kotlin/ranges/IntRange\n 73: dup\n 74: iconst_0\n 75: bipush 100\n 77: invokespecial #16 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 80: checkcast #18 // class java/lang/Iterable\n 83: astore 11\n 85: iconst_0\n 86: istore 12\n 88: aload 11\n 90: astore 13\n 92: new #20 // class java/util/ArrayList\n 95: dup\n 96: aload 11\n 98: bipush 10\n 100: invokestatic #45 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 103: invokespecial #48 // Method java/util/ArrayList.\"<init>\":(I)V\n 106: checkcast #23 // class java/util/Collection\n 109: astore 14\n 111: iconst_0\n 112: istore 15\n 114: aload 13\n 116: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 121: astore 16\n 123: aload 16\n 125: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 130: ifeq 192\n 133: aload 16\n 135: checkcast #35 // class kotlin/collections/IntIterator\n 138: invokevirtual #39 // Method kotlin/collections/IntIterator.nextInt:()I\n 141: istore 17\n 143: aload 14\n 145: iload 17\n 147: istore 18\n 149: astore 19\n 151: iconst_0\n 152: istore 20\n 154: iload 9\n 156: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 159: iload 18\n 161: invokestatic #54 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 164: invokestatic #60 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 167: getstatic #66 // Field Day17.INSTANCE:LDay17;\n 170: iload 9\n 172: iload 18\n 174: invokestatic #70 // Method Day17.access$fire:(LDay17;II)Ljava/util/List;\n 177: invokestatic #60 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 180: aload 19\n 182: swap\n 183: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 188: pop\n 189: goto 123\n 192: aload 14\n 194: checkcast #76 // class java/util/List\n 197: nop\n 198: checkcast #18 // class java/lang/Iterable\n 201: nop\n 202: astore 9\n 204: aload 5\n 206: aload 9\n 208: invokestatic #80 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 211: pop\n 212: goto 43\n 215: aload 5\n 217: checkcast #76 // class java/util/List\n 220: nop\n 221: checkcast #18 // class java/lang/Iterable\n 224: astore_2\n 225: nop\n 226: iconst_0\n 227: istore_3\n 228: aload_2\n 229: astore 4\n 231: new #20 // class java/util/ArrayList\n 234: dup\n 235: invokespecial #21 // Method java/util/ArrayList.\"<init>\":()V\n 238: checkcast #23 // class java/util/Collection\n 241: astore 5\n 243: iconst_0\n 244: istore 6\n 246: aload 4\n 248: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 253: astore 7\n 255: aload 7\n 257: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 262: ifeq 330\n 265: aload 7\n 267: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 272: astore 8\n 274: aload 8\n 276: checkcast #86 // class kotlin/Pair\n 279: astore 9\n 281: iconst_0\n 282: istore 10\n 284: aload 9\n 286: invokevirtual #89 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 289: checkcast #76 // class java/util/List\n 292: astore 11\n 294: getstatic #66 // Field Day17.INSTANCE:LDay17;\n 297: getstatic #66 // Field Day17.INSTANCE:LDay17;\n 300: invokevirtual #93 // Method Day17.getTargetArea:()Lkotlin/Pair;\n 303: aload 11\n 305: invokestatic #97 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 308: checkcast #99 // class Day17$Coord\n 311: invokevirtual #103 // Method Day17.within:(Lkotlin/Pair;LDay17$Coord;)Z\n 314: ifeq 255\n 317: aload 5\n 319: aload 8\n 321: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 326: pop\n 327: goto 255\n 330: aload 5\n 332: checkcast #76 // class java/util/List\n 335: nop\n 336: checkcast #18 // class java/lang/Iterable\n 339: astore_2\n 340: nop\n 341: iconst_0\n 342: istore_3\n 343: aload_2\n 344: new #105 // class Day17$Part1$run$$inlined$sortedBy$1\n 347: dup\n 348: invokespecial #106 // Method Day17$Part1$run$$inlined$sortedBy$1.\"<init>\":()V\n 351: checkcast #108 // class java/util/Comparator\n 354: invokestatic #112 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 357: astore_1\n 358: aload_1\n 359: checkcast #18 // class java/lang/Iterable\n 362: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 367: astore_3\n 368: aload_3\n 369: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 374: ifne 385\n 377: new #114 // class java/util/NoSuchElementException\n 380: dup\n 381: invokespecial #115 // Method java/util/NoSuchElementException.\"<init>\":()V\n 384: athrow\n 385: aload_3\n 386: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 391: checkcast #86 // class kotlin/Pair\n 394: astore 4\n 396: iconst_0\n 397: istore 5\n 399: aload 4\n 401: invokevirtual #89 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 404: checkcast #76 // class java/util/List\n 407: astore 6\n 409: aload 6\n 411: checkcast #18 // class java/lang/Iterable\n 414: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 419: astore 7\n 421: aload 7\n 423: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 428: ifne 439\n 431: new #114 // class java/util/NoSuchElementException\n 434: dup\n 435: invokespecial #115 // Method java/util/NoSuchElementException.\"<init>\":()V\n 438: athrow\n 439: aload 7\n 441: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 446: checkcast #99 // class Day17$Coord\n 449: astore 8\n 451: iconst_0\n 452: istore 9\n 454: aload 8\n 456: invokevirtual #118 // Method Day17$Coord.getY:()I\n 459: istore 8\n 461: aload 7\n 463: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 468: ifeq 507\n 471: aload 7\n 473: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 478: checkcast #99 // class Day17$Coord\n 481: astore 9\n 483: iconst_0\n 484: istore 10\n 486: aload 9\n 488: invokevirtual #118 // Method Day17$Coord.getY:()I\n 491: istore 9\n 493: iload 8\n 495: iload 9\n 497: if_icmpge 461\n 500: iload 9\n 502: istore 8\n 504: goto 461\n 507: iload 8\n 509: nop\n 510: istore 4\n 512: aload_3\n 513: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 518: ifeq 662\n 521: aload_3\n 522: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 527: checkcast #86 // class kotlin/Pair\n 530: astore 5\n 532: iconst_0\n 533: istore 6\n 535: aload 5\n 537: invokevirtual #89 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 540: checkcast #76 // class java/util/List\n 543: astore 7\n 545: aload 7\n 547: checkcast #18 // class java/lang/Iterable\n 550: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 555: astore 8\n 557: aload 8\n 559: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 564: ifne 575\n 567: new #114 // class java/util/NoSuchElementException\n 570: dup\n 571: invokespecial #115 // Method java/util/NoSuchElementException.\"<init>\":()V\n 574: athrow\n 575: aload 8\n 577: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 582: checkcast #99 // class Day17$Coord\n 585: astore 9\n 587: iconst_0\n 588: istore 10\n 590: aload 9\n 592: invokevirtual #118 // Method Day17$Coord.getY:()I\n 595: istore 9\n 597: aload 8\n 599: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 604: ifeq 643\n 607: aload 8\n 609: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 614: checkcast #99 // class Day17$Coord\n 617: astore 10\n 619: iconst_0\n 620: istore 11\n 622: aload 10\n 624: invokevirtual #118 // Method Day17$Coord.getY:()I\n 627: istore 10\n 629: iload 9\n 631: iload 10\n 633: if_icmpge 597\n 636: iload 10\n 638: istore 9\n 640: goto 597\n 643: iload 9\n 645: nop\n 646: istore 5\n 648: iload 4\n 650: iload 5\n 652: if_icmpge 512\n 655: iload 5\n 657: istore 4\n 659: goto 512\n 662: iload 4\n 664: istore_2\n 665: getstatic #124 // Field java/lang/System.out:Ljava/io/PrintStream;\n 668: iload_2\n 669: invokevirtual #129 // Method java/io/PrintStream.println:(I)V\n 672: getstatic #66 // Field Day17.INSTANCE:LDay17;\n 675: getstatic #66 // Field Day17.INSTANCE:LDay17;\n 678: invokevirtual #93 // Method Day17.getTargetArea:()Lkotlin/Pair;\n 681: getstatic #66 // Field Day17.INSTANCE:LDay17;\n 684: bipush 23\n 686: bipush 84\n 688: invokestatic #70 // Method Day17.access$fire:(LDay17;II)Ljava/util/List;\n 691: invokestatic #133 // Method Day17.access$draw:(LDay17;Lkotlin/Pair;Ljava/util/List;)V\n 694: return\n\n static {};\n Code:\n 0: new #2 // class Day17$Part1\n 3: dup\n 4: invokespecial #169 // Method \"<init>\":()V\n 7: putstatic #171 // Field INSTANCE:LDay17$Part1;\n 10: return\n}\n", "javap_err": "" } ]
andrewrlee__adventOfCode2021__aace0fc/src/main/kotlin/Day11.kt
import java.io.File import java.nio.charset.Charset.defaultCharset import kotlin.streams.toList typealias OctopusGrid = Map<Pair<Int, Int>, Day11.Octopus> object Day11 { private fun toCoordinates(row: Int, line: String) = line.chars() .map(Character::getNumericValue) .toList() .mapIndexed { col, value -> (row to col) to Octopus((row to col), value) } val octopusGrid = { File("day11/input-Day11.kt.txt") .readLines(defaultCharset()) .mapIndexed(::toCoordinates) .flatten() .associate { it } } data class Octopus(var coord: Pair<Int, Int>, var score: Int, var hasFlashed: Boolean = false) { fun increment() = score++ private fun needsToFlash() = score > 9 && !hasFlashed private fun flash() { hasFlashed = true } fun reset() = if (hasFlashed) { hasFlashed = false; score = 0; 1 } else 0 private fun getNeighbours( validCells: OctopusGrid, deltas: List<Pair<Int, Int>> = listOf( -1 to 0, 0 to -1, 1 to 0, 0 to 1, -1 to -1, 1 to 1, -1 to 1, 1 to -1 ) ) = deltas.asSequence() .map { (x2, y2) -> coord.first + x2 to coord.second + y2 } .mapNotNull { validCells[it] } fun check(grid: OctopusGrid) { if (this.needsToFlash()) { this.flash() this.getNeighbours(grid).forEach { it.increment(); it.check(grid) } } } } private fun OctopusGrid.step(): Int { this.values.forEach { it.increment() } this.values.forEach { oct -> oct.check(this) } return this.values.sumOf { it.reset() } } object Part1 { fun run() { val grid = octopusGrid() val count = (0..99).map { grid.step() }.sum() println(count) } } object Part2 { private fun OctopusGrid.isNotComplete(): Boolean { val flashCount = this.step() return flashCount != this.size } fun run() { val grid = octopusGrid() var count = 0 do { count++ } while (grid.isNotComplete()) println(count) } } } fun main() { Day11.Part1.run() Day11.Part2.run() }
[ { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day11$Part1.class", "javap": "Compiled from \"Day11.kt\"\npublic final class Day11$Part1 {\n public static final Day11$Part1 INSTANCE;\n\n private Day11$Part1();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final void run();\n Code:\n 0: getstatic #17 // Field Day11.INSTANCE:LDay11;\n 3: invokevirtual #21 // Method Day11.getOctopusGrid:()Lkotlin/jvm/functions/Function0;\n 6: invokeinterface #27, 1 // InterfaceMethod kotlin/jvm/functions/Function0.invoke:()Ljava/lang/Object;\n 11: checkcast #29 // class java/util/Map\n 14: astore_1\n 15: new #31 // class kotlin/ranges/IntRange\n 18: dup\n 19: iconst_0\n 20: bipush 99\n 22: invokespecial #34 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 25: checkcast #36 // class java/lang/Iterable\n 28: astore_3\n 29: iconst_0\n 30: istore 4\n 32: aload_3\n 33: astore 5\n 35: new #38 // class java/util/ArrayList\n 38: dup\n 39: aload_3\n 40: bipush 10\n 42: invokestatic #44 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 45: invokespecial #47 // Method java/util/ArrayList.\"<init>\":(I)V\n 48: checkcast #49 // class java/util/Collection\n 51: astore 6\n 53: iconst_0\n 54: istore 7\n 56: aload 5\n 58: invokeinterface #53, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 63: astore 8\n 65: aload 8\n 67: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 72: ifeq 118\n 75: aload 8\n 77: checkcast #61 // class kotlin/collections/IntIterator\n 80: invokevirtual #65 // Method kotlin/collections/IntIterator.nextInt:()I\n 83: istore 9\n 85: aload 6\n 87: iload 9\n 89: istore 10\n 91: astore 12\n 93: iconst_0\n 94: istore 11\n 96: getstatic #17 // Field Day11.INSTANCE:LDay11;\n 99: aload_1\n 100: invokestatic #69 // Method Day11.access$step:(LDay11;Ljava/util/Map;)I\n 103: invokestatic #75 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 106: aload 12\n 108: swap\n 109: invokeinterface #79, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 114: pop\n 115: goto 65\n 118: aload 6\n 120: checkcast #81 // class java/util/List\n 123: nop\n 124: checkcast #36 // class java/lang/Iterable\n 127: invokestatic #85 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 130: istore_2\n 131: getstatic #91 // Field java/lang/System.out:Ljava/io/PrintStream;\n 134: iload_2\n 135: invokevirtual #96 // Method java/io/PrintStream.println:(I)V\n 138: return\n\n static {};\n Code:\n 0: new #2 // class Day11$Part1\n 3: dup\n 4: invokespecial #112 // Method \"<init>\":()V\n 7: putstatic #114 // Field INSTANCE:LDay11$Part1;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day11.class", "javap": "Compiled from \"Day11.kt\"\npublic final class Day11 {\n public static final Day11 INSTANCE;\n\n private static final kotlin.jvm.functions.Function0<java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day11$Octopus>> octopusGrid;\n\n private Day11();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final java.util.List<kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day11$Octopus>> toCoordinates(int, java.lang.String);\n Code:\n 0: aload_2\n 1: invokevirtual #19 // Method java/lang/String.chars:()Ljava/util/stream/IntStream;\n 4: invokedynamic #38, 0 // InvokeDynamic #0:applyAsInt:()Ljava/util/function/IntUnaryOperator;\n 9: invokeinterface #44, 2 // InterfaceMethod java/util/stream/IntStream.map:(Ljava/util/function/IntUnaryOperator;)Ljava/util/stream/IntStream;\n 14: dup\n 15: ldc #46 // String map(...)\n 17: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 20: invokestatic #58 // Method kotlin/streams/jdk8/StreamsKt.toList:(Ljava/util/stream/IntStream;)Ljava/util/List;\n 23: checkcast #60 // class java/lang/Iterable\n 26: astore_3\n 27: nop\n 28: iconst_0\n 29: istore 4\n 31: aload_3\n 32: astore 5\n 34: new #62 // class java/util/ArrayList\n 37: dup\n 38: aload_3\n 39: bipush 10\n 41: invokestatic #68 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 44: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 47: checkcast #73 // class java/util/Collection\n 50: astore 6\n 52: iconst_0\n 53: istore 7\n 55: iconst_0\n 56: istore 8\n 58: aload 5\n 60: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 65: astore 9\n 67: aload 9\n 69: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 74: ifeq 173\n 77: aload 9\n 79: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 84: astore 10\n 86: aload 6\n 88: iload 8\n 90: iinc 8, 1\n 93: istore 11\n 95: iload 11\n 97: ifge 103\n 100: invokestatic #90 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 103: iload 11\n 105: aload 10\n 107: checkcast #92 // class java/lang/Number\n 110: invokevirtual #96 // Method java/lang/Number.intValue:()I\n 113: istore 12\n 115: istore 13\n 117: astore 15\n 119: iconst_0\n 120: istore 14\n 122: iload_1\n 123: invokestatic #102 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 126: iload 13\n 128: invokestatic #102 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 131: invokestatic #108 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 134: new #110 // class Day11$Octopus\n 137: dup\n 138: iload_1\n 139: invokestatic #102 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 142: iload 13\n 144: invokestatic #102 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 147: invokestatic #108 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 150: iload 12\n 152: iconst_0\n 153: iconst_4\n 154: aconst_null\n 155: invokespecial #113 // Method Day11$Octopus.\"<init>\":(Lkotlin/Pair;IZILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 158: invokestatic #108 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 161: aload 15\n 163: swap\n 164: invokeinterface #117, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 169: pop\n 170: goto 67\n 173: aload 6\n 175: checkcast #119 // class java/util/List\n 178: nop\n 179: areturn\n\n public final kotlin.jvm.functions.Function0<java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day11$Octopus>> getOctopusGrid();\n Code:\n 0: getstatic #144 // Field octopusGrid:Lkotlin/jvm/functions/Function0;\n 3: areturn\n\n private final int step(java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day11$Octopus>);\n Code:\n 0: aload_1\n 1: invokeinterface #153, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 6: checkcast #60 // class java/lang/Iterable\n 9: astore_2\n 10: iconst_0\n 11: istore_3\n 12: aload_2\n 13: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 18: astore 4\n 20: aload 4\n 22: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 27: ifeq 59\n 30: aload 4\n 32: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 37: astore 5\n 39: aload 5\n 41: checkcast #110 // class Day11$Octopus\n 44: astore 6\n 46: iconst_0\n 47: istore 7\n 49: aload 6\n 51: invokevirtual #156 // Method Day11$Octopus.increment:()I\n 54: pop\n 55: nop\n 56: goto 20\n 59: nop\n 60: aload_1\n 61: invokeinterface #153, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 66: checkcast #60 // class java/lang/Iterable\n 69: astore_2\n 70: iconst_0\n 71: istore_3\n 72: aload_2\n 73: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 78: astore 4\n 80: aload 4\n 82: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 87: ifeq 119\n 90: aload 4\n 92: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 97: astore 5\n 99: aload 5\n 101: checkcast #110 // class Day11$Octopus\n 104: astore 6\n 106: iconst_0\n 107: istore 7\n 109: aload 6\n 111: aload_1\n 112: invokevirtual #160 // Method Day11$Octopus.check:(Ljava/util/Map;)V\n 115: nop\n 116: goto 80\n 119: nop\n 120: aload_1\n 121: invokeinterface #153, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 126: checkcast #60 // class java/lang/Iterable\n 129: astore_2\n 130: iconst_0\n 131: istore_3\n 132: aload_2\n 133: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 138: astore 4\n 140: aload 4\n 142: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 147: ifeq 188\n 150: aload 4\n 152: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 157: astore 5\n 159: iload_3\n 160: aload 5\n 162: checkcast #110 // class Day11$Octopus\n 165: astore 6\n 167: istore 8\n 169: iconst_0\n 170: istore 7\n 172: aload 6\n 174: invokevirtual #163 // Method Day11$Octopus.reset:()I\n 177: istore 9\n 179: iload 8\n 181: iload 9\n 183: iadd\n 184: istore_3\n 185: goto 140\n 188: iload_3\n 189: ireturn\n\n private static final java.util.Map octopusGrid$lambda$2();\n Code:\n 0: new #178 // class java/io/File\n 3: dup\n 4: ldc #180 // String day11/input-Day11.kt.txt\n 6: invokespecial #183 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: invokestatic #189 // Method java/nio/charset/Charset.defaultCharset:()Ljava/nio/charset/Charset;\n 12: dup\n 13: ldc #191 // String defaultCharset(...)\n 15: invokestatic #52 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: invokestatic #197 // Method kotlin/io/FilesKt.readLines:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/util/List;\n 21: checkcast #60 // class java/lang/Iterable\n 24: astore_0\n 25: getstatic #200 // Field INSTANCE:LDay11;\n 28: astore_1\n 29: iconst_0\n 30: istore_2\n 31: aload_0\n 32: astore_3\n 33: new #62 // class java/util/ArrayList\n 36: dup\n 37: aload_0\n 38: bipush 10\n 40: invokestatic #68 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 43: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 46: checkcast #73 // class java/util/Collection\n 49: astore 4\n 51: iconst_0\n 52: istore 5\n 54: iconst_0\n 55: istore 6\n 57: aload_3\n 58: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 63: astore 7\n 65: aload 7\n 67: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 72: ifeq 137\n 75: aload 7\n 77: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 82: astore 8\n 84: aload 4\n 86: iload 6\n 88: iinc 6, 1\n 91: istore 9\n 93: iload 9\n 95: ifge 101\n 98: invokestatic #90 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 101: iload 9\n 103: aload 8\n 105: checkcast #15 // class java/lang/String\n 108: astore 10\n 110: istore 11\n 112: astore 13\n 114: iconst_0\n 115: istore 12\n 117: aload_1\n 118: iload 11\n 120: aload 10\n 122: invokespecial #202 // Method toCoordinates:(ILjava/lang/String;)Ljava/util/List;\n 125: aload 13\n 127: swap\n 128: invokeinterface #117, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 133: pop\n 134: goto 65\n 137: aload 4\n 139: checkcast #119 // class java/util/List\n 142: nop\n 143: checkcast #60 // class java/lang/Iterable\n 146: invokestatic #206 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 149: checkcast #60 // class java/lang/Iterable\n 152: astore_0\n 153: nop\n 154: iconst_0\n 155: istore_1\n 156: aload_0\n 157: bipush 10\n 159: invokestatic #68 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 162: invokestatic #211 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 165: bipush 16\n 167: invokestatic #217 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 170: istore_2\n 171: aload_0\n 172: astore_3\n 173: new #219 // class java/util/LinkedHashMap\n 176: dup\n 177: iload_2\n 178: invokespecial #220 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 181: checkcast #149 // class java/util/Map\n 184: astore 4\n 186: iconst_0\n 187: istore 5\n 189: aload_3\n 190: invokeinterface #77, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 195: astore 6\n 197: aload 6\n 199: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 204: ifeq 255\n 207: aload 6\n 209: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 214: astore 7\n 216: aload 4\n 218: astore 8\n 220: aload 7\n 222: checkcast #222 // class kotlin/Pair\n 225: astore 9\n 227: iconst_0\n 228: istore 10\n 230: aload 9\n 232: astore 9\n 234: aload 8\n 236: aload 9\n 238: invokevirtual #225 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 241: aload 9\n 243: invokevirtual #228 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 246: invokeinterface #232, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 251: pop\n 252: goto 197\n 255: aload 4\n 257: nop\n 258: areturn\n\n public static final int access$step(Day11, java.util.Map);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #247 // Method step:(Ljava/util/Map;)I\n 5: ireturn\n\n static {};\n Code:\n 0: new #2 // class Day11\n 3: dup\n 4: invokespecial #251 // Method \"<init>\":()V\n 7: putstatic #200 // Field INSTANCE:LDay11;\n 10: invokedynamic #259, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function0;\n 15: putstatic #144 // Field octopusGrid:Lkotlin/jvm/functions/Function0;\n 18: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day11$Part2.class", "javap": "Compiled from \"Day11.kt\"\npublic final class Day11$Part2 {\n public static final Day11$Part2 INSTANCE;\n\n private Day11$Part2();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final boolean isNotComplete(java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day11$Octopus>);\n Code:\n 0: getstatic #19 // Field Day11.INSTANCE:LDay11;\n 3: aload_1\n 4: invokestatic #23 // Method Day11.access$step:(LDay11;Ljava/util/Map;)I\n 7: istore_2\n 8: iload_2\n 9: aload_1\n 10: invokeinterface #29, 1 // InterfaceMethod java/util/Map.size:()I\n 15: if_icmpeq 22\n 18: iconst_1\n 19: goto 23\n 22: iconst_0\n 23: ireturn\n\n public final void run();\n Code:\n 0: getstatic #19 // Field Day11.INSTANCE:LDay11;\n 3: invokevirtual #38 // Method Day11.getOctopusGrid:()Lkotlin/jvm/functions/Function0;\n 6: invokeinterface #44, 1 // InterfaceMethod kotlin/jvm/functions/Function0.invoke:()Ljava/lang/Object;\n 11: checkcast #25 // class java/util/Map\n 14: astore_1\n 15: iconst_0\n 16: istore_2\n 17: iinc 2, 1\n 20: aload_0\n 21: aload_1\n 22: invokespecial #46 // Method isNotComplete:(Ljava/util/Map;)Z\n 25: ifne 17\n 28: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 31: iload_2\n 32: invokevirtual #58 // Method java/io/PrintStream.println:(I)V\n 35: return\n\n static {};\n Code:\n 0: new #2 // class Day11$Part2\n 3: dup\n 4: invokespecial #62 // Method \"<init>\":()V\n 7: putstatic #64 // Field INSTANCE:LDay11$Part2;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day11$Octopus.class", "javap": "Compiled from \"Day11.kt\"\npublic final class Day11$Octopus {\n private kotlin.Pair<java.lang.Integer, java.lang.Integer> coord;\n\n private int score;\n\n private boolean hasFlashed;\n\n public Day11$Octopus(kotlin.Pair<java.lang.Integer, java.lang.Integer>, int, boolean);\n Code:\n 0: aload_1\n 1: ldc #10 // String coord\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #19 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #22 // Field coord:Lkotlin/Pair;\n 15: aload_0\n 16: iload_2\n 17: putfield #26 // Field score:I\n 20: aload_0\n 21: iload_3\n 22: putfield #30 // Field hasFlashed:Z\n 25: return\n\n public Day11$Octopus(kotlin.Pair, int, boolean, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload 4\n 2: iconst_4\n 3: iand\n 4: ifeq 9\n 7: iconst_0\n 8: istore_3\n 9: aload_0\n 10: aload_1\n 11: iload_2\n 12: iload_3\n 13: invokespecial #35 // Method \"<init>\":(Lkotlin/Pair;IZ)V\n 16: return\n\n public final kotlin.Pair<java.lang.Integer, java.lang.Integer> getCoord();\n Code:\n 0: aload_0\n 1: getfield #22 // Field coord:Lkotlin/Pair;\n 4: areturn\n\n public final void setCoord(kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_1\n 1: ldc #43 // 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: aload_1\n 8: putfield #22 // Field coord:Lkotlin/Pair;\n 11: return\n\n public final int getScore();\n Code:\n 0: aload_0\n 1: getfield #26 // Field score:I\n 4: ireturn\n\n public final void setScore(int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #26 // Field score:I\n 5: return\n\n public final boolean getHasFlashed();\n Code:\n 0: aload_0\n 1: getfield #30 // Field hasFlashed:Z\n 4: ireturn\n\n public final void setHasFlashed(boolean);\n Code:\n 0: aload_0\n 1: iload_1\n 2: putfield #30 // Field hasFlashed:Z\n 5: return\n\n public final int increment();\n Code:\n 0: aload_0\n 1: getfield #26 // Field score:I\n 4: istore_1\n 5: aload_0\n 6: iload_1\n 7: iconst_1\n 8: iadd\n 9: putfield #26 // Field score:I\n 12: iload_1\n 13: ireturn\n\n private final boolean needsToFlash();\n Code:\n 0: aload_0\n 1: getfield #26 // Field score:I\n 4: bipush 9\n 6: if_icmple 20\n 9: aload_0\n 10: getfield #30 // Field hasFlashed:Z\n 13: ifne 20\n 16: iconst_1\n 17: goto 21\n 20: iconst_0\n 21: ireturn\n\n private final void flash();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: putfield #30 // Field hasFlashed:Z\n 5: return\n\n public final int reset();\n Code:\n 0: aload_0\n 1: getfield #30 // Field hasFlashed:Z\n 4: ifeq 21\n 7: aload_0\n 8: iconst_0\n 9: putfield #30 // Field hasFlashed:Z\n 12: aload_0\n 13: iconst_0\n 14: putfield #26 // Field score:I\n 17: iconst_1\n 18: goto 22\n 21: iconst_0\n 22: ireturn\n\n private final kotlin.sequences.Sequence<Day11$Octopus> getNeighbours(java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day11$Octopus>, java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>>);\n Code:\n 0: aload_2\n 1: checkcast #60 // class java/lang/Iterable\n 4: invokestatic #66 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 7: aload_0\n 8: invokedynamic #86, 0 // InvokeDynamic #0:invoke:(LDay11$Octopus;)Lkotlin/jvm/functions/Function1;\n 13: invokestatic #92 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 16: aload_1\n 17: invokedynamic #102, 0 // InvokeDynamic #1:invoke:(Ljava/util/Map;)Lkotlin/jvm/functions/Function1;\n 22: invokestatic #105 // Method kotlin/sequences/SequencesKt.mapNotNull:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 25: areturn\n\n static kotlin.sequences.Sequence getNeighbours$default(Day11$Octopus, java.util.Map, java.util.List, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_2\n 2: iand\n 3: ifeq 141\n 6: bipush 8\n 8: anewarray #113 // class kotlin/Pair\n 11: astore 5\n 13: aload 5\n 15: iconst_0\n 16: iconst_m1\n 17: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 20: iconst_0\n 21: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 24: invokestatic #125 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 27: aastore\n 28: aload 5\n 30: iconst_1\n 31: iconst_0\n 32: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: iconst_m1\n 36: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 39: invokestatic #125 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 42: aastore\n 43: aload 5\n 45: iconst_2\n 46: iconst_1\n 47: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 50: iconst_0\n 51: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 54: invokestatic #125 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 57: aastore\n 58: aload 5\n 60: iconst_3\n 61: iconst_0\n 62: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 65: iconst_1\n 66: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 69: invokestatic #125 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 72: aastore\n 73: aload 5\n 75: iconst_4\n 76: iconst_m1\n 77: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 80: iconst_m1\n 81: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 84: invokestatic #125 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 87: aastore\n 88: aload 5\n 90: iconst_5\n 91: iconst_1\n 92: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 95: iconst_1\n 96: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 99: invokestatic #125 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 102: aastore\n 103: aload 5\n 105: bipush 6\n 107: iconst_m1\n 108: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 111: iconst_1\n 112: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 115: invokestatic #125 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 118: aastore\n 119: aload 5\n 121: bipush 7\n 123: iconst_1\n 124: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 127: iconst_m1\n 128: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 131: invokestatic #125 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 134: aastore\n 135: aload 5\n 137: invokestatic #129 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 140: astore_2\n 141: aload_0\n 142: aload_1\n 143: aload_2\n 144: invokespecial #131 // Method getNeighbours:(Ljava/util/Map;Ljava/util/List;)Lkotlin/sequences/Sequence;\n 147: areturn\n\n public final void check(java.util.Map<kotlin.Pair<java.lang.Integer, java.lang.Integer>, Day11$Octopus>);\n Code:\n 0: aload_1\n 1: ldc #136 // String grid\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #138 // Method needsToFlash:()Z\n 10: ifeq 82\n 13: aload_0\n 14: invokespecial #140 // Method flash:()V\n 17: aload_0\n 18: aload_1\n 19: aconst_null\n 20: iconst_2\n 21: aconst_null\n 22: invokestatic #142 // Method getNeighbours$default:(LDay11$Octopus;Ljava/util/Map;Ljava/util/List;ILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 25: astore_2\n 26: iconst_0\n 27: istore_3\n 28: aload_2\n 29: invokeinterface #148, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 34: astore 4\n 36: aload 4\n 38: invokeinterface #153, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 43: ifeq 81\n 46: aload 4\n 48: invokeinterface #157, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 53: astore 5\n 55: aload 5\n 57: checkcast #2 // class Day11$Octopus\n 60: astore 6\n 62: iconst_0\n 63: istore 7\n 65: aload 6\n 67: invokevirtual #159 // Method increment:()I\n 70: pop\n 71: aload 6\n 73: aload_1\n 74: invokevirtual #161 // Method check:(Ljava/util/Map;)V\n 77: nop\n 78: goto 36\n 81: nop\n 82: return\n\n public final kotlin.Pair<java.lang.Integer, java.lang.Integer> component1();\n Code:\n 0: aload_0\n 1: getfield #22 // Field coord:Lkotlin/Pair;\n 4: areturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #26 // Field score:I\n 4: ireturn\n\n public final boolean component3();\n Code:\n 0: aload_0\n 1: getfield #30 // Field hasFlashed:Z\n 4: ireturn\n\n public final Day11$Octopus copy(kotlin.Pair<java.lang.Integer, java.lang.Integer>, int, boolean);\n Code:\n 0: aload_1\n 1: ldc #10 // String coord\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day11$Octopus\n 9: dup\n 10: aload_1\n 11: iload_2\n 12: iload_3\n 13: invokespecial #35 // Method \"<init>\":(Lkotlin/Pair;IZ)V\n 16: areturn\n\n public static Day11$Octopus copy$default(Day11$Octopus, kotlin.Pair, int, boolean, 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 #22 // Field coord:Lkotlin/Pair;\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 #26 // Field score: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 #30 // Field hasFlashed:Z\n 35: istore_3\n 36: aload_0\n 37: aload_1\n 38: iload_2\n 39: iload_3\n 40: invokevirtual #178 // Method copy:(Lkotlin/Pair;IZ)LDay11$Octopus;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #182 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #183 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #185 // String Octopus(coord=\n 9: invokevirtual #189 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #22 // Field coord:Lkotlin/Pair;\n 16: invokevirtual #192 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #194 // String , score=\n 21: invokevirtual #189 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #26 // Field score:I\n 28: invokevirtual #197 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #199 // String , hasFlashed=\n 33: invokevirtual #189 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #30 // Field hasFlashed:Z\n 40: invokevirtual #202 // Method java/lang/StringBuilder.append:(Z)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #205 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #207 // 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 #22 // Field coord:Lkotlin/Pair;\n 4: invokevirtual #210 // Method kotlin/Pair.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 score:I\n 16: invokestatic #213 // 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 #30 // Field hasFlashed:Z\n 29: invokestatic #218 // Method java/lang/Boolean.hashCode:(Z)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 Day11$Octopus\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day11$Octopus\n 20: astore_2\n 21: aload_0\n 22: getfield #22 // Field coord:Lkotlin/Pair;\n 25: aload_2\n 26: getfield #22 // Field coord:Lkotlin/Pair;\n 29: invokestatic #226 // 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 score:I\n 41: aload_2\n 42: getfield #26 // Field score:I\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: aload_0\n 51: getfield #30 // Field hasFlashed:Z\n 54: aload_2\n 55: getfield #30 // Field hasFlashed:Z\n 58: if_icmpeq 63\n 61: iconst_0\n 62: ireturn\n 63: iconst_1\n 64: ireturn\n\n private static final kotlin.Pair getNeighbours$lambda$0(Day11$Octopus, kotlin.Pair);\n Code:\n 0: aload_1\n 1: ldc #229 // String <destruct>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokevirtual #231 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 10: checkcast #233 // class java/lang/Number\n 13: invokevirtual #236 // Method java/lang/Number.intValue:()I\n 16: istore_2\n 17: aload_1\n 18: invokevirtual #238 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 21: checkcast #233 // class java/lang/Number\n 24: invokevirtual #236 // Method java/lang/Number.intValue:()I\n 27: istore_3\n 28: aload_0\n 29: getfield #22 // Field coord:Lkotlin/Pair;\n 32: invokevirtual #241 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 35: checkcast #233 // class java/lang/Number\n 38: invokevirtual #236 // Method java/lang/Number.intValue:()I\n 41: iload_2\n 42: iadd\n 43: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 46: aload_0\n 47: getfield #22 // Field coord:Lkotlin/Pair;\n 50: invokevirtual #244 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 53: checkcast #233 // class java/lang/Number\n 56: invokevirtual #236 // Method java/lang/Number.intValue:()I\n 59: iload_3\n 60: iadd\n 61: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 64: invokestatic #125 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 67: areturn\n\n private static final Day11$Octopus getNeighbours$lambda$1(java.util.Map, kotlin.Pair);\n Code:\n 0: aload_1\n 1: ldc #248 // 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: aload_1\n 8: invokeinterface #253, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 13: checkcast #2 // class Day11$Octopus\n 16: areturn\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day11Kt.class", "javap": "Compiled from \"Day11.kt\"\npublic final class Day11Kt {\n public static final void main();\n Code:\n 0: getstatic #12 // Field Day11$Part1.INSTANCE:LDay11$Part1;\n 3: invokevirtual #15 // Method Day11$Part1.run:()V\n 6: getstatic #20 // Field Day11$Part2.INSTANCE:LDay11$Part2;\n 9: invokevirtual #21 // Method Day11$Part2.run:()V\n 12: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #24 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
andrewrlee__adventOfCode2021__aace0fc/src/main/kotlin/Day13.kt
import java.io.File import java.nio.charset.StandardCharsets.UTF_8 object Day13 { data class Coord(val x: Int, val y: Int) { constructor(coord: Pair<Int, Int>) : this(coord.first, coord.second) } enum class Direction { x { override fun extract(c: Coord) = c.x override fun adjust(c: Coord, value: Int) = Coord((c.x - (c.x - value) * 2) to c.y) }, y { override fun extract(c: Coord) = c.y override fun adjust(c: Coord, value: Int) = Coord(c.x to (c.y - (c.y - value) * 2)) }; abstract fun extract(coord: Coord): Int abstract fun adjust(coord: Coord, value: Int): Coord } private fun toCoordinates(line: String) = line .split(",".toRegex()) .map(Integer::parseInt) .let { Coord(it[0] to it[1]) } private fun toInstructions(line: String): Pair<Direction, Int> { val (axis, value) = "fold along (.)=(.+)".toRegex().find(line)!!.destructured return Direction.valueOf(axis) to Integer.parseInt(value) } private fun fold(instruction: Pair<Direction, Int>, coordinates: Collection<Coord>): Set<Coord> { val (top, bottom) = coordinates.partition { instruction.first.extract(it) > instruction.second } val adjusted = top.map { instruction.first.adjust(it, instruction.second) } return bottom.toMutableSet() + adjusted } private fun draw(coordinates: Collection<Coord>) { println("\n") println("Contains: ${coordinates.size}") val maxCols = coordinates.maxOf { it.x } val maxRows = coordinates.maxOf { it.y } (0..maxRows).forEach { row -> (0..maxCols).forEach { col -> print(if (coordinates.contains(Coord(col, row))) "#" else ".") } println() } } object Part1 { fun run() { val (instr, coords) = File("day13/input-real.txt") .readLines(UTF_8) .partition { it.startsWith("fold along") } val coordinates = coords.filter { it.isNotBlank() }.map(::toCoordinates) val instructions = instr.map(::toInstructions) val first = fold(instructions.first(), coordinates) println(first.size) } } object Part2 { fun run() { val (instr, coords) = File("day13/input-real.txt") .readLines(UTF_8) .partition { it.startsWith("fold along") } val coordinates: Collection<Coord> = coords.filter { it.isNotBlank() }.map(::toCoordinates) val instructions = instr.map(::toInstructions) val result = instructions.fold(coordinates) { acc, i -> fold(i, acc) } draw(result) // L R G P R E C B } } } fun main() { Day13.Part1.run() Day13.Part2.run() }
[ { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day13.class", "javap": "Compiled from \"Day13.kt\"\npublic final class Day13 {\n public static final Day13 INSTANCE;\n\n private Day13();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final Day13$Coord toCoordinates(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #14 // class java/lang/CharSequence\n 4: astore_2\n 5: new #16 // class kotlin/text/Regex\n 8: dup\n 9: ldc #18 // String ,\n 11: invokespecial #21 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 14: astore_3\n 15: iconst_0\n 16: istore 4\n 18: aload_3\n 19: aload_2\n 20: iload 4\n 22: invokevirtual #25 // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 25: checkcast #27 // class java/lang/Iterable\n 28: astore_2\n 29: nop\n 30: iconst_0\n 31: istore_3\n 32: aload_2\n 33: astore 4\n 35: new #29 // class java/util/ArrayList\n 38: dup\n 39: aload_2\n 40: bipush 10\n 42: invokestatic #35 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 45: invokespecial #38 // Method java/util/ArrayList.\"<init>\":(I)V\n 48: checkcast #40 // class java/util/Collection\n 51: astore 5\n 53: iconst_0\n 54: istore 6\n 56: aload 4\n 58: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 63: astore 7\n 65: aload 7\n 67: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 72: ifeq 118\n 75: aload 7\n 77: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 82: astore 8\n 84: aload 5\n 86: aload 8\n 88: checkcast #56 // class java/lang/String\n 91: astore 9\n 93: astore 11\n 95: iconst_0\n 96: istore 10\n 98: aload 9\n 100: invokestatic #62 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 103: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 106: aload 11\n 108: swap\n 109: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 114: pop\n 115: goto 65\n 118: aload 5\n 120: checkcast #72 // class java/util/List\n 123: nop\n 124: astore_3\n 125: iconst_0\n 126: istore 4\n 128: new #74 // class Day13$Coord\n 131: dup\n 132: aload_3\n 133: iconst_0\n 134: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 139: aload_3\n 140: iconst_1\n 141: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 146: invokestatic #84 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 149: invokespecial #87 // Method Day13$Coord.\"<init>\":(Lkotlin/Pair;)V\n 152: nop\n 153: areturn\n\n private final kotlin.Pair<Day13$Direction, java.lang.Integer> toInstructions(java.lang.String);\n Code:\n 0: new #16 // class kotlin/text/Regex\n 3: dup\n 4: ldc #109 // String fold along (.)=(.+)\n 6: invokespecial #21 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: aload_1\n 10: checkcast #14 // class java/lang/CharSequence\n 13: iconst_0\n 14: iconst_2\n 15: aconst_null\n 16: invokestatic #113 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 19: dup\n 20: invokestatic #119 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 23: invokeinterface #125, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 28: astore_2\n 29: aload_2\n 30: invokevirtual #131 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 33: invokeinterface #135, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 38: iconst_1\n 39: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 44: checkcast #56 // class java/lang/String\n 47: astore_3\n 48: aload_2\n 49: invokevirtual #131 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 52: invokeinterface #135, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 57: iconst_2\n 58: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 63: checkcast #56 // class java/lang/String\n 66: astore 4\n 68: aload_3\n 69: invokestatic #140 // Method Day13$Direction.valueOf:(Ljava/lang/String;)LDay13$Direction;\n 72: aload 4\n 74: invokestatic #62 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 77: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 80: invokestatic #84 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 83: areturn\n\n private final java.util.Set<Day13$Coord> fold(kotlin.Pair<? extends Day13$Direction, java.lang.Integer>, java.util.Collection<Day13$Coord>);\n Code:\n 0: aload_2\n 1: checkcast #27 // class java/lang/Iterable\n 4: astore 4\n 6: iconst_0\n 7: istore 5\n 9: new #29 // class java/util/ArrayList\n 12: dup\n 13: invokespecial #146 // Method java/util/ArrayList.\"<init>\":()V\n 16: astore 6\n 18: new #29 // class java/util/ArrayList\n 21: dup\n 22: invokespecial #146 // Method java/util/ArrayList.\"<init>\":()V\n 25: astore 7\n 27: aload 4\n 29: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 34: astore 8\n 36: aload 8\n 38: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 43: ifeq 119\n 46: aload 8\n 48: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 53: astore 9\n 55: aload 9\n 57: checkcast #74 // class Day13$Coord\n 60: astore 10\n 62: iconst_0\n 63: istore 11\n 65: aload_1\n 66: invokevirtual #151 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 69: checkcast #137 // class Day13$Direction\n 72: aload 10\n 74: invokevirtual #155 // Method Day13$Direction.extract:(LDay13$Coord;)I\n 77: aload_1\n 78: invokevirtual #158 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 81: checkcast #160 // class java/lang/Number\n 84: invokevirtual #164 // Method java/lang/Number.intValue:()I\n 87: if_icmple 94\n 90: iconst_1\n 91: goto 95\n 94: iconst_0\n 95: ifeq 108\n 98: aload 6\n 100: aload 9\n 102: invokevirtual #165 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 105: goto 115\n 108: aload 7\n 110: aload 9\n 112: invokevirtual #165 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 115: pop\n 116: goto 36\n 119: new #148 // class kotlin/Pair\n 122: dup\n 123: aload 6\n 125: aload 7\n 127: invokespecial #168 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 130: astore_3\n 131: aload_3\n 132: invokevirtual #171 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 135: checkcast #72 // class java/util/List\n 138: astore 4\n 140: aload_3\n 141: invokevirtual #174 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 144: checkcast #72 // class java/util/List\n 147: astore 5\n 149: aload 4\n 151: checkcast #27 // class java/lang/Iterable\n 154: astore 7\n 156: iconst_0\n 157: istore 8\n 159: aload 7\n 161: astore 9\n 163: new #29 // class java/util/ArrayList\n 166: dup\n 167: aload 7\n 169: bipush 10\n 171: invokestatic #35 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 174: invokespecial #38 // Method java/util/ArrayList.\"<init>\":(I)V\n 177: checkcast #40 // class java/util/Collection\n 180: astore 10\n 182: iconst_0\n 183: istore 11\n 185: aload 9\n 187: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 192: astore 12\n 194: aload 12\n 196: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 201: ifeq 261\n 204: aload 12\n 206: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 211: astore 13\n 213: aload 10\n 215: aload 13\n 217: checkcast #74 // class Day13$Coord\n 220: astore 14\n 222: astore 16\n 224: iconst_0\n 225: istore 15\n 227: aload_1\n 228: invokevirtual #151 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 231: checkcast #137 // class Day13$Direction\n 234: aload 14\n 236: aload_1\n 237: invokevirtual #158 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 240: checkcast #160 // class java/lang/Number\n 243: invokevirtual #164 // Method java/lang/Number.intValue:()I\n 246: invokevirtual #178 // Method Day13$Direction.adjust:(LDay13$Coord;I)LDay13$Coord;\n 249: aload 16\n 251: swap\n 252: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 257: pop\n 258: goto 194\n 261: aload 10\n 263: checkcast #72 // class java/util/List\n 266: nop\n 267: astore 6\n 269: aload 5\n 271: checkcast #27 // class java/lang/Iterable\n 274: invokestatic #182 // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 277: aload 6\n 279: checkcast #27 // class java/lang/Iterable\n 282: invokestatic #188 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Iterable;)Ljava/util/Set;\n 285: areturn\n\n private final void draw(java.util.Collection<Day13$Coord>);\n Code:\n 0: ldc #208 // String \\n\n 2: getstatic #214 // Field java/lang/System.out:Ljava/io/PrintStream;\n 5: swap\n 6: invokevirtual #219 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 9: new #221 // class java/lang/StringBuilder\n 12: dup\n 13: invokespecial #222 // Method java/lang/StringBuilder.\"<init>\":()V\n 16: ldc #224 // String Contains:\n 18: invokevirtual #228 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 21: aload_1\n 22: invokeinterface #231, 1 // InterfaceMethod java/util/Collection.size:()I\n 27: invokevirtual #234 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 30: invokevirtual #238 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 33: getstatic #214 // Field java/lang/System.out:Ljava/io/PrintStream;\n 36: swap\n 37: invokevirtual #219 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 40: aload_1\n 41: checkcast #27 // class java/lang/Iterable\n 44: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 49: astore 4\n 51: aload 4\n 53: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 58: ifne 69\n 61: new #240 // class java/util/NoSuchElementException\n 64: dup\n 65: invokespecial #241 // Method java/util/NoSuchElementException.\"<init>\":()V\n 68: athrow\n 69: aload 4\n 71: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 76: checkcast #74 // class Day13$Coord\n 79: astore 5\n 81: iconst_0\n 82: istore 6\n 84: aload 5\n 86: invokevirtual #244 // Method Day13$Coord.getX:()I\n 89: istore 5\n 91: aload 4\n 93: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 98: ifeq 137\n 101: aload 4\n 103: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 108: checkcast #74 // class Day13$Coord\n 111: astore 6\n 113: iconst_0\n 114: istore 7\n 116: aload 6\n 118: invokevirtual #244 // Method Day13$Coord.getX:()I\n 121: istore 6\n 123: iload 5\n 125: iload 6\n 127: if_icmpge 91\n 130: iload 6\n 132: istore 5\n 134: goto 91\n 137: iload 5\n 139: istore_2\n 140: aload_1\n 141: checkcast #27 // class java/lang/Iterable\n 144: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 149: astore 5\n 151: aload 5\n 153: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 158: ifne 169\n 161: new #240 // class java/util/NoSuchElementException\n 164: dup\n 165: invokespecial #241 // Method java/util/NoSuchElementException.\"<init>\":()V\n 168: athrow\n 169: aload 5\n 171: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 176: checkcast #74 // class Day13$Coord\n 179: astore 6\n 181: iconst_0\n 182: istore 7\n 184: aload 6\n 186: invokevirtual #247 // Method Day13$Coord.getY:()I\n 189: istore 6\n 191: aload 5\n 193: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 198: ifeq 237\n 201: aload 5\n 203: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 208: checkcast #74 // class Day13$Coord\n 211: astore 7\n 213: iconst_0\n 214: istore 8\n 216: aload 7\n 218: invokevirtual #247 // Method Day13$Coord.getY:()I\n 221: istore 7\n 223: iload 6\n 225: iload 7\n 227: if_icmpge 191\n 230: iload 7\n 232: istore 6\n 234: goto 191\n 237: iload 6\n 239: istore_3\n 240: new #249 // class kotlin/ranges/IntRange\n 243: dup\n 244: iconst_0\n 245: iload_3\n 246: invokespecial #252 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 249: checkcast #27 // class java/lang/Iterable\n 252: astore 4\n 254: iconst_0\n 255: istore 5\n 257: aload 4\n 259: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 264: astore 6\n 266: aload 6\n 268: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 273: ifeq 399\n 276: aload 6\n 278: checkcast #254 // class kotlin/collections/IntIterator\n 281: invokevirtual #257 // Method kotlin/collections/IntIterator.nextInt:()I\n 284: istore 7\n 286: iload 7\n 288: istore 8\n 290: iconst_0\n 291: istore 9\n 293: new #249 // class kotlin/ranges/IntRange\n 296: dup\n 297: iconst_0\n 298: iload_2\n 299: invokespecial #252 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 302: checkcast #27 // class java/lang/Iterable\n 305: astore 10\n 307: iconst_0\n 308: istore 11\n 310: aload 10\n 312: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 317: astore 12\n 319: aload 12\n 321: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 326: ifeq 387\n 329: aload 12\n 331: checkcast #254 // class kotlin/collections/IntIterator\n 334: invokevirtual #257 // Method kotlin/collections/IntIterator.nextInt:()I\n 337: istore 13\n 339: iload 13\n 341: istore 14\n 343: iconst_0\n 344: istore 15\n 346: aload_1\n 347: new #74 // class Day13$Coord\n 350: dup\n 351: iload 14\n 353: iload 8\n 355: invokespecial #258 // Method Day13$Coord.\"<init>\":(II)V\n 358: invokeinterface #261, 2 // InterfaceMethod java/util/Collection.contains:(Ljava/lang/Object;)Z\n 363: ifeq 372\n 366: ldc_w #263 // String #\n 369: goto 375\n 372: ldc_w #265 // String .\n 375: getstatic #214 // Field java/lang/System.out:Ljava/io/PrintStream;\n 378: swap\n 379: invokevirtual #268 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 382: nop\n 383: nop\n 384: goto 319\n 387: nop\n 388: getstatic #214 // Field java/lang/System.out:Ljava/io/PrintStream;\n 391: invokevirtual #270 // Method java/io/PrintStream.println:()V\n 394: nop\n 395: nop\n 396: goto 266\n 399: nop\n 400: return\n\n public static final java.util.Set access$fold(Day13, kotlin.Pair, java.util.Collection);\n Code:\n 0: aload_0\n 1: aload_1\n 2: aload_2\n 3: invokespecial #284 // Method fold:(Lkotlin/Pair;Ljava/util/Collection;)Ljava/util/Set;\n 6: areturn\n\n public static final Day13$Coord access$toCoordinates(Day13, java.lang.String);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #289 // Method toCoordinates:(Ljava/lang/String;)LDay13$Coord;\n 5: areturn\n\n public static final kotlin.Pair access$toInstructions(Day13, java.lang.String);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #293 // Method toInstructions:(Ljava/lang/String;)Lkotlin/Pair;\n 5: areturn\n\n public static final void access$draw(Day13, java.util.Collection);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #297 // Method draw:(Ljava/util/Collection;)V\n 5: return\n\n static {};\n Code:\n 0: new #2 // class Day13\n 3: dup\n 4: invokespecial #299 // Method \"<init>\":()V\n 7: putstatic #302 // Field INSTANCE:LDay13;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day13Kt.class", "javap": "Compiled from \"Day13.kt\"\npublic final class Day13Kt {\n public static final void main();\n Code:\n 0: getstatic #12 // Field Day13$Part1.INSTANCE:LDay13$Part1;\n 3: invokevirtual #15 // Method Day13$Part1.run:()V\n 6: getstatic #20 // Field Day13$Part2.INSTANCE:LDay13$Part2;\n 9: invokevirtual #21 // Method Day13$Part2.run:()V\n 12: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #24 // Method main:()V\n 3: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day13$Direction$y.class", "javap": "Compiled from \"Day13.kt\"\nfinal class Day13$Direction$y extends Day13$Direction {\n Day13$Direction$y();\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: aconst_null\n 4: invokespecial #10 // Method Day13$Direction.\"<init>\":(Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 7: return\n\n public int extract(Day13$Coord);\n Code:\n 0: aload_1\n 1: ldc #21 // String c\n 3: invokestatic #27 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokevirtual #33 // Method Day13$Coord.getY:()I\n 10: ireturn\n\n public Day13$Coord adjust(Day13$Coord, int);\n Code:\n 0: aload_1\n 1: ldc #21 // String c\n 3: invokestatic #27 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #29 // class Day13$Coord\n 9: dup\n 10: aload_1\n 11: invokevirtual #39 // Method Day13$Coord.getX:()I\n 14: invokestatic #45 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 17: aload_1\n 18: invokevirtual #33 // Method Day13$Coord.getY:()I\n 21: aload_1\n 22: invokevirtual #33 // Method Day13$Coord.getY:()I\n 25: iload_2\n 26: isub\n 27: iconst_2\n 28: imul\n 29: isub\n 30: invokestatic #45 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 33: invokestatic #51 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 36: invokespecial #54 // Method Day13$Coord.\"<init>\":(Lkotlin/Pair;)V\n 39: areturn\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day13$Coord.class", "javap": "Compiled from \"Day13.kt\"\npublic final class Day13$Coord {\n private final int x;\n\n private final int y;\n\n public Day13$Coord(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 x:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field y:I\n 14: return\n\n public final int getX();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int getY();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public Day13$Coord(kotlin.Pair<java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_1\n 1: ldc #26 // String coord\n 3: invokestatic #32 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokevirtual #38 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 11: checkcast #40 // class java/lang/Number\n 14: invokevirtual #43 // Method java/lang/Number.intValue:()I\n 17: aload_1\n 18: invokevirtual #46 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 21: checkcast #40 // class java/lang/Number\n 24: invokevirtual #43 // Method java/lang/Number.intValue:()I\n 27: invokespecial #48 // Method \"<init>\":(II)V\n 30: return\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public final Day13$Coord copy(int, int);\n Code:\n 0: new #2 // class Day13$Coord\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: invokespecial #48 // Method \"<init>\":(II)V\n 9: areturn\n\n public static Day13$Coord copy$default(Day13$Coord, int, int, 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 #13 // Field x:I\n 10: istore_1\n 11: iload_3\n 12: iconst_2\n 13: iand\n 14: ifeq 22\n 17: aload_0\n 18: getfield #16 // Field y:I\n 21: istore_2\n 22: aload_0\n 23: iload_1\n 24: iload_2\n 25: invokevirtual #57 // Method copy:(II)LDay13$Coord;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #61 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #62 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #64 // String Coord(x=\n 9: invokevirtual #68 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field x:I\n 16: invokevirtual #71 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #73 // String , y=\n 21: invokevirtual #68 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field y:I\n 28: invokevirtual #71 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #76 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #78 // 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 #13 // Field x:I\n 4: invokestatic #84 // 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 y:I\n 16: invokestatic #84 // Method java/lang/Integer.hashCode:(I)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 Day13$Coord\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day13$Coord\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field x:I\n 25: aload_2\n 26: getfield #13 // Field x:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field y:I\n 38: aload_2\n 39: getfield #16 // Field y:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: iconst_1\n 48: ireturn\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day13$Part2.class", "javap": "Compiled from \"Day13.kt\"\npublic final class Day13$Part2 {\n public static final Day13$Part2 INSTANCE;\n\n private Day13$Part2();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final void run();\n Code:\n 0: new #13 // class java/io/File\n 3: dup\n 4: ldc #15 // String day13/input-real.txt\n 6: invokespecial #18 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: getstatic #24 // Field java/nio/charset/StandardCharsets.UTF_8:Ljava/nio/charset/Charset;\n 12: dup\n 13: ldc #25 // String UTF_8\n 15: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: invokestatic #37 // Method kotlin/io/FilesKt.readLines:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/util/List;\n 21: checkcast #39 // class java/lang/Iterable\n 24: astore_2\n 25: nop\n 26: iconst_0\n 27: istore_3\n 28: new #41 // class java/util/ArrayList\n 31: dup\n 32: invokespecial #42 // Method java/util/ArrayList.\"<init>\":()V\n 35: astore 4\n 37: new #41 // class java/util/ArrayList\n 40: dup\n 41: invokespecial #42 // Method java/util/ArrayList.\"<init>\":()V\n 44: astore 5\n 46: aload_2\n 47: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 52: astore 6\n 54: aload 6\n 56: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 61: ifeq 117\n 64: aload 6\n 66: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 71: astore 7\n 73: aload 7\n 75: checkcast #58 // class java/lang/String\n 78: astore 8\n 80: iconst_0\n 81: istore 9\n 83: aload 8\n 85: ldc #60 // String fold along\n 87: iconst_0\n 88: iconst_2\n 89: aconst_null\n 90: invokestatic #66 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 93: ifeq 106\n 96: aload 4\n 98: aload 7\n 100: invokevirtual #70 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 103: goto 113\n 106: aload 5\n 108: aload 7\n 110: invokevirtual #70 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 113: pop\n 114: goto 54\n 117: new #72 // class kotlin/Pair\n 120: dup\n 121: aload 4\n 123: aload 5\n 125: invokespecial #75 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 128: astore_1\n 129: aload_1\n 130: invokevirtual #78 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 133: checkcast #80 // class java/util/List\n 136: astore_2\n 137: aload_1\n 138: invokevirtual #83 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 141: checkcast #80 // class java/util/List\n 144: astore_3\n 145: aload_3\n 146: checkcast #39 // class java/lang/Iterable\n 149: astore 5\n 151: iconst_0\n 152: istore 6\n 154: aload 5\n 156: astore 7\n 158: new #41 // class java/util/ArrayList\n 161: dup\n 162: invokespecial #42 // Method java/util/ArrayList.\"<init>\":()V\n 165: checkcast #85 // class java/util/Collection\n 168: astore 8\n 170: iconst_0\n 171: istore 9\n 173: aload 7\n 175: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 180: astore 10\n 182: aload 10\n 184: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 189: ifeq 244\n 192: aload 10\n 194: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 199: astore 11\n 201: aload 11\n 203: checkcast #58 // class java/lang/String\n 206: astore 12\n 208: iconst_0\n 209: istore 13\n 211: aload 12\n 213: checkcast #87 // class java/lang/CharSequence\n 216: invokestatic #91 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 219: ifne 226\n 222: iconst_1\n 223: goto 227\n 226: iconst_0\n 227: nop\n 228: ifeq 182\n 231: aload 8\n 233: aload 11\n 235: invokeinterface #92, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 240: pop\n 241: goto 182\n 244: aload 8\n 246: checkcast #80 // class java/util/List\n 249: nop\n 250: checkcast #39 // class java/lang/Iterable\n 253: astore 5\n 255: getstatic #98 // Field Day13.INSTANCE:LDay13;\n 258: astore 6\n 260: iconst_0\n 261: istore 7\n 263: aload 5\n 265: astore 8\n 267: new #41 // class java/util/ArrayList\n 270: dup\n 271: aload 5\n 273: bipush 10\n 275: invokestatic #104 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 278: invokespecial #107 // Method java/util/ArrayList.\"<init>\":(I)V\n 281: checkcast #85 // class java/util/Collection\n 284: astore 9\n 286: iconst_0\n 287: istore 10\n 289: aload 8\n 291: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 296: astore 11\n 298: aload 11\n 300: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 305: ifeq 350\n 308: aload 11\n 310: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 315: astore 12\n 317: aload 9\n 319: aload 12\n 321: checkcast #58 // class java/lang/String\n 324: astore 13\n 326: astore 16\n 328: iconst_0\n 329: istore 14\n 331: aload 6\n 333: aload 13\n 335: invokestatic #111 // Method Day13.access$toCoordinates:(LDay13;Ljava/lang/String;)LDay13$Coord;\n 338: aload 16\n 340: swap\n 341: invokeinterface #92, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 346: pop\n 347: goto 298\n 350: aload 9\n 352: checkcast #80 // class java/util/List\n 355: nop\n 356: checkcast #85 // class java/util/Collection\n 359: astore 4\n 361: aload_2\n 362: checkcast #39 // class java/lang/Iterable\n 365: astore 6\n 367: getstatic #98 // Field Day13.INSTANCE:LDay13;\n 370: astore 7\n 372: iconst_0\n 373: istore 8\n 375: aload 6\n 377: astore 9\n 379: new #41 // class java/util/ArrayList\n 382: dup\n 383: aload 6\n 385: bipush 10\n 387: invokestatic #104 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 390: invokespecial #107 // Method java/util/ArrayList.\"<init>\":(I)V\n 393: checkcast #85 // class java/util/Collection\n 396: astore 10\n 398: iconst_0\n 399: istore 11\n 401: aload 9\n 403: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 408: astore 12\n 410: aload 12\n 412: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 417: ifeq 462\n 420: aload 12\n 422: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 427: astore 13\n 429: aload 10\n 431: aload 13\n 433: checkcast #58 // class java/lang/String\n 436: astore 14\n 438: astore 16\n 440: iconst_0\n 441: istore 15\n 443: aload 7\n 445: aload 14\n 447: invokestatic #115 // Method Day13.access$toInstructions:(LDay13;Ljava/lang/String;)Lkotlin/Pair;\n 450: aload 16\n 452: swap\n 453: invokeinterface #92, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 458: pop\n 459: goto 410\n 462: aload 10\n 464: checkcast #80 // class java/util/List\n 467: nop\n 468: astore 5\n 470: aload 5\n 472: checkcast #39 // class java/lang/Iterable\n 475: astore 7\n 477: iconst_0\n 478: istore 8\n 480: aload 4\n 482: astore 9\n 484: aload 7\n 486: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 491: astore 10\n 493: aload 10\n 495: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 500: ifeq 544\n 503: aload 10\n 505: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 510: astore 11\n 512: aload 9\n 514: aload 11\n 516: checkcast #72 // class kotlin/Pair\n 519: astore 12\n 521: astore 13\n 523: iconst_0\n 524: istore 14\n 526: getstatic #98 // Field Day13.INSTANCE:LDay13;\n 529: aload 12\n 531: aload 13\n 533: invokestatic #119 // Method Day13.access$fold:(LDay13;Lkotlin/Pair;Ljava/util/Collection;)Ljava/util/Set;\n 536: checkcast #85 // class java/util/Collection\n 539: astore 9\n 541: goto 493\n 544: aload 9\n 546: astore 6\n 548: getstatic #98 // Field Day13.INSTANCE:LDay13;\n 551: aload 6\n 553: invokestatic #123 // Method Day13.access$draw:(LDay13;Ljava/util/Collection;)V\n 556: return\n\n static {};\n Code:\n 0: new #2 // class Day13$Part2\n 3: dup\n 4: invokespecial #166 // Method \"<init>\":()V\n 7: putstatic #168 // Field INSTANCE:LDay13$Part2;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day13$Direction$x.class", "javap": "Compiled from \"Day13.kt\"\nfinal class Day13$Direction$x extends Day13$Direction {\n Day13$Direction$x();\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: aconst_null\n 4: invokespecial #10 // Method Day13$Direction.\"<init>\":(Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 7: return\n\n public int extract(Day13$Coord);\n Code:\n 0: aload_1\n 1: ldc #21 // String c\n 3: invokestatic #27 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokevirtual #33 // Method Day13$Coord.getX:()I\n 10: ireturn\n\n public Day13$Coord adjust(Day13$Coord, int);\n Code:\n 0: aload_1\n 1: ldc #21 // String c\n 3: invokestatic #27 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #29 // class Day13$Coord\n 9: dup\n 10: aload_1\n 11: invokevirtual #33 // Method Day13$Coord.getX:()I\n 14: aload_1\n 15: invokevirtual #33 // Method Day13$Coord.getX:()I\n 18: iload_2\n 19: isub\n 20: iconst_2\n 21: imul\n 22: isub\n 23: invokestatic #42 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 26: aload_1\n 27: invokevirtual #45 // Method Day13$Coord.getY:()I\n 30: invokestatic #42 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 33: invokestatic #51 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 36: invokespecial #54 // Method Day13$Coord.\"<init>\":(Lkotlin/Pair;)V\n 39: areturn\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day13$Direction.class", "javap": "Compiled from \"Day13.kt\"\npublic abstract class Day13$Direction extends java.lang.Enum<Day13$Direction> {\n public static final Day13$Direction x;\n\n public static final Day13$Direction y;\n\n private static final Day13$Direction[] $VALUES;\n\n private static final kotlin.enums.EnumEntries $ENTRIES;\n\n private Day13$Direction();\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: invokespecial #10 // Method java/lang/Enum.\"<init>\":(Ljava/lang/String;I)V\n 6: return\n\n public abstract int extract(Day13$Coord);\n\n public abstract Day13$Coord adjust(Day13$Coord, int);\n\n public static Day13$Direction[] values();\n Code:\n 0: getstatic #27 // Field $VALUES:[LDay13$Direction;\n 3: invokevirtual #33 // Method java/lang/Object.clone:()Ljava/lang/Object;\n 6: checkcast #34 // class \"[LDay13$Direction;\"\n 9: areturn\n\n public static Day13$Direction valueOf(java.lang.String);\n Code:\n 0: ldc #2 // class Day13$Direction\n 2: aload_0\n 3: invokestatic #39 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;\n 6: checkcast #2 // class Day13$Direction\n 9: areturn\n\n public static kotlin.enums.EnumEntries<Day13$Direction> getEntries();\n Code:\n 0: getstatic #47 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 3: areturn\n\n private static final Day13$Direction[] $values();\n Code:\n 0: iconst_2\n 1: anewarray #2 // class Day13$Direction\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: getstatic #51 // Field x:LDay13$Direction;\n 10: aastore\n 11: aload_0\n 12: iconst_1\n 13: getstatic #54 // Field y:LDay13$Direction;\n 16: aastore\n 17: aload_0\n 18: areturn\n\n public Day13$Direction(java.lang.String, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: invokespecial #56 // Method \"<init>\":(Ljava/lang/String;I)V\n 6: return\n\n static {};\n Code:\n 0: new #61 // class Day13$Direction$x\n 3: dup\n 4: ldc #62 // String x\n 6: iconst_0\n 7: invokespecial #63 // Method Day13$Direction$x.\"<init>\":(Ljava/lang/String;I)V\n 10: putstatic #51 // Field x:LDay13$Direction;\n 13: new #65 // class Day13$Direction$y\n 16: dup\n 17: ldc #66 // String y\n 19: iconst_1\n 20: invokespecial #67 // Method Day13$Direction$y.\"<init>\":(Ljava/lang/String;I)V\n 23: putstatic #54 // Field y:LDay13$Direction;\n 26: invokestatic #69 // Method $values:()[LDay13$Direction;\n 29: putstatic #27 // Field $VALUES:[LDay13$Direction;\n 32: getstatic #27 // Field $VALUES:[LDay13$Direction;\n 35: checkcast #71 // class \"[Ljava/lang/Enum;\"\n 38: invokestatic #77 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;\n 41: putstatic #47 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 44: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day13$Part1.class", "javap": "Compiled from \"Day13.kt\"\npublic final class Day13$Part1 {\n public static final Day13$Part1 INSTANCE;\n\n private Day13$Part1();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final void run();\n Code:\n 0: new #13 // class java/io/File\n 3: dup\n 4: ldc #15 // String day13/input-real.txt\n 6: invokespecial #18 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 9: getstatic #24 // Field java/nio/charset/StandardCharsets.UTF_8:Ljava/nio/charset/Charset;\n 12: dup\n 13: ldc #25 // String UTF_8\n 15: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: invokestatic #37 // Method kotlin/io/FilesKt.readLines:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/util/List;\n 21: checkcast #39 // class java/lang/Iterable\n 24: astore_2\n 25: nop\n 26: iconst_0\n 27: istore_3\n 28: new #41 // class java/util/ArrayList\n 31: dup\n 32: invokespecial #42 // Method java/util/ArrayList.\"<init>\":()V\n 35: astore 4\n 37: new #41 // class java/util/ArrayList\n 40: dup\n 41: invokespecial #42 // Method java/util/ArrayList.\"<init>\":()V\n 44: astore 5\n 46: aload_2\n 47: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 52: astore 6\n 54: aload 6\n 56: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 61: ifeq 117\n 64: aload 6\n 66: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 71: astore 7\n 73: aload 7\n 75: checkcast #58 // class java/lang/String\n 78: astore 8\n 80: iconst_0\n 81: istore 9\n 83: aload 8\n 85: ldc #60 // String fold along\n 87: iconst_0\n 88: iconst_2\n 89: aconst_null\n 90: invokestatic #66 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 93: ifeq 106\n 96: aload 4\n 98: aload 7\n 100: invokevirtual #70 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 103: goto 113\n 106: aload 5\n 108: aload 7\n 110: invokevirtual #70 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 113: pop\n 114: goto 54\n 117: new #72 // class kotlin/Pair\n 120: dup\n 121: aload 4\n 123: aload 5\n 125: invokespecial #75 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 128: astore_1\n 129: aload_1\n 130: invokevirtual #78 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 133: checkcast #80 // class java/util/List\n 136: astore_2\n 137: aload_1\n 138: invokevirtual #83 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 141: checkcast #80 // class java/util/List\n 144: astore_3\n 145: aload_3\n 146: checkcast #39 // class java/lang/Iterable\n 149: astore 5\n 151: iconst_0\n 152: istore 6\n 154: aload 5\n 156: astore 7\n 158: new #41 // class java/util/ArrayList\n 161: dup\n 162: invokespecial #42 // Method java/util/ArrayList.\"<init>\":()V\n 165: checkcast #85 // class java/util/Collection\n 168: astore 8\n 170: iconst_0\n 171: istore 9\n 173: aload 7\n 175: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 180: astore 10\n 182: aload 10\n 184: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 189: ifeq 244\n 192: aload 10\n 194: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 199: astore 11\n 201: aload 11\n 203: checkcast #58 // class java/lang/String\n 206: astore 12\n 208: iconst_0\n 209: istore 13\n 211: aload 12\n 213: checkcast #87 // class java/lang/CharSequence\n 216: invokestatic #91 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 219: ifne 226\n 222: iconst_1\n 223: goto 227\n 226: iconst_0\n 227: nop\n 228: ifeq 182\n 231: aload 8\n 233: aload 11\n 235: invokeinterface #92, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 240: pop\n 241: goto 182\n 244: aload 8\n 246: checkcast #80 // class java/util/List\n 249: nop\n 250: checkcast #39 // class java/lang/Iterable\n 253: astore 5\n 255: getstatic #98 // Field Day13.INSTANCE:LDay13;\n 258: astore 6\n 260: iconst_0\n 261: istore 7\n 263: aload 5\n 265: astore 8\n 267: new #41 // class java/util/ArrayList\n 270: dup\n 271: aload 5\n 273: bipush 10\n 275: invokestatic #104 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 278: invokespecial #107 // Method java/util/ArrayList.\"<init>\":(I)V\n 281: checkcast #85 // class java/util/Collection\n 284: astore 9\n 286: iconst_0\n 287: istore 10\n 289: aload 8\n 291: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 296: astore 11\n 298: aload 11\n 300: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 305: ifeq 350\n 308: aload 11\n 310: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 315: astore 12\n 317: aload 9\n 319: aload 12\n 321: checkcast #58 // class java/lang/String\n 324: astore 13\n 326: astore 16\n 328: iconst_0\n 329: istore 14\n 331: aload 6\n 333: aload 13\n 335: invokestatic #111 // Method Day13.access$toCoordinates:(LDay13;Ljava/lang/String;)LDay13$Coord;\n 338: aload 16\n 340: swap\n 341: invokeinterface #92, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 346: pop\n 347: goto 298\n 350: aload 9\n 352: checkcast #80 // class java/util/List\n 355: nop\n 356: astore 4\n 358: aload_2\n 359: checkcast #39 // class java/lang/Iterable\n 362: astore 6\n 364: getstatic #98 // Field Day13.INSTANCE:LDay13;\n 367: astore 7\n 369: iconst_0\n 370: istore 8\n 372: aload 6\n 374: astore 9\n 376: new #41 // class java/util/ArrayList\n 379: dup\n 380: aload 6\n 382: bipush 10\n 384: invokestatic #104 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 387: invokespecial #107 // Method java/util/ArrayList.\"<init>\":(I)V\n 390: checkcast #85 // class java/util/Collection\n 393: astore 10\n 395: iconst_0\n 396: istore 11\n 398: aload 9\n 400: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 405: astore 12\n 407: aload 12\n 409: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 414: ifeq 459\n 417: aload 12\n 419: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 424: astore 13\n 426: aload 10\n 428: aload 13\n 430: checkcast #58 // class java/lang/String\n 433: astore 14\n 435: astore 16\n 437: iconst_0\n 438: istore 15\n 440: aload 7\n 442: aload 14\n 444: invokestatic #115 // Method Day13.access$toInstructions:(LDay13;Ljava/lang/String;)Lkotlin/Pair;\n 447: aload 16\n 449: swap\n 450: invokeinterface #92, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 455: pop\n 456: goto 407\n 459: aload 10\n 461: checkcast #80 // class java/util/List\n 464: nop\n 465: astore 5\n 467: getstatic #98 // Field Day13.INSTANCE:LDay13;\n 470: aload 5\n 472: invokestatic #119 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 475: checkcast #72 // class kotlin/Pair\n 478: aload 4\n 480: checkcast #85 // class java/util/Collection\n 483: invokestatic #123 // Method Day13.access$fold:(LDay13;Lkotlin/Pair;Ljava/util/Collection;)Ljava/util/Set;\n 486: astore 6\n 488: aload 6\n 490: invokeinterface #129, 1 // InterfaceMethod java/util/Set.size:()I\n 495: istore 7\n 497: getstatic #135 // Field java/lang/System.out:Ljava/io/PrintStream;\n 500: iload 7\n 502: invokevirtual #140 // Method java/io/PrintStream.println:(I)V\n 505: return\n\n static {};\n Code:\n 0: new #2 // class Day13$Part1\n 3: dup\n 4: invokespecial #176 // Method \"<init>\":()V\n 7: putstatic #178 // Field INSTANCE:LDay13$Part1;\n 10: return\n}\n", "javap_err": "" } ]
andrewrlee__adventOfCode2021__aace0fc/src/main/kotlin/Day09.kt
import java.io.File import java.nio.charset.Charset.defaultCharset import kotlin.streams.toList typealias Coordinate = Pair<Int, Int> typealias Basin = Set<Coordinate> typealias ValidCells = Set<Coordinate> object Day09 { fun toCoordinates(row: Int, line: String) = line.chars() .map(Character::getNumericValue) .toList() .mapIndexed { col, value -> (row to col) to value } fun getSurroundingCoordinates( validCells: ValidCells, coord: Coordinate, seenCoordinates: HashSet<Coordinate>, deltas: List<Pair<Int, Int>> = listOf(0 to 1, 1 to 0, 0 to -1, -1 to 0) ) = deltas.asSequence() .map { (x2, y2) -> coord.first + x2 to coord.second + y2 } .filter { validCells.contains(it) } .filter { !seenCoordinates.contains(it) } fun findBasin(validCells: ValidCells, coordinate: Coordinate, seenCoordinates: HashSet<Coordinate>): Basin? { if (seenCoordinates.contains(coordinate)) return null seenCoordinates.add(coordinate) val basin = mutableSetOf(coordinate) getSurroundingCoordinates(validCells, coordinate, seenCoordinates) .filter { !seenCoordinates.contains(it) } .map { findBasin(validCells, it, seenCoordinates) } .filterNotNull() .forEach { basin.addAll(it) } return basin } fun run() { val file = File("day09/input-real.txt") val cells = file.readLines(defaultCharset()) .mapIndexed(::toCoordinates) .flatten() val (highs, unseen) = cells.partition { it.second == 9 } val validCells = cells.map { it.first }.toSet() val seenCoordinates = highs.map { it.first }.toHashSet() val toCheck = unseen.map { it.first } val basins = toCheck.fold(mutableListOf<Basin>()) { basins, coordinate -> findBasin(validCells, coordinate, seenCoordinates)?.let { basins.add(it) } basins } val result = basins.map { it.size }.sortedDescending().take(3).reduce(Int::times) println(result) } } fun main() { Day09.run() }
[ { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day09.class", "javap": "Compiled from \"Day09.kt\"\npublic final class Day09 {\n public static final Day09 INSTANCE;\n\n private Day09();\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.List<kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, java.lang.Integer>> toCoordinates(int, java.lang.String);\n Code:\n 0: aload_2\n 1: ldc #16 // String line\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: invokevirtual #28 // Method java/lang/String.chars:()Ljava/util/stream/IntStream;\n 10: invokedynamic #47, 0 // InvokeDynamic #0:applyAsInt:()Ljava/util/function/IntUnaryOperator;\n 15: invokeinterface #53, 2 // InterfaceMethod java/util/stream/IntStream.map:(Ljava/util/function/IntUnaryOperator;)Ljava/util/stream/IntStream;\n 20: dup\n 21: ldc #55 // String map(...)\n 23: invokestatic #58 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 26: invokestatic #64 // Method kotlin/streams/jdk8/StreamsKt.toList:(Ljava/util/stream/IntStream;)Ljava/util/List;\n 29: checkcast #66 // class java/lang/Iterable\n 32: astore_3\n 33: nop\n 34: iconst_0\n 35: istore 4\n 37: aload_3\n 38: astore 5\n 40: new #68 // class java/util/ArrayList\n 43: dup\n 44: aload_3\n 45: bipush 10\n 47: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 50: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 53: checkcast #79 // class java/util/Collection\n 56: astore 6\n 58: iconst_0\n 59: istore 7\n 61: iconst_0\n 62: istore 8\n 64: aload 5\n 66: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 71: astore 9\n 73: aload 9\n 75: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 80: ifeq 160\n 83: aload 9\n 85: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 90: astore 10\n 92: aload 6\n 94: iload 8\n 96: iinc 8, 1\n 99: istore 11\n 101: iload 11\n 103: ifge 109\n 106: invokestatic #96 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 109: iload 11\n 111: aload 10\n 113: checkcast #98 // class java/lang/Number\n 116: invokevirtual #102 // Method java/lang/Number.intValue:()I\n 119: istore 12\n 121: istore 13\n 123: astore 15\n 125: iconst_0\n 126: istore 14\n 128: iload_1\n 129: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 132: iload 13\n 134: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 137: invokestatic #114 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 140: iload 12\n 142: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 145: invokestatic #114 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 148: aload 15\n 150: swap\n 151: invokeinterface #118, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 156: pop\n 157: goto 73\n 160: aload 6\n 162: checkcast #120 // class java/util/List\n 165: nop\n 166: areturn\n\n public final kotlin.sequences.Sequence<kotlin.Pair<java.lang.Integer, java.lang.Integer>> getSurroundingCoordinates(java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>>, kotlin.Pair<java.lang.Integer, java.lang.Integer>, java.util.HashSet<kotlin.Pair<java.lang.Integer, java.lang.Integer>>, java.util.List<kotlin.Pair<java.lang.Integer, java.lang.Integer>>);\n Code:\n 0: aload_1\n 1: ldc #141 // String validCells\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #143 // String coord\n 9: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_3\n 13: ldc #145 // String seenCoordinates\n 15: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload 4\n 20: ldc #147 // String deltas\n 22: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 25: aload 4\n 27: checkcast #66 // class java/lang/Iterable\n 30: invokestatic #151 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 33: aload_2\n 34: invokedynamic #164, 0 // InvokeDynamic #1:invoke:(Lkotlin/Pair;)Lkotlin/jvm/functions/Function1;\n 39: invokestatic #169 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 42: aload_1\n 43: invokedynamic #179, 0 // InvokeDynamic #2:invoke:(Ljava/util/Set;)Lkotlin/jvm/functions/Function1;\n 48: invokestatic #182 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 51: aload_3\n 52: invokedynamic #190, 0 // InvokeDynamic #3:invoke:(Ljava/util/HashSet;)Lkotlin/jvm/functions/Function1;\n 57: invokestatic #182 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 60: areturn\n\n public static kotlin.sequences.Sequence getSurroundingCoordinates$default(Day09, java.util.Set, kotlin.Pair, java.util.HashSet, java.util.List, int, java.lang.Object);\n Code:\n 0: iload 5\n 2: bipush 8\n 4: iand\n 5: ifeq 81\n 8: iconst_4\n 9: anewarray #198 // class kotlin/Pair\n 12: astore 7\n 14: aload 7\n 16: iconst_0\n 17: iconst_0\n 18: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 21: iconst_1\n 22: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 25: invokestatic #114 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 28: aastore\n 29: aload 7\n 31: iconst_1\n 32: iconst_1\n 33: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 36: iconst_0\n 37: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 40: invokestatic #114 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 43: aastore\n 44: aload 7\n 46: iconst_2\n 47: iconst_0\n 48: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 51: iconst_m1\n 52: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 55: invokestatic #114 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 58: aastore\n 59: aload 7\n 61: iconst_3\n 62: iconst_m1\n 63: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 66: iconst_0\n 67: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 70: invokestatic #114 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 73: aastore\n 74: aload 7\n 76: invokestatic #202 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 79: astore 4\n 81: aload_0\n 82: aload_1\n 83: aload_2\n 84: aload_3\n 85: aload 4\n 87: invokevirtual #204 // Method getSurroundingCoordinates:(Ljava/util/Set;Lkotlin/Pair;Ljava/util/HashSet;Ljava/util/List;)Lkotlin/sequences/Sequence;\n 90: areturn\n\n public final java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>> findBasin(java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>>, kotlin.Pair<java.lang.Integer, java.lang.Integer>, java.util.HashSet<kotlin.Pair<java.lang.Integer, java.lang.Integer>>);\n Code:\n 0: aload_1\n 1: ldc #141 // String validCells\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #210 // String coordinate\n 9: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_3\n 13: ldc #145 // String seenCoordinates\n 15: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_3\n 19: aload_2\n 20: invokevirtual #215 // Method java/util/HashSet.contains:(Ljava/lang/Object;)Z\n 23: ifeq 28\n 26: aconst_null\n 27: areturn\n 28: aload_3\n 29: aload_2\n 30: invokevirtual #216 // Method java/util/HashSet.add:(Ljava/lang/Object;)Z\n 33: pop\n 34: iconst_1\n 35: anewarray #198 // class kotlin/Pair\n 38: astore 5\n 40: aload 5\n 42: iconst_0\n 43: aload_2\n 44: aastore\n 45: aload 5\n 47: invokestatic #222 // Method kotlin/collections/SetsKt.mutableSetOf:([Ljava/lang/Object;)Ljava/util/Set;\n 50: astore 4\n 52: aload_0\n 53: aload_1\n 54: aload_2\n 55: aload_3\n 56: aconst_null\n 57: bipush 8\n 59: aconst_null\n 60: invokestatic #224 // Method getSurroundingCoordinates$default:(LDay09;Ljava/util/Set;Lkotlin/Pair;Ljava/util/HashSet;Ljava/util/List;ILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 63: aload_3\n 64: invokedynamic #229, 0 // InvokeDynamic #4:invoke:(Ljava/util/HashSet;)Lkotlin/jvm/functions/Function1;\n 69: invokestatic #182 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 72: aload_1\n 73: aload_3\n 74: invokedynamic #239, 0 // InvokeDynamic #5:invoke:(Ljava/util/Set;Ljava/util/HashSet;)Lkotlin/jvm/functions/Function1;\n 79: invokestatic #169 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 82: invokestatic #243 // Method kotlin/sequences/SequencesKt.filterNotNull:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 85: astore 5\n 87: nop\n 88: iconst_0\n 89: istore 6\n 91: aload 5\n 93: invokeinterface #246, 1 // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;\n 98: astore 7\n 100: aload 7\n 102: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 107: ifeq 146\n 110: aload 7\n 112: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 117: astore 8\n 119: aload 8\n 121: checkcast #248 // class java/util/Set\n 124: astore 9\n 126: iconst_0\n 127: istore 10\n 129: aload 4\n 131: aload 9\n 133: checkcast #79 // class java/util/Collection\n 136: invokeinterface #252, 2 // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z\n 141: pop\n 142: nop\n 143: goto 100\n 146: nop\n 147: aload 4\n 149: areturn\n\n public final void run();\n Code:\n 0: new #262 // class java/io/File\n 3: dup\n 4: ldc_w #264 // String day09/input-real.txt\n 7: invokespecial #267 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 10: astore_1\n 11: aload_1\n 12: invokestatic #273 // Method java/nio/charset/Charset.defaultCharset:()Ljava/nio/charset/Charset;\n 15: dup\n 16: ldc_w #275 // String defaultCharset(...)\n 19: invokestatic #58 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 22: invokestatic #281 // Method kotlin/io/FilesKt.readLines:(Ljava/io/File;Ljava/nio/charset/Charset;)Ljava/util/List;\n 25: checkcast #66 // class java/lang/Iterable\n 28: astore_3\n 29: nop\n 30: iconst_0\n 31: istore 4\n 33: aload_3\n 34: astore 5\n 36: new #68 // class java/util/ArrayList\n 39: dup\n 40: aload_3\n 41: bipush 10\n 43: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 46: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 49: checkcast #79 // class java/util/Collection\n 52: astore 6\n 54: iconst_0\n 55: istore 7\n 57: iconst_0\n 58: istore 8\n 60: aload 5\n 62: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 67: astore 9\n 69: aload 9\n 71: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 76: ifeq 141\n 79: aload 9\n 81: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: astore 10\n 88: aload 6\n 90: iload 8\n 92: iinc 8, 1\n 95: istore 11\n 97: iload 11\n 99: ifge 105\n 102: invokestatic #96 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 105: iload 11\n 107: aload 10\n 109: checkcast #24 // class java/lang/String\n 112: astore 12\n 114: istore 13\n 116: astore 21\n 118: iconst_0\n 119: istore 14\n 121: aload_0\n 122: iload 13\n 124: aload 12\n 126: invokevirtual #283 // Method toCoordinates:(ILjava/lang/String;)Ljava/util/List;\n 129: aload 21\n 131: swap\n 132: invokeinterface #118, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 137: pop\n 138: goto 69\n 141: aload 6\n 143: checkcast #120 // class java/util/List\n 146: nop\n 147: checkcast #66 // class java/lang/Iterable\n 150: invokestatic #287 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 153: astore_2\n 154: aload_2\n 155: checkcast #66 // class java/lang/Iterable\n 158: astore 4\n 160: iconst_0\n 161: istore 5\n 163: new #68 // class java/util/ArrayList\n 166: dup\n 167: invokespecial #288 // Method java/util/ArrayList.\"<init>\":()V\n 170: astore 6\n 172: new #68 // class java/util/ArrayList\n 175: dup\n 176: invokespecial #288 // Method java/util/ArrayList.\"<init>\":()V\n 179: astore 7\n 181: aload 4\n 183: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 188: astore 8\n 190: aload 8\n 192: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 197: ifeq 264\n 200: aload 8\n 202: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 207: astore 9\n 209: aload 9\n 211: checkcast #198 // class kotlin/Pair\n 214: astore 10\n 216: iconst_0\n 217: istore 11\n 219: aload 10\n 221: invokevirtual #291 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 224: checkcast #98 // class java/lang/Number\n 227: invokevirtual #102 // Method java/lang/Number.intValue:()I\n 230: bipush 9\n 232: if_icmpne 239\n 235: iconst_1\n 236: goto 240\n 239: iconst_0\n 240: ifeq 253\n 243: aload 6\n 245: aload 9\n 247: invokevirtual #292 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 250: goto 260\n 253: aload 7\n 255: aload 9\n 257: invokevirtual #292 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 260: pop\n 261: goto 190\n 264: new #198 // class kotlin/Pair\n 267: dup\n 268: aload 6\n 270: aload 7\n 272: invokespecial #295 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 275: astore_3\n 276: aload_3\n 277: invokevirtual #298 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 280: checkcast #120 // class java/util/List\n 283: astore 4\n 285: aload_3\n 286: invokevirtual #301 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 289: checkcast #120 // class java/util/List\n 292: astore 5\n 294: aload_2\n 295: checkcast #66 // class java/lang/Iterable\n 298: astore 7\n 300: iconst_0\n 301: istore 8\n 303: aload 7\n 305: astore 9\n 307: new #68 // class java/util/ArrayList\n 310: dup\n 311: aload 7\n 313: bipush 10\n 315: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 318: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 321: checkcast #79 // class java/util/Collection\n 324: astore 10\n 326: iconst_0\n 327: istore 11\n 329: aload 9\n 331: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 336: astore 12\n 338: aload 12\n 340: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 345: ifeq 391\n 348: aload 12\n 350: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 355: astore 13\n 357: aload 10\n 359: aload 13\n 361: checkcast #198 // class kotlin/Pair\n 364: astore 14\n 366: astore 21\n 368: iconst_0\n 369: istore 15\n 371: aload 14\n 373: invokevirtual #304 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 376: checkcast #198 // class kotlin/Pair\n 379: aload 21\n 381: swap\n 382: invokeinterface #118, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 387: pop\n 388: goto 338\n 391: aload 10\n 393: checkcast #120 // class java/util/List\n 396: nop\n 397: checkcast #66 // class java/lang/Iterable\n 400: invokestatic #308 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 403: astore 6\n 405: aload 4\n 407: checkcast #66 // class java/lang/Iterable\n 410: astore 8\n 412: iconst_0\n 413: istore 9\n 415: aload 8\n 417: astore 10\n 419: new #68 // class java/util/ArrayList\n 422: dup\n 423: aload 8\n 425: bipush 10\n 427: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 430: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 433: checkcast #79 // class java/util/Collection\n 436: astore 11\n 438: iconst_0\n 439: istore 12\n 441: aload 10\n 443: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 448: astore 13\n 450: aload 13\n 452: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 457: ifeq 503\n 460: aload 13\n 462: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 467: astore 14\n 469: aload 11\n 471: aload 14\n 473: checkcast #198 // class kotlin/Pair\n 476: astore 15\n 478: astore 21\n 480: iconst_0\n 481: istore 16\n 483: aload 15\n 485: invokevirtual #304 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 488: checkcast #198 // class kotlin/Pair\n 491: aload 21\n 493: swap\n 494: invokeinterface #118, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 499: pop\n 500: goto 450\n 503: aload 11\n 505: checkcast #120 // class java/util/List\n 508: nop\n 509: checkcast #66 // class java/lang/Iterable\n 512: invokestatic #312 // Method kotlin/collections/CollectionsKt.toHashSet:(Ljava/lang/Iterable;)Ljava/util/HashSet;\n 515: astore 7\n 517: aload 5\n 519: checkcast #66 // class java/lang/Iterable\n 522: astore 9\n 524: iconst_0\n 525: istore 10\n 527: aload 9\n 529: astore 11\n 531: new #68 // class java/util/ArrayList\n 534: dup\n 535: aload 9\n 537: bipush 10\n 539: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 542: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 545: checkcast #79 // class java/util/Collection\n 548: astore 12\n 550: iconst_0\n 551: istore 13\n 553: aload 11\n 555: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 560: astore 14\n 562: aload 14\n 564: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 569: ifeq 615\n 572: aload 14\n 574: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 579: astore 15\n 581: aload 12\n 583: aload 15\n 585: checkcast #198 // class kotlin/Pair\n 588: astore 16\n 590: astore 21\n 592: iconst_0\n 593: istore 17\n 595: aload 16\n 597: invokevirtual #304 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 600: checkcast #198 // class kotlin/Pair\n 603: aload 21\n 605: swap\n 606: invokeinterface #118, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 611: pop\n 612: goto 562\n 615: aload 12\n 617: checkcast #120 // class java/util/List\n 620: nop\n 621: astore 8\n 623: aload 8\n 625: checkcast #66 // class java/lang/Iterable\n 628: astore 10\n 630: new #68 // class java/util/ArrayList\n 633: dup\n 634: invokespecial #288 // Method java/util/ArrayList.\"<init>\":()V\n 637: checkcast #120 // class java/util/List\n 640: astore 11\n 642: nop\n 643: iconst_0\n 644: istore 12\n 646: aload 11\n 648: astore 13\n 650: aload 10\n 652: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 657: astore 14\n 659: aload 14\n 661: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 666: ifeq 735\n 669: aload 14\n 671: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 676: astore 15\n 678: aload 13\n 680: aload 15\n 682: checkcast #198 // class kotlin/Pair\n 685: astore 16\n 687: astore 17\n 689: iconst_0\n 690: istore 18\n 692: getstatic #315 // Field INSTANCE:LDay09;\n 695: aload 6\n 697: aload 16\n 699: aload 7\n 701: invokevirtual #317 // Method findBasin:(Ljava/util/Set;Lkotlin/Pair;Ljava/util/HashSet;)Ljava/util/Set;\n 704: dup\n 705: ifnull 726\n 708: astore 19\n 710: iconst_0\n 711: istore 20\n 713: aload 17\n 715: aload 19\n 717: invokeinterface #318, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 722: pop\n 723: goto 728\n 726: pop\n 727: nop\n 728: aload 17\n 730: astore 13\n 732: goto 659\n 735: aload 13\n 737: astore 9\n 739: aload 9\n 741: checkcast #66 // class java/lang/Iterable\n 744: astore 11\n 746: iconst_0\n 747: istore 12\n 749: aload 11\n 751: astore 13\n 753: new #68 // class java/util/ArrayList\n 756: dup\n 757: aload 11\n 759: bipush 10\n 761: invokestatic #74 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 764: invokespecial #77 // Method java/util/ArrayList.\"<init>\":(I)V\n 767: checkcast #79 // class java/util/Collection\n 770: astore 14\n 772: iconst_0\n 773: istore 15\n 775: aload 13\n 777: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 782: astore 16\n 784: aload 16\n 786: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 791: ifeq 839\n 794: aload 16\n 796: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 801: astore 17\n 803: aload 14\n 805: aload 17\n 807: checkcast #248 // class java/util/Set\n 810: astore 18\n 812: astore 21\n 814: iconst_0\n 815: istore 19\n 817: aload 18\n 819: invokeinterface #321, 1 // InterfaceMethod java/util/Set.size:()I\n 824: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 827: aload 21\n 829: swap\n 830: invokeinterface #118, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 835: pop\n 836: goto 784\n 839: aload 14\n 841: checkcast #120 // class java/util/List\n 844: nop\n 845: checkcast #66 // class java/lang/Iterable\n 848: invokestatic #324 // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;\n 851: checkcast #66 // class java/lang/Iterable\n 854: iconst_3\n 855: invokestatic #328 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 858: checkcast #66 // class java/lang/Iterable\n 861: astore 11\n 863: iconst_0\n 864: istore 12\n 866: aload 11\n 868: invokeinterface #83, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 873: astore 13\n 875: aload 13\n 877: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 882: ifne 896\n 885: new #330 // class java/lang/UnsupportedOperationException\n 888: dup\n 889: ldc_w #332 // String Empty collection can\\'t be reduced.\n 892: invokespecial #333 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 895: athrow\n 896: aload 13\n 898: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 903: astore 14\n 905: aload 13\n 907: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 912: ifeq 956\n 915: aload 14\n 917: aload 13\n 919: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 924: checkcast #98 // class java/lang/Number\n 927: invokevirtual #102 // Method java/lang/Number.intValue:()I\n 930: istore 15\n 932: checkcast #98 // class java/lang/Number\n 935: invokevirtual #102 // Method java/lang/Number.intValue:()I\n 938: istore 16\n 940: iconst_0\n 941: istore 17\n 943: iload 16\n 945: iload 15\n 947: imul\n 948: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 951: astore 14\n 953: goto 905\n 956: aload 14\n 958: checkcast #98 // class java/lang/Number\n 961: invokevirtual #102 // Method java/lang/Number.intValue:()I\n 964: istore 10\n 966: getstatic #339 // Field java/lang/System.out:Ljava/io/PrintStream;\n 969: iload 10\n 971: invokevirtual #344 // Method java/io/PrintStream.println:(I)V\n 974: return\n\n private static final kotlin.Pair getSurroundingCoordinates$lambda$1(kotlin.Pair, kotlin.Pair);\n Code:\n 0: aload_1\n 1: ldc_w #382 // String <destruct>\n 4: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: invokevirtual #298 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 11: checkcast #98 // class java/lang/Number\n 14: invokevirtual #102 // Method java/lang/Number.intValue:()I\n 17: istore_2\n 18: aload_1\n 19: invokevirtual #301 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 22: checkcast #98 // class java/lang/Number\n 25: invokevirtual #102 // Method java/lang/Number.intValue:()I\n 28: istore_3\n 29: aload_0\n 30: invokevirtual #304 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 33: checkcast #98 // class java/lang/Number\n 36: invokevirtual #102 // Method java/lang/Number.intValue:()I\n 39: iload_2\n 40: iadd\n 41: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 44: aload_0\n 45: invokevirtual #291 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 48: checkcast #98 // class java/lang/Number\n 51: invokevirtual #102 // Method java/lang/Number.intValue:()I\n 54: iload_3\n 55: iadd\n 56: invokestatic #108 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 59: invokestatic #114 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 62: areturn\n\n private static final boolean getSurroundingCoordinates$lambda$2(java.util.Set, kotlin.Pair);\n Code:\n 0: aload_1\n 1: ldc_w #386 // String it\n 4: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: aload_1\n 9: invokeinterface #387, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 14: ireturn\n\n private static final boolean getSurroundingCoordinates$lambda$3(java.util.HashSet, kotlin.Pair);\n Code:\n 0: aload_1\n 1: ldc_w #386 // String it\n 4: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: aload_1\n 9: invokevirtual #215 // Method java/util/HashSet.contains:(Ljava/lang/Object;)Z\n 12: ifne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ireturn\n\n private static final boolean findBasin$lambda$4(java.util.HashSet, kotlin.Pair);\n Code:\n 0: aload_1\n 1: ldc_w #386 // String it\n 4: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: aload_1\n 9: invokevirtual #215 // Method java/util/HashSet.contains:(Ljava/lang/Object;)Z\n 12: ifne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ireturn\n\n private static final java.util.Set findBasin$lambda$5(java.util.Set, java.util.HashSet, kotlin.Pair);\n Code:\n 0: aload_2\n 1: ldc_w #386 // String it\n 4: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: getstatic #315 // Field INSTANCE:LDay09;\n 10: aload_0\n 11: aload_2\n 12: aload_1\n 13: invokevirtual #317 // Method findBasin:(Ljava/util/Set;Lkotlin/Pair;Ljava/util/HashSet;)Ljava/util/Set;\n 16: areturn\n\n static {};\n Code:\n 0: new #2 // class Day09\n 3: dup\n 4: invokespecial #391 // Method \"<init>\":()V\n 7: putstatic #315 // Field INSTANCE:LDay09;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "andrewrlee__adventOfCode2021__aace0fc/Day09Kt.class", "javap": "Compiled from \"Day09.kt\"\npublic final class Day09Kt {\n public static final void main();\n Code:\n 0: getstatic #12 // Field Day09.INSTANCE:LDay09;\n 3: invokevirtual #15 // Method Day09.run:()V\n 6: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #18 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
daily-boj__RanolP__74294a4/P2529.kt
enum class InequationType { LT, // < GT, // > KT, // Nothing } data class Minmax(val min: Long, val max: Long) fun solve(previous: Int, choice: Long, seq: List<InequationType>, available: Set<Int>): Minmax { var min = 9999999999L var max = 0L if (seq.isEmpty()) { return Minmax(choice, choice) } for (i in available) { val canUse = when (seq[0]) { InequationType.KT -> true InequationType.LT -> previous < i InequationType.GT -> previous > i } if (!canUse) { continue } val result = solve(i, choice * 10 + i, seq.subList(1, seq.size), available - i) min = minOf(min, result.min) max = maxOf(max, result.max) } return Minmax(min, max) } fun main(args: Array<out String>) { val k = readLine()!!.toInt() val a = listOf(InequationType.KT) + readLine()!!.split(' ') .asSequence() .filter { it.isNotEmpty() } .map { if (it == "<") InequationType.LT else InequationType.GT } .toList() val (min, max) = solve(0, 0L, a, (0..9).toSet()) println(max.toString().padStart(k + 1, '0')) println(min.toString().padStart(k + 1, '0')) }
[ { "class_path": "daily-boj__RanolP__74294a4/P2529Kt$WhenMappings.class", "javap": "Compiled from \"P2529.kt\"\npublic final class P2529Kt$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method InequationType.values:()[LInequationType;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field InequationType.KT:LInequationType;\n 12: invokevirtual #22 // Method InequationType.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 InequationType.LT:LInequationType;\n 26: invokevirtual #22 // Method InequationType.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 InequationType.GT:LInequationType;\n 40: invokevirtual #22 // Method InequationType.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": "daily-boj__RanolP__74294a4/P2529Kt.class", "javap": "Compiled from \"P2529.kt\"\npublic final class P2529Kt {\n public static final Minmax solve(int, long, java.util.List<? extends InequationType>, java.util.Set<java.lang.Integer>);\n Code:\n 0: aload_3\n 1: ldc #10 // String seq\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload 4\n 8: ldc #18 // String available\n 10: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: ldc2_w #19 // long 9999999999l\n 16: lstore 5\n 18: lconst_0\n 19: lstore 7\n 21: aload_3\n 22: invokeinterface #26, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 27: ifeq 40\n 30: new #28 // class Minmax\n 33: dup\n 34: lload_1\n 35: lload_1\n 36: invokespecial #32 // Method Minmax.\"<init>\":(JJ)V\n 39: areturn\n 40: aload 4\n 42: invokeinterface #38, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 47: astore 9\n 49: aload 9\n 51: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 56: ifeq 236\n 59: aload 9\n 61: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 66: checkcast #49 // class java/lang/Number\n 69: invokevirtual #53 // Method java/lang/Number.intValue:()I\n 72: istore 10\n 74: aload_3\n 75: iconst_0\n 76: invokeinterface #57, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 81: checkcast #59 // class InequationType\n 84: getstatic #65 // Field P2529Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 87: swap\n 88: invokevirtual #68 // Method InequationType.ordinal:()I\n 91: iaload\n 92: tableswitch { // 1 to 3\n 1: 120\n 2: 124\n 3: 138\n default: 152\n }\n 120: iconst_1\n 121: goto 160\n 124: iload_0\n 125: iload 10\n 127: if_icmpge 134\n 130: iconst_1\n 131: goto 160\n 134: iconst_0\n 135: goto 160\n 138: iload_0\n 139: iload 10\n 141: if_icmple 148\n 144: iconst_1\n 145: goto 160\n 148: iconst_0\n 149: goto 160\n 152: new #70 // class kotlin/NoWhenBranchMatchedException\n 155: dup\n 156: invokespecial #73 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 159: athrow\n 160: istore 11\n 162: iload 11\n 164: ifne 170\n 167: goto 49\n 170: iload 10\n 172: lload_1\n 173: bipush 10\n 175: i2l\n 176: lmul\n 177: iload 10\n 179: i2l\n 180: ladd\n 181: aload_3\n 182: iconst_1\n 183: aload_3\n 184: invokeinterface #76, 1 // InterfaceMethod java/util/List.size:()I\n 189: invokeinterface #80, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 194: aload 4\n 196: iload 10\n 198: invokestatic #86 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 201: invokestatic #92 // Method kotlin/collections/SetsKt.minus:(Ljava/util/Set;Ljava/lang/Object;)Ljava/util/Set;\n 204: invokestatic #94 // Method solve:(IJLjava/util/List;Ljava/util/Set;)LMinmax;\n 207: astore 12\n 209: lload 5\n 211: aload 12\n 213: invokevirtual #98 // Method Minmax.getMin:()J\n 216: invokestatic #104 // Method java/lang/Math.min:(JJ)J\n 219: lstore 5\n 221: lload 7\n 223: aload 12\n 225: invokevirtual #107 // Method Minmax.getMax:()J\n 228: invokestatic #110 // Method java/lang/Math.max:(JJ)J\n 231: lstore 7\n 233: goto 49\n 236: new #28 // class Minmax\n 239: dup\n 240: lload 5\n 242: lload 7\n 244: invokespecial #32 // Method Minmax.\"<init>\":(JJ)V\n 247: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #125 // String args\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: invokestatic #131 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 9: dup\n 10: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 13: invokestatic #139 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 16: istore_1\n 17: getstatic #143 // Field InequationType.KT:LInequationType;\n 20: invokestatic #149 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 23: checkcast #151 // class java/util/Collection\n 26: invokestatic #131 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 29: dup\n 30: invokestatic #135 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 33: checkcast #153 // class java/lang/CharSequence\n 36: iconst_1\n 37: newarray char\n 39: astore_3\n 40: aload_3\n 41: iconst_0\n 42: bipush 32\n 44: castore\n 45: aload_3\n 46: iconst_0\n 47: iconst_0\n 48: bipush 6\n 50: aconst_null\n 51: invokestatic #159 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 54: checkcast #161 // class java/lang/Iterable\n 57: invokestatic #165 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 60: invokedynamic #185, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 65: invokestatic #191 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 68: invokedynamic #198, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 73: invokestatic #201 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 76: invokestatic #205 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 79: checkcast #161 // class java/lang/Iterable\n 82: invokestatic #209 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 85: astore_2\n 86: iconst_0\n 87: lconst_0\n 88: aload_2\n 89: new #211 // class kotlin/ranges/IntRange\n 92: dup\n 93: iconst_0\n 94: bipush 9\n 96: invokespecial #214 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 99: checkcast #161 // class java/lang/Iterable\n 102: invokestatic #218 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 105: invokestatic #94 // Method solve:(IJLjava/util/List;Ljava/util/Set;)LMinmax;\n 108: astore_3\n 109: aload_3\n 110: invokevirtual #221 // Method Minmax.component1:()J\n 113: lstore 4\n 115: aload_3\n 116: invokevirtual #224 // Method Minmax.component2:()J\n 119: lstore 6\n 121: lload 6\n 123: invokestatic #229 // Method java/lang/String.valueOf:(J)Ljava/lang/String;\n 126: iload_1\n 127: iconst_1\n 128: iadd\n 129: bipush 48\n 131: invokestatic #233 // Method kotlin/text/StringsKt.padStart:(Ljava/lang/String;IC)Ljava/lang/String;\n 134: getstatic #239 // Field java/lang/System.out:Ljava/io/PrintStream;\n 137: swap\n 138: invokevirtual #244 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 141: lload 4\n 143: invokestatic #229 // Method java/lang/String.valueOf:(J)Ljava/lang/String;\n 146: iload_1\n 147: iconst_1\n 148: iadd\n 149: bipush 48\n 151: invokestatic #233 // Method kotlin/text/StringsKt.padStart:(Ljava/lang/String;IC)Ljava/lang/String;\n 154: getstatic #239 // Field java/lang/System.out:Ljava/io/PrintStream;\n 157: swap\n 158: invokevirtual #244 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 161: return\n\n private static final boolean main$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #249 // 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: checkcast #153 // class java/lang/CharSequence\n 10: invokeinterface #252, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 15: ifle 22\n 18: iconst_1\n 19: goto 23\n 22: iconst_0\n 23: ireturn\n\n private static final InequationType main$lambda$1(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #249 // 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: ldc #255 // String <\n 9: invokestatic #259 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 12: ifeq 21\n 15: getstatic #262 // Field InequationType.LT:LInequationType;\n 18: goto 24\n 21: getstatic #265 // Field InequationType.GT:LInequationType;\n 24: areturn\n}\n", "javap_err": "" } ]
daily-boj__RanolP__74294a4/16117/solution.kt
fun main(args: Array<out String>) { val (height, width) = readLine()!!.split(" ").map { it.toInt() } val realMap = List(height * 2) { if (it % 2 == 0) { List(width * 2) { 0L } } else { readLine()!!.split(" ").flatMap { listOf(0L, it.toLong()) } } } fun getSafe(map: List<List<Long>>, x: Int, y: Int): Long = if (y in 0 until 2 * height && x in 0 until 2 * width) map[y][x] else 0 val intDP = List(height * 2) { MutableList(width * 2) { 0L } } for (x in (0 until width * 2).reversed()) { for (y in (0 until height * 2).reversed()) { val here = realMap[y][x] val best = maxOf( getSafe(realMap, x + 1, y - 1) + getSafe(intDP, x + 2, y - 2), getSafe(realMap, x + 2, y) + getSafe(intDP, x + 4, y), getSafe(realMap, x + 1, y + 1) + getSafe(intDP, x + 2, y + 2) ) intDP[y][x] = here + best } } val max = (0 until height * 2).fold(0L) { acc, y -> maxOf(acc, getSafe(intDP, 0, y), getSafe(intDP, 1, y)) } println(max) }
[ { "class_path": "daily-boj__RanolP__74294a4/SolutionKt.class", "javap": "Compiled from \"solution.kt\"\npublic final class SolutionKt {\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: invokestatic #21 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 9: dup\n 10: invokestatic #25 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 13: checkcast #27 // class java/lang/CharSequence\n 16: iconst_1\n 17: anewarray #29 // class java/lang/String\n 20: astore_2\n 21: aload_2\n 22: iconst_0\n 23: ldc #31 // String\n 25: aastore\n 26: aload_2\n 27: iconst_0\n 28: iconst_0\n 29: bipush 6\n 31: aconst_null\n 32: invokestatic #37 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 35: checkcast #39 // class java/lang/Iterable\n 38: astore_2\n 39: iconst_0\n 40: istore_3\n 41: aload_2\n 42: astore 4\n 44: new #41 // class java/util/ArrayList\n 47: dup\n 48: aload_2\n 49: bipush 10\n 51: invokestatic #47 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 54: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 57: checkcast #53 // class java/util/Collection\n 60: astore 5\n 62: iconst_0\n 63: istore 6\n 65: aload 4\n 67: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 72: astore 7\n 74: aload 7\n 76: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 81: ifeq 128\n 84: aload 7\n 86: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 91: astore 8\n 93: aload 5\n 95: aload 8\n 97: checkcast #29 // class java/lang/String\n 100: astore 9\n 102: astore 24\n 104: iconst_0\n 105: istore 11\n 107: aload 9\n 109: invokestatic #73 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 112: nop\n 113: invokestatic #77 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 116: aload 24\n 118: swap\n 119: invokeinterface #81, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 124: pop\n 125: goto 74\n 128: aload 5\n 130: checkcast #83 // class java/util/List\n 133: nop\n 134: astore_1\n 135: aload_1\n 136: iconst_0\n 137: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 142: checkcast #89 // class java/lang/Number\n 145: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 148: istore_2\n 149: aload_1\n 150: iconst_1\n 151: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 156: checkcast #89 // class java/lang/Number\n 159: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 162: istore_3\n 163: iload_2\n 164: iconst_2\n 165: imul\n 166: istore 5\n 168: new #41 // class java/util/ArrayList\n 171: dup\n 172: iload 5\n 174: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 177: astore 6\n 179: iconst_0\n 180: istore 7\n 182: iload 7\n 184: iload 5\n 186: if_icmpge 441\n 189: iload 7\n 191: istore 8\n 193: aload 6\n 195: iload 8\n 197: istore 9\n 199: astore 24\n 201: iconst_0\n 202: istore 11\n 204: iload 9\n 206: iconst_2\n 207: irem\n 208: ifne 277\n 211: iload_3\n 212: iconst_2\n 213: imul\n 214: istore 12\n 216: new #41 // class java/util/ArrayList\n 219: dup\n 220: iload 12\n 222: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 225: astore 14\n 227: iconst_0\n 228: istore 15\n 230: iload 15\n 232: iload 12\n 234: if_icmpge 269\n 237: iload 15\n 239: istore 16\n 241: aload 14\n 243: iload 16\n 245: istore 17\n 247: astore 18\n 249: iconst_0\n 250: istore 19\n 252: lconst_0\n 253: invokestatic #98 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 256: aload 18\n 258: swap\n 259: invokevirtual #99 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 262: pop\n 263: iinc 15, 1\n 266: goto 230\n 269: aload 14\n 271: checkcast #83 // class java/util/List\n 274: goto 427\n 277: invokestatic #21 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 280: dup\n 281: invokestatic #25 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 284: checkcast #27 // class java/lang/CharSequence\n 287: iconst_1\n 288: anewarray #29 // class java/lang/String\n 291: astore 12\n 293: aload 12\n 295: iconst_0\n 296: ldc #31 // String\n 298: aastore\n 299: aload 12\n 301: iconst_0\n 302: iconst_0\n 303: bipush 6\n 305: aconst_null\n 306: invokestatic #37 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 309: checkcast #39 // class java/lang/Iterable\n 312: astore 12\n 314: iconst_0\n 315: istore 14\n 317: aload 12\n 319: astore 15\n 321: new #41 // class java/util/ArrayList\n 324: dup\n 325: invokespecial #102 // Method java/util/ArrayList.\"<init>\":()V\n 328: checkcast #53 // class java/util/Collection\n 331: astore 16\n 333: iconst_0\n 334: istore 17\n 336: aload 15\n 338: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 343: astore 19\n 345: aload 19\n 347: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 352: ifeq 421\n 355: aload 19\n 357: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 362: astore 20\n 364: aload 20\n 366: checkcast #29 // class java/lang/String\n 369: astore 21\n 371: iconst_0\n 372: istore 22\n 374: iconst_2\n 375: anewarray #95 // class java/lang/Long\n 378: astore 23\n 380: aload 23\n 382: iconst_0\n 383: lconst_0\n 384: invokestatic #98 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 387: aastore\n 388: aload 23\n 390: iconst_1\n 391: aload 21\n 393: invokestatic #106 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 396: invokestatic #98 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 399: aastore\n 400: aload 23\n 402: invokestatic #110 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 405: checkcast #39 // class java/lang/Iterable\n 408: astore 21\n 410: aload 16\n 412: aload 21\n 414: invokestatic #114 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 417: pop\n 418: goto 345\n 421: aload 16\n 423: checkcast #83 // class java/util/List\n 426: nop\n 427: nop\n 428: aload 24\n 430: swap\n 431: invokevirtual #99 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 434: pop\n 435: iinc 7, 1\n 438: goto 182\n 441: aload 6\n 443: checkcast #83 // class java/util/List\n 446: astore 4\n 448: iload_2\n 449: iconst_2\n 450: imul\n 451: istore 6\n 453: new #41 // class java/util/ArrayList\n 456: dup\n 457: iload 6\n 459: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 462: astore 7\n 464: iconst_0\n 465: istore 8\n 467: iload 8\n 469: iload 6\n 471: if_icmpge 566\n 474: iload 8\n 476: istore 9\n 478: aload 7\n 480: iload 9\n 482: istore 11\n 484: astore 24\n 486: iconst_0\n 487: istore 12\n 489: iload_3\n 490: iconst_2\n 491: imul\n 492: istore 14\n 494: new #41 // class java/util/ArrayList\n 497: dup\n 498: iload 14\n 500: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 503: astore 15\n 505: iconst_0\n 506: istore 16\n 508: iload 16\n 510: iload 14\n 512: if_icmpge 547\n 515: iload 16\n 517: istore 17\n 519: aload 15\n 521: iload 17\n 523: istore 18\n 525: astore 19\n 527: iconst_0\n 528: istore 20\n 530: lconst_0\n 531: invokestatic #98 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 534: aload 19\n 536: swap\n 537: invokevirtual #99 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 540: pop\n 541: iinc 16, 1\n 544: goto 508\n 547: aload 15\n 549: checkcast #83 // class java/util/List\n 552: nop\n 553: aload 24\n 555: swap\n 556: invokevirtual #99 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 559: pop\n 560: iinc 8, 1\n 563: goto 467\n 566: aload 7\n 568: checkcast #83 // class java/util/List\n 571: astore 5\n 573: iconst_0\n 574: iload_3\n 575: iconst_2\n 576: imul\n 577: invokestatic #120 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 580: checkcast #122 // class kotlin/ranges/IntProgression\n 583: invokestatic #126 // Method kotlin/ranges/RangesKt.reversed:(Lkotlin/ranges/IntProgression;)Lkotlin/ranges/IntProgression;\n 586: astore 6\n 588: aload 6\n 590: invokevirtual #129 // Method kotlin/ranges/IntProgression.getFirst:()I\n 593: istore 7\n 595: aload 6\n 597: invokevirtual #132 // Method kotlin/ranges/IntProgression.getLast:()I\n 600: istore 8\n 602: aload 6\n 604: invokevirtual #135 // Method kotlin/ranges/IntProgression.getStep:()I\n 607: istore 9\n 609: iload 9\n 611: ifle 621\n 614: iload 7\n 616: iload 8\n 618: if_icmple 633\n 621: iload 9\n 623: ifge 880\n 626: iload 8\n 628: iload 7\n 630: if_icmpgt 880\n 633: iconst_0\n 634: iload_2\n 635: iconst_2\n 636: imul\n 637: invokestatic #120 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 640: checkcast #122 // class kotlin/ranges/IntProgression\n 643: invokestatic #126 // Method kotlin/ranges/RangesKt.reversed:(Lkotlin/ranges/IntProgression;)Lkotlin/ranges/IntProgression;\n 646: astore 11\n 648: aload 11\n 650: invokevirtual #129 // Method kotlin/ranges/IntProgression.getFirst:()I\n 653: istore 12\n 655: aload 11\n 657: invokevirtual #132 // Method kotlin/ranges/IntProgression.getLast:()I\n 660: istore 14\n 662: aload 11\n 664: invokevirtual #135 // Method kotlin/ranges/IntProgression.getStep:()I\n 667: istore 15\n 669: iload 15\n 671: ifle 681\n 674: iload 12\n 676: iload 14\n 678: if_icmple 693\n 681: iload 15\n 683: ifge 863\n 686: iload 14\n 688: iload 12\n 690: if_icmpgt 863\n 693: aload 4\n 695: iload 12\n 697: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 702: checkcast #83 // class java/util/List\n 705: iload 7\n 707: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 712: checkcast #89 // class java/lang/Number\n 715: invokevirtual #139 // Method java/lang/Number.longValue:()J\n 718: lstore 16\n 720: nop\n 721: iload_2\n 722: iload_3\n 723: aload 4\n 725: iload 7\n 727: iconst_1\n 728: iadd\n 729: iload 12\n 731: iconst_1\n 732: isub\n 733: invokestatic #143 // Method main$getSafe:(IILjava/util/List;II)J\n 736: iload_2\n 737: iload_3\n 738: aload 5\n 740: iload 7\n 742: iconst_2\n 743: iadd\n 744: iload 12\n 746: iconst_2\n 747: isub\n 748: invokestatic #143 // Method main$getSafe:(IILjava/util/List;II)J\n 751: ladd\n 752: iload_2\n 753: iload_3\n 754: aload 4\n 756: iload 7\n 758: iconst_2\n 759: iadd\n 760: iload 12\n 762: invokestatic #143 // Method main$getSafe:(IILjava/util/List;II)J\n 765: iload_2\n 766: iload_3\n 767: aload 5\n 769: iload 7\n 771: iconst_4\n 772: iadd\n 773: iload 12\n 775: invokestatic #143 // Method main$getSafe:(IILjava/util/List;II)J\n 778: ladd\n 779: iload_2\n 780: iload_3\n 781: aload 4\n 783: iload 7\n 785: iconst_1\n 786: iadd\n 787: iload 12\n 789: iconst_1\n 790: iadd\n 791: invokestatic #143 // Method main$getSafe:(IILjava/util/List;II)J\n 794: iload_2\n 795: iload_3\n 796: aload 5\n 798: iload 7\n 800: iconst_2\n 801: iadd\n 802: iload 12\n 804: iconst_2\n 805: iadd\n 806: invokestatic #143 // Method main$getSafe:(IILjava/util/List;II)J\n 809: ladd\n 810: invokestatic #149 // Method java/lang/Math.max:(JJ)J\n 813: invokestatic #149 // Method java/lang/Math.max:(JJ)J\n 816: lstore 18\n 818: aload 5\n 820: iload 12\n 822: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 827: checkcast #83 // class java/util/List\n 830: iload 7\n 832: lload 16\n 834: lload 18\n 836: ladd\n 837: invokestatic #98 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 840: invokeinterface #153, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 845: pop\n 846: iload 12\n 848: iload 14\n 850: if_icmpeq 863\n 853: iload 12\n 855: iload 15\n 857: iadd\n 858: istore 12\n 860: goto 693\n 863: iload 7\n 865: iload 8\n 867: if_icmpeq 880\n 870: iload 7\n 872: iload 9\n 874: iadd\n 875: istore 7\n 877: goto 633\n 880: iconst_0\n 881: iload_2\n 882: iconst_2\n 883: imul\n 884: invokestatic #120 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 887: checkcast #39 // class java/lang/Iterable\n 890: astore 8\n 892: lconst_0\n 893: lstore 9\n 895: iconst_0\n 896: istore 11\n 898: lload 9\n 900: lstore 12\n 902: aload 8\n 904: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 909: astore 14\n 911: aload 14\n 913: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 918: ifeq 976\n 921: aload 14\n 923: checkcast #155 // class kotlin/collections/IntIterator\n 926: invokevirtual #158 // Method kotlin/collections/IntIterator.nextInt:()I\n 929: istore 15\n 931: lload 12\n 933: iload 15\n 935: istore 16\n 937: lstore 17\n 939: iconst_0\n 940: istore 19\n 942: lload 17\n 944: iload_2\n 945: iload_3\n 946: aload 5\n 948: iconst_0\n 949: iload 16\n 951: invokestatic #143 // Method main$getSafe:(IILjava/util/List;II)J\n 954: iload_2\n 955: iload_3\n 956: aload 5\n 958: iconst_1\n 959: iload 16\n 961: invokestatic #143 // Method main$getSafe:(IILjava/util/List;II)J\n 964: invokestatic #149 // Method java/lang/Math.max:(JJ)J\n 967: invokestatic #149 // Method java/lang/Math.max:(JJ)J\n 970: nop\n 971: lstore 12\n 973: goto 911\n 976: lload 12\n 978: lstore 6\n 980: getstatic #164 // Field java/lang/System.out:Ljava/io/PrintStream;\n 983: lload 6\n 985: invokevirtual #170 // Method java/io/PrintStream.println:(J)V\n 988: return\n\n private static final long main$getSafe(int, int, java.util.List<? extends java.util.List<java.lang.Long>>, int, int);\n Code:\n 0: iconst_0\n 1: iload 4\n 3: if_icmpgt 22\n 6: iload 4\n 8: iconst_2\n 9: iload_0\n 10: imul\n 11: if_icmpge 18\n 14: iconst_1\n 15: goto 23\n 18: iconst_0\n 19: goto 23\n 22: iconst_0\n 23: ifeq 76\n 26: iconst_0\n 27: iload_3\n 28: if_icmpgt 46\n 31: iload_3\n 32: iconst_2\n 33: iload_1\n 34: imul\n 35: if_icmpge 42\n 38: iconst_1\n 39: goto 47\n 42: iconst_0\n 43: goto 47\n 46: iconst_0\n 47: ifeq 76\n 50: aload_2\n 51: iload 4\n 53: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 58: checkcast #83 // class java/util/List\n 61: iload_3\n 62: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 67: checkcast #89 // class java/lang/Number\n 70: invokevirtual #139 // Method java/lang/Number.longValue:()J\n 73: goto 77\n 76: lconst_0\n 77: lreturn\n}\n", "javap_err": "" } ]
daily-boj__RanolP__74294a4/P9735.kt
import kotlin.math.* data class QuadraticEquation(val a: Long, val b: Long, val c: Long) { fun solve(): Set<Double> { val discriminant = b.toDouble() * b.toDouble() - 4.0 * a.toDouble() * c.toDouble() if (discriminant < 0) { return emptySet() } val sqrtedDiscriminant = sqrt(discriminant) return setOf((-b + sqrtedDiscriminant) / 2 / a, (-b - sqrtedDiscriminant) / 2 / a) } } fun syntheticDivision(a: Long, b: Long, c: Long, d: Long): Set<Double> { if (d == 0L) { return setOf(0.0) + QuadraticEquation(a, b, c).solve() } for (i in 1..sqrt(abs(d.toDouble())).toLong()) { if (d % i != 0L) { continue } for (e in listOf(i, -i, d / i, -d / i)) { val newA = a val newB = e * newA + b val newC = e * newB + c val newD = e * newC + d if (newD == 0L) { return setOf(e.toDouble()) + QuadraticEquation(newA, newB, newC).solve() } } } return emptySet() } fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b) fun main(args: Array<out String>) { (0 until readLine()!!.toLong()).joinToString("\n") { val (a, b, c, d) = readLine()!!.split(" ").map { it.toLong() } syntheticDivision(a, b, c, d).toList().sorted().joinToString(" ") { String.format("%f", it) } }.let(::println) }
[ { "class_path": "daily-boj__RanolP__74294a4/P9735Kt.class", "javap": "Compiled from \"P9735.kt\"\npublic final class P9735Kt {\n public static final java.util.Set<java.lang.Double> syntheticDivision(long, long, long, long);\n Code:\n 0: lload 6\n 2: lconst_0\n 3: lcmp\n 4: ifne 35\n 7: dconst_0\n 8: invokestatic #14 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 11: invokestatic #20 // Method kotlin/collections/SetsKt.setOf:(Ljava/lang/Object;)Ljava/util/Set;\n 14: new #22 // class QuadraticEquation\n 17: dup\n 18: lload_0\n 19: lload_2\n 20: lload 4\n 22: invokespecial #26 // Method QuadraticEquation.\"<init>\":(JJJ)V\n 25: invokevirtual #30 // Method QuadraticEquation.solve:()Ljava/util/Set;\n 28: checkcast #32 // class java/lang/Iterable\n 31: invokestatic #36 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Iterable;)Ljava/util/Set;\n 34: areturn\n 35: lconst_1\n 36: lstore 8\n 38: lload 6\n 40: l2d\n 41: invokestatic #42 // Method java/lang/Math.abs:(D)D\n 44: invokestatic #45 // Method java/lang/Math.sqrt:(D)D\n 47: d2l\n 48: lstore 10\n 50: lload 8\n 52: lload 10\n 54: lcmp\n 55: ifgt 246\n 58: lload 6\n 60: lload 8\n 62: lrem\n 63: lconst_0\n 64: lcmp\n 65: ifeq 71\n 68: goto 229\n 71: iconst_4\n 72: anewarray #47 // class java/lang/Long\n 75: astore 13\n 77: aload 13\n 79: iconst_0\n 80: lload 8\n 82: invokestatic #50 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 85: aastore\n 86: aload 13\n 88: iconst_1\n 89: lload 8\n 91: lneg\n 92: invokestatic #50 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 95: aastore\n 96: aload 13\n 98: iconst_2\n 99: lload 6\n 101: lload 8\n 103: ldiv\n 104: invokestatic #50 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 107: aastore\n 108: aload 13\n 110: iconst_3\n 111: lload 6\n 113: lneg\n 114: lload 8\n 116: ldiv\n 117: invokestatic #50 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 120: aastore\n 121: aload 13\n 123: invokestatic #56 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 126: invokeinterface #62, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 131: astore 12\n 133: aload 12\n 135: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 140: ifeq 229\n 143: aload 12\n 145: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 150: checkcast #74 // class java/lang/Number\n 153: invokevirtual #78 // Method java/lang/Number.longValue:()J\n 156: lstore 13\n 158: lload_0\n 159: lstore 15\n 161: lload 13\n 163: lload 15\n 165: lmul\n 166: lload_2\n 167: ladd\n 168: lstore 17\n 170: lload 13\n 172: lload 17\n 174: lmul\n 175: lload 4\n 177: ladd\n 178: lstore 19\n 180: lload 13\n 182: lload 19\n 184: lmul\n 185: lload 6\n 187: ladd\n 188: lstore 21\n 190: lload 21\n 192: lconst_0\n 193: lcmp\n 194: ifne 133\n 197: lload 13\n 199: l2d\n 200: invokestatic #14 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 203: invokestatic #20 // Method kotlin/collections/SetsKt.setOf:(Ljava/lang/Object;)Ljava/util/Set;\n 206: new #22 // class QuadraticEquation\n 209: dup\n 210: lload 15\n 212: lload 17\n 214: lload 19\n 216: invokespecial #26 // Method QuadraticEquation.\"<init>\":(JJJ)V\n 219: invokevirtual #30 // Method QuadraticEquation.solve:()Ljava/util/Set;\n 222: checkcast #32 // class java/lang/Iterable\n 225: invokestatic #36 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Iterable;)Ljava/util/Set;\n 228: areturn\n 229: lload 8\n 231: lload 10\n 233: lcmp\n 234: ifeq 246\n 237: lload 8\n 239: lconst_1\n 240: ladd\n 241: lstore 8\n 243: goto 58\n 246: invokestatic #81 // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;\n 249: areturn\n\n public static final long gcd(long, long);\n Code:\n 0: lload_2\n 1: lconst_0\n 2: lcmp\n 3: ifne 10\n 6: lload_0\n 7: goto 17\n 10: lload_2\n 11: lload_0\n 12: lload_2\n 13: lrem\n 14: invokestatic #96 // Method gcd:(JJ)J\n 17: lreturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #100 // String args\n 3: invokestatic #106 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: invokestatic #112 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 10: dup\n 11: invokestatic #116 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 14: invokestatic #120 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 17: invokestatic #126 // Method kotlin/ranges/RangesKt.until:(IJ)Lkotlin/ranges/LongRange;\n 20: checkcast #32 // class java/lang/Iterable\n 23: ldc #128 // String \\n\n 25: checkcast #130 // class java/lang/CharSequence\n 28: aconst_null\n 29: aconst_null\n 30: iconst_0\n 31: aconst_null\n 32: invokedynamic #150, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 37: bipush 30\n 39: aconst_null\n 40: invokestatic #154 // 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 43: astore_1\n 44: iconst_0\n 45: istore_2\n 46: getstatic #160 // Field java/lang/System.out:Ljava/io/PrintStream;\n 49: aload_1\n 50: invokevirtual #165 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 53: nop\n 54: nop\n 55: return\n\n private static final java.lang.CharSequence main$lambda$2$lambda$1(double);\n Code:\n 0: getstatic #178 // Field kotlin/jvm/internal/StringCompanionObject.INSTANCE:Lkotlin/jvm/internal/StringCompanionObject;\n 3: pop\n 4: ldc #180 // String %f\n 6: astore_2\n 7: iconst_1\n 8: anewarray #4 // class java/lang/Object\n 11: astore_3\n 12: aload_3\n 13: iconst_0\n 14: dload_0\n 15: invokestatic #14 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 18: aastore\n 19: aload_3\n 20: astore_3\n 21: aload_2\n 22: aload_3\n 23: aload_3\n 24: arraylength\n 25: invokestatic #186 // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;\n 28: invokestatic #192 // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;\n 31: dup\n 32: ldc #194 // String format(...)\n 34: invokestatic #197 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 37: checkcast #130 // class java/lang/CharSequence\n 40: areturn\n\n private static final java.lang.CharSequence main$lambda$2(long);\n Code:\n 0: invokestatic #112 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 3: dup\n 4: invokestatic #116 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 7: checkcast #130 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #188 // class java/lang/String\n 14: astore_3\n 15: aload_3\n 16: iconst_0\n 17: ldc #201 // String\n 19: aastore\n 20: aload_3\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #207 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: checkcast #32 // class java/lang/Iterable\n 32: astore_3\n 33: iconst_0\n 34: istore 4\n 36: aload_3\n 37: astore 5\n 39: new #209 // class java/util/ArrayList\n 42: dup\n 43: aload_3\n 44: bipush 10\n 46: invokestatic #213 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 49: invokespecial #216 // Method java/util/ArrayList.\"<init>\":(I)V\n 52: checkcast #218 // class java/util/Collection\n 55: astore 6\n 57: iconst_0\n 58: istore 7\n 60: aload 5\n 62: invokeinterface #219, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 67: astore 8\n 69: aload 8\n 71: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 76: ifeq 123\n 79: aload 8\n 81: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: astore 9\n 88: aload 6\n 90: aload 9\n 92: checkcast #188 // class java/lang/String\n 95: astore 10\n 97: astore 12\n 99: iconst_0\n 100: istore 11\n 102: aload 10\n 104: invokestatic #120 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 107: nop\n 108: invokestatic #50 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 111: aload 12\n 113: swap\n 114: invokeinterface #223, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 119: pop\n 120: goto 69\n 123: aload 6\n 125: checkcast #58 // class java/util/List\n 128: nop\n 129: astore_2\n 130: aload_2\n 131: iconst_0\n 132: invokeinterface #227, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 137: checkcast #74 // class java/lang/Number\n 140: invokevirtual #78 // Method java/lang/Number.longValue:()J\n 143: lstore_3\n 144: aload_2\n 145: iconst_1\n 146: invokeinterface #227, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 151: checkcast #74 // class java/lang/Number\n 154: invokevirtual #78 // Method java/lang/Number.longValue:()J\n 157: lstore 5\n 159: aload_2\n 160: iconst_2\n 161: invokeinterface #227, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 166: checkcast #74 // class java/lang/Number\n 169: invokevirtual #78 // Method java/lang/Number.longValue:()J\n 172: lstore 7\n 174: aload_2\n 175: iconst_3\n 176: invokeinterface #227, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 181: checkcast #74 // class java/lang/Number\n 184: invokevirtual #78 // Method java/lang/Number.longValue:()J\n 187: lstore 9\n 189: lload_3\n 190: lload 5\n 192: lload 7\n 194: lload 9\n 196: invokestatic #229 // Method syntheticDivision:(JJJJ)Ljava/util/Set;\n 199: checkcast #32 // class java/lang/Iterable\n 202: invokestatic #233 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 205: checkcast #32 // class java/lang/Iterable\n 208: invokestatic #236 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 211: checkcast #32 // class java/lang/Iterable\n 214: ldc #201 // String\n 216: checkcast #130 // class java/lang/CharSequence\n 219: aconst_null\n 220: aconst_null\n 221: iconst_0\n 222: aconst_null\n 223: invokedynamic #242, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 228: bipush 30\n 230: aconst_null\n 231: invokestatic #154 // 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 234: checkcast #130 // class java/lang/CharSequence\n 237: areturn\n}\n", "javap_err": "" } ]
lmisea__lab-algos-2__948a9e5/proyecto-1/codigo/VerificadorTSP.kt
/** * Verificador de soluciones para el problema del vendedor viajero * Recibe como argumentos el archivo de instancia y el archivo de solucion * Imprime si la solucion es correcta o no y muestra algunos errores si los hay */ import java.io.BufferedReader import java.io.File import java.io.FileReader /** * Funcion: distancia2D(p1: Pair<Int, Int>, p2: Pair<Int, Int>) * Entradas: p1 y p2, dos pares de enteros que representan las coordenadas de dos puntos * Salidas: La distancia euclidiana entre los dos puntos * Descripcion: Calcula la distancia euclidiana entre dos puntos en el plano */ fun distancia2D(p1: Pair<Double, Double>, p2: Pair<Double, Double>): Double { val x = p1.first - p2.first val y = p1.second - p2.second return Math.sqrt((x * x + y * y).toDouble()) } /** * Funcion: distanciaRuta(ciudades: Array<Pair<Int, Int>>) * Entradas: ciudades, un arreglo de pares de enteros que representan las coordenadas de las ciudades * Salidas: La distancia total de la ruta que recorre todas las ciudades en el orden dado * Descripcion: Calcula la distancia total de la ruta que recorre todas las ciudades en el orden dado */ fun distanciaRuta(ciudades: Array<Pair<Double, Double>>): Int { var acc: Double = 0.0 for (i in 0 until ciudades.size - 1) { acc += distancia2D(ciudades[i], ciudades[i + 1]) } return acc.toInt() } /** * Funcion: checkSolution(ciudadesInstancia: Array<Pair<Int, Int>>, ciudadesSolucion: Array<Pair<Int, Int>>) * Entradas: ciudadesInstancia, un arreglo de pares de enteros que representan las coordenadas de las ciudades de la instancia * ciudadesSolucion, un arreglo de pares de enteros que representan las coordenadas de las ciudades de la solucion * Salidas: true si la solucion es correcta, false en otro caso * Descripcion: Verifica que la solucion dada sea correcta */ fun checkSolution(indicesInstancia: Array<Int>, indicesSolucion: Array<Int>): Boolean { // Verificar que la solucion tenga todas las ciudades de la instancia for (i in 0 until indicesInstancia.size) { if (!indicesInstancia.contains(indicesSolucion[i])) { println("La solución no contiene la ciudad ${indicesSolucion[i] + 1}.") return false } } // Verificar que la solucion no tenga ciudades repetidas for (i in 0 until indicesSolucion.size) { for (j in i + 1 until indicesSolucion.size) { if (indicesSolucion[i] == indicesSolucion[j]) { println("La solución tiene la ciudad ${indicesSolucion[i] + 1} repetida.") return false } } } return true } /** * Funcion: ciudadesFaltantes(ciudadesInstancia: Array<Pair<Int, Int>>, ciudadesSolucion: Array<Pair<Int, Int>>) * Entradas: indicesInstancia, un arreglo de pares de enteros que representan las coordenadas de las ciudades de la instancia * indicesSolucion, un arreglo de pares de enteros que representan las coordenadas de las ciudades de la solucion * Salidas: Imprime (en caso de que sea necesario) las ciudades que faltan en la solucion */ fun ciudadesFaltantes(indicesInstancia: Array<Int>, indicesSolucion: Array<Int>){ for (i in 0 until indicesSolucion.size){ if (!indicesInstancia.contains(indicesSolucion[i])){ println("La ciudad ${indicesSolucion[i]+1} no se encuentra en la instancia") } } } fun main(args: Array<String>) { // args[0] es el archivo de instancia // args[1] es el archivo de solucion val archivoInstancia = File(args[0]) val archivoSolucion = File(args[1]) // Leer las ciudades de la instancia val lectorInstancia = BufferedReader(FileReader(archivoInstancia, Charsets.UTF_8)) lectorInstancia.readLine() // Ignorar primera linea. Es el nombre del archivo lectorInstancia.readLine() // Ignorar segunda linea. Es el comentario val numeroCiudadesInstancia = lectorInstancia.readLine().split(":")[1].trim().toInt() lectorInstancia.readLine() // Ignorar linea. Es el comentario val indicesInstancia = Array<Int>(numeroCiudadesInstancia, { 0 }) for (i in 0 until numeroCiudadesInstancia) { val indice = lectorInstancia.readLine().trim().toInt() indicesInstancia[i] = indice - 1 } lectorInstancia.close() // Leer las ciudades de la solucion val lectorSolucion = BufferedReader(FileReader(archivoSolucion, Charsets.UTF_8)) lectorSolucion.readLine() // Ignorar primera linea. Es el nombre del archivo lectorSolucion.readLine() // Ignorar segunda linea. Es el comentario val numeroCiudadesSolucion = lectorSolucion.readLine().split(":")[1].trim().toInt() lectorSolucion.readLine() // Ignorar linea. Es el comentario val indicesSolucion = Array<Int>(numeroCiudadesSolucion, { 0 }) for (i in 0 until numeroCiudadesSolucion) { val indice = lectorSolucion.readLine().trim().toInt() indicesSolucion[i] = indice-1 } lectorSolucion.close() // Verificar que la solucion sea correcta if (!checkSolution(indicesInstancia, indicesSolucion)) { // Si la solucion no es correcta, terminar el programa println("Solución incorrecta!!") ciudadesFaltantes(indicesInstancia, indicesSolucion) return } println("Es una solución correcta!!") println("Se visitaron todas las ciudades de la instancia, solo una vez cada una.") }
[ { "class_path": "lmisea__lab-algos-2__948a9e5/VerificadorTSPKt.class", "javap": "Compiled from \"VerificadorTSP.kt\"\npublic final class VerificadorTSPKt {\n public static final double distancia2D(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 #10 // String p1\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 p2\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokevirtual #24 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 16: checkcast #26 // class java/lang/Number\n 19: invokevirtual #30 // Method java/lang/Number.doubleValue:()D\n 22: aload_1\n 23: invokevirtual #24 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 26: checkcast #26 // class java/lang/Number\n 29: invokevirtual #30 // Method java/lang/Number.doubleValue:()D\n 32: dsub\n 33: dstore_2\n 34: aload_0\n 35: invokevirtual #33 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 38: checkcast #26 // class java/lang/Number\n 41: invokevirtual #30 // Method java/lang/Number.doubleValue:()D\n 44: aload_1\n 45: invokevirtual #33 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 48: checkcast #26 // class java/lang/Number\n 51: invokevirtual #30 // Method java/lang/Number.doubleValue:()D\n 54: dsub\n 55: dstore 4\n 57: dload_2\n 58: dload_2\n 59: dmul\n 60: dload 4\n 62: dload 4\n 64: dmul\n 65: dadd\n 66: invokestatic #39 // Method java/lang/Math.sqrt:(D)D\n 69: dreturn\n\n public static final int distanciaRuta(kotlin.Pair<java.lang.Double, java.lang.Double>[]);\n Code:\n 0: aload_0\n 1: ldc #48 // String ciudades\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: dconst_0\n 7: dstore_1\n 8: iconst_0\n 9: istore_3\n 10: aload_0\n 11: arraylength\n 12: iconst_1\n 13: isub\n 14: istore 4\n 16: iload_3\n 17: iload 4\n 19: if_icmpge 42\n 22: dload_1\n 23: aload_0\n 24: iload_3\n 25: aaload\n 26: aload_0\n 27: iload_3\n 28: iconst_1\n 29: iadd\n 30: aaload\n 31: invokestatic #50 // Method distancia2D:(Lkotlin/Pair;Lkotlin/Pair;)D\n 34: dadd\n 35: dstore_1\n 36: iinc 3, 1\n 39: goto 16\n 42: dload_1\n 43: d2i\n 44: ireturn\n\n public static final boolean checkSolution(java.lang.Integer[], java.lang.Integer[]);\n Code:\n 0: aload_0\n 1: ldc #58 // String indicesInstancia\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #60 // String indicesSolucion\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: iconst_0\n 13: istore_2\n 14: aload_0\n 15: arraylength\n 16: istore_3\n 17: iload_2\n 18: iload_3\n 19: if_icmpge 78\n 22: aload_0\n 23: aload_1\n 24: iload_2\n 25: aaload\n 26: invokestatic #66 // Method kotlin/collections/ArraysKt.contains:([Ljava/lang/Object;Ljava/lang/Object;)Z\n 29: ifne 72\n 32: new #68 // class java/lang/StringBuilder\n 35: dup\n 36: invokespecial #72 // Method java/lang/StringBuilder.\"<init>\":()V\n 39: ldc #74 // String La solución no contiene la ciudad\n 41: invokevirtual #78 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 44: aload_1\n 45: iload_2\n 46: aaload\n 47: invokevirtual #84 // Method java/lang/Integer.intValue:()I\n 50: iconst_1\n 51: iadd\n 52: invokevirtual #87 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 55: bipush 46\n 57: invokevirtual #90 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 60: invokevirtual #94 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 63: getstatic #100 // Field java/lang/System.out:Ljava/io/PrintStream;\n 66: swap\n 67: invokevirtual #106 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 70: iconst_0\n 71: ireturn\n 72: iinc 2, 1\n 75: goto 17\n 78: iconst_0\n 79: istore_2\n 80: aload_1\n 81: arraylength\n 82: istore_3\n 83: iload_2\n 84: iload_3\n 85: if_icmpge 172\n 88: iload_2\n 89: iconst_1\n 90: iadd\n 91: istore 4\n 93: aload_1\n 94: arraylength\n 95: istore 5\n 97: iload 4\n 99: iload 5\n 101: if_icmpge 166\n 104: aload_1\n 105: iload_2\n 106: aaload\n 107: invokevirtual #84 // Method java/lang/Integer.intValue:()I\n 110: aload_1\n 111: iload 4\n 113: aaload\n 114: invokevirtual #84 // Method java/lang/Integer.intValue:()I\n 117: if_icmpne 160\n 120: new #68 // class java/lang/StringBuilder\n 123: dup\n 124: invokespecial #72 // Method java/lang/StringBuilder.\"<init>\":()V\n 127: ldc #108 // String La solución tiene la ciudad\n 129: invokevirtual #78 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 132: aload_1\n 133: iload_2\n 134: aaload\n 135: invokevirtual #84 // Method java/lang/Integer.intValue:()I\n 138: iconst_1\n 139: iadd\n 140: invokevirtual #87 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 143: ldc #110 // String repetida.\n 145: invokevirtual #78 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: invokevirtual #94 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 151: getstatic #100 // Field java/lang/System.out:Ljava/io/PrintStream;\n 154: swap\n 155: invokevirtual #106 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 158: iconst_0\n 159: ireturn\n 160: iinc 4, 1\n 163: goto 97\n 166: iinc 2, 1\n 169: goto 83\n 172: iconst_1\n 173: ireturn\n\n public static final void ciudadesFaltantes(java.lang.Integer[], java.lang.Integer[]);\n Code:\n 0: aload_0\n 1: ldc #58 // String indicesInstancia\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #60 // String indicesSolucion\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: iconst_0\n 13: istore_2\n 14: aload_1\n 15: arraylength\n 16: istore_3\n 17: iload_2\n 18: iload_3\n 19: if_icmpge 76\n 22: aload_0\n 23: aload_1\n 24: iload_2\n 25: aaload\n 26: invokestatic #66 // Method kotlin/collections/ArraysKt.contains:([Ljava/lang/Object;Ljava/lang/Object;)Z\n 29: ifne 70\n 32: new #68 // class java/lang/StringBuilder\n 35: dup\n 36: invokespecial #72 // Method java/lang/StringBuilder.\"<init>\":()V\n 39: ldc #116 // String La ciudad\n 41: invokevirtual #78 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 44: aload_1\n 45: iload_2\n 46: aaload\n 47: invokevirtual #84 // Method java/lang/Integer.intValue:()I\n 50: iconst_1\n 51: iadd\n 52: invokevirtual #87 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 55: ldc #118 // String no se encuentra en la instancia\n 57: invokevirtual #78 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 60: invokevirtual #94 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 63: getstatic #100 // Field java/lang/System.out:Ljava/io/PrintStream;\n 66: swap\n 67: invokevirtual #106 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 70: iinc 2, 1\n 73: goto 17\n 76: return\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #122 // String args\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #124 // class java/io/File\n 9: dup\n 10: aload_0\n 11: iconst_0\n 12: aaload\n 13: invokespecial #127 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 16: astore_1\n 17: new #124 // class java/io/File\n 20: dup\n 21: aload_0\n 22: iconst_1\n 23: aaload\n 24: invokespecial #127 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 27: astore_2\n 28: new #129 // class java/io/BufferedReader\n 31: dup\n 32: new #131 // class java/io/FileReader\n 35: dup\n 36: aload_1\n 37: getstatic #137 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 40: invokespecial #140 // Method java/io/FileReader.\"<init>\":(Ljava/io/File;Ljava/nio/charset/Charset;)V\n 43: checkcast #142 // class java/io/Reader\n 46: invokespecial #145 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 49: astore_3\n 50: aload_3\n 51: invokevirtual #148 // Method java/io/BufferedReader.readLine:()Ljava/lang/String;\n 54: pop\n 55: aload_3\n 56: invokevirtual #148 // Method java/io/BufferedReader.readLine:()Ljava/lang/String;\n 59: pop\n 60: aload_3\n 61: invokevirtual #148 // Method java/io/BufferedReader.readLine:()Ljava/lang/String;\n 64: dup\n 65: ldc #150 // String readLine(...)\n 67: invokestatic #153 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 70: checkcast #155 // class java/lang/CharSequence\n 73: iconst_1\n 74: anewarray #157 // class java/lang/String\n 77: astore 5\n 79: aload 5\n 81: iconst_0\n 82: ldc #159 // String :\n 84: aastore\n 85: aload 5\n 87: iconst_0\n 88: iconst_0\n 89: bipush 6\n 91: aconst_null\n 92: invokestatic #165 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 95: iconst_1\n 96: invokeinterface #171, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 101: checkcast #157 // class java/lang/String\n 104: checkcast #155 // class java/lang/CharSequence\n 107: invokestatic #175 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 110: invokevirtual #176 // Method java/lang/Object.toString:()Ljava/lang/String;\n 113: invokestatic #180 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 116: istore 4\n 118: aload_3\n 119: invokevirtual #148 // Method java/io/BufferedReader.readLine:()Ljava/lang/String;\n 122: pop\n 123: iconst_0\n 124: istore 6\n 126: iload 4\n 128: anewarray #80 // class java/lang/Integer\n 131: astore 7\n 133: iload 6\n 135: iload 4\n 137: if_icmpge 159\n 140: iload 6\n 142: istore 8\n 144: aload 7\n 146: iload 8\n 148: iconst_0\n 149: invokestatic #184 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 152: aastore\n 153: iinc 6, 1\n 156: goto 133\n 159: aload 7\n 161: astore 5\n 163: iconst_0\n 164: istore 6\n 166: iload 6\n 168: iload 4\n 170: if_icmpge 215\n 173: aload_3\n 174: invokevirtual #148 // Method java/io/BufferedReader.readLine:()Ljava/lang/String;\n 177: dup\n 178: ldc #150 // String readLine(...)\n 180: invokestatic #153 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 183: checkcast #155 // class java/lang/CharSequence\n 186: invokestatic #175 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 189: invokevirtual #176 // Method java/lang/Object.toString:()Ljava/lang/String;\n 192: invokestatic #180 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 195: istore 7\n 197: aload 5\n 199: iload 6\n 201: iload 7\n 203: iconst_1\n 204: isub\n 205: invokestatic #184 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 208: aastore\n 209: iinc 6, 1\n 212: goto 166\n 215: aload_3\n 216: invokevirtual #187 // Method java/io/BufferedReader.close:()V\n 219: new #129 // class java/io/BufferedReader\n 222: dup\n 223: new #131 // class java/io/FileReader\n 226: dup\n 227: aload_2\n 228: getstatic #137 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 231: invokespecial #140 // Method java/io/FileReader.\"<init>\":(Ljava/io/File;Ljava/nio/charset/Charset;)V\n 234: checkcast #142 // class java/io/Reader\n 237: invokespecial #145 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;)V\n 240: astore 6\n 242: aload 6\n 244: invokevirtual #148 // Method java/io/BufferedReader.readLine:()Ljava/lang/String;\n 247: pop\n 248: aload 6\n 250: invokevirtual #148 // Method java/io/BufferedReader.readLine:()Ljava/lang/String;\n 253: pop\n 254: aload 6\n 256: invokevirtual #148 // Method java/io/BufferedReader.readLine:()Ljava/lang/String;\n 259: dup\n 260: ldc #150 // String readLine(...)\n 262: invokestatic #153 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 265: checkcast #155 // class java/lang/CharSequence\n 268: iconst_1\n 269: anewarray #157 // class java/lang/String\n 272: astore 8\n 274: aload 8\n 276: iconst_0\n 277: ldc #159 // String :\n 279: aastore\n 280: aload 8\n 282: iconst_0\n 283: iconst_0\n 284: bipush 6\n 286: aconst_null\n 287: invokestatic #165 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 290: iconst_1\n 291: invokeinterface #171, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 296: checkcast #157 // class java/lang/String\n 299: checkcast #155 // class java/lang/CharSequence\n 302: invokestatic #175 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 305: invokevirtual #176 // Method java/lang/Object.toString:()Ljava/lang/String;\n 308: invokestatic #180 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 311: istore 7\n 313: aload 6\n 315: invokevirtual #148 // Method java/io/BufferedReader.readLine:()Ljava/lang/String;\n 318: pop\n 319: iconst_0\n 320: istore 9\n 322: iload 7\n 324: anewarray #80 // class java/lang/Integer\n 327: astore 10\n 329: iload 9\n 331: iload 7\n 333: if_icmpge 355\n 336: iload 9\n 338: istore 11\n 340: aload 10\n 342: iload 11\n 344: iconst_0\n 345: invokestatic #184 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 348: aastore\n 349: iinc 9, 1\n 352: goto 329\n 355: aload 10\n 357: astore 8\n 359: iconst_0\n 360: istore 9\n 362: iload 9\n 364: iload 7\n 366: if_icmpge 412\n 369: aload 6\n 371: invokevirtual #148 // Method java/io/BufferedReader.readLine:()Ljava/lang/String;\n 374: dup\n 375: ldc #150 // String readLine(...)\n 377: invokestatic #153 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 380: checkcast #155 // class java/lang/CharSequence\n 383: invokestatic #175 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 386: invokevirtual #176 // Method java/lang/Object.toString:()Ljava/lang/String;\n 389: invokestatic #180 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 392: istore 10\n 394: aload 8\n 396: iload 9\n 398: iload 10\n 400: iconst_1\n 401: isub\n 402: invokestatic #184 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 405: aastore\n 406: iinc 9, 1\n 409: goto 362\n 412: aload 6\n 414: invokevirtual #187 // Method java/io/BufferedReader.close:()V\n 417: aload 5\n 419: aload 8\n 421: invokestatic #189 // Method checkSolution:([Ljava/lang/Integer;[Ljava/lang/Integer;)Z\n 424: ifne 444\n 427: ldc #191 // String Solución incorrecta!!\n 429: getstatic #100 // Field java/lang/System.out:Ljava/io/PrintStream;\n 432: swap\n 433: invokevirtual #106 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 436: aload 5\n 438: aload 8\n 440: invokestatic #193 // Method ciudadesFaltantes:([Ljava/lang/Integer;[Ljava/lang/Integer;)V\n 443: return\n 444: ldc #195 // String Es una solución correcta!!\n 446: getstatic #100 // Field java/lang/System.out:Ljava/io/PrintStream;\n 449: swap\n 450: invokevirtual #106 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 453: ldc #197 // String Se visitaron todas las ciudades de la instancia, solo una vez cada una.\n 455: getstatic #100 // Field java/lang/System.out:Ljava/io/PrintStream;\n 458: swap\n 459: invokevirtual #106 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 462: return\n}\n", "javap_err": "" } ]
lmisea__lab-algos-2__948a9e5/parcial-1-Juan/AsignarCupo.kt
fun swapDual(A: Array<Int>, B: Array<Int>, i: Int, j: Int): Unit { val aux: Int = A[i] A[i] = A[j] A[j] = aux val temp: Int = B[i] B[i] = B[j] B[j] = temp } fun compararEstudiantes(A: Array<Int>, B: Array<Int>, i: Int, j: Int): Boolean{ return A[i] < A[j] || (A[i] == A[j] && B[i] <= B[j]) } fun parent(i: Int): Int { return i / 2 } fun left(i: Int): Int { return 2 * i } fun right(i: Int): Int { return 2 * i + 1 } fun maxHeapify(A: Array<Int>, B: Array<Int>, i: Int, heapSize: Int): Unit { val l: Int = left(i) val r: Int = right(i) var largest: Int = i if (l <= heapSize && compararEstudiantes(A, B, i, l)) { largest = l } if (r <= heapSize && compararEstudiantes(A, B, largest, r)) { largest = r } if (largest != i) { swapDual(A, B, i, largest) maxHeapify(A, B, largest, heapSize) } } fun buildMaxHeap(A: Array<Int>, B: Array<Int>, heapSize: Int): Unit { for (i in heapSize / 2 downTo 0) { maxHeapify(A, B, i, heapSize) } } fun heapSort(A: Array<Int>, B: Array<Int>): Unit { val heapSize: Int = A.size - 1 buildMaxHeap(A, B, heapSize) for (i in heapSize downTo 1) { swapDual(A, B, 0, i) maxHeapify(A, B, 0, i - 1) } } fun main(args: Array<String>) { val cupos = args[0].toInt() if (cupos < 0){ throw Exception("El número de cupos debe ser positivo") } else if (cupos == 0){ println("NO HAY CUPOS") return } if ((args.size)%2 != 1){ throw Exception("Falta un estudiante por NFC o carnet") } val numeroEstudiantes = (args.size - 1)/2 if (cupos >= numeroEstudiantes){ println("TODOS FUERON ADMITIDOS") return } val carnets: Array<Int> = Array(numeroEstudiantes){0} val NCFs: Array<Int> = Array(numeroEstudiantes){0} for (i in 0 until numeroEstudiantes){ carnets[i] = args[i*2 + 1].toInt() NCFs[i] = args[i*2 + 2].toInt() } heapSort(NCFs, carnets) for (i in 0 until cupos){ println(carnets[i]) } }
[ { "class_path": "lmisea__lab-algos-2__948a9e5/AsignarCupoKt.class", "javap": "Compiled from \"AsignarCupo.kt\"\npublic final class AsignarCupoKt {\n public static final void swapDual(java.lang.Integer[], java.lang.Integer[], int, int);\n Code:\n 0: aload_0\n 1: ldc #9 // 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 #17 // 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: iload_2\n 14: aaload\n 15: invokevirtual #23 // Method java/lang/Integer.intValue:()I\n 18: istore 4\n 20: aload_0\n 21: iload_2\n 22: aload_0\n 23: iload_3\n 24: aaload\n 25: aastore\n 26: aload_0\n 27: iload_3\n 28: iload 4\n 30: invokestatic #27 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 33: aastore\n 34: aload_1\n 35: iload_2\n 36: aaload\n 37: invokevirtual #23 // Method java/lang/Integer.intValue:()I\n 40: istore 5\n 42: aload_1\n 43: iload_2\n 44: aload_1\n 45: iload_3\n 46: aaload\n 47: aastore\n 48: aload_1\n 49: iload_3\n 50: iload 5\n 52: invokestatic #27 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 55: aastore\n 56: return\n\n public static final boolean compararEstudiantes(java.lang.Integer[], java.lang.Integer[], int, int);\n Code:\n 0: aload_0\n 1: ldc #9 // 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 #17 // 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: iload_2\n 14: aaload\n 15: invokevirtual #23 // Method java/lang/Integer.intValue:()I\n 18: aload_0\n 19: iload_3\n 20: aaload\n 21: invokevirtual #23 // Method java/lang/Integer.intValue:()I\n 24: if_icmplt 57\n 27: aload_0\n 28: iload_2\n 29: aaload\n 30: invokevirtual #23 // Method java/lang/Integer.intValue:()I\n 33: aload_0\n 34: iload_3\n 35: aaload\n 36: invokevirtual #23 // Method java/lang/Integer.intValue:()I\n 39: if_icmpne 61\n 42: aload_1\n 43: iload_2\n 44: aaload\n 45: invokevirtual #23 // Method java/lang/Integer.intValue:()I\n 48: aload_1\n 49: iload_3\n 50: aaload\n 51: invokevirtual #23 // Method java/lang/Integer.intValue:()I\n 54: if_icmpgt 61\n 57: iconst_1\n 58: goto 62\n 61: iconst_0\n 62: ireturn\n\n public static final int parent(int);\n Code:\n 0: iload_0\n 1: iconst_2\n 2: idiv\n 3: ireturn\n\n public static final int left(int);\n Code:\n 0: iconst_2\n 1: iload_0\n 2: imul\n 3: ireturn\n\n public static final int right(int);\n Code:\n 0: iconst_2\n 1: iload_0\n 2: imul\n 3: iconst_1\n 4: iadd\n 5: ireturn\n\n public static final void maxHeapify(java.lang.Integer[], java.lang.Integer[], int, int);\n Code:\n 0: aload_0\n 1: ldc #9 // 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 #17 // String B\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: iload_2\n 13: invokestatic #42 // Method left:(I)I\n 16: istore 4\n 18: iload_2\n 19: invokestatic #44 // Method right:(I)I\n 22: istore 5\n 24: iload_2\n 25: istore 6\n 27: iload 4\n 29: iload_3\n 30: if_icmpgt 48\n 33: aload_0\n 34: aload_1\n 35: iload_2\n 36: iload 4\n 38: invokestatic #46 // Method compararEstudiantes:([Ljava/lang/Integer;[Ljava/lang/Integer;II)Z\n 41: ifeq 48\n 44: iload 4\n 46: istore 6\n 48: iload 5\n 50: iload_3\n 51: if_icmpgt 70\n 54: aload_0\n 55: aload_1\n 56: iload 6\n 58: iload 5\n 60: invokestatic #46 // Method compararEstudiantes:([Ljava/lang/Integer;[Ljava/lang/Integer;II)Z\n 63: ifeq 70\n 66: iload 5\n 68: istore 6\n 70: iload 6\n 72: iload_2\n 73: if_icmpeq 92\n 76: aload_0\n 77: aload_1\n 78: iload_2\n 79: iload 6\n 81: invokestatic #48 // Method swapDual:([Ljava/lang/Integer;[Ljava/lang/Integer;II)V\n 84: aload_0\n 85: aload_1\n 86: iload 6\n 88: iload_3\n 89: invokestatic #50 // Method maxHeapify:([Ljava/lang/Integer;[Ljava/lang/Integer;II)V\n 92: return\n\n public static final void buildMaxHeap(java.lang.Integer[], java.lang.Integer[], int);\n Code:\n 0: aload_0\n 1: ldc #9 // 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 #17 // String B\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: iload_2\n 13: iconst_2\n 14: idiv\n 15: istore_3\n 16: iconst_m1\n 17: iload_3\n 18: if_icmpge 34\n 21: aload_0\n 22: aload_1\n 23: iload_3\n 24: iload_2\n 25: invokestatic #50 // Method maxHeapify:([Ljava/lang/Integer;[Ljava/lang/Integer;II)V\n 28: iinc 3, -1\n 31: goto 16\n 34: return\n\n public static final void heapSort(java.lang.Integer[], java.lang.Integer[]);\n Code:\n 0: aload_0\n 1: ldc #9 // 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 #17 // 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: arraylength\n 14: iconst_1\n 15: isub\n 16: istore_2\n 17: aload_0\n 18: aload_1\n 19: iload_2\n 20: invokestatic #60 // Method buildMaxHeap:([Ljava/lang/Integer;[Ljava/lang/Integer;I)V\n 23: iload_2\n 24: istore_3\n 25: iconst_0\n 26: iload_3\n 27: if_icmpge 52\n 30: aload_0\n 31: aload_1\n 32: iconst_0\n 33: iload_3\n 34: invokestatic #48 // Method swapDual:([Ljava/lang/Integer;[Ljava/lang/Integer;II)V\n 37: aload_0\n 38: aload_1\n 39: iconst_0\n 40: iload_3\n 41: iconst_1\n 42: isub\n 43: invokestatic #50 // Method maxHeapify:([Ljava/lang/Integer;[Ljava/lang/Integer;II)V\n 46: iinc 3, -1\n 49: goto 25\n 52: return\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #64 // String args\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iconst_0\n 8: aaload\n 9: invokestatic #68 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 12: istore_1\n 13: iload_1\n 14: ifge 27\n 17: new #70 // class java/lang/Exception\n 20: dup\n 21: ldc #72 // String El número de cupos debe ser positivo\n 23: invokespecial #76 // Method java/lang/Exception.\"<init>\":(Ljava/lang/String;)V\n 26: athrow\n 27: iload_1\n 28: ifne 41\n 31: ldc #78 // String NO HAY CUPOS\n 33: getstatic #84 // Field java/lang/System.out:Ljava/io/PrintStream;\n 36: swap\n 37: invokevirtual #90 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 40: return\n 41: aload_0\n 42: arraylength\n 43: iconst_2\n 44: irem\n 45: iconst_1\n 46: if_icmpeq 59\n 49: new #70 // class java/lang/Exception\n 52: dup\n 53: ldc #92 // String Falta un estudiante por NFC o carnet\n 55: invokespecial #76 // Method java/lang/Exception.\"<init>\":(Ljava/lang/String;)V\n 58: athrow\n 59: aload_0\n 60: arraylength\n 61: iconst_1\n 62: isub\n 63: iconst_2\n 64: idiv\n 65: istore_2\n 66: iload_1\n 67: iload_2\n 68: if_icmplt 81\n 71: ldc #94 // String TODOS FUERON ADMITIDOS\n 73: getstatic #84 // Field java/lang/System.out:Ljava/io/PrintStream;\n 76: swap\n 77: invokevirtual #90 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 80: return\n 81: iconst_0\n 82: istore 4\n 84: iload_2\n 85: anewarray #19 // class java/lang/Integer\n 88: astore 5\n 90: iload 4\n 92: iload_2\n 93: if_icmpge 115\n 96: iload 4\n 98: istore 6\n 100: aload 5\n 102: iload 6\n 104: iconst_0\n 105: invokestatic #27 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 108: aastore\n 109: iinc 4, 1\n 112: goto 90\n 115: aload 5\n 117: astore_3\n 118: iconst_0\n 119: istore 5\n 121: iload_2\n 122: anewarray #19 // class java/lang/Integer\n 125: astore 6\n 127: iload 5\n 129: iload_2\n 130: if_icmpge 152\n 133: iload 5\n 135: istore 7\n 137: aload 6\n 139: iload 7\n 141: iconst_0\n 142: invokestatic #27 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 145: aastore\n 146: iinc 5, 1\n 149: goto 127\n 152: aload 6\n 154: astore 4\n 156: iconst_0\n 157: istore 5\n 159: iload 5\n 161: iload_2\n 162: if_icmpge 208\n 165: aload_3\n 166: iload 5\n 168: aload_0\n 169: iload 5\n 171: iconst_2\n 172: imul\n 173: iconst_1\n 174: iadd\n 175: aaload\n 176: invokestatic #68 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 179: invokestatic #27 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 182: aastore\n 183: aload 4\n 185: iload 5\n 187: aload_0\n 188: iload 5\n 190: iconst_2\n 191: imul\n 192: iconst_2\n 193: iadd\n 194: aaload\n 195: invokestatic #68 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 198: invokestatic #27 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 201: aastore\n 202: iinc 5, 1\n 205: goto 159\n 208: aload 4\n 210: aload_3\n 211: invokestatic #96 // Method heapSort:([Ljava/lang/Integer;[Ljava/lang/Integer;)V\n 214: iconst_0\n 215: istore 5\n 217: iload 5\n 219: iload_1\n 220: if_icmpge 246\n 223: aload_3\n 224: iload 5\n 226: aaload\n 227: invokevirtual #23 // Method java/lang/Integer.intValue:()I\n 230: istore 6\n 232: getstatic #84 // Field java/lang/System.out:Ljava/io/PrintStream;\n 235: iload 6\n 237: invokevirtual #99 // Method java/io/PrintStream.println:(I)V\n 240: iinc 5, 1\n 243: goto 217\n 246: return\n}\n", "javap_err": "" } ]
mr-kaffee__aoc-2022-kotlin__313432b/src/Day01.kt
import java.io.File fun main() { fun part1(elves: List<Int>): Int { return elves.fold(0) { mx, calories -> maxOf(mx, calories) } } fun part2(elves: List<Int>): Int { return elves.fold(mutableListOf(0, 0, 0)) { mx, calories -> if (calories > mx[0]) { mx[2] = mx[1] mx[1] = mx[0] mx[0] = calories } else if (calories > mx[1]) { mx[2] = mx[1] mx[1] = calories } else if (calories > mx[2]) { mx[2] = calories } mx }.sum() } val t0 = System.currentTimeMillis() // input parsing val input = File("src", "Day01.txt").readText() val elves = input .trim().split("\n\n") .map { elf -> elf.lines().sumOf { line -> line.toInt() } } .toList() val tParse = System.currentTimeMillis() // part 1 val exp1 = 67658 val sol1 = part1(elves) val t1 = System.currentTimeMillis() check(sol1 == exp1) { "Expected solution for part 1: $exp1, found $sol1" } // part 2 val exp2 = 200158 val sol2 = part2(elves) val t2 = System.currentTimeMillis() check(sol2 == exp2) { "Expected solution for part 1: $exp2, found $sol2" } // results println("Solved puzzle 2022/01") println(" parsed input in ${tParse - t0}ms") println(" solved part 1 in ${t1 - tParse}ms => $sol1") println(" solved part 2 in ${t2 - t1}ms => $sol2") println(" ---") println(" total time: ${t2 - t0}ms") }
[ { "class_path": "mr-kaffee__aoc-2022-kotlin__313432b/Day01Kt.class", "javap": "Compiled from \"Day01.kt\"\npublic final class Day01Kt {\n public static final void main();\n Code:\n 0: invokestatic #12 // Method java/lang/System.currentTimeMillis:()J\n 3: lstore_0\n 4: new #14 // class java/io/File\n 7: dup\n 8: ldc #16 // String src\n 10: ldc #18 // String Day01.txt\n 12: invokespecial #22 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 15: aconst_null\n 16: iconst_1\n 17: aconst_null\n 18: invokestatic #28 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;\n 21: astore_2\n 22: nop\n 23: aload_2\n 24: checkcast #30 // class java/lang/CharSequence\n 27: invokestatic #36 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 30: invokevirtual #40 // Method java/lang/Object.toString:()Ljava/lang/String;\n 33: checkcast #30 // class java/lang/CharSequence\n 36: iconst_1\n 37: anewarray #42 // class java/lang/String\n 40: astore 4\n 42: aload 4\n 44: iconst_0\n 45: ldc #44 // String \\n\\n\n 47: aastore\n 48: aload 4\n 50: iconst_0\n 51: iconst_0\n 52: bipush 6\n 54: aconst_null\n 55: invokestatic #48 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 58: checkcast #50 // class java/lang/Iterable\n 61: astore 4\n 63: nop\n 64: iconst_0\n 65: istore 5\n 67: aload 4\n 69: astore 6\n 71: new #52 // class java/util/ArrayList\n 74: dup\n 75: aload 4\n 77: bipush 10\n 79: invokestatic #58 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 82: invokespecial #61 // Method java/util/ArrayList.\"<init>\":(I)V\n 85: checkcast #63 // class java/util/Collection\n 88: astore 7\n 90: iconst_0\n 91: istore 8\n 93: aload 6\n 95: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 100: astore 9\n 102: aload 9\n 104: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 109: ifeq 229\n 112: aload 9\n 114: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 119: astore 10\n 121: aload 7\n 123: aload 10\n 125: checkcast #42 // class java/lang/String\n 128: astore 11\n 130: astore 21\n 132: iconst_0\n 133: istore 12\n 135: aload 11\n 137: checkcast #30 // class java/lang/CharSequence\n 140: invokestatic #81 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 143: checkcast #50 // class java/lang/Iterable\n 146: astore 13\n 148: iconst_0\n 149: istore 14\n 151: aload 13\n 153: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 158: astore 15\n 160: aload 15\n 162: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 167: ifeq 211\n 170: aload 15\n 172: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 177: astore 16\n 179: iload 14\n 181: aload 16\n 183: checkcast #42 // class java/lang/String\n 186: astore 17\n 188: istore 18\n 190: iconst_0\n 191: istore 19\n 193: aload 17\n 195: invokestatic #87 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 198: nop\n 199: istore 20\n 201: iload 18\n 203: iload 20\n 205: iadd\n 206: istore 14\n 208: goto 160\n 211: iload 14\n 213: nop\n 214: invokestatic #91 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 217: aload 21\n 219: swap\n 220: invokeinterface #95, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 225: pop\n 226: goto 102\n 229: aload 7\n 231: checkcast #97 // class java/util/List\n 234: nop\n 235: checkcast #50 // class java/lang/Iterable\n 238: invokestatic #101 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 241: astore_3\n 242: invokestatic #12 // Method java/lang/System.currentTimeMillis:()J\n 245: lstore 4\n 247: ldc #102 // int 67658\n 249: istore 6\n 251: aload_3\n 252: invokestatic #106 // Method main$part1:(Ljava/util/List;)I\n 255: istore 7\n 257: invokestatic #12 // Method java/lang/System.currentTimeMillis:()J\n 260: lstore 8\n 262: iload 7\n 264: iload 6\n 266: if_icmpne 273\n 269: iconst_1\n 270: goto 274\n 273: iconst_0\n 274: ifne 325\n 277: iconst_0\n 278: istore 11\n 280: new #108 // class java/lang/StringBuilder\n 283: dup\n 284: invokespecial #110 // Method java/lang/StringBuilder.\"<init>\":()V\n 287: ldc #112 // String Expected solution for part 1:\n 289: invokevirtual #116 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 292: iload 6\n 294: invokevirtual #119 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 297: ldc #121 // String , found\n 299: invokevirtual #116 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 302: iload 7\n 304: invokevirtual #119 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 307: invokevirtual #122 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 310: astore 11\n 312: new #124 // class java/lang/IllegalStateException\n 315: dup\n 316: aload 11\n 318: invokevirtual #40 // Method java/lang/Object.toString:()Ljava/lang/String;\n 321: invokespecial #127 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 324: athrow\n 325: ldc #128 // int 200158\n 327: istore 10\n 329: aload_3\n 330: invokestatic #131 // Method main$part2:(Ljava/util/List;)I\n 333: istore 11\n 335: invokestatic #12 // Method java/lang/System.currentTimeMillis:()J\n 338: lstore 12\n 340: iload 11\n 342: iload 10\n 344: if_icmpne 351\n 347: iconst_1\n 348: goto 352\n 351: iconst_0\n 352: ifne 403\n 355: iconst_0\n 356: istore 15\n 358: new #108 // class java/lang/StringBuilder\n 361: dup\n 362: invokespecial #110 // Method java/lang/StringBuilder.\"<init>\":()V\n 365: ldc #112 // String Expected solution for part 1:\n 367: invokevirtual #116 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 370: iload 10\n 372: invokevirtual #119 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 375: ldc #121 // String , found\n 377: invokevirtual #116 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 380: iload 11\n 382: invokevirtual #119 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 385: invokevirtual #122 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 388: astore 15\n 390: new #124 // class java/lang/IllegalStateException\n 393: dup\n 394: aload 15\n 396: invokevirtual #40 // Method java/lang/Object.toString:()Ljava/lang/String;\n 399: invokespecial #127 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 402: athrow\n 403: ldc #133 // String Solved puzzle 2022/01\n 405: getstatic #137 // Field java/lang/System.out:Ljava/io/PrintStream;\n 408: swap\n 409: invokevirtual #143 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 412: new #108 // class java/lang/StringBuilder\n 415: dup\n 416: invokespecial #110 // Method java/lang/StringBuilder.\"<init>\":()V\n 419: ldc #145 // String parsed input in\n 421: invokevirtual #116 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 424: lload 4\n 426: lload_0\n 427: lsub\n 428: invokevirtual #148 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 431: ldc #150 // String ms\n 433: invokevirtual #116 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 436: invokevirtual #122 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 439: getstatic #137 // Field java/lang/System.out:Ljava/io/PrintStream;\n 442: swap\n 443: invokevirtual #143 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 446: new #108 // class java/lang/StringBuilder\n 449: dup\n 450: invokespecial #110 // Method java/lang/StringBuilder.\"<init>\":()V\n 453: ldc #152 // String solved part 1 in\n 455: invokevirtual #116 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 458: lload 8\n 460: lload 4\n 462: lsub\n 463: invokevirtual #148 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 466: ldc #154 // String ms =>\n 468: invokevirtual #116 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 471: iload 7\n 473: invokevirtual #119 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 476: invokevirtual #122 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 479: getstatic #137 // Field java/lang/System.out:Ljava/io/PrintStream;\n 482: swap\n 483: invokevirtual #143 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 486: new #108 // class java/lang/StringBuilder\n 489: dup\n 490: invokespecial #110 // Method java/lang/StringBuilder.\"<init>\":()V\n 493: ldc #156 // String solved part 2 in\n 495: invokevirtual #116 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 498: lload 12\n 500: lload 8\n 502: lsub\n 503: invokevirtual #148 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 506: ldc #154 // String ms =>\n 508: invokevirtual #116 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 511: iload 11\n 513: invokevirtual #119 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 516: invokevirtual #122 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 519: getstatic #137 // Field java/lang/System.out:Ljava/io/PrintStream;\n 522: swap\n 523: invokevirtual #143 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 526: ldc #158 // String ---\n 528: getstatic #137 // Field java/lang/System.out:Ljava/io/PrintStream;\n 531: swap\n 532: invokevirtual #143 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 535: new #108 // class java/lang/StringBuilder\n 538: dup\n 539: invokespecial #110 // Method java/lang/StringBuilder.\"<init>\":()V\n 542: ldc #160 // String total time:\n 544: invokevirtual #116 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 547: lload 12\n 549: lload_0\n 550: lsub\n 551: invokevirtual #148 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 554: ldc #150 // String ms\n 556: invokevirtual #116 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 559: invokevirtual #122 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 562: getstatic #137 // Field java/lang/System.out:Ljava/io/PrintStream;\n 565: swap\n 566: invokevirtual #143 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 569: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #192 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: checkcast #50 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: iconst_0\n 8: istore_3\n 9: iload_2\n 10: istore 4\n 12: aload_1\n 13: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 18: astore 5\n 20: aload 5\n 22: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 27: ifeq 69\n 30: aload 5\n 32: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 37: astore 6\n 39: iload 4\n 41: aload 6\n 43: checkcast #197 // class java/lang/Number\n 46: invokevirtual #201 // Method java/lang/Number.intValue:()I\n 49: istore 7\n 51: istore 8\n 53: iconst_0\n 54: istore 9\n 56: iload 8\n 58: iload 7\n 60: invokestatic #207 // Method java/lang/Math.max:(II)I\n 63: nop\n 64: istore 4\n 66: goto 20\n 69: iload 4\n 71: ireturn\n\n private static final int main$part2(java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: checkcast #50 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_3\n 6: anewarray #83 // class java/lang/Integer\n 9: astore_2\n 10: aload_2\n 11: iconst_0\n 12: iconst_0\n 13: invokestatic #91 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 16: aastore\n 17: aload_2\n 18: iconst_1\n 19: iconst_0\n 20: invokestatic #91 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 23: aastore\n 24: aload_2\n 25: iconst_2\n 26: iconst_0\n 27: invokestatic #91 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 30: aastore\n 31: aload_2\n 32: invokestatic #219 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 35: astore_2\n 36: iconst_0\n 37: istore_3\n 38: aload_2\n 39: astore 4\n 41: aload_1\n 42: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 47: astore 5\n 49: aload 5\n 51: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 56: ifeq 248\n 59: aload 5\n 61: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 66: astore 6\n 68: aload 4\n 70: aload 6\n 72: checkcast #197 // class java/lang/Number\n 75: invokevirtual #201 // Method java/lang/Number.intValue:()I\n 78: istore 7\n 80: astore 8\n 82: iconst_0\n 83: istore 9\n 85: iload 7\n 87: aload 8\n 89: iconst_0\n 90: invokeinterface #223, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 95: checkcast #197 // class java/lang/Number\n 98: invokevirtual #201 // Method java/lang/Number.intValue:()I\n 101: if_icmple 155\n 104: aload 8\n 106: iconst_2\n 107: aload 8\n 109: iconst_1\n 110: invokeinterface #223, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 115: invokeinterface #227, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 120: pop\n 121: aload 8\n 123: iconst_1\n 124: aload 8\n 126: iconst_0\n 127: invokeinterface #223, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 132: invokeinterface #227, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 137: pop\n 138: aload 8\n 140: iconst_0\n 141: iload 7\n 143: invokestatic #91 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 146: invokeinterface #227, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 151: pop\n 152: goto 241\n 155: iload 7\n 157: aload 8\n 159: iconst_1\n 160: invokeinterface #223, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 165: checkcast #197 // class java/lang/Number\n 168: invokevirtual #201 // Method java/lang/Number.intValue:()I\n 171: if_icmple 208\n 174: aload 8\n 176: iconst_2\n 177: aload 8\n 179: iconst_1\n 180: invokeinterface #223, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 185: invokeinterface #227, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 190: pop\n 191: aload 8\n 193: iconst_1\n 194: iload 7\n 196: invokestatic #91 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 199: invokeinterface #227, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 204: pop\n 205: goto 241\n 208: iload 7\n 210: aload 8\n 212: iconst_2\n 213: invokeinterface #223, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 218: checkcast #197 // class java/lang/Number\n 221: invokevirtual #201 // Method java/lang/Number.intValue:()I\n 224: if_icmple 241\n 227: aload 8\n 229: iconst_2\n 230: iload 7\n 232: invokestatic #91 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 235: invokeinterface #227, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 240: pop\n 241: aload 8\n 243: astore 4\n 245: goto 49\n 248: aload 4\n 250: checkcast #50 // class java/lang/Iterable\n 253: invokestatic #231 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 256: ireturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Utils.kt
import java.io.File /** * Reads lines from the given input txt file. */ fun readInput(name: String) = File("src", "$name.txt") .readLines() fun String.allInts() = allIntsInString(this) fun allIntsInString(line: String): List<Int> { return """-?\d+""".toRegex().findAll(line) .map { it.value.toInt() } .toList() } fun <T> List<T>.nth(n: Int): T = this[n % size] inline fun <T> List<T>.indexOfLast(predicate: (T) -> Boolean): Int { for (i in this.indices.reversed()) { if (predicate(this[i])) { return i } } return -1 } data class Point(var x: Int = 0, var y: Int = 0) { operator fun plus(other: Point): Point { return Point(this.x + other.x, this.y + other.y) } fun adjacents(): Set<Point> = setOf( copy(x = x - 1), copy(x = x + 1), copy(y = y - 1), copy(y = y + 1) ) fun set(x: Int, y: Int) { this.x = x this.y = y } operator fun plusAssign(p: Point) { x += p.x y += p.y } operator fun minus(point: Point): Point { return Point(x + point.x, y - point.y) } } inline fun List<List<Char>>.forEach(block: (row: Int, col: Int) -> Unit) { for (i in indices) { val inner = this[i] for (j in inner.indices) { block(i, j) } } } fun List<List<Char>>.maxOf(block: (row: Int, col: Int) -> Int): Int { var max = 0 forEach { row, col -> val value = block(row, col) max = if (value > max) value else max } return max } fun List<List<Char>>.count(block: (row: Int, col: Int) -> Boolean): Int { var count = 0 forEach { row, col -> count += if (block(row, col)) 1 else 0 } return count }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/UtilsKt.class", "javap": "Compiled from \"Utils.kt\"\npublic final class UtilsKt {\n public static final java.util.List<java.lang.String> readInput(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #10 // String name\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #18 // class java/io/File\n 9: dup\n 10: ldc #20 // String src\n 12: new #22 // class java/lang/StringBuilder\n 15: dup\n 16: invokespecial #26 // Method java/lang/StringBuilder.\"<init>\":()V\n 19: aload_0\n 20: invokevirtual #30 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 23: ldc #32 // String .txt\n 25: invokevirtual #30 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 28: invokevirtual #36 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 31: invokespecial #39 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 34: aconst_null\n 35: iconst_1\n 36: aconst_null\n 37: invokestatic #45 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 40: areturn\n\n public static final java.util.List<java.lang.Integer> allInts(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #50 // 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 #53 // Method allIntsInString:(Ljava/lang/String;)Ljava/util/List;\n 10: areturn\n\n public static final java.util.List<java.lang.Integer> allIntsInString(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #56 // String line\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #58 // class kotlin/text/Regex\n 9: dup\n 10: ldc #60 // String -?\\\\d+\n 12: invokespecial #63 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 15: aload_0\n 16: checkcast #65 // class java/lang/CharSequence\n 19: iconst_0\n 20: iconst_2\n 21: aconst_null\n 22: invokestatic #69 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 25: invokedynamic #89, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 30: invokestatic #95 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 33: invokestatic #99 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 36: areturn\n\n public static final <T> T nth(java.util.List<? extends T>, int);\n Code:\n 0: aload_0\n 1: ldc #50 // 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: iload_1\n 8: aload_0\n 9: invokeinterface #108, 1 // InterfaceMethod java/util/List.size:()I\n 14: irem\n 15: invokeinterface #112, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 20: areturn\n\n public static final <T> int indexOfLast(java.util.List<? extends T>, kotlin.jvm.functions.Function1<? super T, java.lang.Boolean>);\n Code:\n 0: aload_0\n 1: ldc #50 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #121 // String predicate\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: iconst_0\n 13: istore_2\n 14: aload_0\n 15: checkcast #123 // class java/util/Collection\n 18: invokeinterface #124, 1 // InterfaceMethod java/util/Collection.size:()I\n 23: iconst_m1\n 24: iadd\n 25: istore_3\n 26: iconst_0\n 27: iload_3\n 28: if_icmpgt 68\n 31: iload_3\n 32: istore 4\n 34: iinc 3, -1\n 37: aload_1\n 38: aload_0\n 39: iload 4\n 41: invokeinterface #112, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 46: invokeinterface #128, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 51: checkcast #130 // class java/lang/Boolean\n 54: invokevirtual #134 // Method java/lang/Boolean.booleanValue:()Z\n 57: ifeq 63\n 60: iload 4\n 62: ireturn\n 63: iconst_0\n 64: iload_3\n 65: if_icmple 31\n 68: iconst_m1\n 69: ireturn\n\n public static final void forEach(java.util.List<? extends java.util.List<java.lang.Character>>, kotlin.jvm.functions.Function2<? super java.lang.Integer, ? super java.lang.Integer, kotlin.Unit>);\n Code:\n 0: aload_0\n 1: ldc #50 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #143 // String block\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: iconst_0\n 13: istore_2\n 14: iconst_0\n 15: istore_3\n 16: aload_0\n 17: checkcast #123 // class java/util/Collection\n 20: invokeinterface #124, 1 // InterfaceMethod java/util/Collection.size:()I\n 25: istore 4\n 27: iload_3\n 28: iload 4\n 30: if_icmpge 95\n 33: aload_0\n 34: iload_3\n 35: invokeinterface #112, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 40: checkcast #104 // class java/util/List\n 43: astore 5\n 45: iconst_0\n 46: istore 6\n 48: aload 5\n 50: checkcast #123 // class java/util/Collection\n 53: invokeinterface #124, 1 // InterfaceMethod java/util/Collection.size:()I\n 58: istore 7\n 60: iload 6\n 62: iload 7\n 64: if_icmpge 89\n 67: aload_1\n 68: iload_3\n 69: invokestatic #149 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 72: iload 6\n 74: invokestatic #149 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 77: invokeinterface #154, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 82: pop\n 83: iinc 6, 1\n 86: goto 60\n 89: iinc 3, 1\n 92: goto 27\n 95: return\n\n public static final int maxOf(java.util.List<? extends java.util.List<java.lang.Character>>, kotlin.jvm.functions.Function2<? super java.lang.Integer, ? super java.lang.Integer, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #50 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #143 // String block\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: iconst_0\n 13: istore_2\n 14: aload_0\n 15: astore_3\n 16: iconst_0\n 17: istore 4\n 19: iconst_0\n 20: istore 5\n 22: aload_3\n 23: checkcast #123 // class java/util/Collection\n 26: invokeinterface #124, 1 // InterfaceMethod java/util/Collection.size:()I\n 31: istore 6\n 33: iload 5\n 35: iload 6\n 37: if_icmpge 137\n 40: aload_3\n 41: iload 5\n 43: invokeinterface #112, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 48: checkcast #104 // class java/util/List\n 51: astore 7\n 53: iconst_0\n 54: istore 8\n 56: aload 7\n 58: checkcast #123 // class java/util/Collection\n 61: invokeinterface #124, 1 // InterfaceMethod java/util/Collection.size:()I\n 66: istore 9\n 68: iload 8\n 70: iload 9\n 72: if_icmpge 131\n 75: iload 5\n 77: iload 8\n 79: istore 10\n 81: istore 11\n 83: iconst_0\n 84: istore 12\n 86: aload_1\n 87: iload 11\n 89: invokestatic #149 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 92: iload 10\n 94: invokestatic #149 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 97: invokeinterface #154, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 102: checkcast #164 // class java/lang/Number\n 105: invokevirtual #167 // Method java/lang/Number.intValue:()I\n 108: istore 13\n 110: iload 13\n 112: iload_2\n 113: if_icmple 121\n 116: iload 13\n 118: goto 122\n 121: iload_2\n 122: istore_2\n 123: nop\n 124: nop\n 125: iinc 8, 1\n 128: goto 68\n 131: iinc 5, 1\n 134: goto 33\n 137: nop\n 138: iload_2\n 139: ireturn\n\n public static final int count(java.util.List<? extends java.util.List<java.lang.Character>>, kotlin.jvm.functions.Function2<? super java.lang.Integer, ? super java.lang.Integer, java.lang.Boolean>);\n Code:\n 0: aload_0\n 1: ldc #50 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #143 // String block\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: iconst_0\n 13: istore_2\n 14: aload_0\n 15: astore_3\n 16: iconst_0\n 17: istore 4\n 19: iconst_0\n 20: istore 5\n 22: aload_3\n 23: checkcast #123 // class java/util/Collection\n 26: invokeinterface #124, 1 // InterfaceMethod java/util/Collection.size:()I\n 31: istore 6\n 33: iload 5\n 35: iload 6\n 37: if_icmpge 133\n 40: aload_3\n 41: iload 5\n 43: invokeinterface #112, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 48: checkcast #104 // class java/util/List\n 51: astore 7\n 53: iconst_0\n 54: istore 8\n 56: aload 7\n 58: checkcast #123 // class java/util/Collection\n 61: invokeinterface #124, 1 // InterfaceMethod java/util/Collection.size:()I\n 66: istore 9\n 68: iload 8\n 70: iload 9\n 72: if_icmpge 127\n 75: iload 5\n 77: iload 8\n 79: istore 10\n 81: istore 11\n 83: iconst_0\n 84: istore 12\n 86: iload_2\n 87: aload_1\n 88: iload 11\n 90: invokestatic #149 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 93: iload 10\n 95: invokestatic #149 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 98: invokeinterface #154, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 103: checkcast #130 // class java/lang/Boolean\n 106: invokevirtual #134 // Method java/lang/Boolean.booleanValue:()Z\n 109: ifeq 116\n 112: iconst_1\n 113: goto 117\n 116: iconst_0\n 117: iadd\n 118: istore_2\n 119: nop\n 120: nop\n 121: iinc 8, 1\n 124: goto 68\n 127: iinc 5, 1\n 130: goto 33\n 133: nop\n 134: iload_2\n 135: ireturn\n\n private static final int allIntsInString$lambda$0(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc #183 // 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: invokeinterface #188, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 12: invokestatic #192 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 15: ireturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day14.kt
import Type.* enum class Type { NONE, SAND, WALL } fun main() { fun parse(input: List<String>): MutableMap<Point, Type> { val terrain = mutableMapOf<Point, Type>() val walls = input.map { it.split(" -> ") .map { it.split(",") } .map { (x, y) -> Point(x.toInt(), y.toInt()) } } walls.forEach { wall -> wall.reduce { p1, p2 -> val xRange = if (p1.x > p2.x) { p2.x..p1.x } else { p1.x..p2.x } val yRange = if (p1.y > p2.y) { p2.y..p1.y } else { p1.y..p2.y } for (x in xRange) { terrain[Point(x, p1.y)] = WALL } for (y in yRange) { terrain[Point(p1.x, y)] = WALL } p2 } } return terrain } fun findMaxY(terrain: MutableMap<Point, Type>): Int { return terrain.keys.maxOf { it.y } } fun addSand(terrain: MutableMap<Point, Type>): Boolean { val maxY = findMaxY(terrain) val sandPoint = Point(500, 0) while (true) { sandPoint += Point(0, 1) if (sandPoint.y > maxY) { return false } val type = terrain[sandPoint] ?: NONE when (type) { NONE -> continue SAND, WALL -> { val leftType = terrain[sandPoint + Point(-1, 0)] ?: NONE when (leftType) { NONE -> sandPoint += Point(-1, 0) WALL, SAND -> { val rightType = terrain[sandPoint + Point(+1, 0)] ?: NONE if (rightType == NONE) { sandPoint += Point(+1, 0) } else { terrain[sandPoint + Point(0, -1)] = SAND return true } } } } } } } fun addSand2(terrain: MutableMap<Point, Type>, maxY: Int): Boolean { val sandPoint = Point(500, 0) while (true) { sandPoint += Point(0, 1) if (sandPoint.y >= maxY+2) { terrain[sandPoint + Point(0, -1)] = SAND return true } val type = terrain[sandPoint] ?: NONE when (type) { NONE -> continue SAND, WALL -> { val leftType = terrain[sandPoint + Point(-1, 0)] ?: NONE when (leftType) { NONE -> sandPoint += Point(-1, 0) WALL, SAND -> { val rightType = terrain[sandPoint + Point(+1, 0)] ?: NONE if (rightType == NONE) { sandPoint += Point(+1, 0) } else { val restPoint = sandPoint + Point(0, -1) terrain[restPoint] = SAND if (restPoint.x == 500 && restPoint.y == 0) { return false } return true } } } } } } } fun part1(input: List<String>): Int { val terrain = parse(input) var counter = 0 while (addSand(terrain)) { counter++ } return counter } fun part2(input: List<String>): Int { val terrain = parse(input) val maxY = findMaxY(terrain) var counter = 0 while (addSand2(terrain, maxY)) { counter++ } return counter+1 } val input = readInput("inputs/Day14") println(part1(input)) println(part2(input)) }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day14Kt.class", "javap": "Compiled from \"Day14.kt\"\npublic final class Day14Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/Day14\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 main$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 main$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 void main(java.lang.String[]);\n Code:\n 0: invokestatic #38 // Method main:()V\n 3: return\n\n private static final java.util.Map<Point, Type> main$parse(java.util.List<java.lang.String>);\n Code:\n 0: new #45 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #48 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #50 // class java/util/Map\n 10: astore_1\n 11: aload_0\n 12: checkcast #52 // 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 #54 // class java/util/ArrayList\n 25: dup\n 26: aload_3\n 27: bipush 10\n 29: invokestatic #60 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 32: invokespecial #62 // Method java/util/ArrayList.\"<init>\":(I)V\n 35: checkcast #64 // class java/util/Collection\n 38: astore 6\n 40: iconst_0\n 41: istore 7\n 43: aload 5\n 45: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 8\n 52: aload 8\n 54: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 385\n 62: aload 8\n 64: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 9\n 71: aload 6\n 73: aload 9\n 75: checkcast #80 // class java/lang/String\n 78: astore 10\n 80: astore 24\n 82: iconst_0\n 83: istore 11\n 85: aload 10\n 87: checkcast #82 // class java/lang/CharSequence\n 90: iconst_1\n 91: anewarray #80 // class java/lang/String\n 94: astore 12\n 96: aload 12\n 98: iconst_0\n 99: ldc #84 // String ->\n 101: aastore\n 102: aload 12\n 104: iconst_0\n 105: iconst_0\n 106: bipush 6\n 108: aconst_null\n 109: invokestatic #90 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 112: checkcast #52 // class java/lang/Iterable\n 115: astore 12\n 117: nop\n 118: iconst_0\n 119: istore 13\n 121: aload 12\n 123: astore 14\n 125: new #54 // class java/util/ArrayList\n 128: dup\n 129: aload 12\n 131: bipush 10\n 133: invokestatic #60 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 136: invokespecial #62 // Method java/util/ArrayList.\"<init>\":(I)V\n 139: checkcast #64 // class java/util/Collection\n 142: astore 15\n 144: iconst_0\n 145: istore 16\n 147: aload 14\n 149: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 154: astore 17\n 156: aload 17\n 158: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 163: ifeq 228\n 166: aload 17\n 168: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 173: astore 18\n 175: aload 15\n 177: aload 18\n 179: checkcast #80 // class java/lang/String\n 182: astore 19\n 184: astore 20\n 186: iconst_0\n 187: istore 21\n 189: aload 19\n 191: checkcast #82 // class java/lang/CharSequence\n 194: iconst_1\n 195: anewarray #80 // class java/lang/String\n 198: astore 22\n 200: aload 22\n 202: iconst_0\n 203: ldc #92 // String ,\n 205: aastore\n 206: aload 22\n 208: iconst_0\n 209: iconst_0\n 210: bipush 6\n 212: aconst_null\n 213: invokestatic #90 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 216: aload 20\n 218: swap\n 219: invokeinterface #96, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 224: pop\n 225: goto 156\n 228: aload 15\n 230: checkcast #98 // class java/util/List\n 233: nop\n 234: checkcast #52 // class java/lang/Iterable\n 237: astore 12\n 239: nop\n 240: iconst_0\n 241: istore 13\n 243: aload 12\n 245: astore 14\n 247: new #54 // class java/util/ArrayList\n 250: dup\n 251: aload 12\n 253: bipush 10\n 255: invokestatic #60 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 258: invokespecial #62 // Method java/util/ArrayList.\"<init>\":(I)V\n 261: checkcast #64 // class java/util/Collection\n 264: astore 15\n 266: iconst_0\n 267: istore 16\n 269: aload 14\n 271: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 276: astore 17\n 278: aload 17\n 280: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 285: ifeq 366\n 288: aload 17\n 290: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 295: astore 18\n 297: aload 15\n 299: aload 18\n 301: checkcast #98 // class java/util/List\n 304: astore 19\n 306: astore 20\n 308: iconst_0\n 309: istore 21\n 311: aload 19\n 313: iconst_0\n 314: invokeinterface #102, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 319: checkcast #80 // class java/lang/String\n 322: astore 22\n 324: aload 19\n 326: iconst_1\n 327: invokeinterface #102, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 332: checkcast #80 // class java/lang/String\n 335: astore 23\n 337: new #104 // class Point\n 340: dup\n 341: aload 22\n 343: invokestatic #110 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 346: aload 23\n 348: invokestatic #110 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 351: invokespecial #113 // Method Point.\"<init>\":(II)V\n 354: aload 20\n 356: swap\n 357: invokeinterface #96, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 362: pop\n 363: goto 278\n 366: aload 15\n 368: checkcast #98 // class java/util/List\n 371: nop\n 372: nop\n 373: aload 24\n 375: swap\n 376: invokeinterface #96, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 381: pop\n 382: goto 52\n 385: aload 6\n 387: checkcast #98 // class java/util/List\n 390: nop\n 391: astore_2\n 392: aload_2\n 393: checkcast #52 // class java/lang/Iterable\n 396: astore_3\n 397: iconst_0\n 398: istore 4\n 400: aload_3\n 401: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 406: astore 5\n 408: aload 5\n 410: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 415: ifeq 750\n 418: aload 5\n 420: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 425: astore 6\n 427: aload 6\n 429: checkcast #98 // class java/util/List\n 432: astore 7\n 434: iconst_0\n 435: istore 8\n 437: aload 7\n 439: checkcast #52 // class java/lang/Iterable\n 442: astore 9\n 444: iconst_0\n 445: istore 10\n 447: aload 9\n 449: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 454: astore 11\n 456: aload 11\n 458: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 463: ifne 476\n 466: new #115 // class java/lang/UnsupportedOperationException\n 469: dup\n 470: ldc #117 // String Empty collection can\\'t be reduced.\n 472: invokespecial #120 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 475: athrow\n 476: aload 11\n 478: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 483: astore 12\n 485: aload 11\n 487: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 492: ifeq 744\n 495: aload 12\n 497: aload 11\n 499: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 504: checkcast #104 // class Point\n 507: astore 13\n 509: checkcast #104 // class Point\n 512: astore 14\n 514: iconst_0\n 515: istore 15\n 517: aload 14\n 519: invokevirtual #124 // Method Point.getX:()I\n 522: aload 13\n 524: invokevirtual #124 // Method Point.getX:()I\n 527: if_icmple 550\n 530: new #126 // class kotlin/ranges/IntRange\n 533: dup\n 534: aload 13\n 536: invokevirtual #124 // Method Point.getX:()I\n 539: aload 14\n 541: invokevirtual #124 // Method Point.getX:()I\n 544: invokespecial #127 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 547: goto 567\n 550: new #126 // class kotlin/ranges/IntRange\n 553: dup\n 554: aload 14\n 556: invokevirtual #124 // Method Point.getX:()I\n 559: aload 13\n 561: invokevirtual #124 // Method Point.getX:()I\n 564: invokespecial #127 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 567: astore 16\n 569: aload 14\n 571: invokevirtual #130 // Method Point.getY:()I\n 574: aload 13\n 576: invokevirtual #130 // Method Point.getY:()I\n 579: if_icmple 602\n 582: new #126 // class kotlin/ranges/IntRange\n 585: dup\n 586: aload 13\n 588: invokevirtual #130 // Method Point.getY:()I\n 591: aload 14\n 593: invokevirtual #130 // Method Point.getY:()I\n 596: invokespecial #127 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 599: goto 619\n 602: new #126 // class kotlin/ranges/IntRange\n 605: dup\n 606: aload 14\n 608: invokevirtual #130 // Method Point.getY:()I\n 611: aload 13\n 613: invokevirtual #130 // Method Point.getY:()I\n 616: invokespecial #127 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 619: astore 17\n 621: aload 16\n 623: invokevirtual #133 // Method kotlin/ranges/IntRange.getFirst:()I\n 626: istore 18\n 628: aload 16\n 630: invokevirtual #136 // Method kotlin/ranges/IntRange.getLast:()I\n 633: istore 19\n 635: iload 18\n 637: iload 19\n 639: if_icmpgt 679\n 642: aload_1\n 643: new #104 // class Point\n 646: dup\n 647: iload 18\n 649: aload 14\n 651: invokevirtual #130 // Method Point.getY:()I\n 654: invokespecial #113 // Method Point.\"<init>\":(II)V\n 657: getstatic #142 // Field Type.WALL:LType;\n 660: invokeinterface #146, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 665: pop\n 666: iload 18\n 668: iload 19\n 670: if_icmpeq 679\n 673: iinc 18, 1\n 676: goto 642\n 679: aload 17\n 681: invokevirtual #133 // Method kotlin/ranges/IntRange.getFirst:()I\n 684: istore 18\n 686: aload 17\n 688: invokevirtual #136 // Method kotlin/ranges/IntRange.getLast:()I\n 691: istore 19\n 693: iload 18\n 695: iload 19\n 697: if_icmpgt 737\n 700: aload_1\n 701: new #104 // class Point\n 704: dup\n 705: aload 14\n 707: invokevirtual #124 // Method Point.getX:()I\n 710: iload 18\n 712: invokespecial #113 // Method Point.\"<init>\":(II)V\n 715: getstatic #142 // Field Type.WALL:LType;\n 718: invokeinterface #146, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 723: pop\n 724: iload 18\n 726: iload 19\n 728: if_icmpeq 737\n 731: iinc 18, 1\n 734: goto 700\n 737: aload 13\n 739: astore 12\n 741: goto 485\n 744: nop\n 745: nop\n 746: nop\n 747: goto 408\n 750: nop\n 751: aload_1\n 752: areturn\n\n private static final int main$findMaxY(java.util.Map<Point, Type>);\n Code:\n 0: aload_0\n 1: invokeinterface #190, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 6: checkcast #52 // class java/lang/Iterable\n 9: invokeinterface #68, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 14: astore_1\n 15: aload_1\n 16: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 21: ifne 32\n 24: new #192 // class java/util/NoSuchElementException\n 27: dup\n 28: invokespecial #193 // Method java/util/NoSuchElementException.\"<init>\":()V\n 31: athrow\n 32: aload_1\n 33: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 38: checkcast #104 // class Point\n 41: astore_2\n 42: iconst_0\n 43: istore_3\n 44: aload_2\n 45: invokevirtual #130 // Method Point.getY:()I\n 48: istore_2\n 49: aload_1\n 50: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 55: ifeq 86\n 58: aload_1\n 59: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: checkcast #104 // class Point\n 67: astore_3\n 68: iconst_0\n 69: istore 4\n 71: aload_3\n 72: invokevirtual #130 // Method Point.getY:()I\n 75: istore_3\n 76: iload_2\n 77: iload_3\n 78: if_icmpge 49\n 81: iload_3\n 82: istore_2\n 83: goto 49\n 86: iload_2\n 87: ireturn\n\n private static final boolean main$addSand(java.util.Map<Point, Type>);\n Code:\n 0: aload_0\n 1: invokestatic #199 // Method main$findMaxY:(Ljava/util/Map;)I\n 4: istore_1\n 5: new #104 // class Point\n 8: dup\n 9: sipush 500\n 12: iconst_0\n 13: invokespecial #113 // Method Point.\"<init>\":(II)V\n 16: astore_2\n 17: nop\n 18: aload_2\n 19: new #104 // class Point\n 22: dup\n 23: iconst_0\n 24: iconst_1\n 25: invokespecial #113 // Method Point.\"<init>\":(II)V\n 28: invokevirtual #203 // Method Point.plusAssign:(LPoint;)V\n 31: aload_2\n 32: invokevirtual #130 // Method Point.getY:()I\n 35: iload_1\n 36: if_icmple 41\n 39: iconst_0\n 40: ireturn\n 41: aload_0\n 42: aload_2\n 43: invokeinterface #206, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 48: checkcast #138 // class Type\n 51: dup\n 52: ifnonnull 59\n 55: pop\n 56: getstatic #209 // Field Type.NONE:LType;\n 59: astore_3\n 60: aload_3\n 61: getstatic #215 // Field Day14Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 64: swap\n 65: invokevirtual #218 // Method Type.ordinal:()I\n 68: iaload\n 69: tableswitch { // 1 to 3\n 1: 96\n 2: 99\n 3: 99\n default: 273\n }\n 96: goto 17\n 99: aload_0\n 100: aload_2\n 101: new #104 // class Point\n 104: dup\n 105: iconst_m1\n 106: iconst_0\n 107: invokespecial #113 // Method Point.\"<init>\":(II)V\n 110: invokevirtual #222 // Method Point.plus:(LPoint;)LPoint;\n 113: invokeinterface #206, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 118: checkcast #138 // class Type\n 121: dup\n 122: ifnonnull 129\n 125: pop\n 126: getstatic #209 // Field Type.NONE:LType;\n 129: astore 4\n 131: aload 4\n 133: getstatic #215 // Field Day14Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 136: swap\n 137: invokevirtual #218 // Method Type.ordinal:()I\n 140: iaload\n 141: tableswitch { // 1 to 3\n 1: 168\n 2: 184\n 3: 184\n default: 265\n }\n 168: aload_2\n 169: new #104 // class Point\n 172: dup\n 173: iconst_m1\n 174: iconst_0\n 175: invokespecial #113 // Method Point.\"<init>\":(II)V\n 178: invokevirtual #203 // Method Point.plusAssign:(LPoint;)V\n 181: goto 17\n 184: aload_0\n 185: aload_2\n 186: new #104 // class Point\n 189: dup\n 190: iconst_1\n 191: iconst_0\n 192: invokespecial #113 // Method Point.\"<init>\":(II)V\n 195: invokevirtual #222 // Method Point.plus:(LPoint;)LPoint;\n 198: invokeinterface #206, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 203: checkcast #138 // class Type\n 206: dup\n 207: ifnonnull 214\n 210: pop\n 211: getstatic #209 // Field Type.NONE:LType;\n 214: astore 5\n 216: aload 5\n 218: getstatic #209 // Field Type.NONE:LType;\n 221: if_acmpne 240\n 224: aload_2\n 225: new #104 // class Point\n 228: dup\n 229: iconst_1\n 230: iconst_0\n 231: invokespecial #113 // Method Point.\"<init>\":(II)V\n 234: invokevirtual #203 // Method Point.plusAssign:(LPoint;)V\n 237: goto 17\n 240: aload_0\n 241: aload_2\n 242: new #104 // class Point\n 245: dup\n 246: iconst_0\n 247: iconst_m1\n 248: invokespecial #113 // Method Point.\"<init>\":(II)V\n 251: invokevirtual #222 // Method Point.plus:(LPoint;)LPoint;\n 254: getstatic #225 // Field Type.SAND:LType;\n 257: invokeinterface #146, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 262: pop\n 263: iconst_1\n 264: ireturn\n 265: new #227 // class kotlin/NoWhenBranchMatchedException\n 268: dup\n 269: invokespecial #228 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 272: athrow\n 273: new #227 // class kotlin/NoWhenBranchMatchedException\n 276: dup\n 277: invokespecial #228 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 280: athrow\n\n private static final boolean main$addSand2(java.util.Map<Point, Type>, int);\n Code:\n 0: new #104 // class Point\n 3: dup\n 4: sipush 500\n 7: iconst_0\n 8: invokespecial #113 // Method Point.\"<init>\":(II)V\n 11: astore_2\n 12: nop\n 13: aload_2\n 14: new #104 // class Point\n 17: dup\n 18: iconst_0\n 19: iconst_1\n 20: invokespecial #113 // Method Point.\"<init>\":(II)V\n 23: invokevirtual #203 // Method Point.plusAssign:(LPoint;)V\n 26: aload_2\n 27: invokevirtual #130 // Method Point.getY:()I\n 30: iload_1\n 31: iconst_2\n 32: iadd\n 33: if_icmplt 61\n 36: aload_0\n 37: aload_2\n 38: new #104 // class Point\n 41: dup\n 42: iconst_0\n 43: iconst_m1\n 44: invokespecial #113 // Method Point.\"<init>\":(II)V\n 47: invokevirtual #222 // Method Point.plus:(LPoint;)LPoint;\n 50: getstatic #225 // Field Type.SAND:LType;\n 53: invokeinterface #146, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 58: pop\n 59: iconst_1\n 60: ireturn\n 61: aload_0\n 62: aload_2\n 63: invokeinterface #206, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 68: checkcast #138 // class Type\n 71: dup\n 72: ifnonnull 79\n 75: pop\n 76: getstatic #209 // Field Type.NONE:LType;\n 79: astore_3\n 80: aload_3\n 81: getstatic #215 // Field Day14Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 84: swap\n 85: invokevirtual #218 // Method Type.ordinal:()I\n 88: iaload\n 89: tableswitch { // 1 to 3\n 1: 116\n 2: 119\n 3: 119\n default: 318\n }\n 116: goto 12\n 119: aload_0\n 120: aload_2\n 121: new #104 // class Point\n 124: dup\n 125: iconst_m1\n 126: iconst_0\n 127: invokespecial #113 // Method Point.\"<init>\":(II)V\n 130: invokevirtual #222 // Method Point.plus:(LPoint;)LPoint;\n 133: invokeinterface #206, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 138: checkcast #138 // class Type\n 141: dup\n 142: ifnonnull 149\n 145: pop\n 146: getstatic #209 // Field Type.NONE:LType;\n 149: astore 4\n 151: aload 4\n 153: getstatic #215 // Field Day14Kt$WhenMappings.$EnumSwitchMapping$0:[I\n 156: swap\n 157: invokevirtual #218 // Method Type.ordinal:()I\n 160: iaload\n 161: tableswitch { // 1 to 3\n 1: 188\n 2: 204\n 3: 204\n default: 310\n }\n 188: aload_2\n 189: new #104 // class Point\n 192: dup\n 193: iconst_m1\n 194: iconst_0\n 195: invokespecial #113 // Method Point.\"<init>\":(II)V\n 198: invokevirtual #203 // Method Point.plusAssign:(LPoint;)V\n 201: goto 12\n 204: aload_0\n 205: aload_2\n 206: new #104 // class Point\n 209: dup\n 210: iconst_1\n 211: iconst_0\n 212: invokespecial #113 // Method Point.\"<init>\":(II)V\n 215: invokevirtual #222 // Method Point.plus:(LPoint;)LPoint;\n 218: invokeinterface #206, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 223: checkcast #138 // class Type\n 226: dup\n 227: ifnonnull 234\n 230: pop\n 231: getstatic #209 // Field Type.NONE:LType;\n 234: astore 5\n 236: aload 5\n 238: getstatic #209 // Field Type.NONE:LType;\n 241: if_acmpne 260\n 244: aload_2\n 245: new #104 // class Point\n 248: dup\n 249: iconst_1\n 250: iconst_0\n 251: invokespecial #113 // Method Point.\"<init>\":(II)V\n 254: invokevirtual #203 // Method Point.plusAssign:(LPoint;)V\n 257: goto 12\n 260: aload_2\n 261: new #104 // class Point\n 264: dup\n 265: iconst_0\n 266: iconst_m1\n 267: invokespecial #113 // Method Point.\"<init>\":(II)V\n 270: invokevirtual #222 // Method Point.plus:(LPoint;)LPoint;\n 273: astore 6\n 275: aload_0\n 276: aload 6\n 278: getstatic #225 // Field Type.SAND:LType;\n 281: invokeinterface #146, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 286: pop\n 287: aload 6\n 289: invokevirtual #124 // Method Point.getX:()I\n 292: sipush 500\n 295: if_icmpne 308\n 298: aload 6\n 300: invokevirtual #130 // Method Point.getY:()I\n 303: ifne 308\n 306: iconst_0\n 307: ireturn\n 308: iconst_1\n 309: ireturn\n 310: new #227 // class kotlin/NoWhenBranchMatchedException\n 313: dup\n 314: invokespecial #228 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 317: athrow\n 318: new #227 // class kotlin/NoWhenBranchMatchedException\n 321: dup\n 322: invokespecial #228 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 325: athrow\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #240 // Method main$parse:(Ljava/util/List;)Ljava/util/Map;\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokestatic #242 // Method main$addSand:(Ljava/util/Map;)Z\n 11: ifeq 20\n 14: iinc 2, 1\n 17: goto 7\n 20: iload_2\n 21: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #240 // Method main$parse:(Ljava/util/List;)Ljava/util/Map;\n 4: astore_1\n 5: aload_1\n 6: invokestatic #199 // Method main$findMaxY:(Ljava/util/Map;)I\n 9: istore_2\n 10: iconst_0\n 11: istore_3\n 12: aload_1\n 13: iload_2\n 14: invokestatic #245 // Method main$addSand2:(Ljava/util/Map;I)Z\n 17: ifeq 26\n 20: iinc 3, 1\n 23: goto 12\n 26: iload_3\n 27: iconst_1\n 28: iadd\n 29: ireturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day14Kt$WhenMappings.class", "javap": "Compiled from \"Day14.kt\"\npublic final class Day14Kt$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method Type.values:()[LType;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field Type.NONE:LType;\n 12: invokevirtual #22 // Method Type.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 Type.WALL:LType;\n 26: invokevirtual #22 // Method Type.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 Type.SAND:LType;\n 40: invokevirtual #22 // Method Type.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": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day04.kt
fun main() { fun part1(input: List<String>) = input .readRanges() .count { (first, second) -> first contains second || second contains first } fun part2(input: List<String>) = input .readRanges() .count { (first, second) -> first overlaps second } val input = readInput("inputs/Day04") println(part1(input)) println(part2(input)) } fun List<String>.readRanges() = this.map { it.split(",").map { s -> val (start, end) = s.split("-") start.toInt()..end.toInt() } } infix fun IntRange.contains(second: IntRange) = this.first <= second.first && this.last >= second.last infix fun IntRange.overlaps(second: IntRange) = (this intersect second).isNotEmpty()
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day04Kt.class", "javap": "Compiled from \"Day04.kt\"\npublic final class Day04Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/Day04\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 main$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 main$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.List<java.util.List<kotlin.ranges.IntRange>> readRanges(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: ldc #41 // String <this>\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #49 // 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 #51 // class java/util/ArrayList\n 18: dup\n 19: aload_1\n 20: bipush 10\n 22: invokestatic #57 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 25: invokespecial #60 // Method java/util/ArrayList.\"<init>\":(I)V\n 28: checkcast #62 // class java/util/Collection\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: aload_3\n 37: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 6\n 44: aload 6\n 46: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 283\n 54: aload 6\n 56: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 7\n 63: aload 4\n 65: aload 7\n 67: checkcast #78 // class java/lang/String\n 70: astore 8\n 72: astore 23\n 74: iconst_0\n 75: istore 9\n 77: aload 8\n 79: checkcast #80 // class java/lang/CharSequence\n 82: iconst_1\n 83: anewarray #78 // class java/lang/String\n 86: astore 10\n 88: aload 10\n 90: iconst_0\n 91: ldc #82 // 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 #88 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 104: checkcast #49 // 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 #51 // class java/util/ArrayList\n 119: dup\n 120: aload 10\n 122: bipush 10\n 124: invokestatic #57 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 127: invokespecial #60 // Method java/util/ArrayList.\"<init>\":(I)V\n 130: checkcast #62 // class java/util/Collection\n 133: astore 13\n 135: iconst_0\n 136: istore 14\n 138: aload 12\n 140: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 145: astore 15\n 147: aload 15\n 149: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 154: ifeq 264\n 157: aload 15\n 159: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 164: astore 16\n 166: aload 13\n 168: aload 16\n 170: checkcast #78 // 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: checkcast #80 // class java/lang/CharSequence\n 185: iconst_1\n 186: anewarray #78 // class java/lang/String\n 189: astore 20\n 191: aload 20\n 193: iconst_0\n 194: ldc #90 // String -\n 196: aastore\n 197: aload 20\n 199: iconst_0\n 200: iconst_0\n 201: bipush 6\n 203: aconst_null\n 204: invokestatic #88 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 207: astore 21\n 209: aload 21\n 211: iconst_0\n 212: invokeinterface #96, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 217: checkcast #78 // class java/lang/String\n 220: astore 20\n 222: aload 21\n 224: iconst_1\n 225: invokeinterface #96, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 230: checkcast #78 // class java/lang/String\n 233: astore 22\n 235: new #98 // class kotlin/ranges/IntRange\n 238: dup\n 239: aload 20\n 241: invokestatic #104 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 244: aload 22\n 246: invokestatic #104 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 249: invokespecial #107 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 252: aload 18\n 254: swap\n 255: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 260: pop\n 261: goto 147\n 264: aload 13\n 266: checkcast #92 // class java/util/List\n 269: nop\n 270: nop\n 271: aload 23\n 273: swap\n 274: invokeinterface #111, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 279: pop\n 280: goto 44\n 283: aload 4\n 285: checkcast #92 // class java/util/List\n 288: nop\n 289: areturn\n\n public static final boolean contains(kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_0\n 1: ldc #41 // String <this>\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #133 // String second\n 9: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokevirtual #137 // Method kotlin/ranges/IntRange.getFirst:()I\n 16: aload_1\n 17: invokevirtual #137 // Method kotlin/ranges/IntRange.getFirst:()I\n 20: if_icmpgt 38\n 23: aload_0\n 24: invokevirtual #140 // Method kotlin/ranges/IntRange.getLast:()I\n 27: aload_1\n 28: invokevirtual #140 // Method kotlin/ranges/IntRange.getLast:()I\n 31: if_icmplt 38\n 34: iconst_1\n 35: goto 39\n 38: iconst_0\n 39: ireturn\n\n public static final boolean overlaps(kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_0\n 1: ldc #41 // String <this>\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #133 // String second\n 9: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: checkcast #49 // class java/lang/Iterable\n 16: aload_1\n 17: checkcast #49 // class java/lang/Iterable\n 20: invokestatic #147 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 23: checkcast #62 // class java/util/Collection\n 26: invokeinterface #150, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 31: ifne 38\n 34: iconst_1\n 35: goto 39\n 38: iconst_0\n 39: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #154 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #159 // Method readRanges:(Ljava/util/List;)Ljava/util/List;\n 4: checkcast #49 // class java/lang/Iterable\n 7: astore_1\n 8: nop\n 9: iconst_0\n 10: istore_2\n 11: aload_1\n 12: instanceof #62 // class java/util/Collection\n 15: ifeq 34\n 18: aload_1\n 19: checkcast #62 // class java/util/Collection\n 22: invokeinterface #150, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 27: ifeq 34\n 30: iconst_0\n 31: goto 141\n 34: iconst_0\n 35: istore_3\n 36: aload_1\n 37: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 4\n 44: aload 4\n 46: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 140\n 54: aload 4\n 56: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 5\n 63: aload 5\n 65: checkcast #92 // class java/util/List\n 68: astore 6\n 70: iconst_0\n 71: istore 7\n 73: aload 6\n 75: iconst_0\n 76: invokeinterface #96, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 81: checkcast #98 // class kotlin/ranges/IntRange\n 84: astore 8\n 86: aload 6\n 88: iconst_1\n 89: invokeinterface #96, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 94: checkcast #98 // class kotlin/ranges/IntRange\n 97: astore 9\n 99: aload 8\n 101: aload 9\n 103: invokestatic #161 // Method contains:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z\n 106: ifne 119\n 109: aload 9\n 111: aload 8\n 113: invokestatic #161 // Method contains:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z\n 116: ifeq 123\n 119: iconst_1\n 120: goto 124\n 123: iconst_0\n 124: ifeq 44\n 127: iinc 3, 1\n 130: iload_3\n 131: ifge 44\n 134: invokestatic #164 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 137: goto 44\n 140: iload_3\n 141: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #159 // Method readRanges:(Ljava/util/List;)Ljava/util/List;\n 4: checkcast #49 // class java/lang/Iterable\n 7: astore_1\n 8: nop\n 9: iconst_0\n 10: istore_2\n 11: aload_1\n 12: instanceof #62 // class java/util/Collection\n 15: ifeq 34\n 18: aload_1\n 19: checkcast #62 // class java/util/Collection\n 22: invokeinterface #150, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 27: ifeq 34\n 30: iconst_0\n 31: goto 123\n 34: iconst_0\n 35: istore_3\n 36: aload_1\n 37: invokeinterface #66, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 4\n 44: aload 4\n 46: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 122\n 54: aload 4\n 56: invokeinterface #76, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 5\n 63: aload 5\n 65: checkcast #92 // class java/util/List\n 68: astore 6\n 70: iconst_0\n 71: istore 7\n 73: aload 6\n 75: iconst_0\n 76: invokeinterface #96, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 81: checkcast #98 // class kotlin/ranges/IntRange\n 84: astore 8\n 86: aload 6\n 88: iconst_1\n 89: invokeinterface #96, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 94: checkcast #98 // class kotlin/ranges/IntRange\n 97: astore 9\n 99: aload 8\n 101: aload 9\n 103: invokestatic #172 // Method overlaps:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z\n 106: ifeq 44\n 109: iinc 3, 1\n 112: iload_3\n 113: ifge 44\n 116: invokestatic #164 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 119: goto 44\n 122: iload_3\n 123: ireturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day12.kt
fun main() { class Terrain constructor(input: List<String>) { val distances: HashMap<Point, Int> = HashMap() var queue: ArrayDeque<Point> = ArrayDeque() var heightmap: List<List<Char>> = input.map { it.toList() } fun enqueue(point: Point, distance: Int) { if (distances[point] == null || distances[point]!! > distance) { queue += point distances[point] = distance } } fun find(c: Char): Point { heightmap.forEach { x, y -> if (heightmap[x][y] == c) { return Point(x, y) } } error("Not found $c") } fun height(point: Point): Int { val height = heightmap[point.x][point.y] return when (height) { 'S' -> 0 'E' -> 'z' - 'a' else -> height - 'a' } } fun minSteps(start: Point, end: Point): Int { enqueue(start, 0) while (queue.isNotEmpty()) { val point = queue.removeFirst() val distance = distances[point]!! + 1 val height = height(point) walk(Point(point.x-1, point.y), distance, height) walk(Point(point.x+1, point.y), distance, height) walk(Point(point.x, point.y-1), distance, height) walk(Point(point.x, point.y+1), distance, height) } return distances[end] ?: Int.MAX_VALUE } fun walk(p: Point, distance: Int, height: Int) { if (p.x !in heightmap.indices || p.y !in 0 until heightmap[0].size) return if (height <= height(p) + 1) { enqueue(p, distance) } } } fun part1(input: List<String>): Int { val terrain = Terrain(input) val start = terrain.find('E') val end = terrain.find('S') return terrain.minSteps(start, end) } fun part2(input: List<String>): Int { val endingPoints = mutableListOf<Point>() val terrain = Terrain(input) terrain.heightmap .forEach { x, y -> val c = terrain.heightmap[x][y] if (c == 'a' || c == 'S') { endingPoints += Point(x, y) } } val start = terrain.find('E') terrain.minSteps(start, endingPoints[0]) return endingPoints.minOf { terrain.distances[it] ?: Int.MAX_VALUE } } val input = readInput("inputs/Day12") println(part1(input)) println(part2(input)) }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day12Kt$main$Terrain.class", "javap": "Compiled from \"Day12.kt\"\npublic final class Day12Kt$main$Terrain {\n private final java.util.HashMap<Point, java.lang.Integer> distances;\n\n private kotlin.collections.ArrayDeque<Point> queue;\n\n private java.util.List<? extends java.util.List<java.lang.Character>> heightmap;\n\n public Day12Kt$main$Terrain(java.util.List<java.lang.String>);\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: new #20 // class java/util/HashMap\n 14: dup\n 15: invokespecial #21 // Method java/util/HashMap.\"<init>\":()V\n 18: putfield #25 // Field distances:Ljava/util/HashMap;\n 21: aload_0\n 22: new #27 // class kotlin/collections/ArrayDeque\n 25: dup\n 26: invokespecial #28 // Method kotlin/collections/ArrayDeque.\"<init>\":()V\n 29: putfield #32 // Field queue:Lkotlin/collections/ArrayDeque;\n 32: aload_0\n 33: aload_1\n 34: checkcast #34 // class java/lang/Iterable\n 37: astore_2\n 38: astore 11\n 40: iconst_0\n 41: istore_3\n 42: aload_2\n 43: astore 4\n 45: new #36 // class java/util/ArrayList\n 48: dup\n 49: aload_2\n 50: bipush 10\n 52: invokestatic #42 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 55: invokespecial #45 // Method java/util/ArrayList.\"<init>\":(I)V\n 58: checkcast #47 // class java/util/Collection\n 61: astore 5\n 63: iconst_0\n 64: istore 6\n 66: aload 4\n 68: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 73: astore 7\n 75: aload 7\n 77: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 82: ifeq 128\n 85: aload 7\n 87: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 92: astore 8\n 94: aload 5\n 96: aload 8\n 98: checkcast #63 // class java/lang/String\n 101: astore 9\n 103: astore 12\n 105: iconst_0\n 106: istore 10\n 108: aload 9\n 110: checkcast #65 // class java/lang/CharSequence\n 113: invokestatic #71 // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;\n 116: aload 12\n 118: swap\n 119: invokeinterface #75, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 124: pop\n 125: goto 75\n 128: aload 5\n 130: checkcast #77 // class java/util/List\n 133: nop\n 134: aload 11\n 136: swap\n 137: putfield #81 // Field heightmap:Ljava/util/List;\n 140: return\n\n public final java.util.HashMap<Point, java.lang.Integer> getDistances();\n Code:\n 0: aload_0\n 1: getfield #25 // Field distances:Ljava/util/HashMap;\n 4: areturn\n\n public final kotlin.collections.ArrayDeque<Point> getQueue();\n Code:\n 0: aload_0\n 1: getfield #32 // Field queue:Lkotlin/collections/ArrayDeque;\n 4: areturn\n\n public final void setQueue(kotlin.collections.ArrayDeque<Point>);\n Code:\n 0: aload_1\n 1: ldc #107 // String <set-?>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: putfield #32 // Field queue:Lkotlin/collections/ArrayDeque;\n 11: return\n\n public final java.util.List<java.util.List<java.lang.Character>> getHeightmap();\n Code:\n 0: aload_0\n 1: getfield #81 // Field heightmap:Ljava/util/List;\n 4: areturn\n\n public final void setHeightmap(java.util.List<? extends java.util.List<java.lang.Character>>);\n Code:\n 0: aload_1\n 1: ldc #107 // String <set-?>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: putfield #81 // Field heightmap:Ljava/util/List;\n 11: return\n\n public final void enqueue(Point, int);\n Code:\n 0: aload_1\n 1: ldc #116 // String point\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #25 // Field distances:Ljava/util/HashMap;\n 10: aload_1\n 11: invokevirtual #120 // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 14: ifnull 39\n 17: aload_0\n 18: getfield #25 // Field distances:Ljava/util/HashMap;\n 21: aload_1\n 22: invokevirtual #120 // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 25: dup\n 26: invokestatic #124 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 29: checkcast #126 // class java/lang/Number\n 32: invokevirtual #130 // Method java/lang/Number.intValue:()I\n 35: iload_2\n 36: if_icmple 73\n 39: aload_0\n 40: getfield #32 // Field queue:Lkotlin/collections/ArrayDeque;\n 43: checkcast #47 // class java/util/Collection\n 46: aload_1\n 47: invokeinterface #75, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 52: pop\n 53: iload_2\n 54: invokestatic #136 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 57: astore_3\n 58: aload_0\n 59: getfield #25 // Field distances:Ljava/util/HashMap;\n 62: checkcast #138 // class java/util/Map\n 65: aload_1\n 66: aload_3\n 67: invokeinterface #142, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 72: pop\n 73: return\n\n public final Point find(char);\n Code:\n 0: aload_0\n 1: getfield #81 // Field heightmap:Ljava/util/List;\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: iconst_0\n 8: istore 4\n 10: aload_2\n 11: checkcast #47 // class java/util/Collection\n 14: invokeinterface #149, 1 // InterfaceMethod java/util/Collection.size:()I\n 19: istore 5\n 21: iload 4\n 23: iload 5\n 25: if_icmpge 131\n 28: aload_2\n 29: iload 4\n 31: invokeinterface #152, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 36: checkcast #77 // class java/util/List\n 39: astore 6\n 41: iconst_0\n 42: istore 7\n 44: aload 6\n 46: checkcast #47 // class java/util/Collection\n 49: invokeinterface #149, 1 // InterfaceMethod java/util/Collection.size:()I\n 54: istore 8\n 56: iload 7\n 58: iload 8\n 60: if_icmpge 125\n 63: iload 4\n 65: iload 7\n 67: istore 9\n 69: istore 10\n 71: iconst_0\n 72: istore 11\n 74: aload_0\n 75: getfield #81 // Field heightmap:Ljava/util/List;\n 78: iload 10\n 80: invokeinterface #152, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 85: checkcast #77 // class java/util/List\n 88: iload 9\n 90: invokeinterface #152, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 95: checkcast #154 // class java/lang/Character\n 98: invokevirtual #158 // Method java/lang/Character.charValue:()C\n 101: iload_1\n 102: if_icmpne 117\n 105: new #160 // class Point\n 108: dup\n 109: iload 10\n 111: iload 9\n 113: invokespecial #163 // Method Point.\"<init>\":(II)V\n 116: areturn\n 117: nop\n 118: nop\n 119: iinc 7, 1\n 122: goto 56\n 125: iinc 4, 1\n 128: goto 21\n 131: nop\n 132: new #165 // class java/lang/IllegalStateException\n 135: dup\n 136: new #167 // class java/lang/StringBuilder\n 139: dup\n 140: invokespecial #168 // Method java/lang/StringBuilder.\"<init>\":()V\n 143: ldc #170 // String Not found\n 145: invokevirtual #174 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 148: iload_1\n 149: invokevirtual #177 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 152: invokevirtual #181 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 155: invokevirtual #182 // Method java/lang/Object.toString:()Ljava/lang/String;\n 158: invokespecial #185 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 161: athrow\n\n public final int height(Point);\n Code:\n 0: aload_1\n 1: ldc #116 // String point\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #81 // Field heightmap:Ljava/util/List;\n 10: aload_1\n 11: invokevirtual #200 // Method Point.getX:()I\n 14: invokeinterface #152, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 19: checkcast #77 // class java/util/List\n 22: aload_1\n 23: invokevirtual #203 // Method Point.getY:()I\n 26: invokeinterface #152, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 31: checkcast #154 // class java/lang/Character\n 34: invokevirtual #158 // Method java/lang/Character.charValue:()C\n 37: istore_2\n 38: iload_2\n 39: lookupswitch { // 2\n 69: 68\n 83: 64\n default: 73\n }\n 64: iconst_0\n 65: goto 77\n 68: bipush 25\n 70: goto 77\n 73: iload_2\n 74: bipush 97\n 76: isub\n 77: ireturn\n\n public final int minSteps(Point, Point);\n Code:\n 0: aload_1\n 1: ldc #207 // String start\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #209 // String end\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: iconst_0\n 15: invokevirtual #211 // Method enqueue:(LPoint;I)V\n 18: aload_0\n 19: getfield #32 // Field queue:Lkotlin/collections/ArrayDeque;\n 22: checkcast #47 // class java/util/Collection\n 25: invokeinterface #214, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 30: ifne 37\n 33: iconst_1\n 34: goto 38\n 37: iconst_0\n 38: ifeq 184\n 41: aload_0\n 42: getfield #32 // Field queue:Lkotlin/collections/ArrayDeque;\n 45: invokevirtual #217 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;\n 48: checkcast #160 // class Point\n 51: astore_3\n 52: aload_0\n 53: getfield #25 // Field distances:Ljava/util/HashMap;\n 56: aload_3\n 57: invokevirtual #120 // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 60: dup\n 61: invokestatic #124 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 64: checkcast #126 // class java/lang/Number\n 67: invokevirtual #130 // Method java/lang/Number.intValue:()I\n 70: iconst_1\n 71: iadd\n 72: istore 4\n 74: aload_0\n 75: aload_3\n 76: invokevirtual #219 // Method height:(LPoint;)I\n 79: istore 5\n 81: aload_0\n 82: new #160 // class Point\n 85: dup\n 86: aload_3\n 87: invokevirtual #200 // Method Point.getX:()I\n 90: iconst_1\n 91: isub\n 92: aload_3\n 93: invokevirtual #203 // Method Point.getY:()I\n 96: invokespecial #163 // Method Point.\"<init>\":(II)V\n 99: iload 4\n 101: iload 5\n 103: invokevirtual #223 // Method walk:(LPoint;II)V\n 106: aload_0\n 107: new #160 // class Point\n 110: dup\n 111: aload_3\n 112: invokevirtual #200 // Method Point.getX:()I\n 115: iconst_1\n 116: iadd\n 117: aload_3\n 118: invokevirtual #203 // Method Point.getY:()I\n 121: invokespecial #163 // Method Point.\"<init>\":(II)V\n 124: iload 4\n 126: iload 5\n 128: invokevirtual #223 // Method walk:(LPoint;II)V\n 131: aload_0\n 132: new #160 // class Point\n 135: dup\n 136: aload_3\n 137: invokevirtual #200 // Method Point.getX:()I\n 140: aload_3\n 141: invokevirtual #203 // Method Point.getY:()I\n 144: iconst_1\n 145: isub\n 146: invokespecial #163 // Method Point.\"<init>\":(II)V\n 149: iload 4\n 151: iload 5\n 153: invokevirtual #223 // Method walk:(LPoint;II)V\n 156: aload_0\n 157: new #160 // class Point\n 160: dup\n 161: aload_3\n 162: invokevirtual #200 // Method Point.getX:()I\n 165: aload_3\n 166: invokevirtual #203 // Method Point.getY:()I\n 169: iconst_1\n 170: iadd\n 171: invokespecial #163 // Method Point.\"<init>\":(II)V\n 174: iload 4\n 176: iload 5\n 178: invokevirtual #223 // Method walk:(LPoint;II)V\n 181: goto 18\n 184: aload_0\n 185: getfield #25 // Field distances:Ljava/util/HashMap;\n 188: aload_2\n 189: invokevirtual #120 // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 192: checkcast #132 // class java/lang/Integer\n 195: dup\n 196: ifnull 205\n 199: invokevirtual #224 // Method java/lang/Integer.intValue:()I\n 202: goto 208\n 205: pop\n 206: ldc #225 // int 2147483647\n 208: ireturn\n\n public final void walk(Point, int, int);\n Code:\n 0: aload_1\n 1: ldc #227 // String p\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #81 // Field heightmap:Ljava/util/List;\n 10: checkcast #47 // class java/util/Collection\n 13: invokeinterface #149, 1 // InterfaceMethod java/util/Collection.size:()I\n 18: istore 4\n 20: aload_1\n 21: invokevirtual #200 // Method Point.getX:()I\n 24: istore 5\n 26: iconst_0\n 27: iload 5\n 29: if_icmpgt 47\n 32: iload 5\n 34: iload 4\n 36: if_icmpge 43\n 39: iconst_1\n 40: goto 48\n 43: iconst_0\n 44: goto 48\n 47: iconst_0\n 48: ifeq 102\n 51: aload_0\n 52: getfield #81 // Field heightmap:Ljava/util/List;\n 55: iconst_0\n 56: invokeinterface #152, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 61: checkcast #77 // class java/util/List\n 64: invokeinterface #228, 1 // InterfaceMethod java/util/List.size:()I\n 69: istore 4\n 71: aload_1\n 72: invokevirtual #203 // Method Point.getY:()I\n 75: istore 5\n 77: iconst_0\n 78: iload 5\n 80: if_icmpgt 98\n 83: iload 5\n 85: iload 4\n 87: if_icmpge 94\n 90: iconst_1\n 91: goto 99\n 94: iconst_0\n 95: goto 99\n 98: iconst_0\n 99: ifne 103\n 102: return\n 103: iload_3\n 104: aload_0\n 105: aload_1\n 106: invokevirtual #219 // Method height:(LPoint;)I\n 109: iconst_1\n 110: iadd\n 111: if_icmpgt 120\n 114: aload_0\n 115: aload_1\n 116: iload_2\n 117: invokevirtual #211 // Method enqueue:(LPoint;I)V\n 120: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day12Kt.class", "javap": "Compiled from \"Day12.kt\"\npublic final class Day12Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/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 main$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 main$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 void main(java.lang.String[]);\n Code:\n 0: invokestatic #38 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: new #43 // class Day12Kt$main$Terrain\n 3: dup\n 4: aload_0\n 5: invokespecial #47 // Method Day12Kt$main$Terrain.\"<init>\":(Ljava/util/List;)V\n 8: astore_1\n 9: aload_1\n 10: bipush 69\n 12: invokevirtual #51 // Method Day12Kt$main$Terrain.find:(C)LPoint;\n 15: astore_2\n 16: aload_1\n 17: bipush 83\n 19: invokevirtual #51 // Method Day12Kt$main$Terrain.find:(C)LPoint;\n 22: astore_3\n 23: aload_1\n 24: aload_2\n 25: aload_3\n 26: invokevirtual #55 // Method Day12Kt$main$Terrain.minSteps:(LPoint;LPoint;)I\n 29: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: new #62 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #64 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #66 // class java/util/List\n 10: astore_1\n 11: new #43 // class Day12Kt$main$Terrain\n 14: dup\n 15: aload_0\n 16: invokespecial #47 // Method Day12Kt$main$Terrain.\"<init>\":(Ljava/util/List;)V\n 19: astore_2\n 20: aload_2\n 21: invokevirtual #70 // Method Day12Kt$main$Terrain.getHeightmap:()Ljava/util/List;\n 24: astore_3\n 25: nop\n 26: iconst_0\n 27: istore 4\n 29: iconst_0\n 30: istore 5\n 32: aload_3\n 33: checkcast #72 // class java/util/Collection\n 36: invokeinterface #76, 1 // InterfaceMethod java/util/Collection.size:()I\n 41: istore 6\n 43: iload 5\n 45: iload 6\n 47: if_icmpge 187\n 50: aload_3\n 51: iload 5\n 53: invokeinterface #80, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 58: checkcast #66 // class java/util/List\n 61: astore 7\n 63: iconst_0\n 64: istore 8\n 66: aload 7\n 68: checkcast #72 // class java/util/Collection\n 71: invokeinterface #76, 1 // InterfaceMethod java/util/Collection.size:()I\n 76: istore 9\n 78: iload 8\n 80: iload 9\n 82: if_icmpge 181\n 85: iload 5\n 87: iload 8\n 89: istore 10\n 91: istore 11\n 93: iconst_0\n 94: istore 12\n 96: aload_2\n 97: invokevirtual #70 // Method Day12Kt$main$Terrain.getHeightmap:()Ljava/util/List;\n 100: iload 11\n 102: invokeinterface #80, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 107: checkcast #66 // class java/util/List\n 110: iload 10\n 112: invokeinterface #80, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 117: checkcast #82 // class java/lang/Character\n 120: invokevirtual #86 // Method java/lang/Character.charValue:()C\n 123: istore 13\n 125: iload 13\n 127: lookupswitch { // 2\n 83: 152\n 97: 152\n default: 173\n }\n 152: aload_1\n 153: checkcast #72 // class java/util/Collection\n 156: new #88 // class Point\n 159: dup\n 160: iload 11\n 162: iload 10\n 164: invokespecial #91 // Method Point.\"<init>\":(II)V\n 167: invokeinterface #95, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 172: pop\n 173: nop\n 174: nop\n 175: iinc 8, 1\n 178: goto 78\n 181: iinc 5, 1\n 184: goto 43\n 187: nop\n 188: aload_2\n 189: bipush 69\n 191: invokevirtual #51 // Method Day12Kt$main$Terrain.find:(C)LPoint;\n 194: astore_3\n 195: aload_2\n 196: aload_3\n 197: aload_1\n 198: iconst_0\n 199: invokeinterface #80, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 204: checkcast #88 // class Point\n 207: invokevirtual #55 // Method Day12Kt$main$Terrain.minSteps:(LPoint;LPoint;)I\n 210: pop\n 211: aload_1\n 212: checkcast #97 // class java/lang/Iterable\n 215: invokeinterface #101, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 220: astore 5\n 222: aload 5\n 224: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 229: ifne 240\n 232: new #109 // class java/util/NoSuchElementException\n 235: dup\n 236: invokespecial #110 // Method java/util/NoSuchElementException.\"<init>\":()V\n 239: athrow\n 240: aload 5\n 242: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 247: checkcast #88 // class Point\n 250: astore 6\n 252: iconst_0\n 253: istore 7\n 255: aload_2\n 256: invokevirtual #118 // Method Day12Kt$main$Terrain.getDistances:()Ljava/util/HashMap;\n 259: aload 6\n 261: invokevirtual #123 // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 264: checkcast #125 // class java/lang/Integer\n 267: dup\n 268: ifnull 277\n 271: invokevirtual #128 // Method java/lang/Integer.intValue:()I\n 274: goto 280\n 277: pop\n 278: ldc #129 // int 2147483647\n 280: istore 6\n 282: aload 5\n 284: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 289: ifeq 348\n 292: aload 5\n 294: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 299: checkcast #88 // class Point\n 302: astore 7\n 304: iconst_0\n 305: istore 8\n 307: aload_2\n 308: invokevirtual #118 // Method Day12Kt$main$Terrain.getDistances:()Ljava/util/HashMap;\n 311: aload 7\n 313: invokevirtual #123 // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 316: checkcast #125 // class java/lang/Integer\n 319: dup\n 320: ifnull 329\n 323: invokevirtual #128 // Method java/lang/Integer.intValue:()I\n 326: goto 332\n 329: pop\n 330: ldc #129 // int 2147483647\n 332: istore 7\n 334: iload 6\n 336: iload 7\n 338: if_icmple 282\n 341: iload 7\n 343: istore 6\n 345: goto 282\n 348: iload 6\n 350: ireturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day16.kt
fun main() { val day16 = Day16(readInput("inputs/Day16")) println(day16.part1()) println(day16.part2()) } class Day16(input: List<String>) { private val valves = input.map(Valve::from).associateBy(Valve::name) private val usefulValves = valves.filter { it.value.rate > 0 } private val distances = computeDistances() fun part1() = traverse(minutes = 30) fun part2() = traverse(minutes = 26, elephantGoesNext = true) private fun traverse( minutes: Int, current: Valve = valves.getValue("AA"), remaining: Set<Valve> = usefulValves.values.toSet(), cache: MutableMap<State, Int> = mutableMapOf(), elephantGoesNext: Boolean = false ): Int { val currentScore = minutes * current.rate val currentState = State(current.name, minutes, remaining) return currentScore + cache.getOrPut(currentState) { val validValves = remaining.filter { next -> distances[current.name]!![next.name]!! < minutes } var maxCurrent = 0 if (validValves.isNotEmpty()) { maxCurrent = validValves.maxOf { next -> val remainingMinutes = minutes - 1 - distances[current.name]!![next.name]!! traverse(remainingMinutes, next, remaining - next, cache, elephantGoesNext) } } maxOf(maxCurrent, if (elephantGoesNext) traverse(minutes = 26, remaining = remaining) else 0) } } private fun computeDistances(): Map<String, Map<String, Int>> { return valves.keys.map { valve -> val distances = mutableMapOf<String, Int>().withDefault { Int.MAX_VALUE }.apply { put(valve, 0) } val toVisit = mutableListOf(valve) while (toVisit.isNotEmpty()) { val current = toVisit.removeFirst() valves[current]!!.next.forEach { adj -> val newDistance = distances[current]!! + 1 if (newDistance < distances.getValue(adj)) { distances[adj] = newDistance toVisit.add(adj) } } } distances }.associateBy { it.keys.first() } } private data class State(val current: String, val minutes: Int, val opened: Set<Valve>) private data class Valve(val name: String, val rate: Int, val next: List<String>) { companion object { fun from(line: String): Valve { return Valve( name = line.substringAfter("Valve ").substringBefore(" "), rate = line.substringAfter("rate=").substringBefore(";").toInt(), next = line.substringAfter("to valve").substringAfter(" ").split(", ") ) } } } }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day16$State.class", "javap": "Compiled from \"Day16.kt\"\nfinal class Day16$State {\n private final java.lang.String current;\n\n private final int minutes;\n\n private final java.util.Set<Day16$Valve> opened;\n\n public Day16$State(java.lang.String, int, java.util.Set<Day16$Valve>);\n Code:\n 0: aload_1\n 1: ldc #10 // String current\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_3\n 7: ldc #18 // String opened\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 #24 // Field current:Ljava/lang/String;\n 21: aload_0\n 22: iload_2\n 23: putfield #28 // Field minutes:I\n 26: aload_0\n 27: aload_3\n 28: putfield #31 // Field opened:Ljava/util/Set;\n 31: return\n\n public final java.lang.String getCurrent();\n Code:\n 0: aload_0\n 1: getfield #24 // Field current:Ljava/lang/String;\n 4: areturn\n\n public final int getMinutes();\n Code:\n 0: aload_0\n 1: getfield #28 // Field minutes:I\n 4: ireturn\n\n public final java.util.Set<Day16$Valve> getOpened();\n Code:\n 0: aload_0\n 1: getfield #31 // Field opened:Ljava/util/Set;\n 4: areturn\n\n public final java.lang.String component1();\n Code:\n 0: aload_0\n 1: getfield #24 // Field current:Ljava/lang/String;\n 4: areturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #28 // Field minutes:I\n 4: ireturn\n\n public final java.util.Set<Day16$Valve> component3();\n Code:\n 0: aload_0\n 1: getfield #31 // Field opened:Ljava/util/Set;\n 4: areturn\n\n public final Day16$State copy(java.lang.String, int, java.util.Set<Day16$Valve>);\n Code:\n 0: aload_1\n 1: ldc #10 // String current\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_3\n 7: ldc #18 // String opened\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class Day16$State\n 15: dup\n 16: aload_1\n 17: iload_2\n 18: aload_3\n 19: invokespecial #48 // Method \"<init>\":(Ljava/lang/String;ILjava/util/Set;)V\n 22: areturn\n\n public static Day16$State copy$default(Day16$State, java.lang.String, int, java.util.Set, 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 #24 // Field current: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 #28 // Field minutes: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 #31 // Field opened:Ljava/util/Set;\n 35: astore_3\n 36: aload_0\n 37: aload_1\n 38: iload_2\n 39: aload_3\n 40: invokevirtual #52 // Method copy:(Ljava/lang/String;ILjava/util/Set;)LDay16$State;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #55 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #56 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #58 // String State(current=\n 9: invokevirtual #62 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #24 // Field current:Ljava/lang/String;\n 16: invokevirtual #62 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 19: ldc #64 // String , minutes=\n 21: invokevirtual #62 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #28 // Field minutes:I\n 28: invokevirtual #67 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #69 // String , opened=\n 33: invokevirtual #62 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #31 // Field opened:Ljava/util/Set;\n 40: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #75 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #77 // 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 #24 // Field current:Ljava/lang/String;\n 4: invokevirtual #82 // 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 #28 // Field minutes:I\n 16: invokestatic #87 // 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 #31 // Field opened:Ljava/util/Set;\n 29: invokevirtual #88 // Method java/lang/Object.hashCode:()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 Day16$State\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day16$State\n 20: astore_2\n 21: aload_0\n 22: getfield #24 // Field current:Ljava/lang/String;\n 25: aload_2\n 26: getfield #24 // Field current:Ljava/lang/String;\n 29: invokestatic #96 // 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 #28 // Field minutes:I\n 41: aload_2\n 42: getfield #28 // Field minutes:I\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: aload_0\n 51: getfield #31 // Field opened:Ljava/util/Set;\n 54: aload_2\n 55: getfield #31 // Field opened:Ljava/util/Set;\n 58: invokestatic #96 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 61: ifne 66\n 64: iconst_0\n 65: ireturn\n 66: iconst_1\n 67: ireturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day16$Valve.class", "javap": "Compiled from \"Day16.kt\"\nfinal class Day16$Valve {\n public static final Day16$Valve$Companion Companion;\n\n private final java.lang.String name;\n\n private final int rate;\n\n private final java.util.List<java.lang.String> next;\n\n public Day16$Valve(java.lang.String, int, java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #10 // String name\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_3\n 7: ldc #18 // String next\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 #24 // Field name:Ljava/lang/String;\n 21: aload_0\n 22: iload_2\n 23: putfield #28 // Field rate:I\n 26: aload_0\n 27: aload_3\n 28: putfield #31 // Field next:Ljava/util/List;\n 31: return\n\n public final java.lang.String getName();\n Code:\n 0: aload_0\n 1: getfield #24 // Field name:Ljava/lang/String;\n 4: areturn\n\n public final int getRate();\n Code:\n 0: aload_0\n 1: getfield #28 // Field rate:I\n 4: ireturn\n\n public final java.util.List<java.lang.String> getNext();\n Code:\n 0: aload_0\n 1: getfield #31 // Field next:Ljava/util/List;\n 4: areturn\n\n public final java.lang.String component1();\n Code:\n 0: aload_0\n 1: getfield #24 // Field name:Ljava/lang/String;\n 4: areturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #28 // Field rate:I\n 4: ireturn\n\n public final java.util.List<java.lang.String> component3();\n Code:\n 0: aload_0\n 1: getfield #31 // Field next:Ljava/util/List;\n 4: areturn\n\n public final Day16$Valve copy(java.lang.String, int, java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #10 // String name\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_3\n 7: ldc #18 // String next\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class Day16$Valve\n 15: dup\n 16: aload_1\n 17: iload_2\n 18: aload_3\n 19: invokespecial #48 // Method \"<init>\":(Ljava/lang/String;ILjava/util/List;)V\n 22: areturn\n\n public static Day16$Valve copy$default(Day16$Valve, java.lang.String, int, java.util.List, 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 #24 // 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 #28 // Field rate: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 #31 // Field next:Ljava/util/List;\n 35: astore_3\n 36: aload_0\n 37: aload_1\n 38: iload_2\n 39: aload_3\n 40: invokevirtual #52 // Method copy:(Ljava/lang/String;ILjava/util/List;)LDay16$Valve;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #55 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #56 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #58 // String Valve(name=\n 9: invokevirtual #62 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #24 // Field name:Ljava/lang/String;\n 16: invokevirtual #62 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 19: ldc #64 // String , rate=\n 21: invokevirtual #62 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #28 // Field rate:I\n 28: invokevirtual #67 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #69 // String , next=\n 33: invokevirtual #62 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #31 // Field next:Ljava/util/List;\n 40: invokevirtual #72 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #75 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #77 // 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 #24 // Field name:Ljava/lang/String;\n 4: invokevirtual #82 // 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 #28 // Field rate:I\n 16: invokestatic #87 // 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 #31 // Field next:Ljava/util/List;\n 29: invokevirtual #88 // Method java/lang/Object.hashCode:()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 Day16$Valve\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day16$Valve\n 20: astore_2\n 21: aload_0\n 22: getfield #24 // Field name:Ljava/lang/String;\n 25: aload_2\n 26: getfield #24 // Field name:Ljava/lang/String;\n 29: invokestatic #96 // 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 #28 // Field rate:I\n 41: aload_2\n 42: getfield #28 // Field rate:I\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: aload_0\n 51: getfield #31 // Field next:Ljava/util/List;\n 54: aload_2\n 55: getfield #31 // Field next:Ljava/util/List;\n 58: invokestatic #96 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 61: ifne 66\n 64: iconst_0\n 65: ireturn\n 66: iconst_1\n 67: ireturn\n\n static {};\n Code:\n 0: new #101 // class Day16$Valve$Companion\n 3: dup\n 4: aconst_null\n 5: invokespecial #104 // Method Day16$Valve$Companion.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 8: putstatic #108 // Field Companion:LDay16$Valve$Companion;\n 11: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day16.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16 {\n private final java.util.Map<java.lang.String, Day16$Valve> valves;\n\n private final java.util.Map<java.lang.String, Day16$Valve> usefulValves;\n\n private final java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.Integer>> distances;\n\n public Day16(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\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: invokespecial #19 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: checkcast #21 // class java/lang/Iterable\n 15: astore_2\n 16: getstatic #27 // Field Day16$Valve.Companion:LDay16$Valve$Companion;\n 19: astore_3\n 20: astore 12\n 22: iconst_0\n 23: istore 4\n 25: aload_2\n 26: astore 5\n 28: new #29 // class java/util/ArrayList\n 31: dup\n 32: aload_2\n 33: bipush 10\n 35: invokestatic #35 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 38: invokespecial #38 // Method java/util/ArrayList.\"<init>\":(I)V\n 41: checkcast #40 // class java/util/Collection\n 44: astore 6\n 46: iconst_0\n 47: istore 7\n 49: aload 5\n 51: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 56: astore 8\n 58: aload 8\n 60: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 65: ifeq 109\n 68: aload 8\n 70: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 75: astore 9\n 77: aload 6\n 79: aload 9\n 81: checkcast #56 // class java/lang/String\n 84: astore 10\n 86: astore 13\n 88: iconst_0\n 89: istore 11\n 91: aload_3\n 92: aload 10\n 94: invokevirtual #62 // Method Day16$Valve$Companion.from:(Ljava/lang/String;)LDay16$Valve;\n 97: aload 13\n 99: swap\n 100: invokeinterface #66, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 105: pop\n 106: goto 58\n 109: aload 6\n 111: checkcast #68 // class java/util/List\n 114: nop\n 115: aload 12\n 117: swap\n 118: checkcast #21 // class java/lang/Iterable\n 121: astore_2\n 122: astore 12\n 124: iconst_0\n 125: istore_3\n 126: aload_2\n 127: bipush 10\n 129: invokestatic #35 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 132: invokestatic #74 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 135: bipush 16\n 137: invokestatic #80 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 140: istore 4\n 142: aload_2\n 143: astore 5\n 145: new #82 // class java/util/LinkedHashMap\n 148: dup\n 149: iload 4\n 151: invokespecial #83 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 154: checkcast #85 // class java/util/Map\n 157: astore 6\n 159: iconst_0\n 160: istore 7\n 162: aload 5\n 164: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 169: astore 8\n 171: aload 8\n 173: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 178: ifeq 223\n 181: aload 8\n 183: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 188: astore 9\n 190: aload 6\n 192: aload 9\n 194: checkcast #23 // class Day16$Valve\n 197: astore 10\n 199: astore 13\n 201: iconst_0\n 202: istore 11\n 204: aload 10\n 206: invokevirtual #89 // Method Day16$Valve.getName:()Ljava/lang/String;\n 209: aload 13\n 211: swap\n 212: aload 9\n 214: invokeinterface #93, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 219: pop\n 220: goto 171\n 223: aload 6\n 225: nop\n 226: aload 12\n 228: swap\n 229: putfield #97 // Field valves:Ljava/util/Map;\n 232: aload_0\n 233: aload_0\n 234: getfield #97 // Field valves:Ljava/util/Map;\n 237: astore_2\n 238: astore 12\n 240: iconst_0\n 241: istore_3\n 242: aload_2\n 243: astore 4\n 245: new #82 // class java/util/LinkedHashMap\n 248: dup\n 249: invokespecial #98 // Method java/util/LinkedHashMap.\"<init>\":()V\n 252: checkcast #85 // class java/util/Map\n 255: astore 5\n 257: iconst_0\n 258: istore 6\n 260: aload 4\n 262: invokeinterface #102, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 267: invokeinterface #105, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 272: astore 7\n 274: aload 7\n 276: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 281: ifeq 352\n 284: aload 7\n 286: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 291: checkcast #107 // class java/util/Map$Entry\n 294: astore 8\n 296: aload 8\n 298: astore 9\n 300: iconst_0\n 301: istore 10\n 303: aload 9\n 305: invokeinterface #110, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 310: checkcast #23 // class Day16$Valve\n 313: invokevirtual #114 // Method Day16$Valve.getRate:()I\n 316: ifle 323\n 319: iconst_1\n 320: goto 324\n 323: iconst_0\n 324: ifeq 274\n 327: aload 5\n 329: aload 8\n 331: invokeinterface #117, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 336: aload 8\n 338: invokeinterface #110, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 343: invokeinterface #93, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 348: pop\n 349: goto 274\n 352: aload 5\n 354: nop\n 355: aload 12\n 357: swap\n 358: putfield #120 // Field usefulValves:Ljava/util/Map;\n 361: aload_0\n 362: aload_0\n 363: invokespecial #124 // Method computeDistances:()Ljava/util/Map;\n 366: putfield #127 // Field distances:Ljava/util/Map;\n 369: return\n\n public final int part1();\n Code:\n 0: aload_0\n 1: bipush 30\n 3: aconst_null\n 4: aconst_null\n 5: aconst_null\n 6: iconst_0\n 7: bipush 30\n 9: aconst_null\n 10: invokestatic #163 // Method traverse$default:(LDay16;ILDay16$Valve;Ljava/util/Set;Ljava/util/Map;ZILjava/lang/Object;)I\n 13: ireturn\n\n public final int part2();\n Code:\n 0: aload_0\n 1: bipush 26\n 3: aconst_null\n 4: aconst_null\n 5: aconst_null\n 6: iconst_1\n 7: bipush 14\n 9: aconst_null\n 10: invokestatic #163 // Method traverse$default:(LDay16;ILDay16$Valve;Ljava/util/Set;Ljava/util/Map;ZILjava/lang/Object;)I\n 13: ireturn\n\n private final int traverse(int, Day16$Valve, java.util.Set<Day16$Valve>, java.util.Map<Day16$State, java.lang.Integer>, boolean);\n Code:\n 0: iload_1\n 1: aload_2\n 2: invokevirtual #114 // Method Day16$Valve.getRate:()I\n 5: imul\n 6: istore 6\n 8: new #169 // class Day16$State\n 11: dup\n 12: aload_2\n 13: invokevirtual #89 // Method Day16$Valve.getName:()Ljava/lang/String;\n 16: iload_1\n 17: aload_3\n 18: invokespecial #172 // Method Day16$State.\"<init>\":(Ljava/lang/String;ILjava/util/Set;)V\n 21: astore 7\n 23: iload 6\n 25: aload 4\n 27: astore 8\n 29: iconst_0\n 30: istore 9\n 32: aload 8\n 34: aload 7\n 36: invokeinterface #176, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 41: astore 10\n 43: aload 10\n 45: ifnonnull 492\n 48: istore 23\n 50: iconst_0\n 51: istore 11\n 53: aload_3\n 54: checkcast #21 // class java/lang/Iterable\n 57: astore 12\n 59: iconst_0\n 60: istore 13\n 62: aload 12\n 64: astore 14\n 66: new #29 // class java/util/ArrayList\n 69: dup\n 70: invokespecial #177 // Method java/util/ArrayList.\"<init>\":()V\n 73: checkcast #40 // class java/util/Collection\n 76: astore 15\n 78: iconst_0\n 79: istore 16\n 81: aload 14\n 83: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 88: astore 17\n 90: aload 17\n 92: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 97: ifeq 184\n 100: aload 17\n 102: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 107: astore 18\n 109: aload 18\n 111: checkcast #23 // class Day16$Valve\n 114: astore 19\n 116: iconst_0\n 117: istore 20\n 119: aload_0\n 120: getfield #127 // Field distances:Ljava/util/Map;\n 123: aload_2\n 124: invokevirtual #89 // Method Day16$Valve.getName:()Ljava/lang/String;\n 127: invokeinterface #176, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 132: dup\n 133: invokestatic #181 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 136: checkcast #85 // class java/util/Map\n 139: aload 19\n 141: invokevirtual #89 // Method Day16$Valve.getName:()Ljava/lang/String;\n 144: invokeinterface #176, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 149: dup\n 150: invokestatic #181 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 153: checkcast #183 // class java/lang/Number\n 156: invokevirtual #186 // Method java/lang/Number.intValue:()I\n 159: iload_1\n 160: if_icmpge 167\n 163: iconst_1\n 164: goto 168\n 167: iconst_0\n 168: ifeq 90\n 171: aload 15\n 173: aload 18\n 175: invokeinterface #66, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 180: pop\n 181: goto 90\n 184: aload 15\n 186: checkcast #68 // class java/util/List\n 189: nop\n 190: astore 21\n 192: iconst_0\n 193: istore 12\n 195: aload 21\n 197: checkcast #40 // class java/util/Collection\n 200: invokeinterface #189, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 205: ifne 212\n 208: iconst_1\n 209: goto 213\n 212: iconst_0\n 213: ifeq 436\n 216: aload 21\n 218: checkcast #21 // class java/lang/Iterable\n 221: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 226: astore 14\n 228: aload 14\n 230: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 235: ifne 246\n 238: new #191 // class java/util/NoSuchElementException\n 241: dup\n 242: invokespecial #192 // Method java/util/NoSuchElementException.\"<init>\":()V\n 245: athrow\n 246: aload 14\n 248: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 253: checkcast #23 // class Day16$Valve\n 256: astore 15\n 258: iconst_0\n 259: istore 16\n 261: iload_1\n 262: iconst_1\n 263: isub\n 264: aload_0\n 265: getfield #127 // Field distances:Ljava/util/Map;\n 268: aload_2\n 269: invokevirtual #89 // Method Day16$Valve.getName:()Ljava/lang/String;\n 272: invokeinterface #176, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 277: dup\n 278: invokestatic #181 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 281: checkcast #85 // class java/util/Map\n 284: aload 15\n 286: invokevirtual #89 // Method Day16$Valve.getName:()Ljava/lang/String;\n 289: invokeinterface #176, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 294: dup\n 295: invokestatic #181 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 298: checkcast #183 // class java/lang/Number\n 301: invokevirtual #186 // Method java/lang/Number.intValue:()I\n 304: isub\n 305: istore 17\n 307: aload_0\n 308: iload 17\n 310: aload 15\n 312: aload_3\n 313: aload 15\n 315: invokestatic #198 // Method kotlin/collections/SetsKt.minus:(Ljava/util/Set;Ljava/lang/Object;)Ljava/util/Set;\n 318: aload 4\n 320: iload 5\n 322: invokespecial #200 // Method traverse:(ILDay16$Valve;Ljava/util/Set;Ljava/util/Map;Z)I\n 325: istore 15\n 327: aload 14\n 329: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 334: ifeq 432\n 337: aload 14\n 339: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 344: checkcast #23 // class Day16$Valve\n 347: astore 16\n 349: iconst_0\n 350: istore 17\n 352: iload_1\n 353: iconst_1\n 354: isub\n 355: aload_0\n 356: getfield #127 // Field distances:Ljava/util/Map;\n 359: aload_2\n 360: invokevirtual #89 // Method Day16$Valve.getName:()Ljava/lang/String;\n 363: invokeinterface #176, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 368: dup\n 369: invokestatic #181 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 372: checkcast #85 // class java/util/Map\n 375: aload 16\n 377: invokevirtual #89 // Method Day16$Valve.getName:()Ljava/lang/String;\n 380: invokeinterface #176, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 385: dup\n 386: invokestatic #181 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 389: checkcast #183 // class java/lang/Number\n 392: invokevirtual #186 // Method java/lang/Number.intValue:()I\n 395: isub\n 396: istore 18\n 398: aload_0\n 399: iload 18\n 401: aload 16\n 403: aload_3\n 404: aload 16\n 406: invokestatic #198 // Method kotlin/collections/SetsKt.minus:(Ljava/util/Set;Ljava/lang/Object;)Ljava/util/Set;\n 409: aload 4\n 411: iload 5\n 413: invokespecial #200 // Method traverse:(ILDay16$Valve;Ljava/util/Set;Ljava/util/Map;Z)I\n 416: istore 16\n 418: iload 15\n 420: iload 16\n 422: if_icmpge 327\n 425: iload 16\n 427: istore 15\n 429: goto 327\n 432: iload 15\n 434: istore 12\n 436: iload 12\n 438: iload 5\n 440: ifeq 459\n 443: aload_0\n 444: bipush 26\n 446: aconst_null\n 447: aload_3\n 448: aconst_null\n 449: iconst_0\n 450: bipush 26\n 452: aconst_null\n 453: invokestatic #163 // Method traverse$default:(LDay16;ILDay16$Valve;Ljava/util/Set;Ljava/util/Map;ZILjava/lang/Object;)I\n 456: goto 460\n 459: iconst_0\n 460: invokestatic #205 // Method java/lang/Math.max:(II)I\n 463: nop\n 464: invokestatic #211 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 467: astore 24\n 469: iload 23\n 471: aload 24\n 473: astore 22\n 475: aload 8\n 477: aload 7\n 479: aload 22\n 481: invokeinterface #93, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 486: pop\n 487: aload 22\n 489: goto 494\n 492: aload 10\n 494: nop\n 495: checkcast #183 // class java/lang/Number\n 498: invokevirtual #186 // Method java/lang/Number.intValue:()I\n 501: iadd\n 502: ireturn\n\n static int traverse$default(Day16, int, Day16$Valve, java.util.Set, java.util.Map, boolean, int, java.lang.Object);\n Code:\n 0: iload 6\n 2: iconst_2\n 3: iand\n 4: ifeq 20\n 7: aload_0\n 8: getfield #97 // Field valves:Ljava/util/Map;\n 11: ldc #233 // String AA\n 13: invokestatic #236 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 16: checkcast #23 // class Day16$Valve\n 19: astore_2\n 20: iload 6\n 22: iconst_4\n 23: iand\n 24: ifeq 43\n 27: aload_0\n 28: getfield #120 // Field usefulValves:Ljava/util/Map;\n 31: invokeinterface #240, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 36: checkcast #21 // class java/lang/Iterable\n 39: invokestatic #244 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 42: astore_3\n 43: iload 6\n 45: bipush 8\n 47: iand\n 48: ifeq 63\n 51: new #82 // class java/util/LinkedHashMap\n 54: dup\n 55: invokespecial #98 // Method java/util/LinkedHashMap.\"<init>\":()V\n 58: checkcast #85 // class java/util/Map\n 61: astore 4\n 63: iload 6\n 65: bipush 16\n 67: iand\n 68: ifeq 74\n 71: iconst_0\n 72: istore 5\n 74: aload_0\n 75: iload_1\n 76: aload_2\n 77: aload_3\n 78: aload 4\n 80: iload 5\n 82: invokespecial #200 // Method traverse:(ILDay16$Valve;Ljava/util/Set;Ljava/util/Map;Z)I\n 85: ireturn\n\n private final java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.Integer>> computeDistances();\n Code:\n 0: aload_0\n 1: getfield #97 // Field valves:Ljava/util/Map;\n 4: invokeinterface #248, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 9: checkcast #21 // class java/lang/Iterable\n 12: astore_1\n 13: iconst_0\n 14: istore_2\n 15: aload_1\n 16: astore_3\n 17: new #29 // class java/util/ArrayList\n 20: dup\n 21: aload_1\n 22: bipush 10\n 24: invokestatic #35 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 27: invokespecial #38 // Method java/util/ArrayList.\"<init>\":(I)V\n 30: checkcast #40 // class java/util/Collection\n 33: astore 4\n 35: iconst_0\n 36: istore 5\n 38: aload_3\n 39: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 6\n 46: aload 6\n 48: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 343\n 56: aload 6\n 58: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 7\n 65: aload 4\n 67: aload 7\n 69: checkcast #56 // class java/lang/String\n 72: astore 8\n 74: astore 21\n 76: iconst_0\n 77: istore 9\n 79: new #82 // class java/util/LinkedHashMap\n 82: dup\n 83: invokespecial #98 // Method java/util/LinkedHashMap.\"<init>\":()V\n 86: checkcast #85 // class java/util/Map\n 89: invokedynamic #267, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 94: invokestatic #271 // Method kotlin/collections/MapsKt.withDefaultMutable:(Ljava/util/Map;Lkotlin/jvm/functions/Function1;)Ljava/util/Map;\n 97: astore 10\n 99: aload 10\n 101: astore 11\n 103: iconst_0\n 104: istore 12\n 106: aload 11\n 108: aload 8\n 110: iconst_0\n 111: invokestatic #211 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 114: invokeinterface #93, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 119: pop\n 120: aload 10\n 122: astore 13\n 124: iconst_1\n 125: anewarray #56 // class java/lang/String\n 128: astore 11\n 130: aload 11\n 132: iconst_0\n 133: aload 8\n 135: aastore\n 136: aload 11\n 138: invokestatic #275 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 141: astore 10\n 143: aload 10\n 145: checkcast #40 // class java/util/Collection\n 148: invokeinterface #189, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 153: ifne 160\n 156: iconst_1\n 157: goto 161\n 160: iconst_0\n 161: ifeq 329\n 164: aload 10\n 166: invokeinterface #278, 1 // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;\n 171: dup\n 172: ldc_w #280 // String removeFirst(...)\n 175: invokestatic #283 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 178: checkcast #56 // class java/lang/String\n 181: astore 11\n 183: aload_0\n 184: getfield #97 // Field valves:Ljava/util/Map;\n 187: aload 11\n 189: invokeinterface #176, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 194: dup\n 195: invokestatic #181 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 198: checkcast #23 // class Day16$Valve\n 201: invokevirtual #287 // Method Day16$Valve.getNext:()Ljava/util/List;\n 204: checkcast #21 // class java/lang/Iterable\n 207: astore 12\n 209: iconst_0\n 210: istore 14\n 212: aload 12\n 214: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 219: astore 15\n 221: aload 15\n 223: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 228: ifeq 325\n 231: aload 15\n 233: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 238: astore 16\n 240: aload 16\n 242: checkcast #56 // class java/lang/String\n 245: astore 17\n 247: iconst_0\n 248: istore 18\n 250: aload 13\n 252: aload 11\n 254: invokeinterface #176, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 259: dup\n 260: invokestatic #181 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 263: checkcast #183 // class java/lang/Number\n 266: invokevirtual #186 // Method java/lang/Number.intValue:()I\n 269: iconst_1\n 270: iadd\n 271: istore 19\n 273: iload 19\n 275: aload 13\n 277: aload 17\n 279: invokestatic #236 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 282: checkcast #183 // class java/lang/Number\n 285: invokevirtual #186 // Method java/lang/Number.intValue:()I\n 288: if_icmpge 320\n 291: iload 19\n 293: invokestatic #211 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 296: astore 20\n 298: aload 13\n 300: aload 17\n 302: aload 20\n 304: invokeinterface #93, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 309: pop\n 310: aload 10\n 312: aload 17\n 314: invokeinterface #288, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 319: pop\n 320: nop\n 321: nop\n 322: goto 221\n 325: nop\n 326: goto 143\n 329: aload 13\n 331: aload 21\n 333: swap\n 334: invokeinterface #66, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 339: pop\n 340: goto 46\n 343: aload 4\n 345: checkcast #68 // class java/util/List\n 348: nop\n 349: checkcast #21 // class java/lang/Iterable\n 352: astore_1\n 353: nop\n 354: iconst_0\n 355: istore_2\n 356: aload_1\n 357: bipush 10\n 359: invokestatic #35 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 362: invokestatic #74 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 365: bipush 16\n 367: invokestatic #80 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 370: istore_3\n 371: aload_1\n 372: astore 4\n 374: new #82 // class java/util/LinkedHashMap\n 377: dup\n 378: iload_3\n 379: invokespecial #83 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 382: checkcast #85 // class java/util/Map\n 385: astore 5\n 387: iconst_0\n 388: istore 6\n 390: aload 4\n 392: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 397: astore 7\n 399: aload 7\n 401: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 406: ifeq 462\n 409: aload 7\n 411: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 416: astore 8\n 418: aload 5\n 420: aload 8\n 422: checkcast #85 // class java/util/Map\n 425: astore 9\n 427: astore 21\n 429: iconst_0\n 430: istore 10\n 432: aload 9\n 434: invokeinterface #248, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 439: checkcast #21 // class java/lang/Iterable\n 442: invokestatic #292 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 445: checkcast #56 // class java/lang/String\n 448: aload 21\n 450: swap\n 451: aload 8\n 453: invokeinterface #93, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 458: pop\n 459: goto 399\n 462: aload 5\n 464: nop\n 465: areturn\n\n private static final int computeDistances$lambda$8$lambda$5(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #305 // String it\n 4: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: ldc_w #306 // int 2147483647\n 10: ireturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day16$Valve$Companion.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16$Valve$Companion {\n private Day16$Valve$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final Day16$Valve from(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String line\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #23 // class Day16$Valve\n 9: dup\n 10: aload_1\n 11: ldc #25 // String Valve\n 13: aconst_null\n 14: iconst_2\n 15: aconst_null\n 16: invokestatic #31 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 19: ldc #33 // String\n 21: aconst_null\n 22: iconst_2\n 23: aconst_null\n 24: invokestatic #36 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 27: aload_1\n 28: ldc #38 // String rate=\n 30: aconst_null\n 31: iconst_2\n 32: aconst_null\n 33: invokestatic #31 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 36: ldc #40 // String ;\n 38: aconst_null\n 39: iconst_2\n 40: aconst_null\n 41: invokestatic #36 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 44: invokestatic #46 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 47: aload_1\n 48: ldc #48 // String to valve\n 50: aconst_null\n 51: iconst_2\n 52: aconst_null\n 53: invokestatic #31 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 56: ldc #33 // String\n 58: aconst_null\n 59: iconst_2\n 60: aconst_null\n 61: invokestatic #31 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 64: checkcast #50 // class java/lang/CharSequence\n 67: iconst_1\n 68: anewarray #52 // class java/lang/String\n 71: astore_2\n 72: aload_2\n 73: iconst_0\n 74: ldc #54 // String ,\n 76: aastore\n 77: aload_2\n 78: iconst_0\n 79: iconst_0\n 80: bipush 6\n 82: aconst_null\n 83: invokestatic #58 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 86: invokespecial #61 // Method Day16$Valve.\"<init>\":(Ljava/lang/String;ILjava/util/List;)V\n 89: areturn\n\n public Day16$Valve$Companion(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #64 // Method \"<init>\":()V\n 4: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day16Kt.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16Kt {\n public static final void main();\n Code:\n 0: new #8 // class Day16\n 3: dup\n 4: ldc #10 // String inputs/Day16\n 6: invokestatic #16 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 9: invokespecial #20 // Method Day16.\"<init>\":(Ljava/util/List;)V\n 12: astore_0\n 13: aload_0\n 14: invokevirtual #24 // Method Day16.part1:()I\n 17: istore_1\n 18: getstatic #30 // Field java/lang/System.out:Ljava/io/PrintStream;\n 21: iload_1\n 22: invokevirtual #36 // Method java/io/PrintStream.println:(I)V\n 25: aload_0\n 26: invokevirtual #39 // Method Day16.part2:()I\n 29: istore_1\n 30: getstatic #30 // Field java/lang/System.out:Ljava/io/PrintStream;\n 33: iload_1\n 34: invokevirtual #36 // Method java/io/PrintStream.println:(I)V\n 37: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #44 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day22.kt
fun main() { val d = Day22(readInput("inputs/Day22")) println(d.part1()) println(d.part2()) } class Day22(input: List<String>) { private val blockedPlaces: Set<Point> = parseBlockedPlaces(input) private val instructions: List<Instruction> = Instruction.ofList(input) fun part1(): Int = followInstructions(CubeFacing(1)).score() fun part2(): Int = followInstructions(CubeFacing(11)).score() private fun followInstructions(startingCube: CubeFacing): Orientation { var cube = startingCube var orientation = Orientation(cube.topLeft, Facing.East) instructions.forEach { instruction -> when (instruction) { is Left -> orientation = orientation.copy(facing = orientation.facing.left) is Right -> orientation = orientation.copy(facing = orientation.facing.right) is Move -> { var keepMoving = true repeat(instruction.steps) { if (keepMoving) { var nextOrientation = orientation.move() var nextCube = cube if (nextOrientation.location !in cube) { with(cube.transition(orientation.facing)) { nextOrientation = Orientation(move(orientation.location), enter) nextCube = destination } } if (nextOrientation.location in blockedPlaces) { keepMoving = false } else { orientation = nextOrientation cube = nextCube } } } } } } return orientation } private fun parseBlockedPlaces(input: List<String>): Set<Point> = input .takeWhile { it.isNotBlank() } .flatMapIndexed { y, row -> row.mapIndexedNotNull { x, c -> if (c == '#') Point(x, y) else null } }.toSet() private data class Orientation(val location: Point, val facing: Facing) { fun score(): Int = (1000 * (location.y + 1)) + (4 * (location.x + 1)) + facing.points fun move(): Orientation = copy(location = location + facing.offset) } private sealed class Instruction { companion object { fun ofList(input: List<String>): List<Instruction> = input .dropWhile { it.isNotBlank() } .drop(1) .first() .trim() .let { """\d+|[LR]""".toRegex().findAll(it) } .map { it.value } .filter { it.isNotBlank() } .map { symbol -> when (symbol) { "L" -> Left "R" -> Right else -> Move(symbol.toInt()) } }.toList() } } private class Move(val steps: Int) : Instruction() private object Left : Instruction() private object Right : Instruction() sealed class Facing(val points: Int, val offset: Point) { abstract val left: Facing abstract val right: Facing object North : Facing(3, Point(0, -1)) { override val left = West override val right = East } object East : Facing(0, Point(1, 0)) { override val left = North override val right = South } object South : Facing(1, Point(0, 1)) { override val left = East override val right = West } object West : Facing(2, Point(-1, 0)) { override val left = South override val right = North } } class CubeFacing( val id: Int, val size: Int, val topLeft: Point, val north: Transition, val east: Transition, val south: Transition, val west: Transition ) { val minX: Int = topLeft.x val maxX: Int = topLeft.x + size - 1 val minY: Int = topLeft.y val maxY: Int = topLeft.y + size - 1 operator fun contains(place: Point): Boolean = place.x in (minX..maxX) && place.y in (minY..maxY) fun scaleDown(point: Point): Point = point - topLeft fun scaleUp(point: Point): Point = point + topLeft fun transition(direction: Facing): Transition = when (direction) { Facing.North -> north Facing.East -> east Facing.South -> south Facing.West -> west } companion object { private val instances = mutableMapOf<Int, CubeFacing>() operator fun invoke(id: Int): CubeFacing = instances.getValue(id) private operator fun plus(instance: CubeFacing) { instances[instance.id] = instance } init { CubeFacing + CubeFacing( id = 1, size = 50, topLeft = Point(50, 0), north = Transition(1, 5, Facing.North, Facing.North), east = Transition(1, 2, Facing.East, Facing.East), south = Transition(1, 3, Facing.South, Facing.South), west = Transition(1, 2, Facing.West, Facing.West) ) CubeFacing + CubeFacing( id = 2, size = 50, topLeft = Point(100, 0), north = Transition(2, 2, Facing.North, Facing.North), east = Transition(2, 1, Facing.East, Facing.East), south = Transition(2, 2, Facing.South, Facing.South), west = Transition(2, 1, Facing.West, Facing.West) ) CubeFacing + CubeFacing( id = 3, size = 50, topLeft = Point(50, 50), north = Transition(3, 1, Facing.North, Facing.North), east = Transition(3, 3, Facing.East, Facing.East), south = Transition(3, 5, Facing.South, Facing.South), west = Transition(3, 3, Facing.West, Facing.West) ) CubeFacing + CubeFacing( id = 4, size = 50, topLeft = Point(0, 100), north = Transition(4, 6, Facing.North, Facing.North), east = Transition(4, 5, Facing.East, Facing.East), south = Transition(4, 6, Facing.South, Facing.South), west = Transition(4, 5, Facing.West, Facing.West) ) CubeFacing + CubeFacing( id = 5, size = 50, topLeft = Point(50, 100), north = Transition(5, 3, Facing.North, Facing.North), east = Transition(5, 4, Facing.East, Facing.East), south = Transition(5, 1, Facing.South, Facing.South), west = Transition(5, 4, Facing.West, Facing.West) ) CubeFacing + CubeFacing( id = 6, size = 50, topLeft = Point(0, 150), north = Transition(6, 4, Facing.North, Facing.North), east = Transition(6, 6, Facing.East, Facing.East), south = Transition(6, 4, Facing.South, Facing.South), west = Transition(6, 6, Facing.West, Facing.West) ) CubeFacing + CubeFacing( id = 11, size = 50, topLeft = Point(50, 0), north = Transition(11, 16, Facing.North, Facing.East), east = Transition(11, 12, Facing.East, Facing.East), south = Transition(11, 13, Facing.South, Facing.South), west = Transition(11, 14, Facing.West, Facing.East) ) CubeFacing + CubeFacing( id = 12, size = 50, topLeft = Point(100, 0), north = Transition(12, 16, Facing.North, Facing.North), east = Transition(12, 15, Facing.East, Facing.West), south = Transition(12, 13, Facing.South, Facing.West), west = Transition(12, 11, Facing.West, Facing.West) ) CubeFacing + CubeFacing( id = 13, size = 50, topLeft = Point(50, 50), north = Transition(13, 11, Facing.North, Facing.North), east = Transition(13, 12, Facing.East, Facing.North), south = Transition(13, 15, Facing.South, Facing.South), west = Transition(13, 14, Facing.West, Facing.South) ) CubeFacing + CubeFacing( id = 14, size = 50, topLeft = Point(0, 100), north = Transition(14, 13, Facing.North, Facing.East), east = Transition(14, 15, Facing.East, Facing.East), south = Transition(14, 16, Facing.South, Facing.South), west = Transition(14, 11, Facing.West, Facing.East) ) CubeFacing + CubeFacing( id = 15, size = 50, topLeft = Point(50, 100), north = Transition(15, 13, Facing.North, Facing.North), east = Transition(15, 12, Facing.East, Facing.West), south = Transition(15, 16, Facing.South, Facing.West), west = Transition(15, 14, Facing.West, Facing.West) ) CubeFacing + CubeFacing( id = 16, size = 50, topLeft = Point(0, 150), north = Transition(16, 14, Facing.North, Facing.North), east = Transition(16, 15, Facing.East, Facing.North), south = Transition(16, 12, Facing.South, Facing.South), west = Transition(16, 11, Facing.West, Facing.South) ) } } } data class Transition(val sourceId: Int, val destinationId: Int, val exit: Facing, val enter: Facing) { private val byDirection = Pair(exit, enter) private val source: CubeFacing by lazy { CubeFacing(sourceId) } val destination: CubeFacing by lazy { CubeFacing(destinationId) } private fun Point.rescale(): Point = destination.scaleUp(source.scaleDown(this)) private fun Point.flipRescaled(): Point = destination.scaleUp(source.scaleDown(this).flip()) private fun Point.flip(): Point = Point(y, x) fun move(start: Point): Point = when (byDirection) { Pair(Facing.North, Facing.North) -> Point(start.rescale().x, destination.maxY) Pair(Facing.East, Facing.East) -> Point(destination.minX, start.rescale().y) Pair(Facing.West, Facing.West) -> Point(destination.maxX, start.rescale().y) Pair(Facing.South, Facing.South) -> Point(start.rescale().x, destination.minY) Pair(Facing.North, Facing.East) -> Point(destination.minX, start.flipRescaled().y) Pair(Facing.East, Facing.North) -> Point(start.flipRescaled().x, destination.maxY) Pair(Facing.East, Facing.West) -> Point(destination.maxX, destination.maxY - source.scaleDown(start).y) Pair(Facing.West, Facing.East) -> Point(destination.minX, destination.maxY - source.scaleDown(start).y) Pair(Facing.West, Facing.South) -> Point(start.flipRescaled().x, destination.minY) Pair(Facing.South, Facing.West) -> Point(destination.maxX, start.flipRescaled().y) else -> throw IllegalStateException("No transition from $exit to $enter") } } }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22Kt.class", "javap": "Compiled from \"Day22.kt\"\npublic final class Day22Kt {\n public static final void main();\n Code:\n 0: new #8 // class Day22\n 3: dup\n 4: ldc #10 // String inputs/Day22\n 6: invokestatic #16 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 9: invokespecial #20 // Method Day22.\"<init>\":(Ljava/util/List;)V\n 12: astore_0\n 13: aload_0\n 14: invokevirtual #24 // Method Day22.part1:()I\n 17: istore_1\n 18: getstatic #30 // Field java/lang/System.out:Ljava/io/PrintStream;\n 21: iload_1\n 22: invokevirtual #36 // Method java/io/PrintStream.println:(I)V\n 25: aload_0\n 26: invokevirtual #39 // Method Day22.part2:()I\n 29: istore_1\n 30: getstatic #30 // Field java/lang/System.out:Ljava/io/PrintStream;\n 33: iload_1\n 34: invokevirtual #36 // Method java/io/PrintStream.println:(I)V\n 37: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #44 // Method main:()V\n 3: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22$Facing$North.class", "javap": "Compiled from \"Day22.kt\"\npublic final class Day22$Facing$North extends Day22$Facing {\n public static final Day22$Facing$North INSTANCE;\n\n private static final Day22$Facing$West left;\n\n private static final Day22$Facing$East right;\n\n private Day22$Facing$North();\n Code:\n 0: aload_0\n 1: iconst_3\n 2: new #8 // class Point\n 5: dup\n 6: iconst_0\n 7: iconst_m1\n 8: invokespecial #11 // Method Point.\"<init>\":(II)V\n 11: aconst_null\n 12: invokespecial #14 // Method Day22$Facing.\"<init>\":(ILPoint;Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 15: return\n\n public Day22$Facing$West getLeft();\n Code:\n 0: getstatic #23 // Field left:LDay22$Facing$West;\n 3: areturn\n\n public Day22$Facing$East getRight();\n Code:\n 0: getstatic #29 // Field right:LDay22$Facing$East;\n 3: areturn\n\n public Day22$Facing getLeft();\n Code:\n 0: aload_0\n 1: invokevirtual #32 // Method getLeft:()LDay22$Facing$West;\n 4: checkcast #4 // class Day22$Facing\n 7: areturn\n\n public Day22$Facing getRight();\n Code:\n 0: aload_0\n 1: invokevirtual #34 // Method getRight:()LDay22$Facing$East;\n 4: checkcast #4 // class Day22$Facing\n 7: areturn\n\n static {};\n Code:\n 0: new #2 // class Day22$Facing$North\n 3: dup\n 4: invokespecial #37 // Method \"<init>\":()V\n 7: putstatic #40 // Field INSTANCE:LDay22$Facing$North;\n 10: getstatic #44 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 13: putstatic #23 // Field left:LDay22$Facing$West;\n 16: getstatic #48 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 19: putstatic #29 // Field right:LDay22$Facing$East;\n 22: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22$Instruction.class", "javap": "Compiled from \"Day22.kt\"\nabstract class Day22$Instruction {\n public static final Day22$Instruction$Companion Companion;\n\n private Day22$Instruction();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public Day22$Instruction(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #12 // Method \"<init>\":()V\n 4: return\n\n static {};\n Code:\n 0: new #17 // class Day22$Instruction$Companion\n 3: dup\n 4: aconst_null\n 5: invokespecial #19 // Method Day22$Instruction$Companion.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 8: putstatic #23 // Field Companion:LDay22$Instruction$Companion;\n 11: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22$Left.class", "javap": "Compiled from \"Day22.kt\"\nfinal class Day22$Left extends Day22$Instruction {\n public static final Day22$Left INSTANCE;\n\n private Day22$Left();\n Code:\n 0: aload_0\n 1: aconst_null\n 2: invokespecial #9 // Method Day22$Instruction.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 5: return\n\n static {};\n Code:\n 0: new #2 // class Day22$Left\n 3: dup\n 4: invokespecial #14 // Method \"<init>\":()V\n 7: putstatic #17 // Field INSTANCE:LDay22$Left;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22$Facing$West.class", "javap": "Compiled from \"Day22.kt\"\npublic final class Day22$Facing$West extends Day22$Facing {\n public static final Day22$Facing$West INSTANCE;\n\n private static final Day22$Facing$South left;\n\n private static final Day22$Facing$North right;\n\n private Day22$Facing$West();\n Code:\n 0: aload_0\n 1: iconst_2\n 2: new #8 // class Point\n 5: dup\n 6: iconst_m1\n 7: iconst_0\n 8: invokespecial #11 // Method Point.\"<init>\":(II)V\n 11: aconst_null\n 12: invokespecial #14 // Method Day22$Facing.\"<init>\":(ILPoint;Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 15: return\n\n public Day22$Facing$South getLeft();\n Code:\n 0: getstatic #23 // Field left:LDay22$Facing$South;\n 3: areturn\n\n public Day22$Facing$North getRight();\n Code:\n 0: getstatic #29 // Field right:LDay22$Facing$North;\n 3: areturn\n\n public Day22$Facing getLeft();\n Code:\n 0: aload_0\n 1: invokevirtual #32 // Method getLeft:()LDay22$Facing$South;\n 4: checkcast #4 // class Day22$Facing\n 7: areturn\n\n public Day22$Facing getRight();\n Code:\n 0: aload_0\n 1: invokevirtual #34 // Method getRight:()LDay22$Facing$North;\n 4: checkcast #4 // class Day22$Facing\n 7: areturn\n\n static {};\n Code:\n 0: new #2 // class Day22$Facing$West\n 3: dup\n 4: invokespecial #37 // Method \"<init>\":()V\n 7: putstatic #40 // Field INSTANCE:LDay22$Facing$West;\n 10: getstatic #44 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 13: putstatic #23 // Field left:LDay22$Facing$South;\n 16: getstatic #48 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 19: putstatic #29 // Field right:LDay22$Facing$North;\n 22: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22$Facing$South.class", "javap": "Compiled from \"Day22.kt\"\npublic final class Day22$Facing$South extends Day22$Facing {\n public static final Day22$Facing$South INSTANCE;\n\n private static final Day22$Facing$East left;\n\n private static final Day22$Facing$West right;\n\n private Day22$Facing$South();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: new #8 // class Point\n 5: dup\n 6: iconst_0\n 7: iconst_1\n 8: invokespecial #11 // Method Point.\"<init>\":(II)V\n 11: aconst_null\n 12: invokespecial #14 // Method Day22$Facing.\"<init>\":(ILPoint;Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 15: return\n\n public Day22$Facing$East getLeft();\n Code:\n 0: getstatic #23 // Field left:LDay22$Facing$East;\n 3: areturn\n\n public Day22$Facing$West getRight();\n Code:\n 0: getstatic #29 // Field right:LDay22$Facing$West;\n 3: areturn\n\n public Day22$Facing getLeft();\n Code:\n 0: aload_0\n 1: invokevirtual #32 // Method getLeft:()LDay22$Facing$East;\n 4: checkcast #4 // class Day22$Facing\n 7: areturn\n\n public Day22$Facing getRight();\n Code:\n 0: aload_0\n 1: invokevirtual #34 // Method getRight:()LDay22$Facing$West;\n 4: checkcast #4 // class Day22$Facing\n 7: areturn\n\n static {};\n Code:\n 0: new #2 // class Day22$Facing$South\n 3: dup\n 4: invokespecial #37 // Method \"<init>\":()V\n 7: putstatic #40 // Field INSTANCE:LDay22$Facing$South;\n 10: getstatic #44 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 13: putstatic #23 // Field left:LDay22$Facing$East;\n 16: getstatic #48 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 19: putstatic #29 // Field right:LDay22$Facing$West;\n 22: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22$Instruction$Companion.class", "javap": "Compiled from \"Day22.kt\"\npublic final class Day22$Instruction$Companion {\n private Day22$Instruction$Companion();\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.List<Day22$Instruction> ofList(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #24 // class java/lang/Iterable\n 10: astore_2\n 11: nop\n 12: iconst_0\n 13: istore_3\n 14: iconst_0\n 15: istore 4\n 17: new #26 // class java/util/ArrayList\n 20: dup\n 21: invokespecial #27 // Method java/util/ArrayList.\"<init>\":()V\n 24: astore 5\n 26: aload_2\n 27: invokeinterface #31, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 6\n 34: aload 6\n 36: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 113\n 44: aload 6\n 46: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: astore 7\n 53: iload 4\n 55: ifeq 69\n 58: aload 5\n 60: aload 7\n 62: invokevirtual #45 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 65: pop\n 66: goto 34\n 69: aload 7\n 71: checkcast #47 // class java/lang/String\n 74: astore 8\n 76: iconst_0\n 77: istore 9\n 79: aload 8\n 81: checkcast #49 // class java/lang/CharSequence\n 84: invokestatic #55 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 87: ifne 94\n 90: iconst_1\n 91: goto 95\n 94: iconst_0\n 95: nop\n 96: ifne 34\n 99: aload 5\n 101: aload 7\n 103: invokevirtual #45 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 106: pop\n 107: iconst_1\n 108: istore 4\n 110: goto 34\n 113: aload 5\n 115: checkcast #57 // class java/util/List\n 118: checkcast #24 // class java/lang/Iterable\n 121: iconst_1\n 122: invokestatic #63 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 125: invokestatic #67 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 128: checkcast #47 // class java/lang/String\n 131: checkcast #49 // class java/lang/CharSequence\n 134: invokestatic #71 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 137: invokevirtual #75 // Method java/lang/Object.toString:()Ljava/lang/String;\n 140: astore_3\n 141: iconst_0\n 142: istore 4\n 144: new #77 // class kotlin/text/Regex\n 147: dup\n 148: ldc #79 // String \\\\d+|[LR]\n 150: invokespecial #82 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 153: aload_3\n 154: checkcast #49 // class java/lang/CharSequence\n 157: iconst_0\n 158: iconst_2\n 159: aconst_null\n 160: invokestatic #86 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 163: invokedynamic #105, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 168: invokestatic #111 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 171: invokedynamic #119, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 176: invokestatic #122 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 179: invokedynamic #129, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;\n 184: invokestatic #111 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 187: invokestatic #133 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 190: areturn\n\n private static final java.lang.String ofList$lambda$2(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc #149 // String it\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #154, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 12: areturn\n\n private static final boolean ofList$lambda$3(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #149 // String it\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #49 // class java/lang/CharSequence\n 10: invokestatic #55 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 13: ifne 20\n 16: iconst_1\n 17: goto 21\n 20: iconst_0\n 21: ireturn\n\n private static final Day22$Instruction ofList$lambda$4(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #157 // String symbol\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: astore_1\n 8: aload_1\n 9: ldc #159 // String L\n 11: invokestatic #163 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 14: ifeq 26\n 17: getstatic #169 // Field Day22$Left.INSTANCE:LDay22$Left;\n 20: checkcast #171 // class Day22$Instruction\n 23: goto 58\n 26: aload_1\n 27: ldc #173 // String R\n 29: invokestatic #163 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifeq 44\n 35: getstatic #178 // Field Day22$Right.INSTANCE:LDay22$Right;\n 38: checkcast #171 // class Day22$Instruction\n 41: goto 58\n 44: new #180 // class Day22$Move\n 47: dup\n 48: aload_0\n 49: invokestatic #186 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 52: invokespecial #189 // Method Day22$Move.\"<init>\":(I)V\n 55: checkcast #171 // class Day22$Instruction\n 58: areturn\n\n public Day22$Instruction$Companion(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #191 // Method \"<init>\":()V\n 4: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22$Right.class", "javap": "Compiled from \"Day22.kt\"\nfinal class Day22$Right extends Day22$Instruction {\n public static final Day22$Right INSTANCE;\n\n private Day22$Right();\n Code:\n 0: aload_0\n 1: aconst_null\n 2: invokespecial #9 // Method Day22$Instruction.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 5: return\n\n static {};\n Code:\n 0: new #2 // class Day22$Right\n 3: dup\n 4: invokespecial #14 // Method \"<init>\":()V\n 7: putstatic #17 // Field INSTANCE:LDay22$Right;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22$Facing.class", "javap": "Compiled from \"Day22.kt\"\npublic abstract class Day22$Facing {\n private final int points;\n\n private final Point offset;\n\n private Day22$Facing(int, Point);\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 points:I\n 9: aload_0\n 10: aload_2\n 11: putfield #17 // Field offset:LPoint;\n 14: return\n\n public final int getPoints();\n Code:\n 0: aload_0\n 1: getfield #13 // Field points:I\n 4: ireturn\n\n public final Point getOffset();\n Code:\n 0: aload_0\n 1: getfield #17 // Field offset:LPoint;\n 4: areturn\n\n public abstract Day22$Facing getLeft();\n\n public abstract Day22$Facing getRight();\n\n public Day22$Facing(int, Point, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: iload_1\n 2: aload_2\n 3: invokespecial #30 // Method \"<init>\":(ILPoint;)V\n 6: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22$Facing$East.class", "javap": "Compiled from \"Day22.kt\"\npublic final class Day22$Facing$East extends Day22$Facing {\n public static final Day22$Facing$East INSTANCE;\n\n private static final Day22$Facing$North left;\n\n private static final Day22$Facing$South right;\n\n private Day22$Facing$East();\n Code:\n 0: aload_0\n 1: iconst_0\n 2: new #8 // class Point\n 5: dup\n 6: iconst_1\n 7: iconst_0\n 8: invokespecial #11 // Method Point.\"<init>\":(II)V\n 11: aconst_null\n 12: invokespecial #14 // Method Day22$Facing.\"<init>\":(ILPoint;Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 15: return\n\n public Day22$Facing$North getLeft();\n Code:\n 0: getstatic #23 // Field left:LDay22$Facing$North;\n 3: areturn\n\n public Day22$Facing$South getRight();\n Code:\n 0: getstatic #29 // Field right:LDay22$Facing$South;\n 3: areturn\n\n public Day22$Facing getLeft();\n Code:\n 0: aload_0\n 1: invokevirtual #32 // Method getLeft:()LDay22$Facing$North;\n 4: checkcast #4 // class Day22$Facing\n 7: areturn\n\n public Day22$Facing getRight();\n Code:\n 0: aload_0\n 1: invokevirtual #34 // Method getRight:()LDay22$Facing$South;\n 4: checkcast #4 // class Day22$Facing\n 7: areturn\n\n static {};\n Code:\n 0: new #2 // class Day22$Facing$East\n 3: dup\n 4: invokespecial #37 // Method \"<init>\":()V\n 7: putstatic #40 // Field INSTANCE:LDay22$Facing$East;\n 10: getstatic #44 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 13: putstatic #23 // Field left:LDay22$Facing$North;\n 16: getstatic #48 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 19: putstatic #29 // Field right:LDay22$Facing$South;\n 22: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22$Move.class", "javap": "Compiled from \"Day22.kt\"\nfinal class Day22$Move extends Day22$Instruction {\n private final int steps;\n\n public Day22$Move(int);\n Code:\n 0: aload_0\n 1: aconst_null\n 2: invokespecial #9 // Method Day22$Instruction.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 5: aload_0\n 6: iload_1\n 7: putfield #13 // Field steps:I\n 10: return\n\n public final int getSteps();\n Code:\n 0: aload_0\n 1: getfield #13 // Field steps:I\n 4: ireturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22$CubeFacing.class", "javap": "Compiled from \"Day22.kt\"\npublic final class Day22$CubeFacing {\n public static final Day22$CubeFacing$Companion Companion;\n\n private final int id;\n\n private final int size;\n\n private final Point topLeft;\n\n private final Day22$Transition north;\n\n private final Day22$Transition east;\n\n private final Day22$Transition south;\n\n private final Day22$Transition west;\n\n private final int minX;\n\n private final int maxX;\n\n private final int minY;\n\n private final int maxY;\n\n private static final java.util.Map<java.lang.Integer, Day22$CubeFacing> instances;\n\n public Day22$CubeFacing(int, int, Point, Day22$Transition, Day22$Transition, Day22$Transition, Day22$Transition);\n Code:\n 0: aload_3\n 1: ldc #9 // String topLeft\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload 4\n 8: ldc #17 // String north\n 10: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: aload 5\n 15: ldc #19 // String east\n 17: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 20: aload 6\n 22: ldc #21 // String south\n 24: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 27: aload 7\n 29: ldc #23 // String west\n 31: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 34: aload_0\n 35: invokespecial #26 // Method java/lang/Object.\"<init>\":()V\n 38: aload_0\n 39: iload_1\n 40: putfield #30 // Field id:I\n 43: aload_0\n 44: iload_2\n 45: putfield #33 // Field size:I\n 48: aload_0\n 49: aload_3\n 50: putfield #36 // Field topLeft:LPoint;\n 53: aload_0\n 54: aload 4\n 56: putfield #39 // Field north:LDay22$Transition;\n 59: aload_0\n 60: aload 5\n 62: putfield #41 // Field east:LDay22$Transition;\n 65: aload_0\n 66: aload 6\n 68: putfield #43 // Field south:LDay22$Transition;\n 71: aload_0\n 72: aload 7\n 74: putfield #45 // Field west:LDay22$Transition;\n 77: aload_0\n 78: aload_0\n 79: getfield #36 // Field topLeft:LPoint;\n 82: invokevirtual #51 // Method Point.getX:()I\n 85: putfield #54 // Field minX:I\n 88: aload_0\n 89: aload_0\n 90: getfield #36 // Field topLeft:LPoint;\n 93: invokevirtual #51 // Method Point.getX:()I\n 96: aload_0\n 97: getfield #33 // Field size:I\n 100: iadd\n 101: iconst_1\n 102: isub\n 103: putfield #57 // Field maxX:I\n 106: aload_0\n 107: aload_0\n 108: getfield #36 // Field topLeft:LPoint;\n 111: invokevirtual #60 // Method Point.getY:()I\n 114: putfield #63 // Field minY:I\n 117: aload_0\n 118: aload_0\n 119: getfield #36 // Field topLeft:LPoint;\n 122: invokevirtual #60 // Method Point.getY:()I\n 125: aload_0\n 126: getfield #33 // Field size:I\n 129: iadd\n 130: iconst_1\n 131: isub\n 132: putfield #66 // Field maxY:I\n 135: return\n\n public final int getId();\n Code:\n 0: aload_0\n 1: getfield #30 // Field id:I\n 4: ireturn\n\n public final int getSize();\n Code:\n 0: aload_0\n 1: getfield #33 // Field size:I\n 4: ireturn\n\n public final Point getTopLeft();\n Code:\n 0: aload_0\n 1: getfield #36 // Field topLeft:LPoint;\n 4: areturn\n\n public final Day22$Transition getNorth();\n Code:\n 0: aload_0\n 1: getfield #39 // Field north:LDay22$Transition;\n 4: areturn\n\n public final Day22$Transition getEast();\n Code:\n 0: aload_0\n 1: getfield #41 // Field east:LDay22$Transition;\n 4: areturn\n\n public final Day22$Transition getSouth();\n Code:\n 0: aload_0\n 1: getfield #43 // Field south:LDay22$Transition;\n 4: areturn\n\n public final Day22$Transition getWest();\n Code:\n 0: aload_0\n 1: getfield #45 // Field west:LDay22$Transition;\n 4: areturn\n\n public final int getMinX();\n Code:\n 0: aload_0\n 1: getfield #54 // Field minX:I\n 4: ireturn\n\n public final int getMaxX();\n Code:\n 0: aload_0\n 1: getfield #57 // Field maxX:I\n 4: ireturn\n\n public final int getMinY();\n Code:\n 0: aload_0\n 1: getfield #63 // Field minY:I\n 4: ireturn\n\n public final int getMaxY();\n Code:\n 0: aload_0\n 1: getfield #66 // Field maxY:I\n 4: ireturn\n\n public final boolean contains(Point);\n Code:\n 0: aload_1\n 1: ldc #85 // String place\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #54 // Field minX:I\n 10: istore_2\n 11: aload_0\n 12: getfield #57 // Field maxX:I\n 15: istore_3\n 16: aload_1\n 17: invokevirtual #51 // Method Point.getX:()I\n 20: istore 4\n 22: iload_2\n 23: iload 4\n 25: if_icmpgt 42\n 28: iload 4\n 30: iload_3\n 31: if_icmpgt 38\n 34: iconst_1\n 35: goto 43\n 38: iconst_0\n 39: goto 43\n 42: iconst_0\n 43: ifeq 90\n 46: aload_0\n 47: getfield #63 // Field minY:I\n 50: istore_2\n 51: aload_0\n 52: getfield #66 // Field maxY:I\n 55: istore_3\n 56: aload_1\n 57: invokevirtual #60 // Method Point.getY:()I\n 60: istore 4\n 62: iload_2\n 63: iload 4\n 65: if_icmpgt 82\n 68: iload 4\n 70: iload_3\n 71: if_icmpgt 78\n 74: iconst_1\n 75: goto 83\n 78: iconst_0\n 79: goto 83\n 82: iconst_0\n 83: ifeq 90\n 86: iconst_1\n 87: goto 91\n 90: iconst_0\n 91: ireturn\n\n public final Point scaleDown(Point);\n Code:\n 0: aload_1\n 1: ldc #89 // String point\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: aload_0\n 8: getfield #36 // Field topLeft:LPoint;\n 11: invokevirtual #92 // Method Point.minus:(LPoint;)LPoint;\n 14: areturn\n\n public final Point scaleUp(Point);\n Code:\n 0: aload_1\n 1: ldc #89 // String point\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: aload_0\n 8: getfield #36 // Field topLeft:LPoint;\n 11: invokevirtual #96 // Method Point.plus:(LPoint;)LPoint;\n 14: areturn\n\n public final Day22$Transition transition(Day22$Facing);\n Code:\n 0: aload_1\n 1: ldc #100 // String direction\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: astore_2\n 8: aload_2\n 9: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 12: invokestatic #110 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 15: ifeq 25\n 18: aload_0\n 19: getfield #39 // Field north:LDay22$Transition;\n 22: goto 84\n 25: aload_2\n 26: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 29: invokestatic #110 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifeq 42\n 35: aload_0\n 36: getfield #41 // Field east:LDay22$Transition;\n 39: goto 84\n 42: aload_2\n 43: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 46: invokestatic #110 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 49: ifeq 59\n 52: aload_0\n 53: getfield #43 // Field south:LDay22$Transition;\n 56: goto 84\n 59: aload_2\n 60: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 63: invokestatic #110 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 66: ifeq 76\n 69: aload_0\n 70: getfield #45 // Field west:LDay22$Transition;\n 73: goto 84\n 76: new #127 // class kotlin/NoWhenBranchMatchedException\n 79: dup\n 80: invokespecial #128 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 83: athrow\n 84: areturn\n\n public static final java.util.Map access$getInstances$cp();\n Code:\n 0: getstatic #139 // Field instances:Ljava/util/Map;\n 3: areturn\n\n static {};\n Code:\n 0: new #142 // class Day22$CubeFacing$Companion\n 3: dup\n 4: aconst_null\n 5: invokespecial #145 // Method Day22$CubeFacing$Companion.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 8: putstatic #149 // Field Companion:LDay22$CubeFacing$Companion;\n 11: new #151 // class java/util/LinkedHashMap\n 14: dup\n 15: invokespecial #152 // Method java/util/LinkedHashMap.\"<init>\":()V\n 18: checkcast #154 // class java/util/Map\n 21: putstatic #139 // Field instances:Ljava/util/Map;\n 24: nop\n 25: getstatic #149 // Field Companion:LDay22$CubeFacing$Companion;\n 28: new #2 // class Day22$CubeFacing\n 31: dup\n 32: iconst_1\n 33: bipush 50\n 35: new #47 // class Point\n 38: dup\n 39: bipush 50\n 41: iconst_0\n 42: invokespecial #157 // Method Point.\"<init>\":(II)V\n 45: new #133 // class Day22$Transition\n 48: dup\n 49: iconst_1\n 50: iconst_5\n 51: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 54: checkcast #131 // class Day22$Facing\n 57: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 60: checkcast #131 // class Day22$Facing\n 63: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 66: new #133 // class Day22$Transition\n 69: dup\n 70: iconst_1\n 71: iconst_2\n 72: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 75: checkcast #131 // class Day22$Facing\n 78: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 81: checkcast #131 // class Day22$Facing\n 84: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 87: new #133 // class Day22$Transition\n 90: dup\n 91: iconst_1\n 92: iconst_3\n 93: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 96: checkcast #131 // class Day22$Facing\n 99: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 102: checkcast #131 // class Day22$Facing\n 105: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 108: new #133 // class Day22$Transition\n 111: dup\n 112: iconst_1\n 113: iconst_2\n 114: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 117: checkcast #131 // class Day22$Facing\n 120: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 123: checkcast #131 // class Day22$Facing\n 126: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 129: invokespecial #162 // Method \"<init>\":(IILPoint;LDay22$Transition;LDay22$Transition;LDay22$Transition;LDay22$Transition;)V\n 132: invokestatic #166 // Method Day22$CubeFacing$Companion.access$plus:(LDay22$CubeFacing$Companion;LDay22$CubeFacing;)V\n 135: getstatic #149 // Field Companion:LDay22$CubeFacing$Companion;\n 138: new #2 // class Day22$CubeFacing\n 141: dup\n 142: iconst_2\n 143: bipush 50\n 145: new #47 // class Point\n 148: dup\n 149: bipush 100\n 151: iconst_0\n 152: invokespecial #157 // Method Point.\"<init>\":(II)V\n 155: new #133 // class Day22$Transition\n 158: dup\n 159: iconst_2\n 160: iconst_2\n 161: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 164: checkcast #131 // class Day22$Facing\n 167: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 170: checkcast #131 // class Day22$Facing\n 173: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 176: new #133 // class Day22$Transition\n 179: dup\n 180: iconst_2\n 181: iconst_1\n 182: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 185: checkcast #131 // class Day22$Facing\n 188: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 191: checkcast #131 // class Day22$Facing\n 194: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 197: new #133 // class Day22$Transition\n 200: dup\n 201: iconst_2\n 202: iconst_2\n 203: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 206: checkcast #131 // class Day22$Facing\n 209: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 212: checkcast #131 // class Day22$Facing\n 215: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 218: new #133 // class Day22$Transition\n 221: dup\n 222: iconst_2\n 223: iconst_1\n 224: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 227: checkcast #131 // class Day22$Facing\n 230: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 233: checkcast #131 // class Day22$Facing\n 236: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 239: invokespecial #162 // Method \"<init>\":(IILPoint;LDay22$Transition;LDay22$Transition;LDay22$Transition;LDay22$Transition;)V\n 242: invokestatic #166 // Method Day22$CubeFacing$Companion.access$plus:(LDay22$CubeFacing$Companion;LDay22$CubeFacing;)V\n 245: getstatic #149 // Field Companion:LDay22$CubeFacing$Companion;\n 248: new #2 // class Day22$CubeFacing\n 251: dup\n 252: iconst_3\n 253: bipush 50\n 255: new #47 // class Point\n 258: dup\n 259: bipush 50\n 261: bipush 50\n 263: invokespecial #157 // Method Point.\"<init>\":(II)V\n 266: new #133 // class Day22$Transition\n 269: dup\n 270: iconst_3\n 271: iconst_1\n 272: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 275: checkcast #131 // class Day22$Facing\n 278: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 281: checkcast #131 // class Day22$Facing\n 284: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 287: new #133 // class Day22$Transition\n 290: dup\n 291: iconst_3\n 292: iconst_3\n 293: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 296: checkcast #131 // class Day22$Facing\n 299: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 302: checkcast #131 // class Day22$Facing\n 305: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 308: new #133 // class Day22$Transition\n 311: dup\n 312: iconst_3\n 313: iconst_5\n 314: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 317: checkcast #131 // class Day22$Facing\n 320: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 323: checkcast #131 // class Day22$Facing\n 326: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 329: new #133 // class Day22$Transition\n 332: dup\n 333: iconst_3\n 334: iconst_3\n 335: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 338: checkcast #131 // class Day22$Facing\n 341: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 344: checkcast #131 // class Day22$Facing\n 347: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 350: invokespecial #162 // Method \"<init>\":(IILPoint;LDay22$Transition;LDay22$Transition;LDay22$Transition;LDay22$Transition;)V\n 353: invokestatic #166 // Method Day22$CubeFacing$Companion.access$plus:(LDay22$CubeFacing$Companion;LDay22$CubeFacing;)V\n 356: getstatic #149 // Field Companion:LDay22$CubeFacing$Companion;\n 359: new #2 // class Day22$CubeFacing\n 362: dup\n 363: iconst_4\n 364: bipush 50\n 366: new #47 // class Point\n 369: dup\n 370: iconst_0\n 371: bipush 100\n 373: invokespecial #157 // Method Point.\"<init>\":(II)V\n 376: new #133 // class Day22$Transition\n 379: dup\n 380: iconst_4\n 381: bipush 6\n 383: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 386: checkcast #131 // class Day22$Facing\n 389: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 392: checkcast #131 // class Day22$Facing\n 395: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 398: new #133 // class Day22$Transition\n 401: dup\n 402: iconst_4\n 403: iconst_5\n 404: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 407: checkcast #131 // class Day22$Facing\n 410: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 413: checkcast #131 // class Day22$Facing\n 416: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 419: new #133 // class Day22$Transition\n 422: dup\n 423: iconst_4\n 424: bipush 6\n 426: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 429: checkcast #131 // class Day22$Facing\n 432: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 435: checkcast #131 // class Day22$Facing\n 438: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 441: new #133 // class Day22$Transition\n 444: dup\n 445: iconst_4\n 446: iconst_5\n 447: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 450: checkcast #131 // class Day22$Facing\n 453: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 456: checkcast #131 // class Day22$Facing\n 459: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 462: invokespecial #162 // Method \"<init>\":(IILPoint;LDay22$Transition;LDay22$Transition;LDay22$Transition;LDay22$Transition;)V\n 465: invokestatic #166 // Method Day22$CubeFacing$Companion.access$plus:(LDay22$CubeFacing$Companion;LDay22$CubeFacing;)V\n 468: getstatic #149 // Field Companion:LDay22$CubeFacing$Companion;\n 471: new #2 // class Day22$CubeFacing\n 474: dup\n 475: iconst_5\n 476: bipush 50\n 478: new #47 // class Point\n 481: dup\n 482: bipush 50\n 484: bipush 100\n 486: invokespecial #157 // Method Point.\"<init>\":(II)V\n 489: new #133 // class Day22$Transition\n 492: dup\n 493: iconst_5\n 494: iconst_3\n 495: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 498: checkcast #131 // class Day22$Facing\n 501: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 504: checkcast #131 // class Day22$Facing\n 507: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 510: new #133 // class Day22$Transition\n 513: dup\n 514: iconst_5\n 515: iconst_4\n 516: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 519: checkcast #131 // class Day22$Facing\n 522: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 525: checkcast #131 // class Day22$Facing\n 528: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 531: new #133 // class Day22$Transition\n 534: dup\n 535: iconst_5\n 536: iconst_1\n 537: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 540: checkcast #131 // class Day22$Facing\n 543: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 546: checkcast #131 // class Day22$Facing\n 549: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 552: new #133 // class Day22$Transition\n 555: dup\n 556: iconst_5\n 557: iconst_4\n 558: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 561: checkcast #131 // class Day22$Facing\n 564: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 567: checkcast #131 // class Day22$Facing\n 570: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 573: invokespecial #162 // Method \"<init>\":(IILPoint;LDay22$Transition;LDay22$Transition;LDay22$Transition;LDay22$Transition;)V\n 576: invokestatic #166 // Method Day22$CubeFacing$Companion.access$plus:(LDay22$CubeFacing$Companion;LDay22$CubeFacing;)V\n 579: getstatic #149 // Field Companion:LDay22$CubeFacing$Companion;\n 582: new #2 // class Day22$CubeFacing\n 585: dup\n 586: bipush 6\n 588: bipush 50\n 590: new #47 // class Point\n 593: dup\n 594: iconst_0\n 595: sipush 150\n 598: invokespecial #157 // Method Point.\"<init>\":(II)V\n 601: new #133 // class Day22$Transition\n 604: dup\n 605: bipush 6\n 607: iconst_4\n 608: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 611: checkcast #131 // class Day22$Facing\n 614: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 617: checkcast #131 // class Day22$Facing\n 620: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 623: new #133 // class Day22$Transition\n 626: dup\n 627: bipush 6\n 629: bipush 6\n 631: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 634: checkcast #131 // class Day22$Facing\n 637: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 640: checkcast #131 // class Day22$Facing\n 643: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 646: new #133 // class Day22$Transition\n 649: dup\n 650: bipush 6\n 652: iconst_4\n 653: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 656: checkcast #131 // class Day22$Facing\n 659: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 662: checkcast #131 // class Day22$Facing\n 665: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 668: new #133 // class Day22$Transition\n 671: dup\n 672: bipush 6\n 674: bipush 6\n 676: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 679: checkcast #131 // class Day22$Facing\n 682: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 685: checkcast #131 // class Day22$Facing\n 688: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 691: invokespecial #162 // Method \"<init>\":(IILPoint;LDay22$Transition;LDay22$Transition;LDay22$Transition;LDay22$Transition;)V\n 694: invokestatic #166 // Method Day22$CubeFacing$Companion.access$plus:(LDay22$CubeFacing$Companion;LDay22$CubeFacing;)V\n 697: getstatic #149 // Field Companion:LDay22$CubeFacing$Companion;\n 700: new #2 // class Day22$CubeFacing\n 703: dup\n 704: bipush 11\n 706: bipush 50\n 708: new #47 // class Point\n 711: dup\n 712: bipush 50\n 714: iconst_0\n 715: invokespecial #157 // Method Point.\"<init>\":(II)V\n 718: new #133 // class Day22$Transition\n 721: dup\n 722: bipush 11\n 724: bipush 16\n 726: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 729: checkcast #131 // class Day22$Facing\n 732: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 735: checkcast #131 // class Day22$Facing\n 738: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 741: new #133 // class Day22$Transition\n 744: dup\n 745: bipush 11\n 747: bipush 12\n 749: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 752: checkcast #131 // class Day22$Facing\n 755: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 758: checkcast #131 // class Day22$Facing\n 761: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 764: new #133 // class Day22$Transition\n 767: dup\n 768: bipush 11\n 770: bipush 13\n 772: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 775: checkcast #131 // class Day22$Facing\n 778: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 781: checkcast #131 // class Day22$Facing\n 784: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 787: new #133 // class Day22$Transition\n 790: dup\n 791: bipush 11\n 793: bipush 14\n 795: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 798: checkcast #131 // class Day22$Facing\n 801: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 804: checkcast #131 // class Day22$Facing\n 807: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 810: invokespecial #162 // Method \"<init>\":(IILPoint;LDay22$Transition;LDay22$Transition;LDay22$Transition;LDay22$Transition;)V\n 813: invokestatic #166 // Method Day22$CubeFacing$Companion.access$plus:(LDay22$CubeFacing$Companion;LDay22$CubeFacing;)V\n 816: getstatic #149 // Field Companion:LDay22$CubeFacing$Companion;\n 819: new #2 // class Day22$CubeFacing\n 822: dup\n 823: bipush 12\n 825: bipush 50\n 827: new #47 // class Point\n 830: dup\n 831: bipush 100\n 833: iconst_0\n 834: invokespecial #157 // Method Point.\"<init>\":(II)V\n 837: new #133 // class Day22$Transition\n 840: dup\n 841: bipush 12\n 843: bipush 16\n 845: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 848: checkcast #131 // class Day22$Facing\n 851: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 854: checkcast #131 // class Day22$Facing\n 857: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 860: new #133 // class Day22$Transition\n 863: dup\n 864: bipush 12\n 866: bipush 15\n 868: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 871: checkcast #131 // class Day22$Facing\n 874: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 877: checkcast #131 // class Day22$Facing\n 880: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 883: new #133 // class Day22$Transition\n 886: dup\n 887: bipush 12\n 889: bipush 13\n 891: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 894: checkcast #131 // class Day22$Facing\n 897: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 900: checkcast #131 // class Day22$Facing\n 903: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 906: new #133 // class Day22$Transition\n 909: dup\n 910: bipush 12\n 912: bipush 11\n 914: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 917: checkcast #131 // class Day22$Facing\n 920: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 923: checkcast #131 // class Day22$Facing\n 926: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 929: invokespecial #162 // Method \"<init>\":(IILPoint;LDay22$Transition;LDay22$Transition;LDay22$Transition;LDay22$Transition;)V\n 932: invokestatic #166 // Method Day22$CubeFacing$Companion.access$plus:(LDay22$CubeFacing$Companion;LDay22$CubeFacing;)V\n 935: getstatic #149 // Field Companion:LDay22$CubeFacing$Companion;\n 938: new #2 // class Day22$CubeFacing\n 941: dup\n 942: bipush 13\n 944: bipush 50\n 946: new #47 // class Point\n 949: dup\n 950: bipush 50\n 952: bipush 50\n 954: invokespecial #157 // Method Point.\"<init>\":(II)V\n 957: new #133 // class Day22$Transition\n 960: dup\n 961: bipush 13\n 963: bipush 11\n 965: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 968: checkcast #131 // class Day22$Facing\n 971: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 974: checkcast #131 // class Day22$Facing\n 977: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 980: new #133 // class Day22$Transition\n 983: dup\n 984: bipush 13\n 986: bipush 12\n 988: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 991: checkcast #131 // class Day22$Facing\n 994: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 997: checkcast #131 // class Day22$Facing\n 1000: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 1003: new #133 // class Day22$Transition\n 1006: dup\n 1007: bipush 13\n 1009: bipush 15\n 1011: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 1014: checkcast #131 // class Day22$Facing\n 1017: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 1020: checkcast #131 // class Day22$Facing\n 1023: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 1026: new #133 // class Day22$Transition\n 1029: dup\n 1030: bipush 13\n 1032: bipush 14\n 1034: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 1037: checkcast #131 // class Day22$Facing\n 1040: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 1043: checkcast #131 // class Day22$Facing\n 1046: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 1049: invokespecial #162 // Method \"<init>\":(IILPoint;LDay22$Transition;LDay22$Transition;LDay22$Transition;LDay22$Transition;)V\n 1052: invokestatic #166 // Method Day22$CubeFacing$Companion.access$plus:(LDay22$CubeFacing$Companion;LDay22$CubeFacing;)V\n 1055: getstatic #149 // Field Companion:LDay22$CubeFacing$Companion;\n 1058: new #2 // class Day22$CubeFacing\n 1061: dup\n 1062: bipush 14\n 1064: bipush 50\n 1066: new #47 // class Point\n 1069: dup\n 1070: iconst_0\n 1071: bipush 100\n 1073: invokespecial #157 // Method Point.\"<init>\":(II)V\n 1076: new #133 // class Day22$Transition\n 1079: dup\n 1080: bipush 14\n 1082: bipush 13\n 1084: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 1087: checkcast #131 // class Day22$Facing\n 1090: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 1093: checkcast #131 // class Day22$Facing\n 1096: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 1099: new #133 // class Day22$Transition\n 1102: dup\n 1103: bipush 14\n 1105: bipush 15\n 1107: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 1110: checkcast #131 // class Day22$Facing\n 1113: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 1116: checkcast #131 // class Day22$Facing\n 1119: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 1122: new #133 // class Day22$Transition\n 1125: dup\n 1126: bipush 14\n 1128: bipush 16\n 1130: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 1133: checkcast #131 // class Day22$Facing\n 1136: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 1139: checkcast #131 // class Day22$Facing\n 1142: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 1145: new #133 // class Day22$Transition\n 1148: dup\n 1149: bipush 14\n 1151: bipush 11\n 1153: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 1156: checkcast #131 // class Day22$Facing\n 1159: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 1162: checkcast #131 // class Day22$Facing\n 1165: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 1168: invokespecial #162 // Method \"<init>\":(IILPoint;LDay22$Transition;LDay22$Transition;LDay22$Transition;LDay22$Transition;)V\n 1171: invokestatic #166 // Method Day22$CubeFacing$Companion.access$plus:(LDay22$CubeFacing$Companion;LDay22$CubeFacing;)V\n 1174: getstatic #149 // Field Companion:LDay22$CubeFacing$Companion;\n 1177: new #2 // class Day22$CubeFacing\n 1180: dup\n 1181: bipush 15\n 1183: bipush 50\n 1185: new #47 // class Point\n 1188: dup\n 1189: bipush 50\n 1191: bipush 100\n 1193: invokespecial #157 // Method Point.\"<init>\":(II)V\n 1196: new #133 // class Day22$Transition\n 1199: dup\n 1200: bipush 15\n 1202: bipush 13\n 1204: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 1207: checkcast #131 // class Day22$Facing\n 1210: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 1213: checkcast #131 // class Day22$Facing\n 1216: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 1219: new #133 // class Day22$Transition\n 1222: dup\n 1223: bipush 15\n 1225: bipush 12\n 1227: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 1230: checkcast #131 // class Day22$Facing\n 1233: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 1236: checkcast #131 // class Day22$Facing\n 1239: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 1242: new #133 // class Day22$Transition\n 1245: dup\n 1246: bipush 15\n 1248: bipush 16\n 1250: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 1253: checkcast #131 // class Day22$Facing\n 1256: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 1259: checkcast #131 // class Day22$Facing\n 1262: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 1265: new #133 // class Day22$Transition\n 1268: dup\n 1269: bipush 15\n 1271: bipush 14\n 1273: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 1276: checkcast #131 // class Day22$Facing\n 1279: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 1282: checkcast #131 // class Day22$Facing\n 1285: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 1288: invokespecial #162 // Method \"<init>\":(IILPoint;LDay22$Transition;LDay22$Transition;LDay22$Transition;LDay22$Transition;)V\n 1291: invokestatic #166 // Method Day22$CubeFacing$Companion.access$plus:(LDay22$CubeFacing$Companion;LDay22$CubeFacing;)V\n 1294: getstatic #149 // Field Companion:LDay22$CubeFacing$Companion;\n 1297: new #2 // class Day22$CubeFacing\n 1300: dup\n 1301: bipush 16\n 1303: bipush 50\n 1305: new #47 // class Point\n 1308: dup\n 1309: iconst_0\n 1310: sipush 150\n 1313: invokespecial #157 // Method Point.\"<init>\":(II)V\n 1316: new #133 // class Day22$Transition\n 1319: dup\n 1320: bipush 16\n 1322: bipush 14\n 1324: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 1327: checkcast #131 // class Day22$Facing\n 1330: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 1333: checkcast #131 // class Day22$Facing\n 1336: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 1339: new #133 // class Day22$Transition\n 1342: dup\n 1343: bipush 16\n 1345: bipush 15\n 1347: getstatic #115 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 1350: checkcast #131 // class Day22$Facing\n 1353: getstatic #106 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 1356: checkcast #131 // class Day22$Facing\n 1359: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 1362: new #133 // class Day22$Transition\n 1365: dup\n 1366: bipush 16\n 1368: bipush 12\n 1370: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 1373: checkcast #131 // class Day22$Facing\n 1376: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 1379: checkcast #131 // class Day22$Facing\n 1382: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 1385: new #133 // class Day22$Transition\n 1388: dup\n 1389: bipush 16\n 1391: bipush 11\n 1393: getstatic #125 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 1396: checkcast #131 // class Day22$Facing\n 1399: getstatic #120 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 1402: checkcast #131 // class Day22$Facing\n 1405: invokespecial #160 // Method Day22$Transition.\"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 1408: invokespecial #162 // Method \"<init>\":(IILPoint;LDay22$Transition;LDay22$Transition;LDay22$Transition;LDay22$Transition;)V\n 1411: invokestatic #166 // Method Day22$CubeFacing$Companion.access$plus:(LDay22$CubeFacing$Companion;LDay22$CubeFacing;)V\n 1414: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22.class", "javap": "Compiled from \"Day22.kt\"\npublic final class Day22 {\n private final java.util.Set<Point> blockedPlaces;\n\n private final java.util.List<Day22$Instruction> instructions;\n\n public Day22(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\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: invokespecial #19 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_0\n 12: aload_1\n 13: invokespecial #23 // Method parseBlockedPlaces:(Ljava/util/List;)Ljava/util/Set;\n 16: putfield #27 // Field blockedPlaces:Ljava/util/Set;\n 19: aload_0\n 20: getstatic #33 // Field Day22$Instruction.Companion:LDay22$Instruction$Companion;\n 23: aload_1\n 24: invokevirtual #39 // Method Day22$Instruction$Companion.ofList:(Ljava/util/List;)Ljava/util/List;\n 27: putfield #43 // Field instructions:Ljava/util/List;\n 30: return\n\n public final int part1();\n Code:\n 0: aload_0\n 1: getstatic #52 // Field Day22$CubeFacing.Companion:LDay22$CubeFacing$Companion;\n 4: iconst_1\n 5: invokevirtual #58 // Method Day22$CubeFacing$Companion.invoke:(I)LDay22$CubeFacing;\n 8: invokespecial #62 // Method followInstructions:(LDay22$CubeFacing;)LDay22$Orientation;\n 11: invokevirtual #67 // Method Day22$Orientation.score:()I\n 14: ireturn\n\n public final int part2();\n Code:\n 0: aload_0\n 1: getstatic #52 // Field Day22$CubeFacing.Companion:LDay22$CubeFacing$Companion;\n 4: bipush 11\n 6: invokevirtual #58 // Method Day22$CubeFacing$Companion.invoke:(I)LDay22$CubeFacing;\n 9: invokespecial #62 // Method followInstructions:(LDay22$CubeFacing;)LDay22$Orientation;\n 12: invokevirtual #67 // Method Day22$Orientation.score:()I\n 15: ireturn\n\n private final Day22$Orientation followInstructions(Day22$CubeFacing);\n Code:\n 0: aconst_null\n 1: astore_2\n 2: aload_1\n 3: astore_2\n 4: aconst_null\n 5: astore_3\n 6: new #64 // class Day22$Orientation\n 9: dup\n 10: aload_2\n 11: invokevirtual #72 // Method Day22$CubeFacing.getTopLeft:()LPoint;\n 14: getstatic #78 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 17: checkcast #80 // class Day22$Facing\n 20: invokespecial #83 // Method Day22$Orientation.\"<init>\":(LPoint;LDay22$Facing;)V\n 23: astore_3\n 24: aload_0\n 25: getfield #43 // Field instructions:Ljava/util/List;\n 28: checkcast #85 // class java/lang/Iterable\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: aload 4\n 38: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 43: astore 6\n 45: aload 6\n 47: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 52: ifeq 297\n 55: aload 6\n 57: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 62: astore 7\n 64: aload 7\n 66: checkcast #29 // class Day22$Instruction\n 69: astore 8\n 71: iconst_0\n 72: istore 9\n 74: aload 8\n 76: astore 10\n 78: aload 10\n 80: instanceof #101 // class Day22$Left\n 83: ifeq 104\n 86: aload_3\n 87: aconst_null\n 88: aload_3\n 89: invokevirtual #105 // Method Day22$Orientation.getFacing:()LDay22$Facing;\n 92: invokevirtual #108 // Method Day22$Facing.getLeft:()LDay22$Facing;\n 95: iconst_1\n 96: aconst_null\n 97: invokestatic #112 // Method Day22$Orientation.copy$default:(LDay22$Orientation;LPoint;LDay22$Facing;ILjava/lang/Object;)LDay22$Orientation;\n 100: astore_3\n 101: goto 292\n 104: aload 10\n 106: instanceof #114 // class Day22$Right\n 109: ifeq 130\n 112: aload_3\n 113: aconst_null\n 114: aload_3\n 115: invokevirtual #105 // Method Day22$Orientation.getFacing:()LDay22$Facing;\n 118: invokevirtual #117 // Method Day22$Facing.getRight:()LDay22$Facing;\n 121: iconst_1\n 122: aconst_null\n 123: invokestatic #112 // Method Day22$Orientation.copy$default:(LDay22$Orientation;LPoint;LDay22$Facing;ILjava/lang/Object;)LDay22$Orientation;\n 126: astore_3\n 127: goto 292\n 130: aload 10\n 132: instanceof #119 // class Day22$Move\n 135: ifeq 284\n 138: iconst_0\n 139: istore 11\n 141: iconst_1\n 142: istore 11\n 144: aload 8\n 146: checkcast #119 // class Day22$Move\n 149: invokevirtual #122 // Method Day22$Move.getSteps:()I\n 152: istore 12\n 154: iconst_0\n 155: istore 13\n 157: iload 13\n 159: iload 12\n 161: if_icmpge 292\n 164: iload 13\n 166: istore 14\n 168: iconst_0\n 169: istore 15\n 171: iload 11\n 173: ifeq 277\n 176: aconst_null\n 177: astore 16\n 179: aload_3\n 180: invokevirtual #126 // Method Day22$Orientation.move:()LDay22$Orientation;\n 183: astore 16\n 185: aconst_null\n 186: astore 17\n 188: aload_2\n 189: astore 17\n 191: aload_2\n 192: aload 16\n 194: invokevirtual #129 // Method Day22$Orientation.getLocation:()LPoint;\n 197: invokevirtual #133 // Method Day22$CubeFacing.contains:(LPoint;)Z\n 200: ifne 248\n 203: aload_2\n 204: aload_3\n 205: invokevirtual #105 // Method Day22$Orientation.getFacing:()LDay22$Facing;\n 208: invokevirtual #137 // Method Day22$CubeFacing.transition:(LDay22$Facing;)LDay22$Transition;\n 211: astore 18\n 213: iconst_0\n 214: istore 19\n 216: new #64 // class Day22$Orientation\n 219: dup\n 220: aload 18\n 222: aload_3\n 223: invokevirtual #129 // Method Day22$Orientation.getLocation:()LPoint;\n 226: invokevirtual #142 // Method Day22$Transition.move:(LPoint;)LPoint;\n 229: aload 18\n 231: invokevirtual #145 // Method Day22$Transition.getEnter:()LDay22$Facing;\n 234: invokespecial #83 // Method Day22$Orientation.\"<init>\":(LPoint;LDay22$Facing;)V\n 237: astore 16\n 239: aload 18\n 241: invokevirtual #149 // Method Day22$Transition.getDestination:()LDay22$CubeFacing;\n 244: astore 17\n 246: nop\n 247: nop\n 248: aload_0\n 249: getfield #27 // Field blockedPlaces:Ljava/util/Set;\n 252: aload 16\n 254: invokevirtual #129 // Method Day22$Orientation.getLocation:()LPoint;\n 257: invokeinterface #154, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 262: ifeq 271\n 265: iconst_0\n 266: istore 11\n 268: goto 277\n 271: aload 16\n 273: astore_3\n 274: aload 17\n 276: astore_2\n 277: nop\n 278: iinc 13, 1\n 281: goto 157\n 284: new #156 // class kotlin/NoWhenBranchMatchedException\n 287: dup\n 288: invokespecial #157 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 291: athrow\n 292: nop\n 293: nop\n 294: goto 45\n 297: nop\n 298: aload_3\n 299: areturn\n\n private final java.util.Set<Point> parseBlockedPlaces(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #85 // class java/lang/Iterable\n 4: astore_2\n 5: nop\n 6: iconst_0\n 7: istore_3\n 8: new #182 // class java/util/ArrayList\n 11: dup\n 12: invokespecial #183 // Method java/util/ArrayList.\"<init>\":()V\n 15: astore 4\n 17: aload_2\n 18: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 23: astore 5\n 25: aload 5\n 27: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 32: ifeq 88\n 35: aload 5\n 37: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 42: astore 6\n 44: aload 6\n 46: checkcast #185 // class java/lang/String\n 49: astore 7\n 51: iconst_0\n 52: istore 8\n 54: aload 7\n 56: checkcast #187 // class java/lang/CharSequence\n 59: invokestatic #193 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 62: ifne 69\n 65: iconst_1\n 66: goto 70\n 69: iconst_0\n 70: nop\n 71: ifne 77\n 74: goto 88\n 77: aload 4\n 79: aload 6\n 81: invokevirtual #196 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 84: pop\n 85: goto 25\n 88: aload 4\n 90: checkcast #198 // class java/util/List\n 93: checkcast #85 // class java/lang/Iterable\n 96: astore_3\n 97: new #182 // class java/util/ArrayList\n 100: dup\n 101: invokespecial #183 // Method java/util/ArrayList.\"<init>\":()V\n 104: checkcast #200 // class java/util/Collection\n 107: astore 4\n 109: iconst_0\n 110: istore 5\n 112: aload_3\n 113: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 118: astore 6\n 120: aload 6\n 122: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 127: ifeq 331\n 130: aload 6\n 132: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 137: astore 7\n 139: iload 5\n 141: iinc 5, 1\n 144: istore 8\n 146: iload 8\n 148: ifge 154\n 151: invokestatic #205 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 154: iload 8\n 156: aload 7\n 158: checkcast #185 // class java/lang/String\n 161: astore 9\n 163: istore 10\n 165: iconst_0\n 166: istore 11\n 168: aload 9\n 170: checkcast #187 // class java/lang/CharSequence\n 173: astore 12\n 175: iconst_0\n 176: istore 13\n 178: aload 12\n 180: astore 14\n 182: new #182 // class java/util/ArrayList\n 185: dup\n 186: invokespecial #183 // Method java/util/ArrayList.\"<init>\":()V\n 189: checkcast #200 // class java/util/Collection\n 192: astore 15\n 194: iconst_0\n 195: istore 16\n 197: aload 14\n 199: astore 17\n 201: iconst_0\n 202: istore 18\n 204: iconst_0\n 205: istore 19\n 207: iconst_0\n 208: istore 20\n 210: iload 20\n 212: aload 17\n 214: invokeinterface #208, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 219: if_icmpge 310\n 222: aload 17\n 224: iload 20\n 226: invokeinterface #212, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 231: istore 21\n 233: iload 19\n 235: iinc 19, 1\n 238: iload 21\n 240: istore 22\n 242: istore 23\n 244: iconst_0\n 245: istore 24\n 247: iload 23\n 249: iload 22\n 251: istore 25\n 253: istore 26\n 255: iconst_0\n 256: istore 27\n 258: iload 25\n 260: bipush 35\n 262: if_icmpne 279\n 265: new #214 // class Point\n 268: dup\n 269: iload 26\n 271: iload 10\n 273: invokespecial #217 // Method Point.\"<init>\":(II)V\n 276: goto 280\n 279: aconst_null\n 280: dup\n 281: ifnull 302\n 284: astore 28\n 286: iconst_0\n 287: istore 29\n 289: aload 15\n 291: aload 28\n 293: invokeinterface #218, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 298: pop\n 299: goto 303\n 302: pop\n 303: nop\n 304: iinc 20, 1\n 307: goto 210\n 310: nop\n 311: aload 15\n 313: checkcast #198 // class java/util/List\n 316: nop\n 317: checkcast #85 // class java/lang/Iterable\n 320: nop\n 321: aload 4\n 323: swap\n 324: invokestatic #222 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 327: pop\n 328: goto 120\n 331: aload 4\n 333: checkcast #198 // class java/util/List\n 336: checkcast #85 // class java/lang/Iterable\n 339: invokestatic #226 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 342: areturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22$Orientation.class", "javap": "Compiled from \"Day22.kt\"\nfinal class Day22$Orientation {\n private final Point location;\n\n private final Day22$Facing facing;\n\n public Day22$Orientation(Point, Day22$Facing);\n Code:\n 0: aload_1\n 1: ldc #9 // String location\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 facing\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 location:LPoint;\n 21: aload_0\n 22: aload_2\n 23: putfield #26 // Field facing:LDay22$Facing;\n 26: return\n\n public final Point getLocation();\n Code:\n 0: aload_0\n 1: getfield #23 // Field location:LPoint;\n 4: areturn\n\n public final Day22$Facing getFacing();\n Code:\n 0: aload_0\n 1: getfield #26 // Field facing:LDay22$Facing;\n 4: areturn\n\n public final int score();\n Code:\n 0: sipush 1000\n 3: aload_0\n 4: getfield #23 // Field location:LPoint;\n 7: invokevirtual #39 // Method Point.getY:()I\n 10: iconst_1\n 11: iadd\n 12: imul\n 13: iconst_4\n 14: aload_0\n 15: getfield #23 // Field location:LPoint;\n 18: invokevirtual #42 // Method Point.getX:()I\n 21: iconst_1\n 22: iadd\n 23: imul\n 24: iadd\n 25: aload_0\n 26: getfield #26 // Field facing:LDay22$Facing;\n 29: invokevirtual #47 // Method Day22$Facing.getPoints:()I\n 32: iadd\n 33: ireturn\n\n public final Day22$Orientation move();\n Code:\n 0: aload_0\n 1: aload_0\n 2: getfield #23 // Field location:LPoint;\n 5: aload_0\n 6: getfield #26 // Field facing:LDay22$Facing;\n 9: invokevirtual #52 // Method Day22$Facing.getOffset:()LPoint;\n 12: invokevirtual #56 // Method Point.plus:(LPoint;)LPoint;\n 15: aconst_null\n 16: iconst_2\n 17: aconst_null\n 18: invokestatic #60 // Method copy$default:(LDay22$Orientation;LPoint;LDay22$Facing;ILjava/lang/Object;)LDay22$Orientation;\n 21: areturn\n\n public final Point component1();\n Code:\n 0: aload_0\n 1: getfield #23 // Field location:LPoint;\n 4: areturn\n\n public final Day22$Facing component2();\n Code:\n 0: aload_0\n 1: getfield #26 // Field facing:LDay22$Facing;\n 4: areturn\n\n public final Day22$Orientation copy(Point, Day22$Facing);\n Code:\n 0: aload_1\n 1: ldc #9 // String location\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 facing\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class Day22$Orientation\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: invokespecial #66 // Method \"<init>\":(LPoint;LDay22$Facing;)V\n 21: areturn\n\n public static Day22$Orientation copy$default(Day22$Orientation, Point, Day22$Facing, 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 location:LPoint;\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 facing:LDay22$Facing;\n 21: astore_2\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokevirtual #68 // Method copy:(LPoint;LDay22$Facing;)LDay22$Orientation;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #72 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #73 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #75 // String Orientation(location=\n 9: invokevirtual #79 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #23 // Field location:LPoint;\n 16: invokevirtual #82 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #84 // String , facing=\n 21: invokevirtual #79 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #26 // Field facing:LDay22$Facing;\n 28: invokevirtual #82 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #87 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #89 // 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 location:LPoint;\n 4: invokevirtual #92 // Method Point.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 facing:LDay22$Facing;\n 16: invokevirtual #93 // Method Day22$Facing.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 Day22$Orientation\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day22$Orientation\n 20: astore_2\n 21: aload_0\n 22: getfield #23 // Field location:LPoint;\n 25: aload_2\n 26: getfield #23 // Field location:LPoint;\n 29: invokestatic #102 // 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 facing:LDay22$Facing;\n 41: aload_2\n 42: getfield #26 // Field facing:LDay22$Facing;\n 45: invokestatic #102 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 48: ifne 53\n 51: iconst_0\n 52: ireturn\n 53: iconst_1\n 54: ireturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22$Transition.class", "javap": "Compiled from \"Day22.kt\"\npublic final class Day22$Transition {\n private final int sourceId;\n\n private final int destinationId;\n\n private final Day22$Facing exit;\n\n private final Day22$Facing enter;\n\n private final kotlin.Pair<Day22$Facing, Day22$Facing> byDirection;\n\n private final kotlin.Lazy source$delegate;\n\n private final kotlin.Lazy destination$delegate;\n\n public Day22$Transition(int, int, Day22$Facing, Day22$Facing);\n Code:\n 0: aload_3\n 1: ldc #9 // String exit\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload 4\n 8: ldc #17 // String enter\n 10: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: aload_0\n 14: invokespecial #20 // Method java/lang/Object.\"<init>\":()V\n 17: aload_0\n 18: iload_1\n 19: putfield #24 // Field sourceId:I\n 22: aload_0\n 23: iload_2\n 24: putfield #27 // Field destinationId:I\n 27: aload_0\n 28: aload_3\n 29: putfield #30 // Field exit:LDay22$Facing;\n 32: aload_0\n 33: aload 4\n 35: putfield #32 // Field enter:LDay22$Facing;\n 38: aload_0\n 39: new #34 // class kotlin/Pair\n 42: dup\n 43: aload_0\n 44: getfield #30 // Field exit:LDay22$Facing;\n 47: aload_0\n 48: getfield #32 // Field enter:LDay22$Facing;\n 51: invokespecial #37 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 54: putfield #41 // Field byDirection:Lkotlin/Pair;\n 57: aload_0\n 58: aload_0\n 59: invokedynamic #61, 0 // InvokeDynamic #0:invoke:(LDay22$Transition;)Lkotlin/jvm/functions/Function0;\n 64: invokestatic #67 // Method kotlin/LazyKt.lazy:(Lkotlin/jvm/functions/Function0;)Lkotlin/Lazy;\n 67: putfield #71 // Field source$delegate:Lkotlin/Lazy;\n 70: aload_0\n 71: aload_0\n 72: invokedynamic #76, 0 // InvokeDynamic #1:invoke:(LDay22$Transition;)Lkotlin/jvm/functions/Function0;\n 77: invokestatic #67 // Method kotlin/LazyKt.lazy:(Lkotlin/jvm/functions/Function0;)Lkotlin/Lazy;\n 80: putfield #79 // Field destination$delegate:Lkotlin/Lazy;\n 83: return\n\n public final int getSourceId();\n Code:\n 0: aload_0\n 1: getfield #24 // Field sourceId:I\n 4: ireturn\n\n public final int getDestinationId();\n Code:\n 0: aload_0\n 1: getfield #27 // Field destinationId:I\n 4: ireturn\n\n public final Day22$Facing getExit();\n Code:\n 0: aload_0\n 1: getfield #30 // Field exit:LDay22$Facing;\n 4: areturn\n\n public final Day22$Facing getEnter();\n Code:\n 0: aload_0\n 1: getfield #32 // Field enter:LDay22$Facing;\n 4: areturn\n\n private final Day22$CubeFacing getSource();\n Code:\n 0: aload_0\n 1: getfield #71 // Field source$delegate:Lkotlin/Lazy;\n 4: astore_1\n 5: aload_1\n 6: invokeinterface #93, 1 // InterfaceMethod kotlin/Lazy.getValue:()Ljava/lang/Object;\n 11: checkcast #95 // class Day22$CubeFacing\n 14: areturn\n\n public final Day22$CubeFacing getDestination();\n Code:\n 0: aload_0\n 1: getfield #79 // Field destination$delegate:Lkotlin/Lazy;\n 4: astore_1\n 5: aload_1\n 6: invokeinterface #93, 1 // InterfaceMethod kotlin/Lazy.getValue:()Ljava/lang/Object;\n 11: checkcast #95 // class Day22$CubeFacing\n 14: areturn\n\n private final Point rescale(Point);\n Code:\n 0: aload_0\n 1: invokevirtual #100 // Method getDestination:()LDay22$CubeFacing;\n 4: aload_0\n 5: invokespecial #102 // Method getSource:()LDay22$CubeFacing;\n 8: aload_1\n 9: invokevirtual #105 // Method Day22$CubeFacing.scaleDown:(LPoint;)LPoint;\n 12: invokevirtual #108 // Method Day22$CubeFacing.scaleUp:(LPoint;)LPoint;\n 15: areturn\n\n private final Point flipRescaled(Point);\n Code:\n 0: aload_0\n 1: invokevirtual #100 // Method getDestination:()LDay22$CubeFacing;\n 4: aload_0\n 5: aload_0\n 6: invokespecial #102 // Method getSource:()LDay22$CubeFacing;\n 9: aload_1\n 10: invokevirtual #105 // Method Day22$CubeFacing.scaleDown:(LPoint;)LPoint;\n 13: invokespecial #114 // Method flip:(LPoint;)LPoint;\n 16: invokevirtual #108 // Method Day22$CubeFacing.scaleUp:(LPoint;)LPoint;\n 19: areturn\n\n private final Point flip(Point);\n Code:\n 0: new #117 // class Point\n 3: dup\n 4: aload_1\n 5: invokevirtual #120 // Method Point.getY:()I\n 8: aload_1\n 9: invokevirtual #123 // Method Point.getX:()I\n 12: invokespecial #126 // Method Point.\"<init>\":(II)V\n 15: areturn\n\n public final Point move(Point);\n Code:\n 0: aload_1\n 1: ldc #130 // String start\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #41 // Field byDirection:Lkotlin/Pair;\n 10: astore_2\n 11: aload_2\n 12: new #34 // class kotlin/Pair\n 15: dup\n 16: getstatic #136 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 19: getstatic #136 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 22: invokespecial #37 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 25: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 28: ifeq 56\n 31: new #117 // class Point\n 34: dup\n 35: aload_0\n 36: aload_1\n 37: invokespecial #142 // Method rescale:(LPoint;)LPoint;\n 40: invokevirtual #123 // Method Point.getX:()I\n 43: aload_0\n 44: invokevirtual #100 // Method getDestination:()LDay22$CubeFacing;\n 47: invokevirtual #145 // Method Day22$CubeFacing.getMaxY:()I\n 50: invokespecial #126 // Method Point.\"<init>\":(II)V\n 53: goto 525\n 56: aload_2\n 57: new #34 // class kotlin/Pair\n 60: dup\n 61: getstatic #150 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 64: getstatic #150 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 67: invokespecial #37 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 70: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 73: ifeq 101\n 76: new #117 // class Point\n 79: dup\n 80: aload_0\n 81: invokevirtual #100 // Method getDestination:()LDay22$CubeFacing;\n 84: invokevirtual #153 // Method Day22$CubeFacing.getMinX:()I\n 87: aload_0\n 88: aload_1\n 89: invokespecial #142 // Method rescale:(LPoint;)LPoint;\n 92: invokevirtual #120 // Method Point.getY:()I\n 95: invokespecial #126 // Method Point.\"<init>\":(II)V\n 98: goto 525\n 101: aload_2\n 102: new #34 // class kotlin/Pair\n 105: dup\n 106: getstatic #158 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 109: getstatic #158 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 112: invokespecial #37 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 115: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 118: ifeq 146\n 121: new #117 // class Point\n 124: dup\n 125: aload_0\n 126: invokevirtual #100 // Method getDestination:()LDay22$CubeFacing;\n 129: invokevirtual #161 // Method Day22$CubeFacing.getMaxX:()I\n 132: aload_0\n 133: aload_1\n 134: invokespecial #142 // Method rescale:(LPoint;)LPoint;\n 137: invokevirtual #120 // Method Point.getY:()I\n 140: invokespecial #126 // Method Point.\"<init>\":(II)V\n 143: goto 525\n 146: aload_2\n 147: new #34 // class kotlin/Pair\n 150: dup\n 151: getstatic #166 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 154: getstatic #166 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 157: invokespecial #37 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 160: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 163: ifeq 191\n 166: new #117 // class Point\n 169: dup\n 170: aload_0\n 171: aload_1\n 172: invokespecial #142 // Method rescale:(LPoint;)LPoint;\n 175: invokevirtual #123 // Method Point.getX:()I\n 178: aload_0\n 179: invokevirtual #100 // Method getDestination:()LDay22$CubeFacing;\n 182: invokevirtual #169 // Method Day22$CubeFacing.getMinY:()I\n 185: invokespecial #126 // Method Point.\"<init>\":(II)V\n 188: goto 525\n 191: aload_2\n 192: new #34 // class kotlin/Pair\n 195: dup\n 196: getstatic #136 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 199: getstatic #150 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 202: invokespecial #37 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 205: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 208: ifeq 236\n 211: new #117 // class Point\n 214: dup\n 215: aload_0\n 216: invokevirtual #100 // Method getDestination:()LDay22$CubeFacing;\n 219: invokevirtual #153 // Method Day22$CubeFacing.getMinX:()I\n 222: aload_0\n 223: aload_1\n 224: invokespecial #171 // Method flipRescaled:(LPoint;)LPoint;\n 227: invokevirtual #120 // Method Point.getY:()I\n 230: invokespecial #126 // Method Point.\"<init>\":(II)V\n 233: goto 525\n 236: aload_2\n 237: new #34 // class kotlin/Pair\n 240: dup\n 241: getstatic #150 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 244: getstatic #136 // Field Day22$Facing$North.INSTANCE:LDay22$Facing$North;\n 247: invokespecial #37 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 250: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 253: ifeq 281\n 256: new #117 // class Point\n 259: dup\n 260: aload_0\n 261: aload_1\n 262: invokespecial #171 // Method flipRescaled:(LPoint;)LPoint;\n 265: invokevirtual #123 // Method Point.getX:()I\n 268: aload_0\n 269: invokevirtual #100 // Method getDestination:()LDay22$CubeFacing;\n 272: invokevirtual #145 // Method Day22$CubeFacing.getMaxY:()I\n 275: invokespecial #126 // Method Point.\"<init>\":(II)V\n 278: goto 525\n 281: aload_2\n 282: new #34 // class kotlin/Pair\n 285: dup\n 286: getstatic #150 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 289: getstatic #158 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 292: invokespecial #37 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 295: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 298: ifeq 337\n 301: new #117 // class Point\n 304: dup\n 305: aload_0\n 306: invokevirtual #100 // Method getDestination:()LDay22$CubeFacing;\n 309: invokevirtual #161 // Method Day22$CubeFacing.getMaxX:()I\n 312: aload_0\n 313: invokevirtual #100 // Method getDestination:()LDay22$CubeFacing;\n 316: invokevirtual #145 // Method Day22$CubeFacing.getMaxY:()I\n 319: aload_0\n 320: invokespecial #102 // Method getSource:()LDay22$CubeFacing;\n 323: aload_1\n 324: invokevirtual #105 // Method Day22$CubeFacing.scaleDown:(LPoint;)LPoint;\n 327: invokevirtual #120 // Method Point.getY:()I\n 330: isub\n 331: invokespecial #126 // Method Point.\"<init>\":(II)V\n 334: goto 525\n 337: aload_2\n 338: new #34 // class kotlin/Pair\n 341: dup\n 342: getstatic #158 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 345: getstatic #150 // Field Day22$Facing$East.INSTANCE:LDay22$Facing$East;\n 348: invokespecial #37 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 351: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 354: ifeq 393\n 357: new #117 // class Point\n 360: dup\n 361: aload_0\n 362: invokevirtual #100 // Method getDestination:()LDay22$CubeFacing;\n 365: invokevirtual #153 // Method Day22$CubeFacing.getMinX:()I\n 368: aload_0\n 369: invokevirtual #100 // Method getDestination:()LDay22$CubeFacing;\n 372: invokevirtual #145 // Method Day22$CubeFacing.getMaxY:()I\n 375: aload_0\n 376: invokespecial #102 // Method getSource:()LDay22$CubeFacing;\n 379: aload_1\n 380: invokevirtual #105 // Method Day22$CubeFacing.scaleDown:(LPoint;)LPoint;\n 383: invokevirtual #120 // Method Point.getY:()I\n 386: isub\n 387: invokespecial #126 // Method Point.\"<init>\":(II)V\n 390: goto 525\n 393: aload_2\n 394: new #34 // class kotlin/Pair\n 397: dup\n 398: getstatic #158 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 401: getstatic #166 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 404: invokespecial #37 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 407: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 410: ifeq 438\n 413: new #117 // class Point\n 416: dup\n 417: aload_0\n 418: aload_1\n 419: invokespecial #171 // Method flipRescaled:(LPoint;)LPoint;\n 422: invokevirtual #123 // Method Point.getX:()I\n 425: aload_0\n 426: invokevirtual #100 // Method getDestination:()LDay22$CubeFacing;\n 429: invokevirtual #169 // Method Day22$CubeFacing.getMinY:()I\n 432: invokespecial #126 // Method Point.\"<init>\":(II)V\n 435: goto 525\n 438: aload_2\n 439: new #34 // class kotlin/Pair\n 442: dup\n 443: getstatic #166 // Field Day22$Facing$South.INSTANCE:LDay22$Facing$South;\n 446: getstatic #158 // Field Day22$Facing$West.INSTANCE:LDay22$Facing$West;\n 449: invokespecial #37 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 452: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 455: ifeq 483\n 458: new #117 // class Point\n 461: dup\n 462: aload_0\n 463: invokevirtual #100 // Method getDestination:()LDay22$CubeFacing;\n 466: invokevirtual #161 // Method Day22$CubeFacing.getMaxX:()I\n 469: aload_0\n 470: aload_1\n 471: invokespecial #171 // Method flipRescaled:(LPoint;)LPoint;\n 474: invokevirtual #120 // Method Point.getY:()I\n 477: invokespecial #126 // Method Point.\"<init>\":(II)V\n 480: goto 525\n 483: new #173 // class java/lang/IllegalStateException\n 486: dup\n 487: new #175 // class java/lang/StringBuilder\n 490: dup\n 491: invokespecial #176 // Method java/lang/StringBuilder.\"<init>\":()V\n 494: ldc #178 // String No transition from\n 496: invokevirtual #182 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 499: aload_0\n 500: getfield #30 // Field exit:LDay22$Facing;\n 503: invokevirtual #185 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 506: ldc #187 // String to\n 508: invokevirtual #182 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 511: aload_0\n 512: getfield #32 // Field enter:LDay22$Facing;\n 515: invokevirtual #185 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 518: invokevirtual #191 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 521: invokespecial #194 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 524: athrow\n 525: areturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #24 // Field sourceId:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #27 // Field destinationId:I\n 4: ireturn\n\n public final Day22$Facing component3();\n Code:\n 0: aload_0\n 1: getfield #30 // Field exit:LDay22$Facing;\n 4: areturn\n\n public final Day22$Facing component4();\n Code:\n 0: aload_0\n 1: getfield #32 // Field enter:LDay22$Facing;\n 4: areturn\n\n public final Day22$Transition copy(int, int, Day22$Facing, Day22$Facing);\n Code:\n 0: aload_3\n 1: ldc #9 // String exit\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload 4\n 8: ldc #17 // String enter\n 10: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 13: new #2 // class Day22$Transition\n 16: dup\n 17: iload_1\n 18: iload_2\n 19: aload_3\n 20: aload 4\n 22: invokespecial #202 // Method \"<init>\":(IILDay22$Facing;LDay22$Facing;)V\n 25: areturn\n\n public static Day22$Transition copy$default(Day22$Transition, int, int, Day22$Facing, Day22$Facing, int, java.lang.Object);\n Code:\n 0: iload 5\n 2: iconst_1\n 3: iand\n 4: ifeq 12\n 7: aload_0\n 8: getfield #24 // Field sourceId:I\n 11: istore_1\n 12: iload 5\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #27 // Field destinationId:I\n 23: istore_2\n 24: iload 5\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #30 // Field exit:LDay22$Facing;\n 35: astore_3\n 36: iload 5\n 38: bipush 8\n 40: iand\n 41: ifeq 50\n 44: aload_0\n 45: getfield #32 // Field enter:LDay22$Facing;\n 48: astore 4\n 50: aload_0\n 51: iload_1\n 52: iload_2\n 53: aload_3\n 54: aload 4\n 56: invokevirtual #206 // Method copy:(IILDay22$Facing;LDay22$Facing;)LDay22$Transition;\n 59: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #175 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #176 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #208 // String Transition(sourceId=\n 9: invokevirtual #182 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #24 // Field sourceId:I\n 16: invokevirtual #211 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #213 // String , destinationId=\n 21: invokevirtual #182 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #27 // Field destinationId:I\n 28: invokevirtual #211 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #215 // String , exit=\n 33: invokevirtual #182 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #30 // Field exit:LDay22$Facing;\n 40: invokevirtual #185 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 43: ldc #217 // String , enter=\n 45: invokevirtual #182 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: aload_0\n 49: getfield #32 // Field enter:LDay22$Facing;\n 52: invokevirtual #185 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 55: bipush 41\n 57: invokevirtual #220 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 60: invokevirtual #191 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 63: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #24 // Field sourceId:I\n 4: invokestatic #226 // 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 #27 // Field destinationId:I\n 16: invokestatic #226 // 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 #30 // Field exit:LDay22$Facing;\n 29: invokevirtual #230 // Method Day22$Facing.hashCode:()I\n 32: iadd\n 33: istore_1\n 34: iload_1\n 35: bipush 31\n 37: imul\n 38: aload_0\n 39: getfield #32 // Field enter:LDay22$Facing;\n 42: invokevirtual #230 // Method Day22$Facing.hashCode:()I\n 45: iadd\n 46: istore_1\n 47: iload_1\n 48: 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 Day22$Transition\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day22$Transition\n 20: astore_2\n 21: aload_0\n 22: getfield #24 // Field sourceId:I\n 25: aload_2\n 26: getfield #24 // Field sourceId:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #27 // Field destinationId:I\n 38: aload_2\n 39: getfield #27 // Field destinationId:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #30 // Field exit:LDay22$Facing;\n 51: aload_2\n 52: getfield #30 // Field exit:LDay22$Facing;\n 55: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 58: ifne 63\n 61: iconst_0\n 62: ireturn\n 63: aload_0\n 64: getfield #32 // Field enter:LDay22$Facing;\n 67: aload_2\n 68: getfield #32 // Field enter:LDay22$Facing;\n 71: invokestatic #140 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 74: ifne 79\n 77: iconst_0\n 78: ireturn\n 79: iconst_1\n 80: ireturn\n\n private static final Day22$CubeFacing source_delegate$lambda$0(Day22$Transition);\n Code:\n 0: getstatic #240 // Field Day22$CubeFacing.Companion:LDay22$CubeFacing$Companion;\n 3: aload_0\n 4: getfield #24 // Field sourceId:I\n 7: invokevirtual #245 // Method Day22$CubeFacing$Companion.invoke:(I)LDay22$CubeFacing;\n 10: areturn\n\n private static final Day22$CubeFacing destination_delegate$lambda$1(Day22$Transition);\n Code:\n 0: getstatic #240 // Field Day22$CubeFacing.Companion:LDay22$CubeFacing$Companion;\n 3: aload_0\n 4: getfield #27 // Field destinationId:I\n 7: invokevirtual #245 // Method Day22$CubeFacing$Companion.invoke:(I)LDay22$CubeFacing;\n 10: areturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day22$CubeFacing$Companion.class", "javap": "Compiled from \"Day22.kt\"\npublic final class Day22$CubeFacing$Companion {\n private Day22$CubeFacing$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final Day22$CubeFacing invoke(int);\n Code:\n 0: invokestatic #19 // Method Day22$CubeFacing.access$getInstances$cp:()Ljava/util/Map;\n 3: iload_1\n 4: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 7: invokestatic #31 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 10: checkcast #15 // class Day22$CubeFacing\n 13: areturn\n\n private final void plus(Day22$CubeFacing);\n Code:\n 0: invokestatic #19 // Method Day22$CubeFacing.access$getInstances$cp:()Ljava/util/Map;\n 3: aload_1\n 4: invokevirtual #39 // Method Day22$CubeFacing.getId:()I\n 7: invokestatic #25 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 10: aload_1\n 11: invokeinterface #45, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 16: pop\n 17: return\n\n public Day22$CubeFacing$Companion(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #49 // Method \"<init>\":()V\n 4: return\n\n public static final void access$plus(Day22$CubeFacing$Companion, Day22$CubeFacing);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #55 // Method plus:(LDay22$CubeFacing;)V\n 5: return\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day17.kt
import java.io.File import kotlin.math.absoluteValue fun main() { val day17 = Day17(File("src/inputs/Day17.txt").readText()) println(day17.part1()) println(day17.part2()) } class Day17(input: String) { private val jets = jets(input) private val shapes = shapes() private val cave = (0..6).map { Point(it, 0) }.toMutableSet() private val down = Point(0, 1) private val up = Point(0, -1) private var jetCounter = 0 private var blockCounter = 0 fun part1(): Int { repeat(2022) { simulate() } return cave.height() } fun part2(): Long = calculateHeight(1000000000000L - 1) private fun simulate() { var currentShape = shapes.nth(blockCounter++).moveToStart(cave.minY()) do { val jetShape = currentShape * jets.nth(jetCounter++) if (jetShape in (0..6) && jetShape.intersect(cave).isEmpty()) { currentShape = jetShape } currentShape = currentShape * down } while (currentShape.intersect(cave).isEmpty()) cave += (currentShape * up) } private fun calculateHeight(targetBlockCount: Long): Long { data class State(val ceiling: List<Int>, val blockIdx: Int, val jetIdx: Int) val seen: MutableMap<State, Pair<Int, Int>> = mutableMapOf() while (true) { simulate() val state = State(cave.heuristicPrevious(), blockCounter % shapes.size, jetCounter % jets.size) if (state in seen) { val (blockCountAtLoopStart, heightAtLoopStart) = seen.getValue(state) val blocksPerLoop = blockCounter - 1L - blockCountAtLoopStart val totalLoops = (targetBlockCount - blockCountAtLoopStart) / blocksPerLoop val remainingBlocks = (targetBlockCount - blockCountAtLoopStart) - (totalLoops * blocksPerLoop) val heightGainedSinceLoop = cave.height() - heightAtLoopStart repeat (remainingBlocks.toInt()) { simulate() } return cave.height() + heightGainedSinceLoop * (totalLoops - 1) } seen[state] = blockCounter - 1 to cave.height() } } private operator fun IntRange.contains(set: Set<Point>): Boolean = set.all { it.x in this } private operator fun Set<Point>.times(point: Point): Set<Point> = map { it + point }.toSet() private fun Set<Point>.minY(): Int = minOf { it.y } private fun Set<Point>.height(): Int = minY().absoluteValue private fun Set<Point>.heuristicPrevious(): List<Int> { return groupBy { it.x } .map { pointList -> pointList.value.minBy { it.y } } .let { val normalTo = minY() it.map { point -> normalTo - point.y } } } private fun Set<Point>.moveToStart(ceilingHeight: Int): Set<Point> = map { it + Point(2, ceilingHeight - 4) }.toSet() private fun shapes(): List<Set<Point>> = 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)) ) private fun jets(input: String): List<Point> = input.map { when (it) { '>' -> Point(1, 0) '<' -> Point(-1, 0) else -> throw IllegalStateException("Wrong jet $it") } } }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day17.class", "javap": "Compiled from \"Day17.kt\"\npublic final class Day17 {\n private final java.util.List<Point> jets;\n\n private final java.util.List<java.util.Set<Point>> shapes;\n\n private final java.util.Set<Point> cave;\n\n private final Point down;\n\n private final Point up;\n\n private int jetCounter;\n\n private int blockCounter;\n\n public Day17(java.lang.String);\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_0\n 12: aload_1\n 13: invokespecial #22 // Method jets:(Ljava/lang/String;)Ljava/util/List;\n 16: putfield #25 // Field jets:Ljava/util/List;\n 19: aload_0\n 20: aload_0\n 21: invokespecial #29 // Method shapes:()Ljava/util/List;\n 24: putfield #31 // Field shapes:Ljava/util/List;\n 27: aload_0\n 28: new #33 // class kotlin/ranges/IntRange\n 31: dup\n 32: iconst_0\n 33: bipush 6\n 35: invokespecial #36 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 38: checkcast #38 // class java/lang/Iterable\n 41: astore_2\n 42: astore 11\n 44: iconst_0\n 45: istore_3\n 46: aload_2\n 47: astore 4\n 49: new #40 // class java/util/ArrayList\n 52: dup\n 53: aload_2\n 54: bipush 10\n 56: invokestatic #46 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 59: invokespecial #49 // Method java/util/ArrayList.\"<init>\":(I)V\n 62: checkcast #51 // class java/util/Collection\n 65: astore 5\n 67: iconst_0\n 68: istore 6\n 70: aload 4\n 72: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 77: astore 7\n 79: aload 7\n 81: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 86: ifeq 132\n 89: aload 7\n 91: checkcast #63 // class kotlin/collections/IntIterator\n 94: invokevirtual #67 // Method kotlin/collections/IntIterator.nextInt:()I\n 97: istore 8\n 99: aload 5\n 101: iload 8\n 103: istore 9\n 105: astore 12\n 107: iconst_0\n 108: istore 10\n 110: new #69 // class Point\n 113: dup\n 114: iload 9\n 116: iconst_0\n 117: invokespecial #70 // Method Point.\"<init>\":(II)V\n 120: aload 12\n 122: swap\n 123: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 128: pop\n 129: goto 79\n 132: aload 5\n 134: checkcast #76 // class java/util/List\n 137: nop\n 138: aload 11\n 140: swap\n 141: checkcast #38 // class java/lang/Iterable\n 144: invokestatic #80 // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 147: putfield #84 // Field cave:Ljava/util/Set;\n 150: aload_0\n 151: new #69 // class Point\n 154: dup\n 155: iconst_0\n 156: iconst_1\n 157: invokespecial #70 // Method Point.\"<init>\":(II)V\n 160: putfield #88 // Field down:LPoint;\n 163: aload_0\n 164: new #69 // class Point\n 167: dup\n 168: iconst_0\n 169: iconst_m1\n 170: invokespecial #70 // Method Point.\"<init>\":(II)V\n 173: putfield #91 // Field up:LPoint;\n 176: return\n\n public final int part1();\n Code:\n 0: sipush 2022\n 3: istore_1\n 4: iconst_0\n 5: istore_2\n 6: iload_2\n 7: iload_1\n 8: if_icmpge 27\n 11: iload_2\n 12: istore_3\n 13: iconst_0\n 14: istore 4\n 16: aload_0\n 17: invokespecial #111 // Method simulate:()V\n 20: nop\n 21: iinc 2, 1\n 24: goto 6\n 27: aload_0\n 28: aload_0\n 29: getfield #84 // Field cave:Ljava/util/Set;\n 32: invokespecial #115 // Method height:(Ljava/util/Set;)I\n 35: ireturn\n\n public final long part2();\n Code:\n 0: aload_0\n 1: ldc2_w #119 // long 999999999999l\n 4: invokespecial #124 // Method calculateHeight:(J)J\n 7: lreturn\n\n private final void simulate();\n Code:\n 0: aload_0\n 1: aload_0\n 2: getfield #31 // Field shapes:Ljava/util/List;\n 5: aload_0\n 6: getfield #127 // Field blockCounter:I\n 9: istore_2\n 10: aload_0\n 11: iload_2\n 12: iconst_1\n 13: iadd\n 14: putfield #127 // Field blockCounter:I\n 17: iload_2\n 18: invokestatic #133 // Method UtilsKt.nth:(Ljava/util/List;I)Ljava/lang/Object;\n 21: checkcast #135 // class java/util/Set\n 24: aload_0\n 25: aload_0\n 26: getfield #84 // Field cave:Ljava/util/Set;\n 29: invokespecial #138 // Method minY:(Ljava/util/Set;)I\n 32: invokespecial #142 // Method moveToStart:(Ljava/util/Set;I)Ljava/util/Set;\n 35: astore_1\n 36: aload_0\n 37: aload_1\n 38: aload_0\n 39: getfield #25 // Field jets:Ljava/util/List;\n 42: aload_0\n 43: getfield #145 // Field jetCounter:I\n 46: istore_3\n 47: aload_0\n 48: iload_3\n 49: iconst_1\n 50: iadd\n 51: putfield #145 // Field jetCounter:I\n 54: iload_3\n 55: invokestatic #133 // Method UtilsKt.nth:(Ljava/util/List;I)Ljava/lang/Object;\n 58: checkcast #69 // class Point\n 61: invokespecial #149 // Method times:(Ljava/util/Set;LPoint;)Ljava/util/Set;\n 64: astore_2\n 65: aload_0\n 66: new #33 // class kotlin/ranges/IntRange\n 69: dup\n 70: iconst_0\n 71: bipush 6\n 73: invokespecial #36 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 76: aload_2\n 77: invokespecial #153 // Method contains:(Lkotlin/ranges/IntRange;Ljava/util/Set;)Z\n 80: ifeq 107\n 83: aload_2\n 84: checkcast #38 // class java/lang/Iterable\n 87: aload_0\n 88: getfield #84 // Field cave:Ljava/util/Set;\n 91: checkcast #38 // class java/lang/Iterable\n 94: invokestatic #157 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 97: invokeinterface #160, 1 // InterfaceMethod java/util/Set.isEmpty:()Z\n 102: ifeq 107\n 105: aload_2\n 106: astore_1\n 107: aload_0\n 108: aload_1\n 109: aload_0\n 110: getfield #88 // Field down:LPoint;\n 113: invokespecial #149 // Method times:(Ljava/util/Set;LPoint;)Ljava/util/Set;\n 116: astore_1\n 117: aload_1\n 118: checkcast #38 // class java/lang/Iterable\n 121: aload_0\n 122: getfield #84 // Field cave:Ljava/util/Set;\n 125: checkcast #38 // class java/lang/Iterable\n 128: invokestatic #157 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 131: invokeinterface #160, 1 // InterfaceMethod java/util/Set.isEmpty:()Z\n 136: ifne 36\n 139: aload_0\n 140: getfield #84 // Field cave:Ljava/util/Set;\n 143: checkcast #51 // class java/util/Collection\n 146: aload_0\n 147: aload_1\n 148: aload_0\n 149: getfield #91 // Field up:LPoint;\n 152: invokespecial #149 // Method times:(Ljava/util/Set;LPoint;)Ljava/util/Set;\n 155: checkcast #38 // class java/lang/Iterable\n 158: invokestatic #164 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 161: pop\n 162: return\n\n private final long calculateHeight(long);\n Code:\n 0: new #168 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #169 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #171 // class java/util/Map\n 10: astore_3\n 11: nop\n 12: aload_0\n 13: invokespecial #111 // Method simulate:()V\n 16: new #173 // class Day17$calculateHeight$State\n 19: dup\n 20: aload_0\n 21: aload_0\n 22: getfield #84 // Field cave:Ljava/util/Set;\n 25: invokespecial #177 // Method heuristicPrevious:(Ljava/util/Set;)Ljava/util/List;\n 28: aload_0\n 29: getfield #127 // Field blockCounter:I\n 32: aload_0\n 33: getfield #31 // Field shapes:Ljava/util/List;\n 36: invokeinterface #180, 1 // InterfaceMethod java/util/List.size:()I\n 41: irem\n 42: aload_0\n 43: getfield #145 // Field jetCounter:I\n 46: aload_0\n 47: getfield #25 // Field jets:Ljava/util/List;\n 50: invokeinterface #180, 1 // InterfaceMethod java/util/List.size:()I\n 55: irem\n 56: invokespecial #183 // Method Day17$calculateHeight$State.\"<init>\":(Ljava/util/List;II)V\n 59: astore 4\n 61: aload_3\n 62: aload 4\n 64: invokeinterface #186, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 69: ifeq 210\n 72: aload_3\n 73: aload 4\n 75: invokestatic #192 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 78: checkcast #194 // class kotlin/Pair\n 81: astore 5\n 83: aload 5\n 85: invokevirtual #198 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 88: checkcast #200 // class java/lang/Number\n 91: invokevirtual #203 // Method java/lang/Number.intValue:()I\n 94: istore 6\n 96: aload 5\n 98: invokevirtual #206 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 101: checkcast #200 // class java/lang/Number\n 104: invokevirtual #203 // Method java/lang/Number.intValue:()I\n 107: istore 7\n 109: aload_0\n 110: getfield #127 // Field blockCounter:I\n 113: i2l\n 114: lconst_1\n 115: lsub\n 116: iload 6\n 118: i2l\n 119: lsub\n 120: lstore 8\n 122: lload_1\n 123: iload 6\n 125: i2l\n 126: lsub\n 127: lload 8\n 129: ldiv\n 130: lstore 10\n 132: lload_1\n 133: iload 6\n 135: i2l\n 136: lsub\n 137: lload 10\n 139: lload 8\n 141: lmul\n 142: lsub\n 143: lstore 12\n 145: aload_0\n 146: aload_0\n 147: getfield #84 // Field cave:Ljava/util/Set;\n 150: invokespecial #115 // Method height:(Ljava/util/Set;)I\n 153: iload 7\n 155: isub\n 156: istore 14\n 158: lload 12\n 160: l2i\n 161: istore 15\n 163: iconst_0\n 164: istore 16\n 166: iload 16\n 168: iload 15\n 170: if_icmpge 191\n 173: iload 16\n 175: istore 17\n 177: iconst_0\n 178: istore 18\n 180: aload_0\n 181: invokespecial #111 // Method simulate:()V\n 184: nop\n 185: iinc 16, 1\n 188: goto 166\n 191: aload_0\n 192: aload_0\n 193: getfield #84 // Field cave:Ljava/util/Set;\n 196: invokespecial #115 // Method height:(Ljava/util/Set;)I\n 199: i2l\n 200: iload 14\n 202: i2l\n 203: lload 10\n 205: lconst_1\n 206: lsub\n 207: lmul\n 208: ladd\n 209: lreturn\n 210: aload_3\n 211: aload 4\n 213: aload_0\n 214: getfield #127 // Field blockCounter:I\n 217: iconst_1\n 218: isub\n 219: invokestatic #212 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 222: aload_0\n 223: aload_0\n 224: getfield #84 // Field cave:Ljava/util/Set;\n 227: invokespecial #115 // Method height:(Ljava/util/Set;)I\n 230: invokestatic #212 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 233: invokestatic #218 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 236: invokeinterface #222, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 241: pop\n 242: goto 11\n\n private final boolean contains(kotlin.ranges.IntRange, java.util.Set<Point>);\n Code:\n 0: aload_1\n 1: ldc #238 // String <this>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: checkcast #38 // class java/lang/Iterable\n 10: astore_3\n 11: iconst_0\n 12: istore 4\n 14: aload_3\n 15: instanceof #51 // class java/util/Collection\n 18: ifeq 37\n 21: aload_3\n 22: checkcast #51 // class java/util/Collection\n 25: invokeinterface #239, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 30: ifeq 37\n 33: iconst_1\n 34: goto 124\n 37: aload_3\n 38: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 43: astore 5\n 45: aload 5\n 47: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 52: ifeq 123\n 55: aload 5\n 57: invokeinterface #242, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 62: astore 6\n 64: aload 6\n 66: checkcast #69 // class Point\n 69: astore 7\n 71: iconst_0\n 72: istore 8\n 74: aload_1\n 75: invokevirtual #245 // Method kotlin/ranges/IntRange.getFirst:()I\n 78: istore 9\n 80: aload_1\n 81: invokevirtual #248 // Method kotlin/ranges/IntRange.getLast:()I\n 84: istore 10\n 86: aload 7\n 88: invokevirtual #251 // Method Point.getX:()I\n 91: istore 11\n 93: iload 9\n 95: iload 11\n 97: if_icmpgt 115\n 100: iload 11\n 102: iload 10\n 104: if_icmpgt 111\n 107: iconst_1\n 108: goto 116\n 111: iconst_0\n 112: goto 116\n 115: iconst_0\n 116: ifne 45\n 119: iconst_0\n 120: goto 124\n 123: iconst_1\n 124: ireturn\n\n private final java.util.Set<Point> times(java.util.Set<Point>, Point);\n Code:\n 0: aload_1\n 1: ldc #238 // 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: checkcast #38 // 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 #40 // class java/util/ArrayList\n 20: dup\n 21: aload_3\n 22: bipush 10\n 24: invokestatic #46 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 27: invokespecial #49 // Method java/util/ArrayList.\"<init>\":(I)V\n 30: checkcast #51 // class java/util/Collection\n 33: astore 6\n 35: iconst_0\n 36: istore 7\n 38: aload 5\n 40: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 8\n 47: aload 8\n 49: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 98\n 57: aload 8\n 59: invokeinterface #242, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 9\n 66: aload 6\n 68: aload 9\n 70: checkcast #69 // class Point\n 73: astore 10\n 75: astore 12\n 77: iconst_0\n 78: istore 11\n 80: aload 10\n 82: aload_2\n 83: invokevirtual #264 // Method Point.plus:(LPoint;)LPoint;\n 86: aload 12\n 88: swap\n 89: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 94: pop\n 95: goto 47\n 98: aload 6\n 100: checkcast #76 // class java/util/List\n 103: nop\n 104: checkcast #38 // class java/lang/Iterable\n 107: invokestatic #267 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 110: areturn\n\n private final int minY(java.util.Set<Point>);\n Code:\n 0: aload_1\n 1: checkcast #38 // class java/lang/Iterable\n 4: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 9: astore_2\n 10: aload_2\n 11: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 16: ifne 27\n 19: new #273 // class java/util/NoSuchElementException\n 22: dup\n 23: invokespecial #274 // Method java/util/NoSuchElementException.\"<init>\":()V\n 26: athrow\n 27: aload_2\n 28: invokeinterface #242, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 33: checkcast #69 // class Point\n 36: astore_3\n 37: iconst_0\n 38: istore 4\n 40: aload_3\n 41: invokevirtual #277 // Method Point.getY:()I\n 44: istore_3\n 45: aload_2\n 46: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 87\n 54: aload_2\n 55: invokeinterface #242, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 60: checkcast #69 // class Point\n 63: astore 4\n 65: iconst_0\n 66: istore 5\n 68: aload 4\n 70: invokevirtual #277 // Method Point.getY:()I\n 73: istore 4\n 75: iload_3\n 76: iload 4\n 78: if_icmple 45\n 81: iload 4\n 83: istore_3\n 84: goto 45\n 87: iload_3\n 88: ireturn\n\n private final int height(java.util.Set<Point>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #138 // Method minY:(Ljava/util/Set;)I\n 5: invokestatic #285 // Method java/lang/Math.abs:(I)I\n 8: ireturn\n\n private final java.util.List<java.lang.Integer> heuristicPrevious(java.util.Set<Point>);\n Code:\n 0: aload_1\n 1: checkcast #38 // 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 #168 // class java/util/LinkedHashMap\n 13: dup\n 14: invokespecial #169 // Method java/util/LinkedHashMap.\"<init>\":()V\n 17: checkcast #171 // class java/util/Map\n 20: astore 5\n 22: iconst_0\n 23: istore 6\n 25: aload 4\n 27: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 7\n 34: aload 7\n 36: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 149\n 44: aload 7\n 46: invokeinterface #242, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: astore 8\n 53: aload 8\n 55: checkcast #69 // class Point\n 58: astore 9\n 60: iconst_0\n 61: istore 10\n 63: aload 9\n 65: invokevirtual #251 // Method Point.getX:()I\n 68: invokestatic #212 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 71: astore 11\n 73: aload 5\n 75: astore 12\n 77: iconst_0\n 78: istore 13\n 80: aload 12\n 82: aload 11\n 84: invokeinterface #291, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 89: astore 14\n 91: aload 14\n 93: ifnonnull 128\n 96: iconst_0\n 97: istore 15\n 99: new #40 // class java/util/ArrayList\n 102: dup\n 103: invokespecial #292 // Method java/util/ArrayList.\"<init>\":()V\n 106: checkcast #76 // class java/util/List\n 109: astore 15\n 111: aload 12\n 113: aload 11\n 115: aload 15\n 117: invokeinterface #222, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 122: pop\n 123: aload 15\n 125: goto 130\n 128: aload 14\n 130: nop\n 131: checkcast #76 // class java/util/List\n 134: astore 9\n 136: aload 9\n 138: aload 8\n 140: invokeinterface #293, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 145: pop\n 146: goto 34\n 149: aload 5\n 151: nop\n 152: astore_2\n 153: nop\n 154: iconst_0\n 155: istore_3\n 156: aload_2\n 157: astore 4\n 159: new #40 // class java/util/ArrayList\n 162: dup\n 163: aload_2\n 164: invokeinterface #294, 1 // InterfaceMethod java/util/Map.size:()I\n 169: invokespecial #49 // Method java/util/ArrayList.\"<init>\":(I)V\n 172: checkcast #51 // class java/util/Collection\n 175: astore 5\n 177: iconst_0\n 178: istore 6\n 180: aload 4\n 182: invokeinterface #298, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 187: invokeinterface #299, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 192: astore 7\n 194: aload 7\n 196: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 201: ifeq 379\n 204: aload 7\n 206: invokeinterface #242, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 211: checkcast #301 // class java/util/Map$Entry\n 214: astore 8\n 216: aload 5\n 218: aload 8\n 220: astore 9\n 222: astore 19\n 224: iconst_0\n 225: istore 10\n 227: aload 9\n 229: invokeinterface #303, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 234: checkcast #38 // class java/lang/Iterable\n 237: astore 11\n 239: iconst_0\n 240: istore 12\n 242: aload 11\n 244: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 249: astore 13\n 251: aload 13\n 253: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 258: ifne 269\n 261: new #273 // class java/util/NoSuchElementException\n 264: dup\n 265: invokespecial #274 // Method java/util/NoSuchElementException.\"<init>\":()V\n 268: athrow\n 269: aload 13\n 271: invokeinterface #242, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 276: astore 14\n 278: aload 13\n 280: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 285: ifne 293\n 288: aload 14\n 290: goto 363\n 293: aload 14\n 295: checkcast #69 // class Point\n 298: astore 15\n 300: iconst_0\n 301: istore 16\n 303: aload 15\n 305: invokevirtual #277 // Method Point.getY:()I\n 308: istore 15\n 310: aload 13\n 312: invokeinterface #242, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 317: astore 16\n 319: aload 16\n 321: checkcast #69 // class Point\n 324: astore 17\n 326: iconst_0\n 327: istore 18\n 329: aload 17\n 331: invokevirtual #277 // Method Point.getY:()I\n 334: istore 17\n 336: iload 15\n 338: iload 17\n 340: if_icmple 351\n 343: aload 16\n 345: astore 14\n 347: iload 17\n 349: istore 15\n 351: aload 13\n 353: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 358: ifne 310\n 361: aload 14\n 363: checkcast #69 // class Point\n 366: nop\n 367: aload 19\n 369: swap\n 370: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 375: pop\n 376: goto 194\n 379: aload 5\n 381: checkcast #76 // class java/util/List\n 384: nop\n 385: astore_3\n 386: iconst_0\n 387: istore 4\n 389: aload_0\n 390: aload_1\n 391: invokespecial #138 // Method minY:(Ljava/util/Set;)I\n 394: istore 5\n 396: aload_3\n 397: checkcast #38 // class java/lang/Iterable\n 400: astore 6\n 402: iconst_0\n 403: istore 7\n 405: aload 6\n 407: astore 8\n 409: new #40 // class java/util/ArrayList\n 412: dup\n 413: aload 6\n 415: bipush 10\n 417: invokestatic #46 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 420: invokespecial #49 // Method java/util/ArrayList.\"<init>\":(I)V\n 423: checkcast #51 // class java/util/Collection\n 426: astore 9\n 428: iconst_0\n 429: istore 10\n 431: aload 8\n 433: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 438: astore 11\n 440: aload 11\n 442: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 447: ifeq 496\n 450: aload 11\n 452: invokeinterface #242, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 457: astore 12\n 459: aload 9\n 461: aload 12\n 463: checkcast #69 // class Point\n 466: astore 13\n 468: astore 14\n 470: iconst_0\n 471: istore 15\n 473: iload 5\n 475: aload 13\n 477: invokevirtual #277 // Method Point.getY:()I\n 480: isub\n 481: invokestatic #212 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 484: aload 14\n 486: swap\n 487: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 492: pop\n 493: goto 440\n 496: aload 9\n 498: checkcast #76 // class java/util/List\n 501: nop\n 502: nop\n 503: nop\n 504: areturn\n\n private final java.util.Set<Point> moveToStart(java.util.Set<Point>, int);\n Code:\n 0: aload_1\n 1: checkcast #38 // 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 #40 // class java/util/ArrayList\n 14: dup\n 15: aload_3\n 16: bipush 10\n 18: invokestatic #46 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 21: invokespecial #49 // Method java/util/ArrayList.\"<init>\":(I)V\n 24: checkcast #51 // class java/util/Collection\n 27: astore 6\n 29: iconst_0\n 30: istore 7\n 32: aload 5\n 34: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 8\n 41: aload 8\n 43: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 102\n 51: aload 8\n 53: invokeinterface #242, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 9\n 60: aload 6\n 62: aload 9\n 64: checkcast #69 // class Point\n 67: astore 10\n 69: astore 12\n 71: iconst_0\n 72: istore 11\n 74: aload 10\n 76: new #69 // class Point\n 79: dup\n 80: iconst_2\n 81: iload_2\n 82: iconst_4\n 83: isub\n 84: invokespecial #70 // Method Point.\"<init>\":(II)V\n 87: invokevirtual #264 // Method Point.plus:(LPoint;)LPoint;\n 90: aload 12\n 92: swap\n 93: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 98: pop\n 99: goto 41\n 102: aload 6\n 104: checkcast #76 // class java/util/List\n 107: nop\n 108: checkcast #38 // class java/lang/Iterable\n 111: invokestatic #267 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 114: areturn\n\n private final java.util.List<java.util.Set<Point>> shapes();\n Code:\n 0: iconst_5\n 1: anewarray #135 // class java/util/Set\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: iconst_4\n 8: anewarray #69 // class Point\n 11: astore_2\n 12: aload_2\n 13: iconst_0\n 14: new #69 // class Point\n 17: dup\n 18: iconst_0\n 19: iconst_0\n 20: invokespecial #70 // Method Point.\"<init>\":(II)V\n 23: aastore\n 24: aload_2\n 25: iconst_1\n 26: new #69 // class Point\n 29: dup\n 30: iconst_1\n 31: iconst_0\n 32: invokespecial #70 // Method Point.\"<init>\":(II)V\n 35: aastore\n 36: aload_2\n 37: iconst_2\n 38: new #69 // class Point\n 41: dup\n 42: iconst_2\n 43: iconst_0\n 44: invokespecial #70 // Method Point.\"<init>\":(II)V\n 47: aastore\n 48: aload_2\n 49: iconst_3\n 50: new #69 // class Point\n 53: dup\n 54: iconst_3\n 55: iconst_0\n 56: invokespecial #70 // Method Point.\"<init>\":(II)V\n 59: aastore\n 60: aload_2\n 61: invokestatic #343 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 64: aastore\n 65: aload_1\n 66: iconst_1\n 67: iconst_5\n 68: anewarray #69 // class Point\n 71: astore_2\n 72: aload_2\n 73: iconst_0\n 74: new #69 // class Point\n 77: dup\n 78: iconst_1\n 79: iconst_0\n 80: invokespecial #70 // Method Point.\"<init>\":(II)V\n 83: aastore\n 84: aload_2\n 85: iconst_1\n 86: new #69 // class Point\n 89: dup\n 90: iconst_0\n 91: iconst_m1\n 92: invokespecial #70 // Method Point.\"<init>\":(II)V\n 95: aastore\n 96: aload_2\n 97: iconst_2\n 98: new #69 // class Point\n 101: dup\n 102: iconst_1\n 103: iconst_m1\n 104: invokespecial #70 // Method Point.\"<init>\":(II)V\n 107: aastore\n 108: aload_2\n 109: iconst_3\n 110: new #69 // class Point\n 113: dup\n 114: iconst_2\n 115: iconst_m1\n 116: invokespecial #70 // Method Point.\"<init>\":(II)V\n 119: aastore\n 120: aload_2\n 121: iconst_4\n 122: new #69 // class Point\n 125: dup\n 126: iconst_1\n 127: bipush -2\n 129: invokespecial #70 // Method Point.\"<init>\":(II)V\n 132: aastore\n 133: aload_2\n 134: invokestatic #343 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 137: aastore\n 138: aload_1\n 139: iconst_2\n 140: iconst_5\n 141: anewarray #69 // class Point\n 144: astore_2\n 145: aload_2\n 146: iconst_0\n 147: new #69 // class Point\n 150: dup\n 151: iconst_0\n 152: iconst_0\n 153: invokespecial #70 // Method Point.\"<init>\":(II)V\n 156: aastore\n 157: aload_2\n 158: iconst_1\n 159: new #69 // class Point\n 162: dup\n 163: iconst_1\n 164: iconst_0\n 165: invokespecial #70 // Method Point.\"<init>\":(II)V\n 168: aastore\n 169: aload_2\n 170: iconst_2\n 171: new #69 // class Point\n 174: dup\n 175: iconst_2\n 176: iconst_0\n 177: invokespecial #70 // Method Point.\"<init>\":(II)V\n 180: aastore\n 181: aload_2\n 182: iconst_3\n 183: new #69 // class Point\n 186: dup\n 187: iconst_2\n 188: iconst_m1\n 189: invokespecial #70 // Method Point.\"<init>\":(II)V\n 192: aastore\n 193: aload_2\n 194: iconst_4\n 195: new #69 // class Point\n 198: dup\n 199: iconst_2\n 200: bipush -2\n 202: invokespecial #70 // Method Point.\"<init>\":(II)V\n 205: aastore\n 206: aload_2\n 207: invokestatic #343 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 210: aastore\n 211: aload_1\n 212: iconst_3\n 213: iconst_4\n 214: anewarray #69 // class Point\n 217: astore_2\n 218: aload_2\n 219: iconst_0\n 220: new #69 // class Point\n 223: dup\n 224: iconst_0\n 225: iconst_0\n 226: invokespecial #70 // Method Point.\"<init>\":(II)V\n 229: aastore\n 230: aload_2\n 231: iconst_1\n 232: new #69 // class Point\n 235: dup\n 236: iconst_0\n 237: iconst_m1\n 238: invokespecial #70 // Method Point.\"<init>\":(II)V\n 241: aastore\n 242: aload_2\n 243: iconst_2\n 244: new #69 // class Point\n 247: dup\n 248: iconst_0\n 249: bipush -2\n 251: invokespecial #70 // Method Point.\"<init>\":(II)V\n 254: aastore\n 255: aload_2\n 256: iconst_3\n 257: new #69 // class Point\n 260: dup\n 261: iconst_0\n 262: bipush -3\n 264: invokespecial #70 // Method Point.\"<init>\":(II)V\n 267: aastore\n 268: aload_2\n 269: invokestatic #343 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 272: aastore\n 273: aload_1\n 274: iconst_4\n 275: iconst_4\n 276: anewarray #69 // class Point\n 279: astore_2\n 280: aload_2\n 281: iconst_0\n 282: new #69 // class Point\n 285: dup\n 286: iconst_0\n 287: iconst_0\n 288: invokespecial #70 // Method Point.\"<init>\":(II)V\n 291: aastore\n 292: aload_2\n 293: iconst_1\n 294: new #69 // class Point\n 297: dup\n 298: iconst_1\n 299: iconst_0\n 300: invokespecial #70 // Method Point.\"<init>\":(II)V\n 303: aastore\n 304: aload_2\n 305: iconst_2\n 306: new #69 // class Point\n 309: dup\n 310: iconst_0\n 311: iconst_m1\n 312: invokespecial #70 // Method Point.\"<init>\":(II)V\n 315: aastore\n 316: aload_2\n 317: iconst_3\n 318: new #69 // class Point\n 321: dup\n 322: iconst_1\n 323: iconst_m1\n 324: invokespecial #70 // Method Point.\"<init>\":(II)V\n 327: aastore\n 328: aload_2\n 329: invokestatic #343 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 332: aastore\n 333: aload_1\n 334: invokestatic #347 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 337: areturn\n\n private final java.util.List<Point> jets(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #350 // class java/lang/CharSequence\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: astore 4\n 10: new #40 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: invokeinterface #353, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 20: invokespecial #49 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #51 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: iconst_0\n 32: istore 7\n 34: iload 7\n 36: aload 4\n 38: invokeinterface #353, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 43: if_icmpge 165\n 46: aload 4\n 48: iload 7\n 50: invokeinterface #357, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 55: istore 8\n 57: aload 5\n 59: iload 8\n 61: istore 9\n 63: astore 11\n 65: iconst_0\n 66: istore 10\n 68: iload 9\n 70: tableswitch { // 60 to 62\n 60: 108\n 61: 120\n 62: 96\n default: 120\n }\n 96: new #69 // class Point\n 99: dup\n 100: iconst_1\n 101: iconst_0\n 102: invokespecial #70 // Method Point.\"<init>\":(II)V\n 105: goto 149\n 108: new #69 // class Point\n 111: dup\n 112: iconst_m1\n 113: iconst_0\n 114: invokespecial #70 // Method Point.\"<init>\":(II)V\n 117: goto 149\n 120: new #359 // class java/lang/IllegalStateException\n 123: dup\n 124: new #361 // class java/lang/StringBuilder\n 127: dup\n 128: invokespecial #362 // Method java/lang/StringBuilder.\"<init>\":()V\n 131: ldc_w #364 // String Wrong jet\n 134: invokevirtual #368 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 137: iload 9\n 139: invokevirtual #371 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 142: invokevirtual #375 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 145: invokespecial #377 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 148: athrow\n 149: nop\n 150: aload 11\n 152: swap\n 153: invokeinterface #74, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 158: pop\n 159: iinc 7, 1\n 162: goto 34\n 165: aload 5\n 167: checkcast #76 // class java/util/List\n 170: nop\n 171: areturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day17Kt.class", "javap": "Compiled from \"Day17.kt\"\npublic final class Day17Kt {\n public static final void main();\n Code:\n 0: new #8 // class Day17\n 3: dup\n 4: new #10 // class java/io/File\n 7: dup\n 8: ldc #12 // String src/inputs/Day17.txt\n 10: invokespecial #16 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 13: aconst_null\n 14: iconst_1\n 15: aconst_null\n 16: invokestatic #22 // Method kotlin/io/FilesKt.readText$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/lang/String;\n 19: invokespecial #23 // Method Day17.\"<init>\":(Ljava/lang/String;)V\n 22: astore_0\n 23: aload_0\n 24: invokevirtual #27 // Method Day17.part1:()I\n 27: istore_1\n 28: getstatic #33 // Field java/lang/System.out:Ljava/io/PrintStream;\n 31: iload_1\n 32: invokevirtual #39 // Method java/io/PrintStream.println:(I)V\n 35: aload_0\n 36: invokevirtual #43 // Method Day17.part2:()J\n 39: lstore_1\n 40: getstatic #33 // Field java/lang/System.out:Ljava/io/PrintStream;\n 43: lload_1\n 44: invokevirtual #46 // Method java/io/PrintStream.println:(J)V\n 47: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #51 // Method main:()V\n 3: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day17$calculateHeight$State.class", "javap": "Compiled from \"Day17.kt\"\npublic final class Day17$calculateHeight$State {\n private final java.util.List<java.lang.Integer> ceiling;\n\n private final int blockIdx;\n\n private final int jetIdx;\n\n public Day17$calculateHeight$State(java.util.List<java.lang.Integer>, int, int);\n Code:\n 0: aload_1\n 1: ldc #9 // String ceiling\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 ceiling:Ljava/util/List;\n 15: aload_0\n 16: iload_2\n 17: putfield #25 // Field blockIdx:I\n 20: aload_0\n 21: iload_3\n 22: putfield #28 // Field jetIdx:I\n 25: return\n\n public final java.util.List<java.lang.Integer> getCeiling();\n Code:\n 0: aload_0\n 1: getfield #21 // Field ceiling:Ljava/util/List;\n 4: areturn\n\n public final int getBlockIdx();\n Code:\n 0: aload_0\n 1: getfield #25 // Field blockIdx:I\n 4: ireturn\n\n public final int getJetIdx();\n Code:\n 0: aload_0\n 1: getfield #28 // Field jetIdx:I\n 4: ireturn\n\n public final java.util.List<java.lang.Integer> component1();\n Code:\n 0: aload_0\n 1: getfield #21 // Field ceiling:Ljava/util/List;\n 4: areturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field blockIdx:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #28 // Field jetIdx:I\n 4: ireturn\n\n public final Day17$calculateHeight$State copy(java.util.List<java.lang.Integer>, int, int);\n Code:\n 0: aload_1\n 1: ldc #9 // String ceiling\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day17$calculateHeight$State\n 9: dup\n 10: aload_1\n 11: iload_2\n 12: iload_3\n 13: invokespecial #44 // Method \"<init>\":(Ljava/util/List;II)V\n 16: areturn\n\n public static Day17$calculateHeight$State copy$default(Day17$calculateHeight$State, java.util.List, 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 ceiling:Ljava/util/List;\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 blockIdx: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 jetIdx:I\n 35: istore_3\n 36: aload_0\n 37: aload_1\n 38: iload_2\n 39: iload_3\n 40: invokevirtual #48 // Method copy:(Ljava/util/List;II)LDay17$calculateHeight$State;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #52 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #53 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #55 // String State(ceiling=\n 9: invokevirtual #59 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #21 // Field ceiling:Ljava/util/List;\n 16: invokevirtual #62 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #64 // String , blockIdx=\n 21: invokevirtual #59 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #25 // Field blockIdx:I\n 28: invokevirtual #67 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #69 // String , jetIdx=\n 33: invokevirtual #59 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #28 // Field jetIdx:I\n 40: invokevirtual #67 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #72 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #74 // 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 #21 // Field ceiling:Ljava/util/List;\n 4: invokevirtual #77 // Method java/lang/Object.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 blockIdx:I\n 16: invokestatic #82 // 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 jetIdx:I\n 29: invokestatic #82 // 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 Day17$calculateHeight$State\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day17$calculateHeight$State\n 20: astore_2\n 21: aload_0\n 22: getfield #21 // Field ceiling:Ljava/util/List;\n 25: aload_2\n 26: getfield #21 // Field ceiling:Ljava/util/List;\n 29: invokestatic #89 // 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 blockIdx:I\n 41: aload_2\n 42: getfield #25 // Field blockIdx:I\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: aload_0\n 51: getfield #28 // Field jetIdx:I\n 54: aload_2\n 55: getfield #28 // Field jetIdx:I\n 58: if_icmpeq 63\n 61: iconst_0\n 62: ireturn\n 63: iconst_1\n 64: ireturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day23.kt
fun main() { val d = Day23(readInput("inputs/Day23")) println(d.part1()) println(d.part2()) } class Day23(input: List<String>) { private val startingPositions = parseInput(input) private val nextTurnOffsets: List<List<Point>> = createOffsets() fun part1(): Int { val locations = (0 until 10).fold(startingPositions) { carry, round -> carry.playRound(round) } val gridSize = ((locations.maxOf { it.x } - locations.minOf { it.x }) + 1) * ((locations.maxOf { it.y } - locations.minOf { it.y }) + 1) return gridSize - locations.size } fun part2(): Int { var thisTurn = startingPositions var roundId = 0 do { val previousTurn = thisTurn thisTurn = previousTurn.playRound(roundId++) } while (previousTurn != thisTurn) return roundId } fun Point.neighbors(): Set<Point> = setOf( Point(x - 1, y - 1), Point(x, y - 1), Point(x + 1, y - 1), Point(x - 1, y), Point(x + 1, y), Point(x - 1, y + 1), Point(x, y + 1), Point(x + 1, y + 1) ) private fun Set<Point>.playRound(roundNumber: Int): Set<Point> { val nextPositions = this.toMutableSet() val movers: Map<Point, Point> = this .filter { elf -> elf.neighbors().any { it in this } } .mapNotNull { elf -> nextTurnOffsets.indices.map { direction -> nextTurnOffsets[(roundNumber + direction) % 4] } .firstNotNullOfOrNull { offsets -> if (offsets.none { offset -> (elf + offset) in this }) elf to (elf + offsets.first()) else null } }.toMap() val safeDestinations = movers.values.groupingBy { it }.eachCount().filter { it.value == 1 }.keys movers .filter { (_, target) -> target in safeDestinations } .forEach { (source, target) -> nextPositions.remove(source) nextPositions.add(target) } return nextPositions } private fun createOffsets(): List<List<Point>> = listOf( listOf(Point(0, -1), Point(-1, -1), Point(1, -1)), // N listOf(Point(0, 1), Point(-1, 1), Point(1, 1)), // S listOf(Point(-1, 0), Point(-1, -1), Point(-1, 1)), // W listOf(Point(1, 0), Point(1, -1), Point(1, 1)), // E ) private fun parseInput(input: List<String>): Set<Point> = input.flatMapIndexed { y, row -> row.mapIndexedNotNull { x, char -> if (char == '#') Point(x, y) else null } }.toSet() }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day23Kt.class", "javap": "Compiled from \"Day23.kt\"\npublic final class Day23Kt {\n public static final void main();\n Code:\n 0: new #8 // class Day23\n 3: dup\n 4: ldc #10 // String inputs/Day23\n 6: invokestatic #16 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 9: invokespecial #20 // Method Day23.\"<init>\":(Ljava/util/List;)V\n 12: astore_0\n 13: aload_0\n 14: invokevirtual #24 // Method Day23.part1:()I\n 17: istore_1\n 18: getstatic #30 // Field java/lang/System.out:Ljava/io/PrintStream;\n 21: iload_1\n 22: invokevirtual #36 // Method java/io/PrintStream.println:(I)V\n 25: aload_0\n 26: invokevirtual #39 // Method Day23.part2:()I\n 29: istore_1\n 30: getstatic #30 // Field java/lang/System.out:Ljava/io/PrintStream;\n 33: iload_1\n 34: invokevirtual #36 // Method java/io/PrintStream.println:(I)V\n 37: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #44 // Method main:()V\n 3: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day23$playRound$$inlined$groupingBy$1.class", "javap": "Compiled from \"_Collections.kt\"\npublic final class Day23$playRound$$inlined$groupingBy$1 implements kotlin.collections.Grouping<Point, Point> {\n final java.lang.Iterable $this_groupingBy;\n\n public Day23$playRound$$inlined$groupingBy$1(java.lang.Iterable);\n Code:\n 0: aload_0\n 1: aload_1\n 2: putfield #18 // Field $this_groupingBy:Ljava/lang/Iterable;\n 5: aload_0\n 6: invokespecial #21 // Method java/lang/Object.\"<init>\":()V\n 9: return\n\n public java.util.Iterator<Point> sourceIterator();\n Code:\n 0: aload_0\n 1: getfield #18 // Field $this_groupingBy:Ljava/lang/Iterable;\n 4: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 9: areturn\n\n public Point keyOf(Point);\n Code:\n 0: aload_1\n 1: checkcast #37 // class Point\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: areturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day23.class", "javap": "Compiled from \"Day23.kt\"\npublic final class Day23 {\n private final java.util.Set<Point> startingPositions;\n\n private final java.util.List<java.util.List<Point>> nextTurnOffsets;\n\n public Day23(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\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: invokespecial #19 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_0\n 12: aload_1\n 13: invokespecial #23 // Method parseInput:(Ljava/util/List;)Ljava/util/Set;\n 16: putfield #27 // Field startingPositions:Ljava/util/Set;\n 19: aload_0\n 20: aload_0\n 21: invokespecial #31 // Method createOffsets:()Ljava/util/List;\n 24: putfield #35 // Field nextTurnOffsets:Ljava/util/List;\n 27: return\n\n public final int part1();\n Code:\n 0: iconst_0\n 1: bipush 10\n 3: invokestatic #45 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 6: checkcast #47 // class java/lang/Iterable\n 9: astore_2\n 10: aload_0\n 11: getfield #27 // Field startingPositions:Ljava/util/Set;\n 14: astore_3\n 15: iconst_0\n 16: istore 4\n 18: aload_3\n 19: astore 5\n 21: aload_2\n 22: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 27: astore 6\n 29: aload 6\n 31: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 36: ifeq 73\n 39: aload 6\n 41: checkcast #59 // class kotlin/collections/IntIterator\n 44: invokevirtual #62 // Method kotlin/collections/IntIterator.nextInt:()I\n 47: istore 7\n 49: aload 5\n 51: iload 7\n 53: istore 8\n 55: astore 9\n 57: iconst_0\n 58: istore 10\n 60: aload_0\n 61: aload 9\n 63: iload 8\n 65: invokespecial #66 // Method playRound:(Ljava/util/Set;I)Ljava/util/Set;\n 68: astore 5\n 70: goto 29\n 73: aload 5\n 75: astore_1\n 76: aload_1\n 77: checkcast #47 // class java/lang/Iterable\n 80: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 85: astore 4\n 87: aload 4\n 89: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 94: ifne 105\n 97: new #68 // class java/util/NoSuchElementException\n 100: dup\n 101: invokespecial #69 // Method java/util/NoSuchElementException.\"<init>\":()V\n 104: athrow\n 105: aload 4\n 107: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 112: checkcast #75 // class Point\n 115: astore 5\n 117: iconst_0\n 118: istore 6\n 120: aload 5\n 122: invokevirtual #78 // Method Point.getX:()I\n 125: istore 5\n 127: aload 4\n 129: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 134: ifeq 173\n 137: aload 4\n 139: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 144: checkcast #75 // class Point\n 147: astore 6\n 149: iconst_0\n 150: istore 7\n 152: aload 6\n 154: invokevirtual #78 // Method Point.getX:()I\n 157: istore 6\n 159: iload 5\n 161: iload 6\n 163: if_icmpge 127\n 166: iload 6\n 168: istore 5\n 170: goto 127\n 173: iload 5\n 175: aload_1\n 176: checkcast #47 // class java/lang/Iterable\n 179: astore_3\n 180: istore 11\n 182: aload_3\n 183: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 188: astore 4\n 190: aload 4\n 192: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 197: ifne 208\n 200: new #68 // class java/util/NoSuchElementException\n 203: dup\n 204: invokespecial #69 // Method java/util/NoSuchElementException.\"<init>\":()V\n 207: athrow\n 208: aload 4\n 210: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 215: checkcast #75 // class Point\n 218: astore 5\n 220: iconst_0\n 221: istore 6\n 223: aload 5\n 225: invokevirtual #78 // Method Point.getX:()I\n 228: istore 5\n 230: aload 4\n 232: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 237: ifeq 276\n 240: aload 4\n 242: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 247: checkcast #75 // class Point\n 250: astore 6\n 252: iconst_0\n 253: istore 7\n 255: aload 6\n 257: invokevirtual #78 // Method Point.getX:()I\n 260: istore 6\n 262: iload 5\n 264: iload 6\n 266: if_icmple 230\n 269: iload 6\n 271: istore 5\n 273: goto 230\n 276: iload 5\n 278: istore 12\n 280: iload 11\n 282: iload 12\n 284: isub\n 285: iconst_1\n 286: iadd\n 287: aload_1\n 288: checkcast #47 // class java/lang/Iterable\n 291: astore_3\n 292: istore 11\n 294: aload_3\n 295: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 300: astore 4\n 302: aload 4\n 304: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 309: ifne 320\n 312: new #68 // class java/util/NoSuchElementException\n 315: dup\n 316: invokespecial #69 // Method java/util/NoSuchElementException.\"<init>\":()V\n 319: athrow\n 320: aload 4\n 322: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 327: checkcast #75 // class Point\n 330: astore 5\n 332: iconst_0\n 333: istore 6\n 335: aload 5\n 337: invokevirtual #81 // Method Point.getY:()I\n 340: istore 5\n 342: aload 4\n 344: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 349: ifeq 388\n 352: aload 4\n 354: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 359: checkcast #75 // class Point\n 362: astore 6\n 364: iconst_0\n 365: istore 7\n 367: aload 6\n 369: invokevirtual #81 // Method Point.getY:()I\n 372: istore 6\n 374: iload 5\n 376: iload 6\n 378: if_icmpge 342\n 381: iload 6\n 383: istore 5\n 385: goto 342\n 388: iload 5\n 390: istore 12\n 392: iload 11\n 394: iload 12\n 396: aload_1\n 397: checkcast #47 // class java/lang/Iterable\n 400: astore_3\n 401: istore 12\n 403: istore 11\n 405: aload_3\n 406: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 411: astore 4\n 413: aload 4\n 415: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 420: ifne 431\n 423: new #68 // class java/util/NoSuchElementException\n 426: dup\n 427: invokespecial #69 // Method java/util/NoSuchElementException.\"<init>\":()V\n 430: athrow\n 431: aload 4\n 433: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 438: checkcast #75 // class Point\n 441: astore 5\n 443: iconst_0\n 444: istore 6\n 446: aload 5\n 448: invokevirtual #81 // Method Point.getY:()I\n 451: istore 5\n 453: aload 4\n 455: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 460: ifeq 499\n 463: aload 4\n 465: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 470: checkcast #75 // class Point\n 473: astore 6\n 475: iconst_0\n 476: istore 7\n 478: aload 6\n 480: invokevirtual #81 // Method Point.getY:()I\n 483: istore 6\n 485: iload 5\n 487: iload 6\n 489: if_icmple 453\n 492: iload 6\n 494: istore 5\n 496: goto 453\n 499: iload 5\n 501: istore 13\n 503: iload 11\n 505: iload 12\n 507: iload 13\n 509: isub\n 510: iconst_1\n 511: iadd\n 512: imul\n 513: istore_2\n 514: iload_2\n 515: aload_1\n 516: invokeinterface #86, 1 // InterfaceMethod java/util/Set.size:()I\n 521: isub\n 522: ireturn\n\n public final int part2();\n Code:\n 0: aload_0\n 1: getfield #27 // Field startingPositions:Ljava/util/Set;\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: astore_3\n 9: aload_0\n 10: aload_3\n 11: iload_2\n 12: iinc 2, 1\n 15: invokespecial #66 // Method playRound:(Ljava/util/Set;I)Ljava/util/Set;\n 18: astore_1\n 19: aload_3\n 20: aload_1\n 21: invokestatic #110 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 24: ifeq 7\n 27: iload_2\n 28: ireturn\n\n public final java.util.Set<Point> neighbors(Point);\n Code:\n 0: aload_1\n 1: ldc #118 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: bipush 8\n 8: anewarray #75 // class Point\n 11: astore_2\n 12: aload_2\n 13: iconst_0\n 14: new #75 // class Point\n 17: dup\n 18: aload_1\n 19: invokevirtual #78 // Method Point.getX:()I\n 22: iconst_1\n 23: isub\n 24: aload_1\n 25: invokevirtual #81 // Method Point.getY:()I\n 28: iconst_1\n 29: isub\n 30: invokespecial #121 // Method Point.\"<init>\":(II)V\n 33: aastore\n 34: aload_2\n 35: iconst_1\n 36: new #75 // class Point\n 39: dup\n 40: aload_1\n 41: invokevirtual #78 // Method Point.getX:()I\n 44: aload_1\n 45: invokevirtual #81 // Method Point.getY:()I\n 48: iconst_1\n 49: isub\n 50: invokespecial #121 // Method Point.\"<init>\":(II)V\n 53: aastore\n 54: aload_2\n 55: iconst_2\n 56: new #75 // class Point\n 59: dup\n 60: aload_1\n 61: invokevirtual #78 // Method Point.getX:()I\n 64: iconst_1\n 65: iadd\n 66: aload_1\n 67: invokevirtual #81 // Method Point.getY:()I\n 70: iconst_1\n 71: isub\n 72: invokespecial #121 // Method Point.\"<init>\":(II)V\n 75: aastore\n 76: aload_2\n 77: iconst_3\n 78: new #75 // class Point\n 81: dup\n 82: aload_1\n 83: invokevirtual #78 // Method Point.getX:()I\n 86: iconst_1\n 87: isub\n 88: aload_1\n 89: invokevirtual #81 // Method Point.getY:()I\n 92: invokespecial #121 // Method Point.\"<init>\":(II)V\n 95: aastore\n 96: aload_2\n 97: iconst_4\n 98: new #75 // class Point\n 101: dup\n 102: aload_1\n 103: invokevirtual #78 // Method Point.getX:()I\n 106: iconst_1\n 107: iadd\n 108: aload_1\n 109: invokevirtual #81 // Method Point.getY:()I\n 112: invokespecial #121 // Method Point.\"<init>\":(II)V\n 115: aastore\n 116: aload_2\n 117: iconst_5\n 118: new #75 // class Point\n 121: dup\n 122: aload_1\n 123: invokevirtual #78 // Method Point.getX:()I\n 126: iconst_1\n 127: isub\n 128: aload_1\n 129: invokevirtual #81 // Method Point.getY:()I\n 132: iconst_1\n 133: iadd\n 134: invokespecial #121 // Method Point.\"<init>\":(II)V\n 137: aastore\n 138: aload_2\n 139: bipush 6\n 141: new #75 // class Point\n 144: dup\n 145: aload_1\n 146: invokevirtual #78 // Method Point.getX:()I\n 149: aload_1\n 150: invokevirtual #81 // Method Point.getY:()I\n 153: iconst_1\n 154: iadd\n 155: invokespecial #121 // Method Point.\"<init>\":(II)V\n 158: aastore\n 159: aload_2\n 160: bipush 7\n 162: new #75 // class Point\n 165: dup\n 166: aload_1\n 167: invokevirtual #78 // Method Point.getX:()I\n 170: iconst_1\n 171: iadd\n 172: aload_1\n 173: invokevirtual #81 // Method Point.getY:()I\n 176: iconst_1\n 177: iadd\n 178: invokespecial #121 // Method Point.\"<init>\":(II)V\n 181: aastore\n 182: aload_2\n 183: invokestatic #127 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 186: areturn\n\n private final java.util.Set<Point> playRound(java.util.Set<Point>, int);\n Code:\n 0: aload_1\n 1: checkcast #47 // class java/lang/Iterable\n 4: invokestatic #135 // Method kotlin/collections/CollectionsKt.toMutableSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 7: astore_3\n 8: aload_1\n 9: checkcast #47 // class java/lang/Iterable\n 12: astore 5\n 14: nop\n 15: iconst_0\n 16: istore 6\n 18: aload 5\n 20: astore 7\n 22: new #137 // class java/util/ArrayList\n 25: dup\n 26: invokespecial #138 // Method java/util/ArrayList.\"<init>\":()V\n 29: checkcast #140 // class java/util/Collection\n 32: astore 8\n 34: iconst_0\n 35: istore 9\n 37: aload 7\n 39: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 10\n 46: aload 10\n 48: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 185\n 56: aload 10\n 58: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 11\n 65: aload 11\n 67: checkcast #75 // class Point\n 70: astore 12\n 72: iconst_0\n 73: istore 13\n 75: aload_0\n 76: aload 12\n 78: invokevirtual #142 // Method neighbors:(LPoint;)Ljava/util/Set;\n 81: checkcast #47 // class java/lang/Iterable\n 84: astore 14\n 86: iconst_0\n 87: istore 15\n 89: aload 14\n 91: instanceof #140 // class java/util/Collection\n 94: ifeq 114\n 97: aload 14\n 99: checkcast #140 // class java/util/Collection\n 102: invokeinterface #145, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 107: ifeq 114\n 110: iconst_0\n 111: goto 168\n 114: aload 14\n 116: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 121: astore 16\n 123: aload 16\n 125: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 130: ifeq 167\n 133: aload 16\n 135: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 140: astore 17\n 142: aload 17\n 144: checkcast #75 // class Point\n 147: astore 18\n 149: iconst_0\n 150: istore 19\n 152: aload_1\n 153: aload 18\n 155: invokeinterface #149, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 160: ifeq 123\n 163: iconst_1\n 164: goto 168\n 167: iconst_0\n 168: nop\n 169: ifeq 46\n 172: aload 8\n 174: aload 11\n 176: invokeinterface #152, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 181: pop\n 182: goto 46\n 185: aload 8\n 187: checkcast #154 // class java/util/List\n 190: nop\n 191: checkcast #47 // class java/lang/Iterable\n 194: astore 5\n 196: nop\n 197: iconst_0\n 198: istore 6\n 200: aload 5\n 202: astore 7\n 204: new #137 // class java/util/ArrayList\n 207: dup\n 208: invokespecial #138 // Method java/util/ArrayList.\"<init>\":()V\n 211: checkcast #140 // class java/util/Collection\n 214: astore 8\n 216: iconst_0\n 217: istore 9\n 219: aload 7\n 221: astore 10\n 223: iconst_0\n 224: istore 11\n 226: aload 10\n 228: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 233: astore 12\n 235: aload 12\n 237: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 242: ifeq 586\n 245: aload 12\n 247: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 252: astore 13\n 254: aload 13\n 256: astore 14\n 258: iconst_0\n 259: istore 15\n 261: aload 14\n 263: checkcast #75 // class Point\n 266: astore 16\n 268: iconst_0\n 269: istore 17\n 271: aload_0\n 272: getfield #35 // Field nextTurnOffsets:Ljava/util/List;\n 275: checkcast #140 // class java/util/Collection\n 278: invokestatic #158 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 281: checkcast #47 // class java/lang/Iterable\n 284: astore 18\n 286: iconst_0\n 287: istore 19\n 289: aload 18\n 291: astore 20\n 293: new #137 // class java/util/ArrayList\n 296: dup\n 297: aload 18\n 299: bipush 10\n 301: invokestatic #162 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 304: invokespecial #165 // Method java/util/ArrayList.\"<init>\":(I)V\n 307: checkcast #140 // class java/util/Collection\n 310: astore 21\n 312: iconst_0\n 313: istore 22\n 315: aload 20\n 317: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 322: astore 23\n 324: aload 23\n 326: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 331: ifeq 385\n 334: aload 23\n 336: checkcast #59 // class kotlin/collections/IntIterator\n 339: invokevirtual #62 // Method kotlin/collections/IntIterator.nextInt:()I\n 342: istore 24\n 344: aload 21\n 346: iload 24\n 348: istore 25\n 350: astore 26\n 352: iconst_0\n 353: istore 27\n 355: aload_0\n 356: getfield #35 // Field nextTurnOffsets:Ljava/util/List;\n 359: iload_2\n 360: iload 25\n 362: iadd\n 363: iconst_4\n 364: irem\n 365: invokeinterface #169, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 370: checkcast #154 // class java/util/List\n 373: aload 26\n 375: swap\n 376: invokeinterface #152, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 381: pop\n 382: goto 324\n 385: aload 21\n 387: checkcast #154 // class java/util/List\n 390: nop\n 391: checkcast #47 // class java/lang/Iterable\n 394: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 399: astore 19\n 401: aload 19\n 403: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 408: ifeq 557\n 411: aload 19\n 413: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 418: checkcast #154 // class java/util/List\n 421: astore 20\n 423: iconst_0\n 424: istore 21\n 426: aload 20\n 428: checkcast #47 // class java/lang/Iterable\n 431: astore 22\n 433: iconst_0\n 434: istore 23\n 436: aload 22\n 438: instanceof #140 // class java/util/Collection\n 441: ifeq 461\n 444: aload 22\n 446: checkcast #140 // class java/util/Collection\n 449: invokeinterface #145, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 454: ifeq 461\n 457: iconst_1\n 458: goto 520\n 461: aload 22\n 463: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 468: astore 24\n 470: aload 24\n 472: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 477: ifeq 519\n 480: aload 24\n 482: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 487: astore 25\n 489: aload 25\n 491: checkcast #75 // class Point\n 494: astore 27\n 496: iconst_0\n 497: istore 28\n 499: aload_1\n 500: aload 16\n 502: aload 27\n 504: invokevirtual #173 // Method Point.plus:(LPoint;)LPoint;\n 507: invokeinterface #149, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 512: ifeq 470\n 515: iconst_0\n 516: goto 520\n 519: iconst_1\n 520: ifeq 544\n 523: aload 16\n 525: aload 16\n 527: aload 20\n 529: invokestatic #177 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 532: checkcast #75 // class Point\n 535: invokevirtual #173 // Method Point.plus:(LPoint;)LPoint;\n 538: invokestatic #183 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 541: goto 545\n 544: aconst_null\n 545: astore 20\n 547: aload 20\n 549: ifnull 401\n 552: aload 20\n 554: goto 558\n 557: aconst_null\n 558: nop\n 559: dup\n 560: ifnull 581\n 563: astore 29\n 565: iconst_0\n 566: istore 30\n 568: aload 8\n 570: aload 29\n 572: invokeinterface #152, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 577: pop\n 578: goto 582\n 581: pop\n 582: nop\n 583: goto 235\n 586: nop\n 587: aload 8\n 589: checkcast #154 // class java/util/List\n 592: nop\n 593: checkcast #47 // class java/lang/Iterable\n 596: invokestatic #189 // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;\n 599: astore 4\n 601: aload 4\n 603: invokeinterface #195, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 608: checkcast #47 // class java/lang/Iterable\n 611: astore 6\n 613: iconst_0\n 614: istore 7\n 616: new #197 // class Day23$playRound$$inlined$groupingBy$1\n 619: dup\n 620: aload 6\n 622: invokespecial #200 // Method Day23$playRound$$inlined$groupingBy$1.\"<init>\":(Ljava/lang/Iterable;)V\n 625: checkcast #202 // class kotlin/collections/Grouping\n 628: invokestatic #208 // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;\n 631: astore 6\n 633: iconst_0\n 634: istore 7\n 636: aload 6\n 638: astore 8\n 640: new #210 // class java/util/LinkedHashMap\n 643: dup\n 644: invokespecial #211 // Method java/util/LinkedHashMap.\"<init>\":()V\n 647: checkcast #191 // class java/util/Map\n 650: astore 9\n 652: iconst_0\n 653: istore 10\n 655: aload 8\n 657: invokeinterface #215, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 662: invokeinterface #216, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 667: astore 11\n 669: aload 11\n 671: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 676: ifeq 748\n 679: aload 11\n 681: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 686: checkcast #218 // class java/util/Map$Entry\n 689: astore 12\n 691: aload 12\n 693: astore 13\n 695: iconst_0\n 696: istore 14\n 698: aload 13\n 700: invokeinterface #221, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 705: checkcast #223 // class java/lang/Number\n 708: invokevirtual #226 // Method java/lang/Number.intValue:()I\n 711: iconst_1\n 712: if_icmpne 719\n 715: iconst_1\n 716: goto 720\n 719: iconst_0\n 720: ifeq 669\n 723: aload 9\n 725: aload 12\n 727: invokeinterface #229, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 732: aload 12\n 734: invokeinterface #221, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 739: invokeinterface #233, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 744: pop\n 745: goto 669\n 748: aload 9\n 750: nop\n 751: invokeinterface #236, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 756: astore 5\n 758: aload 4\n 760: astore 6\n 762: nop\n 763: iconst_0\n 764: istore 7\n 766: aload 6\n 768: astore 8\n 770: new #210 // class java/util/LinkedHashMap\n 773: dup\n 774: invokespecial #211 // Method java/util/LinkedHashMap.\"<init>\":()V\n 777: checkcast #191 // class java/util/Map\n 780: astore 9\n 782: iconst_0\n 783: istore 10\n 785: aload 8\n 787: invokeinterface #215, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 792: invokeinterface #216, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 797: astore 11\n 799: aload 11\n 801: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 806: ifeq 877\n 809: aload 11\n 811: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 816: checkcast #218 // class java/util/Map$Entry\n 819: astore 12\n 821: aload 12\n 823: astore 13\n 825: iconst_0\n 826: istore 14\n 828: aload 13\n 830: invokeinterface #221, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 835: checkcast #75 // class Point\n 838: astore 15\n 840: aload 5\n 842: aload 15\n 844: invokeinterface #149, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 849: ifeq 799\n 852: aload 9\n 854: aload 12\n 856: invokeinterface #229, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 861: aload 12\n 863: invokeinterface #221, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 868: invokeinterface #233, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 873: pop\n 874: goto 799\n 877: aload 9\n 879: nop\n 880: astore 6\n 882: nop\n 883: iconst_0\n 884: istore 7\n 886: aload 6\n 888: invokeinterface #215, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 893: invokeinterface #216, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 898: astore 8\n 900: aload 8\n 902: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 907: ifeq 976\n 910: aload 8\n 912: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 917: checkcast #218 // class java/util/Map$Entry\n 920: astore 9\n 922: aload 9\n 924: astore 10\n 926: iconst_0\n 927: istore 11\n 929: aload 10\n 931: invokeinterface #229, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 936: checkcast #75 // class Point\n 939: astore 12\n 941: aload 10\n 943: invokeinterface #221, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 948: checkcast #75 // class Point\n 951: astore 13\n 953: aload_3\n 954: aload 12\n 956: invokeinterface #239, 2 // InterfaceMethod java/util/Set.remove:(Ljava/lang/Object;)Z\n 961: pop\n 962: aload_3\n 963: aload 13\n 965: invokeinterface #240, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 970: pop\n 971: nop\n 972: nop\n 973: goto 900\n 976: nop\n 977: aload_3\n 978: areturn\n\n private final java.util.List<java.util.List<Point>> createOffsets();\n Code:\n 0: iconst_4\n 1: anewarray #154 // class java/util/List\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: iconst_3\n 8: anewarray #75 // class Point\n 11: astore_2\n 12: aload_2\n 13: iconst_0\n 14: new #75 // class Point\n 17: dup\n 18: iconst_0\n 19: iconst_m1\n 20: invokespecial #121 // Method Point.\"<init>\":(II)V\n 23: aastore\n 24: aload_2\n 25: iconst_1\n 26: new #75 // class Point\n 29: dup\n 30: iconst_m1\n 31: iconst_m1\n 32: invokespecial #121 // Method Point.\"<init>\":(II)V\n 35: aastore\n 36: aload_2\n 37: iconst_2\n 38: new #75 // class Point\n 41: dup\n 42: iconst_1\n 43: iconst_m1\n 44: invokespecial #121 // Method Point.\"<init>\":(II)V\n 47: aastore\n 48: aload_2\n 49: invokestatic #298 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 52: aastore\n 53: aload_1\n 54: iconst_1\n 55: iconst_3\n 56: anewarray #75 // class Point\n 59: astore_2\n 60: aload_2\n 61: iconst_0\n 62: new #75 // class Point\n 65: dup\n 66: iconst_0\n 67: iconst_1\n 68: invokespecial #121 // Method Point.\"<init>\":(II)V\n 71: aastore\n 72: aload_2\n 73: iconst_1\n 74: new #75 // class Point\n 77: dup\n 78: iconst_m1\n 79: iconst_1\n 80: invokespecial #121 // Method Point.\"<init>\":(II)V\n 83: aastore\n 84: aload_2\n 85: iconst_2\n 86: new #75 // class Point\n 89: dup\n 90: iconst_1\n 91: iconst_1\n 92: invokespecial #121 // Method Point.\"<init>\":(II)V\n 95: aastore\n 96: aload_2\n 97: invokestatic #298 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 100: aastore\n 101: aload_1\n 102: iconst_2\n 103: iconst_3\n 104: anewarray #75 // class Point\n 107: astore_2\n 108: aload_2\n 109: iconst_0\n 110: new #75 // class Point\n 113: dup\n 114: iconst_m1\n 115: iconst_0\n 116: invokespecial #121 // Method Point.\"<init>\":(II)V\n 119: aastore\n 120: aload_2\n 121: iconst_1\n 122: new #75 // class Point\n 125: dup\n 126: iconst_m1\n 127: iconst_m1\n 128: invokespecial #121 // Method Point.\"<init>\":(II)V\n 131: aastore\n 132: aload_2\n 133: iconst_2\n 134: new #75 // class Point\n 137: dup\n 138: iconst_m1\n 139: iconst_1\n 140: invokespecial #121 // Method Point.\"<init>\":(II)V\n 143: aastore\n 144: aload_2\n 145: invokestatic #298 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 148: aastore\n 149: aload_1\n 150: iconst_3\n 151: iconst_3\n 152: anewarray #75 // class Point\n 155: astore_2\n 156: aload_2\n 157: iconst_0\n 158: new #75 // class Point\n 161: dup\n 162: iconst_1\n 163: iconst_0\n 164: invokespecial #121 // Method Point.\"<init>\":(II)V\n 167: aastore\n 168: aload_2\n 169: iconst_1\n 170: new #75 // class Point\n 173: dup\n 174: iconst_1\n 175: iconst_m1\n 176: invokespecial #121 // Method Point.\"<init>\":(II)V\n 179: aastore\n 180: aload_2\n 181: iconst_2\n 182: new #75 // class Point\n 185: dup\n 186: iconst_1\n 187: iconst_1\n 188: invokespecial #121 // Method Point.\"<init>\":(II)V\n 191: aastore\n 192: aload_2\n 193: invokestatic #298 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 196: aastore\n 197: aload_1\n 198: invokestatic #298 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 201: areturn\n\n private final java.util.Set<Point> parseInput(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #47 // class java/lang/Iterable\n 4: astore_2\n 5: new #137 // class java/util/ArrayList\n 8: dup\n 9: invokespecial #138 // Method java/util/ArrayList.\"<init>\":()V\n 12: checkcast #140 // class java/util/Collection\n 15: astore_3\n 16: iconst_0\n 17: istore 4\n 19: aload_2\n 20: invokeinterface #51, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 25: astore 5\n 27: aload 5\n 29: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 34: ifeq 237\n 37: aload 5\n 39: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 44: astore 6\n 46: iload 4\n 48: iinc 4, 1\n 51: istore 7\n 53: iload 7\n 55: ifge 61\n 58: invokestatic #302 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 61: iload 7\n 63: aload 6\n 65: checkcast #304 // class java/lang/String\n 68: astore 8\n 70: istore 9\n 72: iconst_0\n 73: istore 10\n 75: aload 8\n 77: checkcast #306 // class java/lang/CharSequence\n 80: astore 11\n 82: iconst_0\n 83: istore 12\n 85: aload 11\n 87: astore 13\n 89: new #137 // class java/util/ArrayList\n 92: dup\n 93: invokespecial #138 // Method java/util/ArrayList.\"<init>\":()V\n 96: checkcast #140 // class java/util/Collection\n 99: astore 14\n 101: iconst_0\n 102: istore 15\n 104: aload 13\n 106: astore 16\n 108: iconst_0\n 109: istore 17\n 111: iconst_0\n 112: istore 18\n 114: iconst_0\n 115: istore 19\n 117: iload 19\n 119: aload 16\n 121: invokeinterface #309, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 126: if_icmpge 217\n 129: aload 16\n 131: iload 19\n 133: invokeinterface #313, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 138: istore 20\n 140: iload 18\n 142: iinc 18, 1\n 145: iload 20\n 147: istore 21\n 149: istore 22\n 151: iconst_0\n 152: istore 23\n 154: iload 22\n 156: iload 21\n 158: istore 24\n 160: istore 25\n 162: iconst_0\n 163: istore 26\n 165: iload 24\n 167: bipush 35\n 169: if_icmpne 186\n 172: new #75 // class Point\n 175: dup\n 176: iload 25\n 178: iload 9\n 180: invokespecial #121 // Method Point.\"<init>\":(II)V\n 183: goto 187\n 186: aconst_null\n 187: dup\n 188: ifnull 209\n 191: astore 27\n 193: iconst_0\n 194: istore 28\n 196: aload 14\n 198: aload 27\n 200: invokeinterface #152, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 205: pop\n 206: goto 210\n 209: pop\n 210: nop\n 211: iinc 19, 1\n 214: goto 117\n 217: nop\n 218: aload 14\n 220: checkcast #154 // class java/util/List\n 223: nop\n 224: checkcast #47 // class java/lang/Iterable\n 227: nop\n 228: aload_3\n 229: swap\n 230: invokestatic #317 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 233: pop\n 234: goto 27\n 237: aload_3\n 238: checkcast #154 // class java/util/List\n 241: checkcast #47 // class java/lang/Iterable\n 244: invokestatic #320 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 247: areturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day15.kt
import kotlin.math.abs import kotlin.math.sign fun main() { fun List<IntRange>.union(): List<IntRange> { val sorted = sortedBy { it.first } val init = mutableListOf(sorted.first()) return sortedBy { it.first }.fold(init) { acc, r -> val last = acc.last() if (r.first <= last.last) { acc[acc.lastIndex] = (last.first..maxOf(last.last, r.last)) } else { acc += r } acc } } fun Point.frequency() = (x * 4_000_000L) + y infix fun Point.distanceTo(other: Point): Int { return abs(x - other.x) + abs(y - other.y) } infix fun Point.lineTo(other: Point): List<Point> { val xDelta = (other.x - x).sign val yDelta = (other.y - y).sign val steps = maxOf(abs(x - other.x), abs(y - other.y)) return (1..steps).scan(this) { prev, _ -> Point(prev.x + xDelta, prev.y + yDelta) } } fun Point.findRange(y: Int, distance: Int): IntRange? { val width = distance - abs(this.y - y) return (this.x - width..this.x + width).takeIf { it.first <= it.last } } fun parse(input: List<String>): MutableList<Pair<Point, Point>> { return input.map { val sensorX = it.substringAfter("Sensor at x=").substringBefore(",").toInt() val sensorY = it.substringBefore(":").substringAfter("y=").toInt() val beaconX = it.substringAfter("closest beacon is at x=").substringBefore(",").toInt() val beaconY = it.substringAfterLast("y=").toInt() Pair(Point(sensorX, sensorY), Point(beaconX, beaconY)) } .toMutableList() } fun part1(input: List<String>): Int { val pairs = parse(input) val y = 2_000_000 return pairs .mapNotNull { (sensor, beacon) -> val distance = sensor distanceTo beacon sensor.findRange(y, distance) } .union() .sumOf { it.last - it.first } } fun part2(input: List<String>): Long { val pairs = parse(input) val cave = 0..4_000_000L return pairs.firstNotNullOf { (sensor, beacon) -> val distance = sensor distanceTo beacon val up = Point(sensor.x, sensor.y - distance - 1) val down = Point(sensor.x, sensor.y + distance + 1) val left = Point(sensor.x - distance - 1, sensor.y) val right = Point(sensor.x + distance + 1, sensor.y) (up.lineTo(right) + right.lineTo(down) + down.lineTo(left) + left.lineTo(up)) .filter { it.x in cave && it.y in cave } .firstOrNull { point -> pairs.all { (sensor, beacon) -> sensor distanceTo point > sensor distanceTo beacon } } }.frequency() } val input = readInput("inputs/Day15") println(part1(input)) println(part2(input)) }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day15Kt$main$union$$inlined$sortedBy$2.class", "javap": "Compiled from \"Comparisons.kt\"\npublic final class Day15Kt$main$union$$inlined$sortedBy$2<T> implements java.util.Comparator {\n public Day15Kt$main$union$$inlined$sortedBy$2();\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": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day15Kt.class", "javap": "Compiled from \"Day15.kt\"\npublic final class Day15Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/Day15\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 main$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 main$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 #37 // Method java/io/PrintStream.println:(J)V\n 30: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #42 // Method main:()V\n 3: return\n\n private static final java.util.List<kotlin.ranges.IntRange> main$union(java.util.List<kotlin.ranges.IntRange>);\n Code:\n 0: aload_0\n 1: checkcast #49 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: new #51 // class Day15Kt$main$union$$inlined$sortedBy$1\n 11: dup\n 12: invokespecial #54 // Method Day15Kt$main$union$$inlined$sortedBy$1.\"<init>\":()V\n 15: checkcast #56 // class java/util/Comparator\n 18: invokestatic #62 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 21: astore_1\n 22: iconst_1\n 23: anewarray #64 // class kotlin/ranges/IntRange\n 26: astore_3\n 27: aload_3\n 28: iconst_0\n 29: aload_1\n 30: invokestatic #68 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 33: aastore\n 34: aload_3\n 35: invokestatic #72 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 38: astore_2\n 39: aload_0\n 40: checkcast #49 // class java/lang/Iterable\n 43: astore_3\n 44: iconst_0\n 45: istore 4\n 47: aload_3\n 48: new #74 // class Day15Kt$main$union$$inlined$sortedBy$2\n 51: dup\n 52: invokespecial #75 // Method Day15Kt$main$union$$inlined$sortedBy$2.\"<init>\":()V\n 55: checkcast #56 // class java/util/Comparator\n 58: invokestatic #62 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 61: checkcast #49 // class java/lang/Iterable\n 64: astore_3\n 65: nop\n 66: iconst_0\n 67: istore 4\n 69: aload_2\n 70: astore 5\n 72: aload_3\n 73: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 78: astore 6\n 80: aload 6\n 82: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 87: ifeq 197\n 90: aload 6\n 92: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 97: astore 7\n 99: aload 5\n 101: aload 7\n 103: checkcast #64 // class kotlin/ranges/IntRange\n 106: astore 8\n 108: astore 9\n 110: iconst_0\n 111: istore 10\n 113: aload 9\n 115: invokestatic #92 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 118: checkcast #64 // class kotlin/ranges/IntRange\n 121: astore 11\n 123: aload 8\n 125: invokevirtual #96 // Method kotlin/ranges/IntRange.getFirst:()I\n 128: aload 11\n 130: invokevirtual #99 // Method kotlin/ranges/IntRange.getLast:()I\n 133: if_icmpgt 177\n 136: aload 9\n 138: aload 9\n 140: invokestatic #102 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 143: new #64 // class kotlin/ranges/IntRange\n 146: dup\n 147: aload 11\n 149: invokevirtual #96 // Method kotlin/ranges/IntRange.getFirst:()I\n 152: aload 11\n 154: invokevirtual #99 // Method kotlin/ranges/IntRange.getLast:()I\n 157: aload 8\n 159: invokevirtual #99 // Method kotlin/ranges/IntRange.getLast:()I\n 162: invokestatic #108 // Method java/lang/Math.max:(II)I\n 165: invokespecial #111 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 168: invokeinterface #117, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 173: pop\n 174: goto 190\n 177: aload 9\n 179: checkcast #119 // class java/util/Collection\n 182: aload 8\n 184: invokeinterface #123, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 189: pop\n 190: aload 9\n 192: astore 5\n 194: goto 80\n 197: aload 5\n 199: areturn\n\n private static final long main$frequency(Point);\n Code:\n 0: aload_0\n 1: invokevirtual #146 // Method Point.getX:()I\n 4: i2l\n 5: ldc2_w #147 // long 4000000l\n 8: lmul\n 9: aload_0\n 10: invokevirtual #151 // Method Point.getY:()I\n 13: i2l\n 14: ladd\n 15: lreturn\n\n private static final int main$distanceTo(Point, Point);\n Code:\n 0: aload_0\n 1: invokevirtual #146 // Method Point.getX:()I\n 4: aload_1\n 5: invokevirtual #146 // Method Point.getX:()I\n 8: isub\n 9: invokestatic #159 // Method java/lang/Math.abs:(I)I\n 12: aload_0\n 13: invokevirtual #151 // Method Point.getY:()I\n 16: aload_1\n 17: invokevirtual #151 // Method Point.getY:()I\n 20: isub\n 21: invokestatic #159 // Method java/lang/Math.abs:(I)I\n 24: iadd\n 25: ireturn\n\n private static final java.util.List<Point> main$lineTo(Point, Point);\n Code:\n 0: aload_1\n 1: invokevirtual #146 // Method Point.getX:()I\n 4: aload_0\n 5: invokevirtual #146 // Method Point.getX:()I\n 8: isub\n 9: invokestatic #169 // Method kotlin/math/MathKt.getSign:(I)I\n 12: istore_2\n 13: aload_1\n 14: invokevirtual #151 // Method Point.getY:()I\n 17: aload_0\n 18: invokevirtual #151 // Method Point.getY:()I\n 21: isub\n 22: invokestatic #169 // Method kotlin/math/MathKt.getSign:(I)I\n 25: istore_3\n 26: nop\n 27: aload_0\n 28: invokevirtual #146 // Method Point.getX:()I\n 31: aload_1\n 32: invokevirtual #146 // Method Point.getX:()I\n 35: isub\n 36: invokestatic #159 // Method java/lang/Math.abs:(I)I\n 39: aload_0\n 40: invokevirtual #151 // Method Point.getY:()I\n 43: aload_1\n 44: invokevirtual #151 // Method Point.getY:()I\n 47: isub\n 48: invokestatic #159 // Method java/lang/Math.abs:(I)I\n 51: invokestatic #108 // Method java/lang/Math.max:(II)I\n 54: istore 4\n 56: new #64 // class kotlin/ranges/IntRange\n 59: dup\n 60: iconst_1\n 61: iload 4\n 63: invokespecial #111 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 66: checkcast #49 // class java/lang/Iterable\n 69: astore 5\n 71: iconst_0\n 72: istore 6\n 74: aload 5\n 76: astore 7\n 78: iconst_0\n 79: istore 8\n 81: aload 7\n 83: bipush 9\n 85: invokestatic #173 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 88: istore 9\n 90: iload 9\n 92: ifne 102\n 95: aload_0\n 96: invokestatic #177 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 99: goto 211\n 102: new #179 // class java/util/ArrayList\n 105: dup\n 106: iload 9\n 108: iconst_1\n 109: iadd\n 110: invokespecial #181 // Method java/util/ArrayList.\"<init>\":(I)V\n 113: astore 10\n 115: aload 10\n 117: astore 11\n 119: iconst_0\n 120: istore 12\n 122: aload 11\n 124: aload_0\n 125: invokevirtual #182 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 128: pop\n 129: aload 10\n 131: astore 13\n 133: aload_0\n 134: astore 10\n 136: aload 7\n 138: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 143: astore 11\n 145: aload 11\n 147: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 152: ifeq 206\n 155: aload 11\n 157: checkcast #184 // class kotlin/collections/IntIterator\n 160: invokevirtual #187 // Method kotlin/collections/IntIterator.nextInt:()I\n 163: istore 12\n 165: aload 10\n 167: astore 14\n 169: iconst_0\n 170: istore 15\n 172: new #143 // class Point\n 175: dup\n 176: aload 14\n 178: invokevirtual #146 // Method Point.getX:()I\n 181: iload_2\n 182: iadd\n 183: aload 14\n 185: invokevirtual #151 // Method Point.getY:()I\n 188: iload_3\n 189: iadd\n 190: invokespecial #188 // Method Point.\"<init>\":(II)V\n 193: astore 10\n 195: aload 13\n 197: aload 10\n 199: invokevirtual #182 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 202: pop\n 203: goto 145\n 206: aload 13\n 208: checkcast #113 // class java/util/List\n 211: nop\n 212: areturn\n\n private static final kotlin.ranges.IntRange main$findRange(Point, int, int);\n Code:\n 0: iload_2\n 1: aload_0\n 2: invokevirtual #151 // Method Point.getY:()I\n 5: iload_1\n 6: isub\n 7: invokestatic #159 // Method java/lang/Math.abs:(I)I\n 10: isub\n 11: istore_3\n 12: new #64 // class kotlin/ranges/IntRange\n 15: dup\n 16: aload_0\n 17: invokevirtual #146 // Method Point.getX:()I\n 20: iload_3\n 21: isub\n 22: aload_0\n 23: invokevirtual #146 // Method Point.getX:()I\n 26: iload_3\n 27: iadd\n 28: invokespecial #111 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 31: astore 4\n 33: aload 4\n 35: astore 5\n 37: iconst_0\n 38: istore 6\n 40: aload 5\n 42: invokevirtual #96 // Method kotlin/ranges/IntRange.getFirst:()I\n 45: aload 5\n 47: invokevirtual #99 // Method kotlin/ranges/IntRange.getLast:()I\n 50: if_icmpgt 57\n 53: iconst_1\n 54: goto 58\n 57: iconst_0\n 58: ifeq 66\n 61: aload 4\n 63: goto 67\n 66: aconst_null\n 67: areturn\n\n private static final java.util.List<kotlin.Pair<Point, Point>> main$parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #49 // 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 #179 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #173 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #181 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #119 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 196\n 48: aload 6\n 50: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #217 // 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: ldc #219 // String Sensor at x=\n 75: aconst_null\n 76: iconst_2\n 77: aconst_null\n 78: invokestatic #225 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 81: ldc #227 // String ,\n 83: aconst_null\n 84: iconst_2\n 85: aconst_null\n 86: invokestatic #230 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 89: invokestatic #236 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 92: istore 10\n 94: aload 8\n 96: ldc #238 // String :\n 98: aconst_null\n 99: iconst_2\n 100: aconst_null\n 101: invokestatic #230 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 104: ldc #240 // String y=\n 106: aconst_null\n 107: iconst_2\n 108: aconst_null\n 109: invokestatic #225 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 112: invokestatic #236 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 115: istore 11\n 117: aload 8\n 119: ldc #242 // String closest beacon is at x=\n 121: aconst_null\n 122: iconst_2\n 123: aconst_null\n 124: invokestatic #225 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 127: ldc #227 // String ,\n 129: aconst_null\n 130: iconst_2\n 131: aconst_null\n 132: invokestatic #230 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 135: invokestatic #236 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 138: istore 12\n 140: aload 8\n 142: ldc #240 // String y=\n 144: aconst_null\n 145: iconst_2\n 146: aconst_null\n 147: invokestatic #245 // Method kotlin/text/StringsKt.substringAfterLast$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 150: invokestatic #236 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 153: istore 13\n 155: new #247 // class kotlin/Pair\n 158: dup\n 159: new #143 // class Point\n 162: dup\n 163: iload 10\n 165: iload 11\n 167: invokespecial #188 // Method Point.\"<init>\":(II)V\n 170: new #143 // class Point\n 173: dup\n 174: iload 12\n 176: iload 13\n 178: invokespecial #188 // Method Point.\"<init>\":(II)V\n 181: invokespecial #250 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 184: aload 14\n 186: swap\n 187: invokeinterface #123, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 192: pop\n 193: goto 38\n 196: aload 4\n 198: checkcast #113 // class java/util/List\n 201: nop\n 202: checkcast #119 // class java/util/Collection\n 205: invokestatic #254 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 208: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #270 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: ldc_w #271 // int 2000000\n 8: istore_2\n 9: aload_1\n 10: checkcast #49 // class java/lang/Iterable\n 13: astore_3\n 14: nop\n 15: iconst_0\n 16: istore 4\n 18: aload_3\n 19: astore 5\n 21: new #179 // class java/util/ArrayList\n 24: dup\n 25: invokespecial #272 // Method java/util/ArrayList.\"<init>\":()V\n 28: checkcast #119 // class java/util/Collection\n 31: astore 6\n 33: iconst_0\n 34: istore 7\n 36: aload 5\n 38: astore 8\n 40: iconst_0\n 41: istore 9\n 43: aload 8\n 45: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 10\n 52: aload 10\n 54: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 152\n 62: aload 10\n 64: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 11\n 71: aload 11\n 73: astore 12\n 75: iconst_0\n 76: istore 13\n 78: aload 12\n 80: checkcast #247 // class kotlin/Pair\n 83: astore 14\n 85: iconst_0\n 86: istore 15\n 88: aload 14\n 90: invokevirtual #275 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 93: checkcast #143 // class Point\n 96: astore 16\n 98: aload 14\n 100: invokevirtual #278 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 103: checkcast #143 // class Point\n 106: astore 17\n 108: aload 16\n 110: aload 17\n 112: invokestatic #280 // Method main$distanceTo:(LPoint;LPoint;)I\n 115: istore 18\n 117: aload 16\n 119: iload_2\n 120: iload 18\n 122: invokestatic #282 // Method main$findRange:(LPoint;II)Lkotlin/ranges/IntRange;\n 125: dup\n 126: ifnull 147\n 129: astore 19\n 131: iconst_0\n 132: istore 20\n 134: aload 6\n 136: aload 19\n 138: invokeinterface #123, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 143: pop\n 144: goto 148\n 147: pop\n 148: nop\n 149: goto 52\n 152: nop\n 153: aload 6\n 155: checkcast #113 // class java/util/List\n 158: nop\n 159: invokestatic #284 // Method main$union:(Ljava/util/List;)Ljava/util/List;\n 162: checkcast #49 // class java/lang/Iterable\n 165: astore_3\n 166: iconst_0\n 167: istore 4\n 169: aload_3\n 170: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 175: astore 5\n 177: aload 5\n 179: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 184: ifeq 233\n 187: aload 5\n 189: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 194: astore 6\n 196: iload 4\n 198: aload 6\n 200: checkcast #64 // class kotlin/ranges/IntRange\n 203: astore 7\n 205: istore 21\n 207: iconst_0\n 208: istore 8\n 210: aload 7\n 212: invokevirtual #99 // Method kotlin/ranges/IntRange.getLast:()I\n 215: aload 7\n 217: invokevirtual #96 // Method kotlin/ranges/IntRange.getFirst:()I\n 220: isub\n 221: istore 22\n 223: iload 21\n 225: iload 22\n 227: iadd\n 228: istore 4\n 230: goto 177\n 233: iload 4\n 235: ireturn\n\n private static final long main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #270 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: new #302 // class kotlin/ranges/LongRange\n 8: dup\n 9: lconst_0\n 10: ldc2_w #147 // long 4000000l\n 13: invokespecial #305 // Method kotlin/ranges/LongRange.\"<init>\":(JJ)V\n 16: astore_2\n 17: aload_1\n 18: checkcast #49 // class java/lang/Iterable\n 21: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 26: astore_3\n 27: aload_3\n 28: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 33: ifeq 610\n 36: aload_3\n 37: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 42: checkcast #247 // class kotlin/Pair\n 45: astore 4\n 47: iconst_0\n 48: istore 5\n 50: aload 4\n 52: invokevirtual #275 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 55: checkcast #143 // class Point\n 58: astore 6\n 60: aload 4\n 62: invokevirtual #278 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 65: checkcast #143 // class Point\n 68: astore 7\n 70: aload 6\n 72: aload 7\n 74: invokestatic #280 // Method main$distanceTo:(LPoint;LPoint;)I\n 77: istore 8\n 79: new #143 // class Point\n 82: dup\n 83: aload 6\n 85: invokevirtual #146 // Method Point.getX:()I\n 88: aload 6\n 90: invokevirtual #151 // Method Point.getY:()I\n 93: iload 8\n 95: isub\n 96: iconst_1\n 97: isub\n 98: invokespecial #188 // Method Point.\"<init>\":(II)V\n 101: astore 9\n 103: new #143 // class Point\n 106: dup\n 107: aload 6\n 109: invokevirtual #146 // Method Point.getX:()I\n 112: aload 6\n 114: invokevirtual #151 // Method Point.getY:()I\n 117: iload 8\n 119: iadd\n 120: iconst_1\n 121: iadd\n 122: invokespecial #188 // Method Point.\"<init>\":(II)V\n 125: astore 10\n 127: new #143 // class Point\n 130: dup\n 131: aload 6\n 133: invokevirtual #146 // Method Point.getX:()I\n 136: iload 8\n 138: isub\n 139: iconst_1\n 140: isub\n 141: aload 6\n 143: invokevirtual #151 // Method Point.getY:()I\n 146: invokespecial #188 // Method Point.\"<init>\":(II)V\n 149: astore 11\n 151: new #143 // class Point\n 154: dup\n 155: aload 6\n 157: invokevirtual #146 // Method Point.getX:()I\n 160: iload 8\n 162: iadd\n 163: iconst_1\n 164: iadd\n 165: aload 6\n 167: invokevirtual #151 // Method Point.getY:()I\n 170: invokespecial #188 // Method Point.\"<init>\":(II)V\n 173: astore 12\n 175: aload 9\n 177: aload 12\n 179: invokestatic #307 // Method main$lineTo:(LPoint;LPoint;)Ljava/util/List;\n 182: checkcast #119 // class java/util/Collection\n 185: aload 12\n 187: aload 10\n 189: invokestatic #307 // Method main$lineTo:(LPoint;LPoint;)Ljava/util/List;\n 192: checkcast #49 // class java/lang/Iterable\n 195: invokestatic #311 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 198: checkcast #119 // class java/util/Collection\n 201: aload 10\n 203: aload 11\n 205: invokestatic #307 // Method main$lineTo:(LPoint;LPoint;)Ljava/util/List;\n 208: checkcast #49 // class java/lang/Iterable\n 211: invokestatic #311 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 214: checkcast #119 // class java/util/Collection\n 217: aload 11\n 219: aload 9\n 221: invokestatic #307 // Method main$lineTo:(LPoint;LPoint;)Ljava/util/List;\n 224: checkcast #49 // class java/lang/Iterable\n 227: invokestatic #311 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 230: checkcast #49 // class java/lang/Iterable\n 233: astore 13\n 235: nop\n 236: iconst_0\n 237: istore 14\n 239: aload 13\n 241: astore 15\n 243: new #179 // class java/util/ArrayList\n 246: dup\n 247: invokespecial #272 // Method java/util/ArrayList.\"<init>\":()V\n 250: checkcast #119 // class java/util/Collection\n 253: astore 16\n 255: iconst_0\n 256: istore 17\n 258: aload 15\n 260: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 265: astore 18\n 267: aload 18\n 269: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 274: ifeq 413\n 277: aload 18\n 279: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 284: astore 19\n 286: aload 19\n 288: checkcast #143 // class Point\n 291: astore 20\n 293: iconst_0\n 294: istore 21\n 296: aload_2\n 297: invokevirtual #314 // Method kotlin/ranges/LongRange.getFirst:()J\n 300: lstore 22\n 302: aload_2\n 303: invokevirtual #316 // Method kotlin/ranges/LongRange.getLast:()J\n 306: lstore 24\n 308: aload 20\n 310: invokevirtual #146 // Method Point.getX:()I\n 313: i2l\n 314: lstore 26\n 316: lload 22\n 318: lload 26\n 320: lcmp\n 321: ifgt 340\n 324: lload 26\n 326: lload 24\n 328: lcmp\n 329: ifgt 336\n 332: iconst_1\n 333: goto 341\n 336: iconst_0\n 337: goto 341\n 340: iconst_0\n 341: ifeq 396\n 344: aload_2\n 345: invokevirtual #314 // Method kotlin/ranges/LongRange.getFirst:()J\n 348: lstore 22\n 350: aload_2\n 351: invokevirtual #316 // Method kotlin/ranges/LongRange.getLast:()J\n 354: lstore 24\n 356: aload 20\n 358: invokevirtual #151 // Method Point.getY:()I\n 361: i2l\n 362: lstore 26\n 364: lload 22\n 366: lload 26\n 368: lcmp\n 369: ifgt 388\n 372: lload 26\n 374: lload 24\n 376: lcmp\n 377: ifgt 384\n 380: iconst_1\n 381: goto 389\n 384: iconst_0\n 385: goto 389\n 388: iconst_0\n 389: ifeq 396\n 392: iconst_1\n 393: goto 397\n 396: iconst_0\n 397: ifeq 267\n 400: aload 16\n 402: aload 19\n 404: invokeinterface #123, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 409: pop\n 410: goto 267\n 413: aload 16\n 415: checkcast #113 // class java/util/List\n 418: nop\n 419: checkcast #49 // class java/lang/Iterable\n 422: astore 13\n 424: nop\n 425: iconst_0\n 426: istore 14\n 428: aload 13\n 430: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 435: astore 15\n 437: aload 15\n 439: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 444: ifeq 597\n 447: aload 15\n 449: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 454: astore 16\n 456: aload 16\n 458: checkcast #143 // class Point\n 461: astore 17\n 463: iconst_0\n 464: istore 18\n 466: aload_1\n 467: checkcast #49 // class java/lang/Iterable\n 470: astore 19\n 472: iconst_0\n 473: istore 20\n 475: aload 19\n 477: instanceof #119 // class java/util/Collection\n 480: ifeq 500\n 483: aload 19\n 485: checkcast #119 // class java/util/Collection\n 488: invokeinterface #319, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 493: ifeq 500\n 496: iconst_1\n 497: goto 588\n 500: aload 19\n 502: invokeinterface #79, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 507: astore 21\n 509: aload 21\n 511: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 516: ifeq 587\n 519: aload 21\n 521: invokeinterface #89, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 526: astore 28\n 528: aload 28\n 530: checkcast #247 // class kotlin/Pair\n 533: astore 29\n 535: iconst_0\n 536: istore 30\n 538: aload 29\n 540: invokevirtual #275 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 543: checkcast #143 // class Point\n 546: astore 31\n 548: aload 29\n 550: invokevirtual #278 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 553: checkcast #143 // class Point\n 556: astore 32\n 558: aload 31\n 560: aload 17\n 562: invokestatic #280 // Method main$distanceTo:(LPoint;LPoint;)I\n 565: aload 31\n 567: aload 32\n 569: invokestatic #280 // Method main$distanceTo:(LPoint;LPoint;)I\n 572: if_icmple 579\n 575: iconst_1\n 576: goto 580\n 579: iconst_0\n 580: ifne 509\n 583: iconst_0\n 584: goto 588\n 587: iconst_1\n 588: nop\n 589: ifeq 437\n 592: aload 16\n 594: goto 598\n 597: aconst_null\n 598: checkcast #143 // class Point\n 601: nop\n 602: dup\n 603: ifnonnull 611\n 606: pop\n 607: goto 27\n 610: aconst_null\n 611: dup\n 612: ifnonnull 627\n 615: pop\n 616: new #321 // class java/util/NoSuchElementException\n 619: dup\n 620: ldc_w #323 // String No element of the collection was transformed to a non-null value.\n 623: invokespecial #326 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 626: athrow\n 627: invokestatic #328 // Method main$frequency:(LPoint;)J\n 630: lreturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day15Kt$main$union$$inlined$sortedBy$1.class", "javap": "Compiled from \"Comparisons.kt\"\npublic final class Day15Kt$main$union$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public Day15Kt$main$union$$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": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day24.kt
fun main() { val d = Day24(readInput("inputs/Day24")) println(d.part1()) println(d.part2()) } class Day24(input: List<String>) { private val initialMapState: MapState = MapState.of(input) private val start: Point = Point(input.first().indexOfFirst { it == '.' }, 0) private val goal: Point = Point(input.last().indexOfFirst { it == '.' }, input.lastIndex) fun part1(): Int = solve().first fun part2(): Int { val toGoal = solve() val backToStart = solve(goal, start, toGoal.second, toGoal.first) val backToGoal = solve(start, goal, backToStart.second, backToStart.first) return backToGoal.first } private fun solve( startPlace: Point = start, stopPlace: Point = goal, startState: MapState = initialMapState, stepsSoFar: Int = 0 ): Pair<Int, MapState> { val mapStates = mutableMapOf(stepsSoFar to startState) val queue = mutableListOf(PathAttempt(stepsSoFar, startPlace)) val seen = mutableSetOf<PathAttempt>() while (queue.isNotEmpty()) { val thisAttempt = queue.removeFirst() if (thisAttempt !in seen) { seen += thisAttempt val nextMapState = mapStates.computeIfAbsent(thisAttempt.steps + 1) { key -> mapStates.getValue(key - 1).nextState() } if (nextMapState.isOpen(thisAttempt.location)) queue.add(thisAttempt.next()) val neighbors = thisAttempt.location.adjacents() if (stopPlace in neighbors) return Pair(thisAttempt.steps + 1, nextMapState) neighbors .filter { it == start || (nextMapState.inBounds(it) && nextMapState.isOpen(it)) } .forEach { neighbor -> queue.add(thisAttempt.next(neighbor)) } } } throw IllegalStateException("No paths found") } private data class PathAttempt(val steps: Int, val location: Point) { fun next(place: Point = location): PathAttempt = PathAttempt(steps + 1, place) } private data class MapState(val boundary: Point, val blizzards: Set<Blizzard>) { private val unsafeSpots = blizzards.map { it.location }.toSet() fun isOpen(place: Point): Boolean = place !in unsafeSpots fun inBounds(place: Point): Boolean = place.x > 0 && place.y > 0 && place.x <= boundary.x && place.y <= boundary.y fun nextState(): MapState = copy(blizzards = blizzards.map { it.next(boundary) }.toSet()) companion object { fun of(input: List<String>): MapState = MapState( Point(input.first().lastIndex - 1, input.lastIndex - 1), input.flatMapIndexed { y, row -> row.mapIndexedNotNull { x, char -> when (char) { '>' -> Blizzard(Point(x, y), Point(1, 0)) '<' -> Blizzard(Point(x, y), Point(-1, 0)) 'v' -> Blizzard(Point(x, y), Point(0, 1)) '^' -> Blizzard(Point(x, y), Point(0, -1)) else -> null } } }.toSet() ) } } private data class Blizzard(val location: Point, val offset: Point) { fun next(boundary: Point): Blizzard { var nextLocation = location + offset when { nextLocation.x == 0 -> nextLocation = Point(boundary.x, location.y) nextLocation.x > boundary.x -> nextLocation = Point(1, location.y) nextLocation.y == 0 -> nextLocation = Point(location.x, boundary.y) nextLocation.y > boundary.y -> nextLocation = Point(location.x, 1) } return copy(location = nextLocation) } } }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day24$Blizzard.class", "javap": "Compiled from \"Day24.kt\"\nfinal class Day24$Blizzard {\n private final Point location;\n\n private final Point offset;\n\n public Day24$Blizzard(Point, Point);\n Code:\n 0: aload_1\n 1: ldc #9 // String location\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 offset\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 location:LPoint;\n 21: aload_0\n 22: aload_2\n 23: putfield #25 // Field offset:LPoint;\n 26: return\n\n public final Point getLocation();\n Code:\n 0: aload_0\n 1: getfield #23 // Field location:LPoint;\n 4: areturn\n\n public final Point getOffset();\n Code:\n 0: aload_0\n 1: getfield #25 // Field offset:LPoint;\n 4: areturn\n\n public final Day24$Blizzard next(Point);\n Code:\n 0: aload_1\n 1: ldc #34 // String boundary\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #23 // Field location:LPoint;\n 10: aload_0\n 11: getfield #25 // Field offset:LPoint;\n 14: invokevirtual #40 // Method Point.plus:(LPoint;)LPoint;\n 17: astore_2\n 18: nop\n 19: aload_2\n 20: invokevirtual #44 // Method Point.getX:()I\n 23: ifne 48\n 26: new #36 // class Point\n 29: dup\n 30: aload_1\n 31: invokevirtual #44 // Method Point.getX:()I\n 34: aload_0\n 35: getfield #23 // Field location:LPoint;\n 38: invokevirtual #47 // Method Point.getY:()I\n 41: invokespecial #50 // Method Point.\"<init>\":(II)V\n 44: astore_2\n 45: goto 134\n 48: aload_2\n 49: invokevirtual #44 // Method Point.getX:()I\n 52: aload_1\n 53: invokevirtual #44 // Method Point.getX:()I\n 56: if_icmple 78\n 59: new #36 // class Point\n 62: dup\n 63: iconst_1\n 64: aload_0\n 65: getfield #23 // Field location:LPoint;\n 68: invokevirtual #47 // Method Point.getY:()I\n 71: invokespecial #50 // Method Point.\"<init>\":(II)V\n 74: astore_2\n 75: goto 134\n 78: aload_2\n 79: invokevirtual #47 // Method Point.getY:()I\n 82: ifne 107\n 85: new #36 // class Point\n 88: dup\n 89: aload_0\n 90: getfield #23 // Field location:LPoint;\n 93: invokevirtual #44 // Method Point.getX:()I\n 96: aload_1\n 97: invokevirtual #47 // Method Point.getY:()I\n 100: invokespecial #50 // Method Point.\"<init>\":(II)V\n 103: astore_2\n 104: goto 134\n 107: aload_2\n 108: invokevirtual #47 // Method Point.getY:()I\n 111: aload_1\n 112: invokevirtual #47 // Method Point.getY:()I\n 115: if_icmple 134\n 118: new #36 // class Point\n 121: dup\n 122: aload_0\n 123: getfield #23 // Field location:LPoint;\n 126: invokevirtual #44 // Method Point.getX:()I\n 129: iconst_1\n 130: invokespecial #50 // Method Point.\"<init>\":(II)V\n 133: astore_2\n 134: aload_0\n 135: aload_2\n 136: aconst_null\n 137: iconst_2\n 138: aconst_null\n 139: invokestatic #54 // Method copy$default:(LDay24$Blizzard;LPoint;LPoint;ILjava/lang/Object;)LDay24$Blizzard;\n 142: areturn\n\n public final Point component1();\n Code:\n 0: aload_0\n 1: getfield #23 // Field location:LPoint;\n 4: areturn\n\n public final Point component2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field offset:LPoint;\n 4: areturn\n\n public final Day24$Blizzard copy(Point, Point);\n Code:\n 0: aload_1\n 1: ldc #9 // String location\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 offset\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class Day24$Blizzard\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: invokespecial #61 // Method \"<init>\":(LPoint;LPoint;)V\n 21: areturn\n\n public static Day24$Blizzard copy$default(Day24$Blizzard, Point, Point, 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 location:LPoint;\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 #25 // Field offset:LPoint;\n 21: astore_2\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokevirtual #63 // Method copy:(LPoint;LPoint;)LDay24$Blizzard;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #67 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #68 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #70 // String Blizzard(location=\n 9: invokevirtual #74 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #23 // Field location:LPoint;\n 16: invokevirtual #77 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #79 // String , offset=\n 21: invokevirtual #74 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #25 // Field offset:LPoint;\n 28: invokevirtual #77 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #82 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #84 // 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 location:LPoint;\n 4: invokevirtual #87 // Method Point.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 offset:LPoint;\n 16: invokevirtual #87 // Method Point.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 Day24$Blizzard\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day24$Blizzard\n 20: astore_2\n 21: aload_0\n 22: getfield #23 // Field location:LPoint;\n 25: aload_2\n 26: getfield #23 // Field location:LPoint;\n 29: invokestatic #96 // 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 offset:LPoint;\n 41: aload_2\n 42: getfield #25 // Field offset:LPoint;\n 45: invokestatic #96 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 48: ifne 53\n 51: iconst_0\n 52: ireturn\n 53: iconst_1\n 54: ireturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day24$MapState.class", "javap": "Compiled from \"Day24.kt\"\nfinal class Day24$MapState {\n public static final Day24$MapState$Companion Companion;\n\n private final Point boundary;\n\n private final java.util.Set<Day24$Blizzard> blizzards;\n\n private final java.util.Set<Point> unsafeSpots;\n\n public Day24$MapState(Point, java.util.Set<Day24$Blizzard>);\n Code:\n 0: aload_1\n 1: ldc #10 // String boundary\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 blizzards\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 #24 // Field boundary:LPoint;\n 21: aload_0\n 22: aload_2\n 23: putfield #27 // Field blizzards:Ljava/util/Set;\n 26: aload_0\n 27: aload_0\n 28: getfield #27 // Field blizzards:Ljava/util/Set;\n 31: checkcast #29 // class java/lang/Iterable\n 34: astore_3\n 35: astore 12\n 37: iconst_0\n 38: istore 4\n 40: aload_3\n 41: astore 5\n 43: new #31 // class java/util/ArrayList\n 46: dup\n 47: aload_3\n 48: bipush 10\n 50: invokestatic #37 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 53: invokespecial #40 // Method java/util/ArrayList.\"<init>\":(I)V\n 56: checkcast #42 // class java/util/Collection\n 59: astore 6\n 61: iconst_0\n 62: istore 7\n 64: aload 5\n 66: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 71: astore 8\n 73: aload 8\n 75: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 80: ifeq 123\n 83: aload 8\n 85: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 90: astore 9\n 92: aload 6\n 94: aload 9\n 96: checkcast #58 // class Day24$Blizzard\n 99: astore 10\n 101: astore 13\n 103: iconst_0\n 104: istore 11\n 106: aload 10\n 108: invokevirtual #62 // Method Day24$Blizzard.getLocation:()LPoint;\n 111: aload 13\n 113: swap\n 114: invokeinterface #66, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 119: pop\n 120: goto 73\n 123: aload 6\n 125: checkcast #68 // class java/util/List\n 128: nop\n 129: aload 12\n 131: swap\n 132: checkcast #29 // class java/lang/Iterable\n 135: invokestatic #72 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 138: putfield #75 // Field unsafeSpots:Ljava/util/Set;\n 141: return\n\n public final Point getBoundary();\n Code:\n 0: aload_0\n 1: getfield #24 // Field boundary:LPoint;\n 4: areturn\n\n public final java.util.Set<Day24$Blizzard> getBlizzards();\n Code:\n 0: aload_0\n 1: getfield #27 // Field blizzards:Ljava/util/Set;\n 4: areturn\n\n public final boolean isOpen(Point);\n Code:\n 0: aload_1\n 1: ldc #102 // String place\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #75 // Field unsafeSpots:Ljava/util/Set;\n 10: aload_1\n 11: invokeinterface #105, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 16: ifne 23\n 19: iconst_1\n 20: goto 24\n 23: iconst_0\n 24: ireturn\n\n public final boolean inBounds(Point);\n Code:\n 0: aload_1\n 1: ldc #102 // String place\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokevirtual #110 // Method Point.getX:()I\n 10: ifle 52\n 13: aload_1\n 14: invokevirtual #113 // Method Point.getY:()I\n 17: ifle 52\n 20: aload_1\n 21: invokevirtual #110 // Method Point.getX:()I\n 24: aload_0\n 25: getfield #24 // Field boundary:LPoint;\n 28: invokevirtual #110 // Method Point.getX:()I\n 31: if_icmpgt 52\n 34: aload_1\n 35: invokevirtual #113 // Method Point.getY:()I\n 38: aload_0\n 39: getfield #24 // Field boundary:LPoint;\n 42: invokevirtual #113 // Method Point.getY:()I\n 45: if_icmpgt 52\n 48: iconst_1\n 49: goto 53\n 52: iconst_0\n 53: ireturn\n\n public final Day24$MapState nextState();\n Code:\n 0: aload_0\n 1: aconst_null\n 2: aload_0\n 3: getfield #27 // Field blizzards:Ljava/util/Set;\n 6: checkcast #29 // class java/lang/Iterable\n 9: astore_1\n 10: astore 11\n 12: astore 10\n 14: iconst_0\n 15: istore_2\n 16: aload_1\n 17: astore_3\n 18: new #31 // class java/util/ArrayList\n 21: dup\n 22: aload_1\n 23: bipush 10\n 25: invokestatic #37 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 28: invokespecial #40 // Method java/util/ArrayList.\"<init>\":(I)V\n 31: checkcast #42 // class java/util/Collection\n 34: astore 4\n 36: iconst_0\n 37: istore 5\n 39: aload_3\n 40: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 6\n 47: aload 6\n 49: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 101\n 57: aload 6\n 59: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 7\n 66: aload 4\n 68: aload 7\n 70: checkcast #58 // class Day24$Blizzard\n 73: astore 8\n 75: astore 12\n 77: iconst_0\n 78: istore 9\n 80: aload 8\n 82: aload_0\n 83: getfield #24 // Field boundary:LPoint;\n 86: invokevirtual #118 // Method Day24$Blizzard.next:(LPoint;)LDay24$Blizzard;\n 89: aload 12\n 91: swap\n 92: invokeinterface #66, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 97: pop\n 98: goto 47\n 101: aload 4\n 103: checkcast #68 // class java/util/List\n 106: nop\n 107: astore 12\n 109: aload 10\n 111: aload 11\n 113: aload 12\n 115: checkcast #29 // class java/lang/Iterable\n 118: invokestatic #72 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 121: iconst_1\n 122: aconst_null\n 123: invokestatic #122 // Method copy$default:(LDay24$MapState;LPoint;Ljava/util/Set;ILjava/lang/Object;)LDay24$MapState;\n 126: areturn\n\n public final Point component1();\n Code:\n 0: aload_0\n 1: getfield #24 // Field boundary:LPoint;\n 4: areturn\n\n public final java.util.Set<Day24$Blizzard> component2();\n Code:\n 0: aload_0\n 1: getfield #27 // Field blizzards:Ljava/util/Set;\n 4: areturn\n\n public final Day24$MapState copy(Point, java.util.Set<Day24$Blizzard>);\n Code:\n 0: aload_1\n 1: ldc #10 // String boundary\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 blizzards\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class Day24$MapState\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: invokespecial #130 // Method \"<init>\":(LPoint;Ljava/util/Set;)V\n 21: areturn\n\n public static Day24$MapState copy$default(Day24$MapState, Point, java.util.Set, 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 #24 // Field boundary:LPoint;\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 #27 // Field blizzards:Ljava/util/Set;\n 21: astore_2\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokevirtual #132 // Method copy:(LPoint;Ljava/util/Set;)LDay24$MapState;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #136 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #137 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #139 // String MapState(boundary=\n 9: invokevirtual #143 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #24 // Field boundary:LPoint;\n 16: invokevirtual #146 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #148 // String , blizzards=\n 21: invokevirtual #143 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #27 // Field blizzards:Ljava/util/Set;\n 28: invokevirtual #146 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #151 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #153 // 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 #24 // Field boundary:LPoint;\n 4: invokevirtual #156 // Method Point.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #27 // Field blizzards:Ljava/util/Set;\n 16: invokevirtual #157 // Method java/lang/Object.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 Day24$MapState\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day24$MapState\n 20: astore_2\n 21: aload_0\n 22: getfield #24 // Field boundary:LPoint;\n 25: aload_2\n 26: getfield #24 // Field boundary:LPoint;\n 29: invokestatic #164 // 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 #27 // Field blizzards:Ljava/util/Set;\n 41: aload_2\n 42: getfield #27 // Field blizzards:Ljava/util/Set;\n 45: invokestatic #164 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 48: ifne 53\n 51: iconst_0\n 52: ireturn\n 53: iconst_1\n 54: ireturn\n\n static {};\n Code:\n 0: new #168 // class Day24$MapState$Companion\n 3: dup\n 4: aconst_null\n 5: invokespecial #171 // Method Day24$MapState$Companion.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 8: putstatic #175 // Field Companion:LDay24$MapState$Companion;\n 11: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day24$PathAttempt.class", "javap": "Compiled from \"Day24.kt\"\nfinal class Day24$PathAttempt {\n private final int steps;\n\n private final Point location;\n\n public Day24$PathAttempt(int, Point);\n Code:\n 0: aload_2\n 1: ldc #9 // String location\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: iload_1\n 12: putfield #22 // Field steps:I\n 15: aload_0\n 16: aload_2\n 17: putfield #25 // Field location:LPoint;\n 20: return\n\n public final int getSteps();\n Code:\n 0: aload_0\n 1: getfield #22 // Field steps:I\n 4: ireturn\n\n public final Point getLocation();\n Code:\n 0: aload_0\n 1: getfield #25 // Field location:LPoint;\n 4: areturn\n\n public final Day24$PathAttempt next(Point);\n Code:\n 0: aload_1\n 1: ldc #35 // String place\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day24$PathAttempt\n 9: dup\n 10: aload_0\n 11: getfield #22 // Field steps:I\n 14: iconst_1\n 15: iadd\n 16: aload_1\n 17: invokespecial #37 // Method \"<init>\":(ILPoint;)V\n 20: areturn\n\n public static Day24$PathAttempt next$default(Day24$PathAttempt, Point, int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #25 // Field location:LPoint;\n 10: astore_1\n 11: aload_0\n 12: aload_1\n 13: invokevirtual #41 // Method next:(LPoint;)LDay24$PathAttempt;\n 16: areturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #22 // Field steps:I\n 4: ireturn\n\n public final Point component2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field location:LPoint;\n 4: areturn\n\n public final Day24$PathAttempt copy(int, Point);\n Code:\n 0: aload_2\n 1: ldc #9 // String location\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day24$PathAttempt\n 9: dup\n 10: iload_1\n 11: aload_2\n 12: invokespecial #37 // Method \"<init>\":(ILPoint;)V\n 15: areturn\n\n public static Day24$PathAttempt copy$default(Day24$PathAttempt, int, Point, 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 #22 // Field steps:I\n 10: istore_1\n 11: iload_3\n 12: iconst_2\n 13: iand\n 14: ifeq 22\n 17: aload_0\n 18: getfield #25 // Field location:LPoint;\n 21: astore_2\n 22: aload_0\n 23: iload_1\n 24: aload_2\n 25: invokevirtual #49 // Method copy:(ILPoint;)LDay24$PathAttempt;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #53 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #54 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #56 // String PathAttempt(steps=\n 9: invokevirtual #60 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #22 // Field steps:I\n 16: invokevirtual #63 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #65 // String , location=\n 21: invokevirtual #60 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #25 // Field location:LPoint;\n 28: invokevirtual #68 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #71 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #73 // 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 #22 // Field steps:I\n 4: invokestatic #79 // 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 #25 // Field location:LPoint;\n 16: invokevirtual #83 // Method Point.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 Day24$PathAttempt\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day24$PathAttempt\n 20: astore_2\n 21: aload_0\n 22: getfield #22 // Field steps:I\n 25: aload_2\n 26: getfield #22 // Field steps:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #25 // Field location:LPoint;\n 38: aload_2\n 39: getfield #25 // Field location:LPoint;\n 42: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 45: ifne 50\n 48: iconst_0\n 49: ireturn\n 50: iconst_1\n 51: ireturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day24Kt.class", "javap": "Compiled from \"Day24.kt\"\npublic final class Day24Kt {\n public static final void main();\n Code:\n 0: new #8 // class Day24\n 3: dup\n 4: ldc #10 // String inputs/Day24\n 6: invokestatic #16 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 9: invokespecial #20 // Method Day24.\"<init>\":(Ljava/util/List;)V\n 12: astore_0\n 13: aload_0\n 14: invokevirtual #24 // Method Day24.part1:()I\n 17: istore_1\n 18: getstatic #30 // Field java/lang/System.out:Ljava/io/PrintStream;\n 21: iload_1\n 22: invokevirtual #36 // Method java/io/PrintStream.println:(I)V\n 25: aload_0\n 26: invokevirtual #39 // Method Day24.part2:()I\n 29: istore_1\n 30: getstatic #30 // Field java/lang/System.out:Ljava/io/PrintStream;\n 33: iload_1\n 34: invokevirtual #36 // Method java/io/PrintStream.println:(I)V\n 37: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #44 // Method main:()V\n 3: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day24$MapState$Companion.class", "javap": "Compiled from \"Day24.kt\"\npublic final class Day24$MapState$Companion {\n private Day24$MapState$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final Day24$MapState of(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #16 // String input\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #24 // class Point\n 9: dup\n 10: aload_1\n 11: invokestatic #30 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 14: checkcast #32 // class java/lang/CharSequence\n 17: invokestatic #38 // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I\n 20: iconst_1\n 21: isub\n 22: aload_1\n 23: invokestatic #41 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 26: iconst_1\n 27: isub\n 28: invokespecial #44 // Method Point.\"<init>\":(II)V\n 31: aload_1\n 32: checkcast #46 // class java/lang/Iterable\n 35: astore_2\n 36: astore 30\n 38: aload_2\n 39: astore_3\n 40: new #48 // class java/util/ArrayList\n 43: dup\n 44: invokespecial #49 // Method java/util/ArrayList.\"<init>\":()V\n 47: checkcast #51 // class java/util/Collection\n 50: astore 4\n 52: iconst_0\n 53: istore 5\n 55: aload_3\n 56: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 61: astore 6\n 63: aload 6\n 65: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 70: ifeq 417\n 73: aload 6\n 75: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 80: astore 7\n 82: iload 5\n 84: iinc 5, 1\n 87: istore 8\n 89: iload 8\n 91: ifge 97\n 94: invokestatic #68 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 97: iload 8\n 99: aload 7\n 101: checkcast #70 // class java/lang/String\n 104: astore 9\n 106: istore 10\n 108: iconst_0\n 109: istore 11\n 111: aload 9\n 113: checkcast #32 // class java/lang/CharSequence\n 116: astore 12\n 118: iconst_0\n 119: istore 13\n 121: aload 12\n 123: astore 14\n 125: new #48 // class java/util/ArrayList\n 128: dup\n 129: invokespecial #49 // Method java/util/ArrayList.\"<init>\":()V\n 132: checkcast #51 // class java/util/Collection\n 135: astore 15\n 137: iconst_0\n 138: istore 16\n 140: aload 14\n 142: astore 17\n 144: iconst_0\n 145: istore 18\n 147: iconst_0\n 148: istore 19\n 150: iconst_0\n 151: istore 20\n 153: iload 20\n 155: aload 17\n 157: invokeinterface #74, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 162: if_icmpge 396\n 165: aload 17\n 167: iload 20\n 169: invokeinterface #78, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 174: istore 21\n 176: iload 19\n 178: iinc 19, 1\n 181: iload 21\n 183: istore 22\n 185: istore 23\n 187: iconst_0\n 188: istore 24\n 190: iload 23\n 192: iload 22\n 194: istore 25\n 196: istore 26\n 198: iconst_0\n 199: istore 27\n 201: iload 25\n 203: lookupswitch { // 4\n 60: 274\n 62: 244\n 94: 334\n 118: 304\n default: 364\n }\n 244: new #80 // class Day24$Blizzard\n 247: dup\n 248: new #24 // class Point\n 251: dup\n 252: iload 26\n 254: iload 10\n 256: invokespecial #44 // Method Point.\"<init>\":(II)V\n 259: new #24 // class Point\n 262: dup\n 263: iconst_1\n 264: iconst_0\n 265: invokespecial #44 // Method Point.\"<init>\":(II)V\n 268: invokespecial #83 // Method Day24$Blizzard.\"<init>\":(LPoint;LPoint;)V\n 271: goto 365\n 274: new #80 // class Day24$Blizzard\n 277: dup\n 278: new #24 // class Point\n 281: dup\n 282: iload 26\n 284: iload 10\n 286: invokespecial #44 // Method Point.\"<init>\":(II)V\n 289: new #24 // class Point\n 292: dup\n 293: iconst_m1\n 294: iconst_0\n 295: invokespecial #44 // Method Point.\"<init>\":(II)V\n 298: invokespecial #83 // Method Day24$Blizzard.\"<init>\":(LPoint;LPoint;)V\n 301: goto 365\n 304: new #80 // class Day24$Blizzard\n 307: dup\n 308: new #24 // class Point\n 311: dup\n 312: iload 26\n 314: iload 10\n 316: invokespecial #44 // Method Point.\"<init>\":(II)V\n 319: new #24 // class Point\n 322: dup\n 323: iconst_0\n 324: iconst_1\n 325: invokespecial #44 // Method Point.\"<init>\":(II)V\n 328: invokespecial #83 // Method Day24$Blizzard.\"<init>\":(LPoint;LPoint;)V\n 331: goto 365\n 334: new #80 // class Day24$Blizzard\n 337: dup\n 338: new #24 // class Point\n 341: dup\n 342: iload 26\n 344: iload 10\n 346: invokespecial #44 // Method Point.\"<init>\":(II)V\n 349: new #24 // class Point\n 352: dup\n 353: iconst_0\n 354: iconst_m1\n 355: invokespecial #44 // Method Point.\"<init>\":(II)V\n 358: invokespecial #83 // Method Day24$Blizzard.\"<init>\":(LPoint;LPoint;)V\n 361: goto 365\n 364: aconst_null\n 365: nop\n 366: dup\n 367: ifnull 388\n 370: astore 28\n 372: iconst_0\n 373: istore 29\n 375: aload 15\n 377: aload 28\n 379: invokeinterface #87, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 384: pop\n 385: goto 389\n 388: pop\n 389: nop\n 390: iinc 20, 1\n 393: goto 153\n 396: nop\n 397: aload 15\n 399: checkcast #89 // class java/util/List\n 402: nop\n 403: checkcast #46 // class java/lang/Iterable\n 406: nop\n 407: aload 4\n 409: swap\n 410: invokestatic #93 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 413: pop\n 414: goto 63\n 417: aload 4\n 419: checkcast #89 // class java/util/List\n 422: aload 30\n 424: swap\n 425: checkcast #46 // class java/lang/Iterable\n 428: invokestatic #97 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 431: astore 31\n 433: astore 32\n 435: new #99 // class Day24$MapState\n 438: dup\n 439: aload 32\n 441: aload 31\n 443: invokespecial #102 // Method Day24$MapState.\"<init>\":(LPoint;Ljava/util/Set;)V\n 446: areturn\n\n public Day24$MapState$Companion(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #131 // Method \"<init>\":()V\n 4: return\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day24.class", "javap": "Compiled from \"Day24.kt\"\npublic final class Day24 {\n private final Day24$MapState initialMapState;\n\n private final Point start;\n\n private final Point goal;\n\n public Day24(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\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: invokespecial #19 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: getstatic #25 // Field Day24$MapState.Companion:LDay24$MapState$Companion;\n 14: aload_1\n 15: invokevirtual #31 // Method Day24$MapState$Companion.of:(Ljava/util/List;)LDay24$MapState;\n 18: putfield #35 // Field initialMapState:LDay24$MapState;\n 21: aload_0\n 22: aload_1\n 23: invokestatic #41 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 26: checkcast #43 // class java/lang/CharSequence\n 29: astore_2\n 30: astore 8\n 32: iconst_0\n 33: istore_3\n 34: iconst_0\n 35: istore 4\n 37: aload_2\n 38: invokeinterface #47, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 43: istore 5\n 45: iload 4\n 47: iload 5\n 49: if_icmpge 91\n 52: aload_2\n 53: iload 4\n 55: invokeinterface #51, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 60: istore 6\n 62: iconst_0\n 63: istore 7\n 65: iload 6\n 67: bipush 46\n 69: if_icmpne 76\n 72: iconst_1\n 73: goto 77\n 76: iconst_0\n 77: ifeq 85\n 80: iload 4\n 82: goto 92\n 85: iinc 4, 1\n 88: goto 45\n 91: iconst_m1\n 92: istore 9\n 94: aload 8\n 96: iload 9\n 98: iconst_0\n 99: istore 10\n 101: istore 11\n 103: new #53 // class Point\n 106: dup\n 107: iload 11\n 109: iload 10\n 111: invokespecial #56 // Method Point.\"<init>\":(II)V\n 114: putfield #60 // Field start:LPoint;\n 117: aload_0\n 118: aload_1\n 119: invokestatic #63 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 122: checkcast #43 // class java/lang/CharSequence\n 125: astore_2\n 126: astore 8\n 128: iconst_0\n 129: istore_3\n 130: iconst_0\n 131: istore 4\n 133: aload_2\n 134: invokeinterface #47, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 139: istore 5\n 141: iload 4\n 143: iload 5\n 145: if_icmpge 187\n 148: aload_2\n 149: iload 4\n 151: invokeinterface #51, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 156: istore 6\n 158: iconst_0\n 159: istore 7\n 161: iload 6\n 163: bipush 46\n 165: if_icmpne 172\n 168: iconst_1\n 169: goto 173\n 172: iconst_0\n 173: ifeq 181\n 176: iload 4\n 178: goto 188\n 181: iinc 4, 1\n 184: goto 141\n 187: iconst_m1\n 188: istore 9\n 190: aload 8\n 192: iload 9\n 194: aload_1\n 195: invokestatic #67 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 198: istore 12\n 200: istore 13\n 202: new #53 // class Point\n 205: dup\n 206: iload 13\n 208: iload 12\n 210: invokespecial #56 // Method Point.\"<init>\":(II)V\n 213: putfield #70 // Field goal:LPoint;\n 216: return\n\n public final int part1();\n Code:\n 0: aload_0\n 1: aconst_null\n 2: aconst_null\n 3: aconst_null\n 4: iconst_0\n 5: bipush 15\n 7: aconst_null\n 8: invokestatic #89 // Method solve$default:(LDay24;LPoint;LPoint;LDay24$MapState;IILjava/lang/Object;)Lkotlin/Pair;\n 11: invokevirtual #95 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 14: checkcast #97 // class java/lang/Number\n 17: invokevirtual #100 // Method java/lang/Number.intValue:()I\n 20: ireturn\n\n public final int part2();\n Code:\n 0: aload_0\n 1: aconst_null\n 2: aconst_null\n 3: aconst_null\n 4: iconst_0\n 5: bipush 15\n 7: aconst_null\n 8: invokestatic #89 // Method solve$default:(LDay24;LPoint;LPoint;LDay24$MapState;IILjava/lang/Object;)Lkotlin/Pair;\n 11: astore_1\n 12: aload_0\n 13: aload_0\n 14: getfield #70 // Field goal:LPoint;\n 17: aload_0\n 18: getfield #60 // Field start:LPoint;\n 21: aload_1\n 22: invokevirtual #104 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 25: checkcast #21 // class Day24$MapState\n 28: aload_1\n 29: invokevirtual #95 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 32: checkcast #97 // class java/lang/Number\n 35: invokevirtual #100 // Method java/lang/Number.intValue:()I\n 38: invokespecial #108 // Method solve:(LPoint;LPoint;LDay24$MapState;I)Lkotlin/Pair;\n 41: astore_2\n 42: aload_0\n 43: aload_0\n 44: getfield #60 // Field start:LPoint;\n 47: aload_0\n 48: getfield #70 // Field goal:LPoint;\n 51: aload_2\n 52: invokevirtual #104 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 55: checkcast #21 // class Day24$MapState\n 58: aload_2\n 59: invokevirtual #95 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 62: checkcast #97 // class java/lang/Number\n 65: invokevirtual #100 // Method java/lang/Number.intValue:()I\n 68: invokespecial #108 // Method solve:(LPoint;LPoint;LDay24$MapState;I)Lkotlin/Pair;\n 71: astore_3\n 72: aload_3\n 73: invokevirtual #95 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 76: checkcast #97 // class java/lang/Number\n 79: invokevirtual #100 // Method java/lang/Number.intValue:()I\n 82: ireturn\n\n private final kotlin.Pair<java.lang.Integer, Day24$MapState> solve(Point, Point, Day24$MapState, int);\n Code:\n 0: iconst_1\n 1: anewarray #91 // class kotlin/Pair\n 4: astore 6\n 6: aload 6\n 8: iconst_0\n 9: iload 4\n 11: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 14: aload_3\n 15: invokestatic #125 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 18: aastore\n 19: aload 6\n 21: invokestatic #131 // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 24: astore 5\n 26: iconst_1\n 27: anewarray #133 // class Day24$PathAttempt\n 30: astore 7\n 32: aload 7\n 34: iconst_0\n 35: new #133 // class Day24$PathAttempt\n 38: dup\n 39: iload 4\n 41: aload_1\n 42: invokespecial #136 // Method Day24$PathAttempt.\"<init>\":(ILPoint;)V\n 45: aastore\n 46: aload 7\n 48: invokestatic #140 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 51: astore 6\n 53: new #142 // class java/util/LinkedHashSet\n 56: dup\n 57: invokespecial #143 // Method java/util/LinkedHashSet.\"<init>\":()V\n 60: checkcast #145 // class java/util/Set\n 63: astore 7\n 65: aload 6\n 67: checkcast #147 // class java/util/Collection\n 70: invokeinterface #151, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 75: ifne 82\n 78: iconst_1\n 79: goto 83\n 82: iconst_0\n 83: ifeq 437\n 86: aload 6\n 88: invokeinterface #154, 1 // InterfaceMethod java/util/List.removeFirst:()Ljava/lang/Object;\n 93: dup\n 94: ldc #156 // String removeFirst(...)\n 96: invokestatic #159 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 99: checkcast #133 // class Day24$PathAttempt\n 102: astore 8\n 104: aload 7\n 106: aload 8\n 108: invokeinterface #163, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 113: ifne 65\n 116: aload 7\n 118: checkcast #147 // class java/util/Collection\n 121: aload 8\n 123: invokeinterface #166, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 128: pop\n 129: aload 5\n 131: aload 8\n 133: invokevirtual #169 // Method Day24$PathAttempt.getSteps:()I\n 136: iconst_1\n 137: iadd\n 138: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 141: aload 5\n 143: invokedynamic #189, 0 // InvokeDynamic #0:invoke:(Ljava/util/Map;)Lkotlin/jvm/functions/Function1;\n 148: invokedynamic #200, 0 // InvokeDynamic #1:apply:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Function;\n 153: invokeinterface #206, 3 // InterfaceMethod java/util/Map.computeIfAbsent:(Ljava/lang/Object;Ljava/util/function/Function;)Ljava/lang/Object;\n 158: dup\n 159: ldc #208 // String computeIfAbsent(...)\n 161: invokestatic #159 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 164: checkcast #21 // class Day24$MapState\n 167: astore 9\n 169: aload 9\n 171: aload 8\n 173: invokevirtual #212 // Method Day24$PathAttempt.getLocation:()LPoint;\n 176: invokevirtual #216 // Method Day24$MapState.isOpen:(LPoint;)Z\n 179: ifeq 198\n 182: aload 6\n 184: aload 8\n 186: aconst_null\n 187: iconst_1\n 188: aconst_null\n 189: invokestatic #220 // Method Day24$PathAttempt.next$default:(LDay24$PathAttempt;LPoint;ILjava/lang/Object;)LDay24$PathAttempt;\n 192: invokeinterface #221, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 197: pop\n 198: aload 8\n 200: invokevirtual #212 // Method Day24$PathAttempt.getLocation:()LPoint;\n 203: invokevirtual #225 // Method Point.adjacents:()Ljava/util/Set;\n 206: astore 10\n 208: aload 10\n 210: aload_2\n 211: invokeinterface #163, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 216: ifeq 239\n 219: new #91 // class kotlin/Pair\n 222: dup\n 223: aload 8\n 225: invokevirtual #169 // Method Day24$PathAttempt.getSteps:()I\n 228: iconst_1\n 229: iadd\n 230: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 233: aload 9\n 235: invokespecial #228 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 238: areturn\n 239: aload 10\n 241: checkcast #230 // class java/lang/Iterable\n 244: astore 11\n 246: nop\n 247: iconst_0\n 248: istore 12\n 250: aload 11\n 252: astore 13\n 254: new #232 // class java/util/ArrayList\n 257: dup\n 258: invokespecial #233 // Method java/util/ArrayList.\"<init>\":()V\n 261: checkcast #147 // class java/util/Collection\n 264: astore 14\n 266: iconst_0\n 267: istore 15\n 269: aload 13\n 271: invokeinterface #237, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 276: astore 16\n 278: aload 16\n 280: invokeinterface #242, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 285: ifeq 360\n 288: aload 16\n 290: invokeinterface #245, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 295: astore 17\n 297: aload 17\n 299: checkcast #53 // class Point\n 302: astore 18\n 304: iconst_0\n 305: istore 19\n 307: aload 18\n 309: aload_0\n 310: getfield #60 // Field start:LPoint;\n 313: invokestatic #249 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 316: ifne 339\n 319: aload 9\n 321: aload 18\n 323: invokevirtual #252 // Method Day24$MapState.inBounds:(LPoint;)Z\n 326: ifeq 343\n 329: aload 9\n 331: aload 18\n 333: invokevirtual #216 // Method Day24$MapState.isOpen:(LPoint;)Z\n 336: ifeq 343\n 339: iconst_1\n 340: goto 344\n 343: iconst_0\n 344: ifeq 278\n 347: aload 14\n 349: aload 17\n 351: invokeinterface #166, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 356: pop\n 357: goto 278\n 360: aload 14\n 362: checkcast #84 // class java/util/List\n 365: nop\n 366: checkcast #230 // class java/lang/Iterable\n 369: astore 11\n 371: nop\n 372: iconst_0\n 373: istore 12\n 375: aload 11\n 377: invokeinterface #237, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 382: astore 13\n 384: aload 13\n 386: invokeinterface #242, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 391: ifeq 433\n 394: aload 13\n 396: invokeinterface #245, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 401: astore 14\n 403: aload 14\n 405: checkcast #53 // class Point\n 408: astore 15\n 410: iconst_0\n 411: istore 16\n 413: aload 6\n 415: aload 8\n 417: aload 15\n 419: invokevirtual #255 // Method Day24$PathAttempt.next:(LPoint;)LDay24$PathAttempt;\n 422: invokeinterface #221, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 427: pop\n 428: nop\n 429: nop\n 430: goto 384\n 433: nop\n 434: goto 65\n 437: new #257 // class java/lang/IllegalStateException\n 440: dup\n 441: ldc_w #259 // String No paths found\n 444: invokespecial #262 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 447: athrow\n\n static kotlin.Pair solve$default(Day24, Point, Point, Day24$MapState, int, int, java.lang.Object);\n Code:\n 0: iload 5\n 2: iconst_1\n 3: iand\n 4: ifeq 12\n 7: aload_0\n 8: getfield #60 // Field start:LPoint;\n 11: astore_1\n 12: iload 5\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #70 // Field goal:LPoint;\n 23: astore_2\n 24: iload 5\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #35 // Field initialMapState:LDay24$MapState;\n 35: astore_3\n 36: iload 5\n 38: bipush 8\n 40: iand\n 41: ifeq 47\n 44: iconst_0\n 45: istore 4\n 47: aload_0\n 48: aload_1\n 49: aload_2\n 50: aload_3\n 51: iload 4\n 53: invokespecial #108 // Method solve:(LPoint;LPoint;LDay24$MapState;I)Lkotlin/Pair;\n 56: areturn\n\n private static final Day24$MapState solve$lambda$2(java.util.Map, java.lang.Integer);\n Code:\n 0: aload_1\n 1: ldc_w #292 // String key\n 4: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: aload_1\n 9: invokevirtual #293 // Method java/lang/Integer.intValue:()I\n 12: iconst_1\n 13: isub\n 14: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 17: invokestatic #297 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 20: checkcast #21 // class Day24$MapState\n 23: invokevirtual #301 // Method Day24$MapState.nextState:()LDay24$MapState;\n 26: areturn\n\n private static final Day24$MapState solve$lambda$3(kotlin.jvm.functions.Function1, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #307, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #21 // class Day24$MapState\n 10: areturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day05.kt
fun main() { data class Common(val input: List<String>) { lateinit var moves: List<String> lateinit var stacks: List<ArrayDeque<Char>> init { parse() } fun parse() { val map = input.groupBy { when { it.contains("move") -> "moves" it.contains("[") -> "crates" else -> "garbage" } } val maxStringLength = map["crates"]!!.maxOf { it.length } val crates = map["crates"]!! .map { it.padEnd(maxStringLength) .toList() .chunked(4) .map { list -> list[1] } } val rowLength = crates.first().size stacks = List(rowLength) { ArrayDeque() } crates.forEach { it.forEachIndexed { i, c -> stacks[i].addLast(c) } } moves = map["moves"]!!.map { it.replace("move", "") .replace("from", "") .replace("to", "") .trim() } } } fun part1(input: List<String>): String { val common = Common(input) common.moves.forEach { val (count, from, to) = it.split(" ").filterNot { s -> s.isBlank() }.map { n -> n.toInt() } repeat (count) { var element: Char do { element = common.stacks[from - 1].removeFirst() } while(element == ' ') common.stacks[to-1].addFirst(element) } } return List(common.stacks.size) { i -> common.stacks[i].removeFirst() }.joinToString(separator = "") } fun part2(input: List<String>): String { val main = Common(input) main.moves.forEach { val (count, from, to) = it.split(" ").filterNot { s -> s.isBlank() }.map { n -> n.toInt() } val cratesToMove = mutableListOf<Char>() repeat (count) { if (main.stacks[from -1].isNotEmpty()) { var element: Char do { element = main.stacks[from - 1].removeFirst() if (element != ' ') { cratesToMove.add(element) } } while (element == ' ') } } cratesToMove.reversed().forEach { c -> main.stacks[to - 1].addFirst(c) } } return List(main.stacks.size) { i -> main.stacks[i].removeFirst() }.joinToString(separator = "") } val input = readInput("inputs/Day05") println(part1(input)) println(part2(input)) }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day05Kt.class", "javap": "Compiled from \"Day05.kt\"\npublic final class Day05Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/Day05\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 main$part1:(Ljava/util/List;)Ljava/lang/String;\n 10: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 13: swap\n 14: invokevirtual #30 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 17: aload_0\n 18: invokestatic #33 // Method main$part2:(Ljava/util/List;)Ljava/lang/String;\n 21: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 24: swap\n 25: invokevirtual #30 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 28: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #38 // Method main:()V\n 3: return\n\n private static final java.lang.String main$part1(java.util.List<java.lang.String>);\n Code:\n 0: new #43 // class Day05Kt$main$Common\n 3: dup\n 4: aload_0\n 5: invokespecial #47 // Method Day05Kt$main$Common.\"<init>\":(Ljava/util/List;)V\n 8: astore_1\n 9: aload_1\n 10: invokevirtual #51 // Method Day05Kt$main$Common.getMoves:()Ljava/util/List;\n 13: checkcast #53 // class java/lang/Iterable\n 16: astore_2\n 17: iconst_0\n 18: istore_3\n 19: aload_2\n 20: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 25: astore 4\n 27: aload 4\n 29: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 34: ifeq 422\n 37: aload 4\n 39: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 44: astore 5\n 46: aload 5\n 48: checkcast #69 // class java/lang/String\n 51: astore 6\n 53: iconst_0\n 54: istore 7\n 56: aload 6\n 58: checkcast #71 // class java/lang/CharSequence\n 61: iconst_1\n 62: anewarray #69 // class java/lang/String\n 65: astore 8\n 67: aload 8\n 69: iconst_0\n 70: ldc #73 // String\n 72: aastore\n 73: aload 8\n 75: iconst_0\n 76: iconst_0\n 77: bipush 6\n 79: aconst_null\n 80: invokestatic #79 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 83: checkcast #53 // class java/lang/Iterable\n 86: astore 8\n 88: iconst_0\n 89: istore 9\n 91: aload 8\n 93: astore 10\n 95: new #81 // class java/util/ArrayList\n 98: dup\n 99: invokespecial #83 // Method java/util/ArrayList.\"<init>\":()V\n 102: checkcast #85 // class java/util/Collection\n 105: astore 11\n 107: iconst_0\n 108: istore 12\n 110: aload 10\n 112: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 117: astore 13\n 119: aload 13\n 121: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 126: ifeq 172\n 129: aload 13\n 131: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 136: astore 14\n 138: aload 14\n 140: checkcast #69 // class java/lang/String\n 143: astore 15\n 145: iconst_0\n 146: istore 16\n 148: aload 15\n 150: checkcast #71 // class java/lang/CharSequence\n 153: invokestatic #89 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 156: ifne 119\n 159: aload 11\n 161: aload 14\n 163: invokeinterface #93, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 168: pop\n 169: goto 119\n 172: aload 11\n 174: checkcast #95 // class java/util/List\n 177: nop\n 178: checkcast #53 // class java/lang/Iterable\n 181: astore 8\n 183: nop\n 184: iconst_0\n 185: istore 9\n 187: aload 8\n 189: astore 10\n 191: new #81 // class java/util/ArrayList\n 194: dup\n 195: aload 8\n 197: bipush 10\n 199: invokestatic #101 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 202: invokespecial #104 // Method java/util/ArrayList.\"<init>\":(I)V\n 205: checkcast #85 // class java/util/Collection\n 208: astore 11\n 210: iconst_0\n 211: istore 12\n 213: aload 10\n 215: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 220: astore 13\n 222: aload 13\n 224: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 229: ifeq 276\n 232: aload 13\n 234: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 239: astore 14\n 241: aload 11\n 243: aload 14\n 245: checkcast #69 // class java/lang/String\n 248: astore 15\n 250: astore 17\n 252: iconst_0\n 253: istore 16\n 255: aload 15\n 257: invokestatic #110 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 260: nop\n 261: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 264: aload 17\n 266: swap\n 267: invokeinterface #93, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 272: pop\n 273: goto 222\n 276: aload 11\n 278: checkcast #95 // class java/util/List\n 281: nop\n 282: astore 18\n 284: aload 18\n 286: iconst_0\n 287: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 292: checkcast #120 // class java/lang/Number\n 295: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 298: istore 8\n 300: aload 18\n 302: iconst_1\n 303: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 308: checkcast #120 // class java/lang/Number\n 311: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 314: istore 9\n 316: aload 18\n 318: iconst_2\n 319: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 324: checkcast #120 // class java/lang/Number\n 327: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 330: istore 10\n 332: iconst_0\n 333: istore 11\n 335: iload 11\n 337: iload 8\n 339: if_icmpge 417\n 342: iload 11\n 344: istore 12\n 346: iconst_0\n 347: istore 13\n 349: iconst_0\n 350: istore 14\n 352: aload_1\n 353: invokevirtual #127 // Method Day05Kt$main$Common.getStacks:()Ljava/util/List;\n 356: iload 9\n 358: iconst_1\n 359: isub\n 360: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 365: checkcast #129 // class kotlin/collections/ArrayDeque\n 368: invokevirtual #132 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;\n 371: checkcast #134 // class java/lang/Character\n 374: invokevirtual #138 // Method java/lang/Character.charValue:()C\n 377: istore 14\n 379: iload 14\n 381: bipush 32\n 383: if_icmpeq 352\n 386: aload_1\n 387: invokevirtual #127 // Method Day05Kt$main$Common.getStacks:()Ljava/util/List;\n 390: iload 10\n 392: iconst_1\n 393: isub\n 394: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 399: checkcast #129 // class kotlin/collections/ArrayDeque\n 402: iload 14\n 404: invokestatic #141 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 407: invokevirtual #144 // Method kotlin/collections/ArrayDeque.addFirst:(Ljava/lang/Object;)V\n 410: nop\n 411: iinc 11, 1\n 414: goto 335\n 417: nop\n 418: nop\n 419: goto 27\n 422: nop\n 423: aload_1\n 424: invokevirtual #127 // Method Day05Kt$main$Common.getStacks:()Ljava/util/List;\n 427: invokeinterface #147, 1 // InterfaceMethod java/util/List.size:()I\n 432: istore_2\n 433: new #81 // class java/util/ArrayList\n 436: dup\n 437: iload_2\n 438: invokespecial #104 // Method java/util/ArrayList.\"<init>\":(I)V\n 441: astore_3\n 442: iconst_0\n 443: istore 4\n 445: iload 4\n 447: iload_2\n 448: if_icmpge 504\n 451: iload 4\n 453: istore 5\n 455: aload_3\n 456: iload 5\n 458: istore 6\n 460: astore 19\n 462: iconst_0\n 463: istore 7\n 465: aload_1\n 466: invokevirtual #127 // Method Day05Kt$main$Common.getStacks:()Ljava/util/List;\n 469: iload 6\n 471: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 476: checkcast #129 // class kotlin/collections/ArrayDeque\n 479: invokevirtual #132 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;\n 482: checkcast #134 // class java/lang/Character\n 485: invokevirtual #138 // Method java/lang/Character.charValue:()C\n 488: invokestatic #141 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 491: aload 19\n 493: swap\n 494: invokevirtual #148 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 497: pop\n 498: iinc 4, 1\n 501: goto 445\n 504: aload_3\n 505: checkcast #95 // class java/util/List\n 508: checkcast #53 // class java/lang/Iterable\n 511: ldc #150 // String\n 513: checkcast #71 // class java/lang/CharSequence\n 516: aconst_null\n 517: aconst_null\n 518: iconst_0\n 519: aconst_null\n 520: aconst_null\n 521: bipush 62\n 523: aconst_null\n 524: invokestatic #154 // 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 527: areturn\n\n private static final java.lang.String main$part2(java.util.List<java.lang.String>);\n Code:\n 0: new #43 // class Day05Kt$main$Common\n 3: dup\n 4: aload_0\n 5: invokespecial #47 // Method Day05Kt$main$Common.\"<init>\":(Ljava/util/List;)V\n 8: astore_1\n 9: aload_1\n 10: invokevirtual #51 // Method Day05Kt$main$Common.getMoves:()Ljava/util/List;\n 13: checkcast #53 // class java/lang/Iterable\n 16: astore_2\n 17: iconst_0\n 18: istore_3\n 19: aload_2\n 20: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 25: astore 4\n 27: aload 4\n 29: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 34: ifeq 549\n 37: aload 4\n 39: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 44: astore 5\n 46: aload 5\n 48: checkcast #69 // class java/lang/String\n 51: astore 6\n 53: iconst_0\n 54: istore 7\n 56: aload 6\n 58: checkcast #71 // class java/lang/CharSequence\n 61: iconst_1\n 62: anewarray #69 // class java/lang/String\n 65: astore 8\n 67: aload 8\n 69: iconst_0\n 70: ldc #73 // String\n 72: aastore\n 73: aload 8\n 75: iconst_0\n 76: iconst_0\n 77: bipush 6\n 79: aconst_null\n 80: invokestatic #79 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 83: checkcast #53 // class java/lang/Iterable\n 86: astore 8\n 88: iconst_0\n 89: istore 9\n 91: aload 8\n 93: astore 10\n 95: new #81 // class java/util/ArrayList\n 98: dup\n 99: invokespecial #83 // Method java/util/ArrayList.\"<init>\":()V\n 102: checkcast #85 // class java/util/Collection\n 105: astore 11\n 107: iconst_0\n 108: istore 12\n 110: aload 10\n 112: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 117: astore 13\n 119: aload 13\n 121: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 126: ifeq 172\n 129: aload 13\n 131: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 136: astore 14\n 138: aload 14\n 140: checkcast #69 // class java/lang/String\n 143: astore 15\n 145: iconst_0\n 146: istore 16\n 148: aload 15\n 150: checkcast #71 // class java/lang/CharSequence\n 153: invokestatic #89 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 156: ifne 119\n 159: aload 11\n 161: aload 14\n 163: invokeinterface #93, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 168: pop\n 169: goto 119\n 172: aload 11\n 174: checkcast #95 // class java/util/List\n 177: nop\n 178: checkcast #53 // class java/lang/Iterable\n 181: astore 8\n 183: nop\n 184: iconst_0\n 185: istore 9\n 187: aload 8\n 189: astore 10\n 191: new #81 // class java/util/ArrayList\n 194: dup\n 195: aload 8\n 197: bipush 10\n 199: invokestatic #101 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 202: invokespecial #104 // Method java/util/ArrayList.\"<init>\":(I)V\n 205: checkcast #85 // class java/util/Collection\n 208: astore 11\n 210: iconst_0\n 211: istore 12\n 213: aload 10\n 215: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 220: astore 13\n 222: aload 13\n 224: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 229: ifeq 276\n 232: aload 13\n 234: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 239: astore 14\n 241: aload 11\n 243: aload 14\n 245: checkcast #69 // class java/lang/String\n 248: astore 15\n 250: astore 17\n 252: iconst_0\n 253: istore 16\n 255: aload 15\n 257: invokestatic #110 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 260: nop\n 261: invokestatic #114 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 264: aload 17\n 266: swap\n 267: invokeinterface #93, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 272: pop\n 273: goto 222\n 276: aload 11\n 278: checkcast #95 // class java/util/List\n 281: nop\n 282: astore 18\n 284: aload 18\n 286: iconst_0\n 287: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 292: checkcast #120 // class java/lang/Number\n 295: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 298: istore 8\n 300: aload 18\n 302: iconst_1\n 303: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 308: checkcast #120 // class java/lang/Number\n 311: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 314: istore 9\n 316: aload 18\n 318: iconst_2\n 319: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 324: checkcast #120 // class java/lang/Number\n 327: invokevirtual #124 // Method java/lang/Number.intValue:()I\n 330: istore 10\n 332: new #81 // class java/util/ArrayList\n 335: dup\n 336: invokespecial #83 // Method java/util/ArrayList.\"<init>\":()V\n 339: checkcast #95 // class java/util/List\n 342: astore 11\n 344: iconst_0\n 345: istore 12\n 347: iload 12\n 349: iload 8\n 351: if_icmpge 457\n 354: iload 12\n 356: istore 13\n 358: iconst_0\n 359: istore 14\n 361: aload_1\n 362: invokevirtual #127 // Method Day05Kt$main$Common.getStacks:()Ljava/util/List;\n 365: iload 9\n 367: iconst_1\n 368: isub\n 369: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 374: checkcast #85 // class java/util/Collection\n 377: invokeinterface #192, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 382: ifne 389\n 385: iconst_1\n 386: goto 390\n 389: iconst_0\n 390: ifeq 450\n 393: iconst_0\n 394: istore 15\n 396: aload_1\n 397: invokevirtual #127 // Method Day05Kt$main$Common.getStacks:()Ljava/util/List;\n 400: iload 9\n 402: iconst_1\n 403: isub\n 404: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 409: checkcast #129 // class kotlin/collections/ArrayDeque\n 412: invokevirtual #132 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;\n 415: checkcast #134 // class java/lang/Character\n 418: invokevirtual #138 // Method java/lang/Character.charValue:()C\n 421: istore 15\n 423: iload 15\n 425: bipush 32\n 427: if_icmpeq 443\n 430: aload 11\n 432: iload 15\n 434: invokestatic #141 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 437: invokeinterface #193, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 442: pop\n 443: iload 15\n 445: bipush 32\n 447: if_icmpeq 396\n 450: nop\n 451: iinc 12, 1\n 454: goto 347\n 457: aload 11\n 459: checkcast #53 // class java/lang/Iterable\n 462: invokestatic #197 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 465: checkcast #53 // class java/lang/Iterable\n 468: astore 12\n 470: iconst_0\n 471: istore 13\n 473: aload 12\n 475: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 480: astore 14\n 482: aload 14\n 484: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 489: ifeq 543\n 492: aload 14\n 494: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 499: astore 15\n 501: aload 15\n 503: checkcast #134 // class java/lang/Character\n 506: invokevirtual #138 // Method java/lang/Character.charValue:()C\n 509: istore 16\n 511: iconst_0\n 512: istore 19\n 514: aload_1\n 515: invokevirtual #127 // Method Day05Kt$main$Common.getStacks:()Ljava/util/List;\n 518: iload 10\n 520: iconst_1\n 521: isub\n 522: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 527: checkcast #129 // class kotlin/collections/ArrayDeque\n 530: iload 16\n 532: invokestatic #141 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 535: invokevirtual #144 // Method kotlin/collections/ArrayDeque.addFirst:(Ljava/lang/Object;)V\n 538: nop\n 539: nop\n 540: goto 482\n 543: nop\n 544: nop\n 545: nop\n 546: goto 27\n 549: nop\n 550: aload_1\n 551: invokevirtual #127 // Method Day05Kt$main$Common.getStacks:()Ljava/util/List;\n 554: invokeinterface #147, 1 // InterfaceMethod java/util/List.size:()I\n 559: istore_2\n 560: new #81 // class java/util/ArrayList\n 563: dup\n 564: iload_2\n 565: invokespecial #104 // Method java/util/ArrayList.\"<init>\":(I)V\n 568: astore_3\n 569: iconst_0\n 570: istore 4\n 572: iload 4\n 574: iload_2\n 575: if_icmpge 631\n 578: iload 4\n 580: istore 5\n 582: aload_3\n 583: iload 5\n 585: istore 6\n 587: astore 20\n 589: iconst_0\n 590: istore 7\n 592: aload_1\n 593: invokevirtual #127 // Method Day05Kt$main$Common.getStacks:()Ljava/util/List;\n 596: iload 6\n 598: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 603: checkcast #129 // class kotlin/collections/ArrayDeque\n 606: invokevirtual #132 // Method kotlin/collections/ArrayDeque.removeFirst:()Ljava/lang/Object;\n 609: checkcast #134 // class java/lang/Character\n 612: invokevirtual #138 // Method java/lang/Character.charValue:()C\n 615: invokestatic #141 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 618: aload 20\n 620: swap\n 621: invokevirtual #148 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 624: pop\n 625: iinc 4, 1\n 628: goto 572\n 631: aload_3\n 632: checkcast #95 // class java/util/List\n 635: checkcast #53 // class java/lang/Iterable\n 638: ldc #150 // String\n 640: checkcast #71 // class java/lang/CharSequence\n 643: aconst_null\n 644: aconst_null\n 645: iconst_0\n 646: aconst_null\n 647: aconst_null\n 648: bipush 62\n 650: aconst_null\n 651: invokestatic #154 // 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 654: areturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day05Kt$main$Common.class", "javap": "Compiled from \"Day05.kt\"\npublic final class Day05Kt$main$Common {\n private final java.util.List<java.lang.String> input;\n\n public java.util.List<java.lang.String> moves;\n\n public java.util.List<kotlin.collections.ArrayDeque<java.lang.Character>> stacks;\n\n public Day05Kt$main$Common(java.util.List<java.lang.String>);\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:Ljava/util/List;\n 15: nop\n 16: aload_0\n 17: invokevirtual #24 // Method parse:()V\n 20: nop\n 21: return\n\n public final java.util.List<java.lang.String> getInput();\n Code:\n 0: aload_0\n 1: getfield #21 // Field input:Ljava/util/List;\n 4: areturn\n\n public final java.util.List<java.lang.String> getMoves();\n Code:\n 0: aload_0\n 1: getfield #33 // Field moves:Ljava/util/List;\n 4: dup\n 5: ifnull 9\n 8: areturn\n 9: pop\n 10: ldc #34 // String moves\n 12: invokestatic #38 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V\n 15: aconst_null\n 16: areturn\n\n public final void setMoves(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: ldc #43 // String <set-?>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: putfield #33 // Field moves:Ljava/util/List;\n 11: return\n\n public final java.util.List<kotlin.collections.ArrayDeque<java.lang.Character>> getStacks();\n Code:\n 0: aload_0\n 1: getfield #48 // Field stacks:Ljava/util/List;\n 4: dup\n 5: ifnull 9\n 8: areturn\n 9: pop\n 10: ldc #49 // String stacks\n 12: invokestatic #38 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V\n 15: aconst_null\n 16: areturn\n\n public final void setStacks(java.util.List<kotlin.collections.ArrayDeque<java.lang.Character>>);\n Code:\n 0: aload_1\n 1: ldc #43 // String <set-?>\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: putfield #48 // Field stacks:Ljava/util/List;\n 11: return\n\n public final void parse();\n Code:\n 0: aload_0\n 1: getfield #21 // Field input:Ljava/util/List;\n 4: checkcast #53 // class java/lang/Iterable\n 7: astore_2\n 8: iconst_0\n 9: istore_3\n 10: aload_2\n 11: astore 4\n 13: new #55 // class java/util/LinkedHashMap\n 16: dup\n 17: invokespecial #56 // Method java/util/LinkedHashMap.\"<init>\":()V\n 20: checkcast #58 // class java/util/Map\n 23: astore 5\n 25: iconst_0\n 26: istore 6\n 28: aload 4\n 30: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 35: astore 7\n 37: aload 7\n 39: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 44: ifeq 196\n 47: aload 7\n 49: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 54: astore 8\n 56: aload 8\n 58: checkcast #74 // class java/lang/String\n 61: astore 9\n 63: iconst_0\n 64: istore 10\n 66: nop\n 67: aload 9\n 69: checkcast #76 // class java/lang/CharSequence\n 72: ldc #78 // String move\n 74: checkcast #76 // class java/lang/CharSequence\n 77: iconst_0\n 78: iconst_2\n 79: aconst_null\n 80: invokestatic #84 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z\n 83: ifeq 91\n 86: ldc #34 // String moves\n 88: goto 117\n 91: aload 9\n 93: checkcast #76 // class java/lang/CharSequence\n 96: ldc #86 // String [\n 98: checkcast #76 // class java/lang/CharSequence\n 101: iconst_0\n 102: iconst_2\n 103: aconst_null\n 104: invokestatic #84 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z\n 107: ifeq 115\n 110: ldc #88 // String crates\n 112: goto 117\n 115: ldc #90 // String garbage\n 117: nop\n 118: astore 11\n 120: aload 5\n 122: astore 12\n 124: iconst_0\n 125: istore 13\n 127: aload 12\n 129: aload 11\n 131: invokeinterface #94, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 136: astore 14\n 138: aload 14\n 140: ifnonnull 175\n 143: iconst_0\n 144: istore 15\n 146: new #96 // class java/util/ArrayList\n 149: dup\n 150: invokespecial #97 // Method java/util/ArrayList.\"<init>\":()V\n 153: checkcast #40 // class java/util/List\n 156: astore 15\n 158: aload 12\n 160: aload 11\n 162: aload 15\n 164: invokeinterface #101, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 169: pop\n 170: aload 15\n 172: goto 177\n 175: aload 14\n 177: nop\n 178: checkcast #40 // class java/util/List\n 181: astore 9\n 183: aload 9\n 185: aload 8\n 187: invokeinterface #105, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 192: pop\n 193: goto 37\n 196: aload 5\n 198: nop\n 199: astore_1\n 200: aload_1\n 201: ldc #88 // String crates\n 203: invokeinterface #94, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 208: dup\n 209: invokestatic #109 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 212: checkcast #53 // class java/lang/Iterable\n 215: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 220: astore 4\n 222: aload 4\n 224: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 229: ifne 240\n 232: new #111 // class java/util/NoSuchElementException\n 235: dup\n 236: invokespecial #112 // Method java/util/NoSuchElementException.\"<init>\":()V\n 239: athrow\n 240: aload 4\n 242: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 247: checkcast #74 // class java/lang/String\n 250: astore 5\n 252: iconst_0\n 253: istore 6\n 255: aload 5\n 257: invokevirtual #116 // Method java/lang/String.length:()I\n 260: istore 5\n 262: aload 4\n 264: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 269: ifeq 308\n 272: aload 4\n 274: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 279: checkcast #74 // class java/lang/String\n 282: astore 6\n 284: iconst_0\n 285: istore 7\n 287: aload 6\n 289: invokevirtual #116 // Method java/lang/String.length:()I\n 292: istore 6\n 294: iload 5\n 296: iload 6\n 298: if_icmpge 262\n 301: iload 6\n 303: istore 5\n 305: goto 262\n 308: iload 5\n 310: istore_2\n 311: aload_1\n 312: ldc #88 // String crates\n 314: invokeinterface #94, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 319: dup\n 320: invokestatic #109 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 323: checkcast #53 // class java/lang/Iterable\n 326: astore 4\n 328: nop\n 329: iconst_0\n 330: istore 5\n 332: aload 4\n 334: astore 6\n 336: new #96 // class java/util/ArrayList\n 339: dup\n 340: aload 4\n 342: bipush 10\n 344: invokestatic #122 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 347: invokespecial #125 // Method java/util/ArrayList.\"<init>\":(I)V\n 350: checkcast #127 // class java/util/Collection\n 353: astore 7\n 355: iconst_0\n 356: istore 8\n 358: aload 6\n 360: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 365: astore 9\n 367: aload 9\n 369: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 374: ifeq 547\n 377: aload 9\n 379: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 384: astore 10\n 386: aload 7\n 388: aload 10\n 390: checkcast #74 // class java/lang/String\n 393: astore 11\n 395: astore 23\n 397: iconst_0\n 398: istore 12\n 400: aload 11\n 402: iload_2\n 403: iconst_0\n 404: iconst_2\n 405: aconst_null\n 406: invokestatic #131 // Method kotlin/text/StringsKt.padEnd$default:(Ljava/lang/String;ICILjava/lang/Object;)Ljava/lang/String;\n 409: checkcast #76 // class java/lang/CharSequence\n 412: invokestatic #135 // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;\n 415: checkcast #53 // class java/lang/Iterable\n 418: iconst_4\n 419: invokestatic #139 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 422: checkcast #53 // class java/lang/Iterable\n 425: astore 13\n 427: nop\n 428: iconst_0\n 429: istore 14\n 431: aload 13\n 433: astore 15\n 435: new #96 // class java/util/ArrayList\n 438: dup\n 439: aload 13\n 441: bipush 10\n 443: invokestatic #122 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 446: invokespecial #125 // Method java/util/ArrayList.\"<init>\":(I)V\n 449: checkcast #127 // class java/util/Collection\n 452: astore 16\n 454: iconst_0\n 455: istore 17\n 457: aload 15\n 459: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 464: astore 18\n 466: aload 18\n 468: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 473: ifeq 528\n 476: aload 18\n 478: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 483: astore 19\n 485: aload 16\n 487: aload 19\n 489: checkcast #40 // class java/util/List\n 492: astore 20\n 494: astore 21\n 496: iconst_0\n 497: istore 22\n 499: aload 20\n 501: iconst_1\n 502: invokeinterface #142, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 507: checkcast #144 // class java/lang/Character\n 510: invokevirtual #148 // Method java/lang/Character.charValue:()C\n 513: invokestatic #152 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 516: aload 21\n 518: swap\n 519: invokeinterface #153, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 524: pop\n 525: goto 466\n 528: aload 16\n 530: checkcast #40 // class java/util/List\n 533: nop\n 534: nop\n 535: aload 23\n 537: swap\n 538: invokeinterface #153, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 543: pop\n 544: goto 367\n 547: aload 7\n 549: checkcast #40 // class java/util/List\n 552: nop\n 553: astore_3\n 554: aload_3\n 555: invokestatic #157 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 558: checkcast #40 // class java/util/List\n 561: invokeinterface #160, 1 // InterfaceMethod java/util/List.size:()I\n 566: istore 4\n 568: aload_0\n 569: astore 23\n 571: new #96 // class java/util/ArrayList\n 574: dup\n 575: iload 4\n 577: invokespecial #125 // Method java/util/ArrayList.\"<init>\":(I)V\n 580: astore 5\n 582: iconst_0\n 583: istore 6\n 585: iload 6\n 587: iload 4\n 589: if_icmpge 627\n 592: iload 6\n 594: istore 7\n 596: aload 5\n 598: iload 7\n 600: istore 8\n 602: astore 24\n 604: iconst_0\n 605: istore 9\n 607: new #162 // class kotlin/collections/ArrayDeque\n 610: dup\n 611: invokespecial #163 // Method kotlin/collections/ArrayDeque.\"<init>\":()V\n 614: aload 24\n 616: swap\n 617: invokevirtual #164 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 620: pop\n 621: iinc 6, 1\n 624: goto 585\n 627: aload 5\n 629: checkcast #40 // class java/util/List\n 632: aload 23\n 634: swap\n 635: invokevirtual #166 // Method setStacks:(Ljava/util/List;)V\n 638: aload_3\n 639: checkcast #53 // class java/lang/Iterable\n 642: astore 5\n 644: iconst_0\n 645: istore 6\n 647: aload 5\n 649: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 654: astore 7\n 656: aload 7\n 658: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 663: ifeq 791\n 666: aload 7\n 668: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 673: astore 8\n 675: aload 8\n 677: checkcast #40 // class java/util/List\n 680: astore 9\n 682: iconst_0\n 683: istore 10\n 685: aload 9\n 687: checkcast #53 // class java/lang/Iterable\n 690: astore 11\n 692: iconst_0\n 693: istore 12\n 695: iconst_0\n 696: istore 13\n 698: aload 11\n 700: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 705: astore 14\n 707: aload 14\n 709: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 714: ifeq 785\n 717: aload 14\n 719: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 724: astore 15\n 726: iload 13\n 728: iinc 13, 1\n 731: istore 16\n 733: iload 16\n 735: ifge 741\n 738: invokestatic #169 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 741: iload 16\n 743: aload 15\n 745: checkcast #144 // class java/lang/Character\n 748: invokevirtual #148 // Method java/lang/Character.charValue:()C\n 751: istore 17\n 753: istore 18\n 755: iconst_0\n 756: istore 19\n 758: aload_0\n 759: invokevirtual #171 // Method getStacks:()Ljava/util/List;\n 762: iload 18\n 764: invokeinterface #142, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 769: checkcast #162 // class kotlin/collections/ArrayDeque\n 772: iload 17\n 774: invokestatic #152 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 777: invokevirtual #174 // Method kotlin/collections/ArrayDeque.addLast:(Ljava/lang/Object;)V\n 780: nop\n 781: nop\n 782: goto 707\n 785: nop\n 786: nop\n 787: nop\n 788: goto 656\n 791: nop\n 792: aload_0\n 793: aload_1\n 794: ldc #34 // String moves\n 796: invokeinterface #94, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 801: dup\n 802: invokestatic #109 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 805: checkcast #53 // class java/lang/Iterable\n 808: astore 5\n 810: astore 23\n 812: iconst_0\n 813: istore 6\n 815: aload 5\n 817: astore 7\n 819: new #96 // class java/util/ArrayList\n 822: dup\n 823: aload 5\n 825: bipush 10\n 827: invokestatic #122 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 830: invokespecial #125 // Method java/util/ArrayList.\"<init>\":(I)V\n 833: checkcast #127 // class java/util/Collection\n 836: astore 8\n 838: iconst_0\n 839: istore 9\n 841: aload 7\n 843: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 848: astore 10\n 850: aload 10\n 852: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 857: ifeq 938\n 860: aload 10\n 862: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 867: astore 11\n 869: aload 8\n 871: aload 11\n 873: checkcast #74 // class java/lang/String\n 876: astore 12\n 878: astore 24\n 880: iconst_0\n 881: istore 13\n 883: nop\n 884: aload 12\n 886: ldc #78 // String move\n 888: ldc #176 // String\n 890: iconst_0\n 891: iconst_4\n 892: aconst_null\n 893: invokestatic #180 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 896: ldc #182 // String from\n 898: ldc #176 // String\n 900: iconst_0\n 901: iconst_4\n 902: aconst_null\n 903: invokestatic #180 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 906: ldc #184 // String to\n 908: ldc #176 // String\n 910: iconst_0\n 911: iconst_4\n 912: aconst_null\n 913: invokestatic #180 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 916: checkcast #76 // class java/lang/CharSequence\n 919: invokestatic #188 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 922: invokevirtual #192 // Method java/lang/Object.toString:()Ljava/lang/String;\n 925: nop\n 926: aload 24\n 928: swap\n 929: invokeinterface #153, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 934: pop\n 935: goto 850\n 938: aload 8\n 940: checkcast #40 // class java/util/List\n 943: nop\n 944: aload 23\n 946: swap\n 947: invokevirtual #194 // Method setMoves:(Ljava/util/List;)V\n 950: return\n\n public final java.util.List<java.lang.String> component1();\n Code:\n 0: aload_0\n 1: getfield #21 // Field input:Ljava/util/List;\n 4: areturn\n\n public final Day05Kt$main$Common copy(java.util.List<java.lang.String>);\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: new #2 // class Day05Kt$main$Common\n 9: dup\n 10: aload_1\n 11: invokespecial #247 // Method \"<init>\":(Ljava/util/List;)V\n 14: areturn\n\n public static Day05Kt$main$Common copy$default(Day05Kt$main$Common, java.util.List, int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #21 // Field input:Ljava/util/List;\n 10: astore_1\n 11: aload_0\n 12: aload_1\n 13: invokevirtual #251 // Method copy:(Ljava/util/List;)LDay05Kt$main$Common;\n 16: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #253 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #254 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc_w #256 // String Common(input=\n 10: invokevirtual #260 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 13: aload_0\n 14: getfield #21 // Field input:Ljava/util/List;\n 17: invokevirtual #263 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 20: bipush 41\n 22: invokevirtual #266 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 25: invokevirtual #267 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 28: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #21 // Field input:Ljava/util/List;\n 4: invokevirtual #270 // Method java/lang/Object.hashCode:()I\n 7: 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 Day05Kt$main$Common\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day05Kt$main$Common\n 20: astore_2\n 21: aload_0\n 22: getfield #21 // Field input:Ljava/util/List;\n 25: aload_2\n 26: getfield #21 // Field input:Ljava/util/List;\n 29: invokestatic #275 // 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: iconst_1\n 38: ireturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day21.kt
fun main() { data class Monkey(val name: String, val expr: String) fun Monkey.evaluateExpr(map: MutableMap<String, Long>): Long? { val parts = this.expr.split(" ") if (parts.size == 1) { return parts[0].toLong() } val name1 = parts.first() val name2 = parts.last() val operator = parts[1] if (operator == "=") { if (name1 in map) { map[name2] = map[name1]!! } else if (name2 in map) { map[name1] = map[name2]!! } } else { if (name1 in map && name2 in map) { val value1 = map[name1]!! val value2 = map[name2]!! return when (operator) { "+" -> value1 + value2 "-" -> value1 - value2 "*" -> value1 * value2 "/" -> value1 / value2 else -> null } } } return null } fun Monkey.variants(): List<Monkey> { val parts = this.expr.split(" ") if (parts.size == 1) { return listOf(this) } val name1 = parts.first() val name2 = parts.last() val operator = parts[1] return when (operator) { "+" -> listOf(this, Monkey(name1, "$name - $name2"), Monkey(name2, "$name - $name1")) "-" -> listOf(this, Monkey(name1, "$name + $name2"), Monkey(name2, "$name1 - $name")) "*" -> listOf(this, Monkey(name1, "$name / $name2"), Monkey(name2, "$name / $name1")) "/" -> listOf(this, Monkey(name1, "$name * $name2"), Monkey(name2, "$name1 / $name")) else -> listOf(this) } } fun List<Monkey>.calc(need: String): Long { val map = mutableMapOf<String, Long>() while (need !in map) { forEach { if (map[it.name] == null) { it.evaluateExpr(map)?.let { result -> map[it.name] = result } } } } return map[need]!! } fun part1(input: List<String>) = input.map { val (name, expr) = it.split(": ") Monkey(name, expr) } .calc("root") fun part2(input: List<String>) = input.flatMap { val (name, expr) = it.split(": ") when (name) { "root" -> Monkey(name, expr.replace("+", "=")).variants() else -> Monkey(name, expr).variants() } } .filterNot { it.name == "humn" && it.expr.split(" ").size == 1 } .calc("humn") val input = readInput("inputs/Day21") println(part1(input)) println(part2(input)) }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day21Kt.class", "javap": "Compiled from \"Day21.kt\"\npublic final class Day21Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/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 main$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 main$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 void main(java.lang.String[]);\n Code:\n 0: invokestatic #38 // Method main:()V\n 3: return\n\n private static final java.lang.Long main$evaluateExpr(Day21Kt$main$Monkey, java.util.Map<java.lang.String, java.lang.Long>);\n Code:\n 0: aload_0\n 1: invokevirtual #49 // Method Day21Kt$main$Monkey.getExpr:()Ljava/lang/String;\n 4: checkcast #51 // class java/lang/CharSequence\n 7: iconst_1\n 8: anewarray #53 // class java/lang/String\n 11: astore_3\n 12: aload_3\n 13: iconst_0\n 14: ldc #55 // String\n 16: aastore\n 17: aload_3\n 18: iconst_0\n 19: iconst_0\n 20: bipush 6\n 22: aconst_null\n 23: invokestatic #61 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 26: astore_2\n 27: aload_2\n 28: invokeinterface #67, 1 // InterfaceMethod java/util/List.size:()I\n 33: iconst_1\n 34: if_icmpne 54\n 37: aload_2\n 38: iconst_0\n 39: invokeinterface #71, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 44: checkcast #53 // class java/lang/String\n 47: invokestatic #77 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 50: invokestatic #81 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 53: areturn\n 54: aload_2\n 55: invokestatic #87 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 58: checkcast #53 // class java/lang/String\n 61: astore_3\n 62: aload_2\n 63: invokestatic #90 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 66: checkcast #53 // class java/lang/String\n 69: astore 4\n 71: aload_2\n 72: iconst_1\n 73: invokeinterface #71, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 78: checkcast #53 // class java/lang/String\n 81: astore 5\n 83: aload 5\n 85: ldc #92 // String =\n 87: invokestatic #98 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 90: ifeq 160\n 93: aload_1\n 94: aload_3\n 95: invokeinterface #104, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 100: ifeq 126\n 103: aload_1\n 104: aload 4\n 106: aload_1\n 107: aload_3\n 108: invokeinterface #107, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 113: dup\n 114: invokestatic #111 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 117: invokeinterface #115, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 122: pop\n 123: goto 366\n 126: aload_1\n 127: aload 4\n 129: invokeinterface #104, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 134: ifeq 366\n 137: aload_1\n 138: aload_3\n 139: aload_1\n 140: aload 4\n 142: invokeinterface #107, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 147: dup\n 148: invokestatic #111 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 151: invokeinterface #115, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 156: pop\n 157: goto 366\n 160: aload_1\n 161: aload_3\n 162: invokeinterface #104, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 167: ifeq 366\n 170: aload_1\n 171: aload 4\n 173: invokeinterface #104, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 178: ifeq 366\n 181: aload_1\n 182: aload_3\n 183: invokeinterface #107, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 188: dup\n 189: invokestatic #111 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 192: checkcast #117 // class java/lang/Number\n 195: invokevirtual #121 // Method java/lang/Number.longValue:()J\n 198: lstore 6\n 200: aload_1\n 201: aload 4\n 203: invokeinterface #107, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 208: dup\n 209: invokestatic #111 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 212: checkcast #117 // class java/lang/Number\n 215: invokevirtual #121 // Method java/lang/Number.longValue:()J\n 218: lstore 8\n 220: aload 5\n 222: astore 10\n 224: aload 10\n 226: invokevirtual #124 // Method java/lang/String.hashCode:()I\n 229: tableswitch { // 42 to 47\n 42: 268\n 43: 281\n 44: 364\n 45: 294\n 46: 364\n 47: 307\n default: 364\n }\n 268: aload 10\n 270: ldc #126 // String *\n 272: invokevirtual #129 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 275: ifne 342\n 278: goto 364\n 281: aload 10\n 283: ldc #131 // String +\n 285: invokevirtual #129 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 288: ifne 320\n 291: goto 364\n 294: aload 10\n 296: ldc #133 // String -\n 298: invokevirtual #129 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 301: ifne 331\n 304: goto 364\n 307: aload 10\n 309: ldc #135 // String /\n 311: invokevirtual #129 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 314: ifne 353\n 317: goto 364\n 320: lload 6\n 322: lload 8\n 324: ladd\n 325: invokestatic #81 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 328: goto 365\n 331: lload 6\n 333: lload 8\n 335: lsub\n 336: invokestatic #81 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 339: goto 365\n 342: lload 6\n 344: lload 8\n 346: lmul\n 347: invokestatic #81 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 350: goto 365\n 353: lload 6\n 355: lload 8\n 357: ldiv\n 358: invokestatic #81 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 361: goto 365\n 364: aconst_null\n 365: areturn\n 366: aconst_null\n 367: areturn\n\n private static final java.util.List<Day21Kt$main$Monkey> main$variants(Day21Kt$main$Monkey);\n Code:\n 0: aload_0\n 1: invokevirtual #49 // Method Day21Kt$main$Monkey.getExpr:()Ljava/lang/String;\n 4: checkcast #51 // class java/lang/CharSequence\n 7: iconst_1\n 8: anewarray #53 // class java/lang/String\n 11: astore_2\n 12: aload_2\n 13: iconst_0\n 14: ldc #55 // String\n 16: aastore\n 17: aload_2\n 18: iconst_0\n 19: iconst_0\n 20: bipush 6\n 22: aconst_null\n 23: invokestatic #61 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 26: astore_1\n 27: aload_1\n 28: invokeinterface #67, 1 // InterfaceMethod java/util/List.size:()I\n 33: iconst_1\n 34: if_icmpne 42\n 37: aload_0\n 38: invokestatic #155 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 41: areturn\n 42: aload_1\n 43: invokestatic #87 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 46: checkcast #53 // class java/lang/String\n 49: astore_2\n 50: aload_1\n 51: invokestatic #90 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 54: checkcast #53 // class java/lang/String\n 57: astore_3\n 58: aload_1\n 59: iconst_1\n 60: invokeinterface #71, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 65: checkcast #53 // class java/lang/String\n 68: astore 4\n 70: aload 4\n 72: astore 5\n 74: aload 5\n 76: invokevirtual #124 // Method java/lang/String.hashCode:()I\n 79: tableswitch { // 42 to 47\n 42: 116\n 43: 129\n 44: 548\n 45: 142\n 46: 548\n 47: 155\n default: 548\n }\n 116: aload 5\n 118: ldc #126 // String *\n 120: invokevirtual #129 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 123: ifne 358\n 126: goto 548\n 129: aload 5\n 131: ldc #131 // String +\n 133: invokevirtual #129 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 136: ifne 168\n 139: goto 548\n 142: aload 5\n 144: ldc #133 // String -\n 146: invokevirtual #129 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 149: ifne 263\n 152: goto 548\n 155: aload 5\n 157: ldc #135 // String /\n 159: invokevirtual #129 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 162: ifne 453\n 165: goto 548\n 168: iconst_3\n 169: anewarray #45 // class Day21Kt$main$Monkey\n 172: astore 6\n 174: aload 6\n 176: iconst_0\n 177: aload_0\n 178: aastore\n 179: aload 6\n 181: iconst_1\n 182: new #45 // class Day21Kt$main$Monkey\n 185: dup\n 186: aload_2\n 187: new #157 // class java/lang/StringBuilder\n 190: dup\n 191: invokespecial #160 // Method java/lang/StringBuilder.\"<init>\":()V\n 194: aload_0\n 195: invokevirtual #163 // Method Day21Kt$main$Monkey.getName:()Ljava/lang/String;\n 198: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 201: ldc #169 // String -\n 203: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 206: aload_3\n 207: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 210: invokevirtual #172 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 213: invokespecial #175 // Method Day21Kt$main$Monkey.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 216: aastore\n 217: aload 6\n 219: iconst_2\n 220: new #45 // class Day21Kt$main$Monkey\n 223: dup\n 224: aload_3\n 225: new #157 // class java/lang/StringBuilder\n 228: dup\n 229: invokespecial #160 // Method java/lang/StringBuilder.\"<init>\":()V\n 232: aload_0\n 233: invokevirtual #163 // Method Day21Kt$main$Monkey.getName:()Ljava/lang/String;\n 236: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 239: ldc #169 // String -\n 241: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 244: aload_2\n 245: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 248: invokevirtual #172 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 251: invokespecial #175 // Method Day21Kt$main$Monkey.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 254: aastore\n 255: aload 6\n 257: invokestatic #178 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 260: goto 552\n 263: iconst_3\n 264: anewarray #45 // class Day21Kt$main$Monkey\n 267: astore 6\n 269: aload 6\n 271: iconst_0\n 272: aload_0\n 273: aastore\n 274: aload 6\n 276: iconst_1\n 277: new #45 // class Day21Kt$main$Monkey\n 280: dup\n 281: aload_2\n 282: new #157 // class java/lang/StringBuilder\n 285: dup\n 286: invokespecial #160 // Method java/lang/StringBuilder.\"<init>\":()V\n 289: aload_0\n 290: invokevirtual #163 // Method Day21Kt$main$Monkey.getName:()Ljava/lang/String;\n 293: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 296: ldc #180 // String +\n 298: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 301: aload_3\n 302: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 305: invokevirtual #172 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 308: invokespecial #175 // Method Day21Kt$main$Monkey.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 311: aastore\n 312: aload 6\n 314: iconst_2\n 315: new #45 // class Day21Kt$main$Monkey\n 318: dup\n 319: aload_3\n 320: new #157 // class java/lang/StringBuilder\n 323: dup\n 324: invokespecial #160 // Method java/lang/StringBuilder.\"<init>\":()V\n 327: aload_2\n 328: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 331: ldc #169 // String -\n 333: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 336: aload_0\n 337: invokevirtual #163 // Method Day21Kt$main$Monkey.getName:()Ljava/lang/String;\n 340: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 343: invokevirtual #172 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 346: invokespecial #175 // Method Day21Kt$main$Monkey.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 349: aastore\n 350: aload 6\n 352: invokestatic #178 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 355: goto 552\n 358: iconst_3\n 359: anewarray #45 // class Day21Kt$main$Monkey\n 362: astore 6\n 364: aload 6\n 366: iconst_0\n 367: aload_0\n 368: aastore\n 369: aload 6\n 371: iconst_1\n 372: new #45 // class Day21Kt$main$Monkey\n 375: dup\n 376: aload_2\n 377: new #157 // class java/lang/StringBuilder\n 380: dup\n 381: invokespecial #160 // Method java/lang/StringBuilder.\"<init>\":()V\n 384: aload_0\n 385: invokevirtual #163 // Method Day21Kt$main$Monkey.getName:()Ljava/lang/String;\n 388: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 391: ldc #182 // String /\n 393: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 396: aload_3\n 397: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 400: invokevirtual #172 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 403: invokespecial #175 // Method Day21Kt$main$Monkey.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 406: aastore\n 407: aload 6\n 409: iconst_2\n 410: new #45 // class Day21Kt$main$Monkey\n 413: dup\n 414: aload_3\n 415: new #157 // class java/lang/StringBuilder\n 418: dup\n 419: invokespecial #160 // Method java/lang/StringBuilder.\"<init>\":()V\n 422: aload_0\n 423: invokevirtual #163 // Method Day21Kt$main$Monkey.getName:()Ljava/lang/String;\n 426: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 429: ldc #182 // String /\n 431: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 434: aload_2\n 435: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 438: invokevirtual #172 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 441: invokespecial #175 // Method Day21Kt$main$Monkey.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 444: aastore\n 445: aload 6\n 447: invokestatic #178 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 450: goto 552\n 453: iconst_3\n 454: anewarray #45 // class Day21Kt$main$Monkey\n 457: astore 6\n 459: aload 6\n 461: iconst_0\n 462: aload_0\n 463: aastore\n 464: aload 6\n 466: iconst_1\n 467: new #45 // class Day21Kt$main$Monkey\n 470: dup\n 471: aload_2\n 472: new #157 // class java/lang/StringBuilder\n 475: dup\n 476: invokespecial #160 // Method java/lang/StringBuilder.\"<init>\":()V\n 479: aload_0\n 480: invokevirtual #163 // Method Day21Kt$main$Monkey.getName:()Ljava/lang/String;\n 483: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 486: ldc #184 // String *\n 488: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 491: aload_3\n 492: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 495: invokevirtual #172 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 498: invokespecial #175 // Method Day21Kt$main$Monkey.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 501: aastore\n 502: aload 6\n 504: iconst_2\n 505: new #45 // class Day21Kt$main$Monkey\n 508: dup\n 509: aload_3\n 510: new #157 // class java/lang/StringBuilder\n 513: dup\n 514: invokespecial #160 // Method java/lang/StringBuilder.\"<init>\":()V\n 517: aload_2\n 518: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 521: ldc #182 // String /\n 523: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 526: aload_0\n 527: invokevirtual #163 // Method Day21Kt$main$Monkey.getName:()Ljava/lang/String;\n 530: invokevirtual #167 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 533: invokevirtual #172 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 536: invokespecial #175 // Method Day21Kt$main$Monkey.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 539: aastore\n 540: aload 6\n 542: invokestatic #178 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 545: goto 552\n 548: aload_0\n 549: invokestatic #155 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 552: areturn\n\n private static final long main$calc(java.util.List<Day21Kt$main$Monkey>, java.lang.String);\n Code:\n 0: new #190 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #191 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #100 // class java/util/Map\n 10: astore_2\n 11: aload_2\n 12: aload_1\n 13: invokeinterface #104, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 18: ifne 137\n 21: aload_0\n 22: checkcast #193 // class java/lang/Iterable\n 25: astore_3\n 26: iconst_0\n 27: istore 4\n 29: aload_3\n 30: invokeinterface #197, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 35: astore 5\n 37: aload 5\n 39: invokeinterface #203, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 44: ifeq 133\n 47: aload 5\n 49: invokeinterface #207, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 54: astore 6\n 56: aload 6\n 58: checkcast #45 // class Day21Kt$main$Monkey\n 61: astore 7\n 63: iconst_0\n 64: istore 8\n 66: aload_2\n 67: aload 7\n 69: invokevirtual #163 // Method Day21Kt$main$Monkey.getName:()Ljava/lang/String;\n 72: invokeinterface #107, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 77: ifnonnull 128\n 80: aload 7\n 82: aload_2\n 83: invokestatic #209 // Method main$evaluateExpr:(LDay21Kt$main$Monkey;Ljava/util/Map;)Ljava/lang/Long;\n 86: dup\n 87: ifnull 126\n 90: checkcast #117 // class java/lang/Number\n 93: invokevirtual #121 // Method java/lang/Number.longValue:()J\n 96: lstore 9\n 98: iconst_0\n 99: istore 11\n 101: lload 9\n 103: invokestatic #81 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 106: astore 12\n 108: aload_2\n 109: aload 7\n 111: invokevirtual #163 // Method Day21Kt$main$Monkey.getName:()Ljava/lang/String;\n 114: aload 12\n 116: invokeinterface #115, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 121: pop\n 122: nop\n 123: goto 128\n 126: pop\n 127: nop\n 128: nop\n 129: nop\n 130: goto 37\n 133: nop\n 134: goto 11\n 137: aload_2\n 138: aload_1\n 139: invokeinterface #107, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 144: dup\n 145: invokestatic #111 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 148: checkcast #117 // class java/lang/Number\n 151: invokevirtual #121 // Method java/lang/Number.longValue:()J\n 154: lreturn\n\n private static final long main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #193 // 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 #224 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #228 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #231 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #233 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #197, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #203, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 149\n 48: aload 6\n 50: invokeinterface #207, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #53 // class java/lang/String\n 64: astore 8\n 66: astore 13\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: checkcast #51 // class java/lang/CharSequence\n 76: iconst_1\n 77: anewarray #53 // class java/lang/String\n 80: astore 10\n 82: aload 10\n 84: iconst_0\n 85: ldc #235 // 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 #61 // 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 #71, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 108: checkcast #53 // class java/lang/String\n 111: astore 10\n 113: aload 11\n 115: iconst_1\n 116: invokeinterface #71, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 121: checkcast #53 // class java/lang/String\n 124: astore 12\n 126: new #45 // class Day21Kt$main$Monkey\n 129: dup\n 130: aload 10\n 132: aload 12\n 134: invokespecial #175 // Method Day21Kt$main$Monkey.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 137: aload 13\n 139: swap\n 140: invokeinterface #238, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 145: pop\n 146: goto 38\n 149: aload 4\n 151: checkcast #63 // class java/util/List\n 154: nop\n 155: ldc #240 // String root\n 157: invokestatic #242 // Method main$calc:(Ljava/util/List;Ljava/lang/String;)J\n 160: lreturn\n\n private static final long main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #193 // 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 #224 // class java/util/ArrayList\n 12: dup\n 13: invokespecial #253 // Method java/util/ArrayList.\"<init>\":()V\n 16: checkcast #233 // class java/util/Collection\n 19: astore 4\n 21: iconst_0\n 22: istore 5\n 24: aload_3\n 25: invokeinterface #197, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 30: astore 6\n 32: aload 6\n 34: invokeinterface #203, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 39: ifeq 184\n 42: aload 6\n 44: invokeinterface #207, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 49: astore 7\n 51: aload 7\n 53: checkcast #53 // class java/lang/String\n 56: astore 8\n 58: iconst_0\n 59: istore 9\n 61: aload 8\n 63: checkcast #51 // class java/lang/CharSequence\n 66: iconst_1\n 67: anewarray #53 // class java/lang/String\n 70: astore 10\n 72: aload 10\n 74: iconst_0\n 75: ldc #235 // String :\n 77: aastore\n 78: aload 10\n 80: iconst_0\n 81: iconst_0\n 82: bipush 6\n 84: aconst_null\n 85: invokestatic #61 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 88: astore 11\n 90: aload 11\n 92: iconst_0\n 93: invokeinterface #71, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 98: checkcast #53 // class java/lang/String\n 101: astore 10\n 103: aload 11\n 105: iconst_1\n 106: invokeinterface #71, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 111: checkcast #53 // class java/lang/String\n 114: astore 12\n 116: aload 10\n 118: ldc #240 // String root\n 120: invokestatic #98 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 123: ifeq 153\n 126: new #45 // class Day21Kt$main$Monkey\n 129: dup\n 130: aload 10\n 132: aload 12\n 134: ldc #131 // String +\n 136: ldc #92 // String =\n 138: iconst_0\n 139: iconst_4\n 140: aconst_null\n 141: invokestatic #257 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 144: invokespecial #175 // Method Day21Kt$main$Monkey.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 147: invokestatic #259 // Method main$variants:(LDay21Kt$main$Monkey;)Ljava/util/List;\n 150: goto 167\n 153: new #45 // class Day21Kt$main$Monkey\n 156: dup\n 157: aload 10\n 159: aload 12\n 161: invokespecial #175 // Method Day21Kt$main$Monkey.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 164: invokestatic #259 // Method main$variants:(LDay21Kt$main$Monkey;)Ljava/util/List;\n 167: checkcast #193 // class java/lang/Iterable\n 170: nop\n 171: astore 8\n 173: aload 4\n 175: aload 8\n 177: invokestatic #263 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 180: pop\n 181: goto 32\n 184: aload 4\n 186: checkcast #63 // class java/util/List\n 189: nop\n 190: checkcast #193 // class java/lang/Iterable\n 193: astore_1\n 194: nop\n 195: iconst_0\n 196: istore_2\n 197: aload_1\n 198: astore_3\n 199: new #224 // class java/util/ArrayList\n 202: dup\n 203: invokespecial #253 // Method java/util/ArrayList.\"<init>\":()V\n 206: checkcast #233 // class java/util/Collection\n 209: astore 4\n 211: iconst_0\n 212: istore 5\n 214: aload_3\n 215: invokeinterface #197, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 220: astore 6\n 222: aload 6\n 224: invokeinterface #203, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 229: ifeq 325\n 232: aload 6\n 234: invokeinterface #207, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 239: astore 7\n 241: aload 7\n 243: checkcast #45 // class Day21Kt$main$Monkey\n 246: astore 8\n 248: iconst_0\n 249: istore 9\n 251: aload 8\n 253: invokevirtual #163 // Method Day21Kt$main$Monkey.getName:()Ljava/lang/String;\n 256: ldc_w #265 // String humn\n 259: invokestatic #98 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 262: ifeq 308\n 265: aload 8\n 267: invokevirtual #49 // Method Day21Kt$main$Monkey.getExpr:()Ljava/lang/String;\n 270: checkcast #51 // class java/lang/CharSequence\n 273: iconst_1\n 274: anewarray #53 // class java/lang/String\n 277: astore 10\n 279: aload 10\n 281: iconst_0\n 282: ldc #55 // String\n 284: aastore\n 285: aload 10\n 287: iconst_0\n 288: iconst_0\n 289: bipush 6\n 291: aconst_null\n 292: invokestatic #61 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 295: invokeinterface #67, 1 // InterfaceMethod java/util/List.size:()I\n 300: iconst_1\n 301: if_icmpne 308\n 304: iconst_1\n 305: goto 309\n 308: iconst_0\n 309: ifne 222\n 312: aload 4\n 314: aload 7\n 316: invokeinterface #238, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 321: pop\n 322: goto 222\n 325: aload 4\n 327: checkcast #63 // class java/util/List\n 330: nop\n 331: ldc_w #265 // String humn\n 334: invokestatic #242 // Method main$calc:(Ljava/util/List;Ljava/lang/String;)J\n 337: lreturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day21Kt$main$Monkey.class", "javap": "Compiled from \"Day21.kt\"\npublic final class Day21Kt$main$Monkey {\n private final java.lang.String name;\n\n private final java.lang.String expr;\n\n public Day21Kt$main$Monkey(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #8 // String name\n 3: invokestatic #14 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #16 // String expr\n 9: invokestatic #14 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokespecial #19 // Method java/lang/Object.\"<init>\":()V\n 16: aload_0\n 17: aload_1\n 18: putfield #22 // Field name:Ljava/lang/String;\n 21: aload_0\n 22: aload_2\n 23: putfield #24 // Field expr:Ljava/lang/String;\n 26: return\n\n public final java.lang.String getName();\n Code:\n 0: aload_0\n 1: getfield #22 // Field name:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.String getExpr();\n Code:\n 0: aload_0\n 1: getfield #24 // Field expr:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.String component1();\n Code:\n 0: aload_0\n 1: getfield #22 // Field name:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.String component2();\n Code:\n 0: aload_0\n 1: getfield #24 // Field expr:Ljava/lang/String;\n 4: areturn\n\n public final Day21Kt$main$Monkey copy(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #8 // String name\n 3: invokestatic #14 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #16 // String expr\n 9: invokestatic #14 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class Day21Kt$main$Monkey\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: invokespecial #35 // Method \"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 21: areturn\n\n public static Day21Kt$main$Monkey copy$default(Day21Kt$main$Monkey, java.lang.String, java.lang.String, 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 #22 // Field name: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 #24 // Field expr:Ljava/lang/String;\n 21: astore_2\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokevirtual #39 // Method copy:(Ljava/lang/String;Ljava/lang/String;)LDay21Kt$main$Monkey;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #42 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #43 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #45 // String Monkey(name=\n 9: invokevirtual #49 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #22 // Field name:Ljava/lang/String;\n 16: invokevirtual #49 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 19: ldc #51 // String , expr=\n 21: invokevirtual #49 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #24 // Field expr:Ljava/lang/String;\n 28: invokevirtual #49 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #54 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #56 // 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 #22 // Field name:Ljava/lang/String;\n 4: invokevirtual #62 // 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 #24 // Field expr:Ljava/lang/String;\n 16: invokevirtual #62 // Method java/lang/String.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 Day21Kt$main$Monkey\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day21Kt$main$Monkey\n 20: astore_2\n 21: aload_0\n 22: getfield #22 // Field name:Ljava/lang/String;\n 25: aload_2\n 26: getfield #22 // Field name:Ljava/lang/String;\n 29: invokestatic #70 // 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 #24 // Field expr:Ljava/lang/String;\n 41: aload_2\n 42: getfield #24 // Field expr:Ljava/lang/String;\n 45: invokestatic #70 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 48: ifne 53\n 51: iconst_0\n 52: ireturn\n 53: iconst_1\n 54: ireturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day07.kt
fun main() { data class Node(val name: String, var size: Int = 0, val dir: Boolean = false, val parent: Node? = null) { fun propagateSize() { var curr = parent while (curr != null) { curr.size += size curr = curr.parent } } } data class Common(val input: List<String>) { val nodes = mutableListOf<Node>() val root = Node(name = "/") init { var currentDir = root input .map { it.split(" ") } .forEach { val (first, second) = it if (first == "$" && second == "cd") { when (val dirName = it[2]) { ".." -> currentDir = currentDir.parent!! "/" -> currentDir = root else -> { currentDir = Node(name = dirName, dir = true, parent = currentDir) nodes.add(currentDir) } } } else if (first.isNumber()) { nodes.add(Node(name = second, size = first.toInt(), parent = currentDir)) } } nodes.filterNot { it.dir } .forEach { it.propagateSize() } } } fun part1(input: List<String>): Int { val common = Common(input) return common.nodes .filter { it.dir && it.size <= 100000 } .sumOf { it.size } } fun part2(input: List<String>): Int { val common = Common(input) val freeSpace = 70000000 - common.root.size return common.nodes .filter { it.dir } .fold(70000000) { acc, item -> if (freeSpace + item.size >= 30000000 && acc > item.size) { item.size } else { acc } } } val input = readInput("inputs/Day07") println(part1(input)) println(part2(input)) } private fun String.isNumber(): Boolean { return toIntOrNull() != null }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day07Kt$main$Common.class", "javap": "Compiled from \"Day07.kt\"\npublic final class Day07Kt$main$Common {\n private final java.util.List<java.lang.String> input;\n\n private final java.util.List<Day07Kt$main$Node> nodes;\n\n private final Day07Kt$main$Node root;\n\n public Day07Kt$main$Common(java.util.List<java.lang.String>);\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:Ljava/util/List;\n 15: aload_0\n 16: new #23 // class java/util/ArrayList\n 19: dup\n 20: invokespecial #24 // Method java/util/ArrayList.\"<init>\":()V\n 23: checkcast #26 // class java/util/List\n 26: putfield #29 // Field nodes:Ljava/util/List;\n 29: aload_0\n 30: new #31 // class Day07Kt$main$Node\n 33: dup\n 34: ldc #33 // String /\n 36: iconst_0\n 37: iconst_0\n 38: aconst_null\n 39: bipush 14\n 41: aconst_null\n 42: invokespecial #36 // Method Day07Kt$main$Node.\"<init>\":(Ljava/lang/String;IZLDay07Kt$main$Node;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 45: putfield #40 // Field root:LDay07Kt$main$Node;\n 48: nop\n 49: aconst_null\n 50: astore_2\n 51: aload_0\n 52: getfield #40 // Field root:LDay07Kt$main$Node;\n 55: astore_2\n 56: aload_0\n 57: getfield #21 // Field input:Ljava/util/List;\n 60: checkcast #42 // class java/lang/Iterable\n 63: astore_3\n 64: nop\n 65: iconst_0\n 66: istore 4\n 68: aload_3\n 69: astore 5\n 71: new #23 // class java/util/ArrayList\n 74: dup\n 75: aload_3\n 76: bipush 10\n 78: invokestatic #48 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 81: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 84: checkcast #53 // class java/util/Collection\n 87: astore 6\n 89: iconst_0\n 90: istore 7\n 92: aload 5\n 94: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 99: astore 8\n 101: aload 8\n 103: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 108: ifeq 173\n 111: aload 8\n 113: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 118: astore 9\n 120: aload 6\n 122: aload 9\n 124: checkcast #69 // class java/lang/String\n 127: astore 10\n 129: astore 13\n 131: iconst_0\n 132: istore 11\n 134: aload 10\n 136: checkcast #71 // class java/lang/CharSequence\n 139: iconst_1\n 140: anewarray #69 // class java/lang/String\n 143: astore 12\n 145: aload 12\n 147: iconst_0\n 148: ldc #73 // String\n 150: aastore\n 151: aload 12\n 153: iconst_0\n 154: iconst_0\n 155: bipush 6\n 157: aconst_null\n 158: invokestatic #79 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 161: aload 13\n 163: swap\n 164: invokeinterface #83, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 169: pop\n 170: goto 101\n 173: aload 6\n 175: checkcast #26 // class java/util/List\n 178: nop\n 179: checkcast #42 // class java/lang/Iterable\n 182: astore_3\n 183: nop\n 184: iconst_0\n 185: istore 4\n 187: aload_3\n 188: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 193: astore 5\n 195: aload 5\n 197: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 202: ifeq 393\n 205: aload 5\n 207: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 212: astore 6\n 214: aload 6\n 216: checkcast #26 // class java/util/List\n 219: astore 7\n 221: iconst_0\n 222: istore 8\n 224: aload 7\n 226: iconst_0\n 227: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 232: checkcast #69 // class java/lang/String\n 235: astore 9\n 237: aload 7\n 239: iconst_1\n 240: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 245: checkcast #69 // class java/lang/String\n 248: astore 10\n 250: aload 9\n 252: ldc #89 // String $\n 254: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 257: ifeq 352\n 260: aload 10\n 262: ldc #95 // String cd\n 264: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 267: ifeq 352\n 270: aload 7\n 272: iconst_2\n 273: invokeinterface #87, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 278: checkcast #69 // class java/lang/String\n 281: astore 11\n 283: aload 11\n 285: ldc #97 // String ..\n 287: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 290: ifeq 305\n 293: aload_2\n 294: invokevirtual #101 // Method Day07Kt$main$Node.getParent:()LDay07Kt$main$Node;\n 297: dup\n 298: invokestatic #105 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 301: astore_2\n 302: goto 388\n 305: aload 11\n 307: ldc #33 // String /\n 309: invokestatic #93 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 312: ifeq 323\n 315: aload_0\n 316: getfield #40 // Field root:LDay07Kt$main$Node;\n 319: astore_2\n 320: goto 388\n 323: new #31 // class Day07Kt$main$Node\n 326: dup\n 327: aload 11\n 329: iconst_0\n 330: iconst_1\n 331: aload_2\n 332: iconst_2\n 333: aconst_null\n 334: invokespecial #36 // Method Day07Kt$main$Node.\"<init>\":(Ljava/lang/String;IZLDay07Kt$main$Node;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 337: astore_2\n 338: aload_0\n 339: getfield #29 // Field nodes:Ljava/util/List;\n 342: aload_2\n 343: invokeinterface #106, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 348: pop\n 349: goto 388\n 352: aload 9\n 354: invokestatic #112 // Method Day07Kt.access$isNumber:(Ljava/lang/String;)Z\n 357: ifeq 388\n 360: aload_0\n 361: getfield #29 // Field nodes:Ljava/util/List;\n 364: new #31 // class Day07Kt$main$Node\n 367: dup\n 368: aload 10\n 370: aload 9\n 372: invokestatic #118 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 375: iconst_0\n 376: aload_2\n 377: iconst_4\n 378: aconst_null\n 379: invokespecial #36 // Method Day07Kt$main$Node.\"<init>\":(Ljava/lang/String;IZLDay07Kt$main$Node;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 382: invokeinterface #106, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 387: pop\n 388: nop\n 389: nop\n 390: goto 195\n 393: nop\n 394: aload_0\n 395: getfield #29 // Field nodes:Ljava/util/List;\n 398: checkcast #42 // class java/lang/Iterable\n 401: astore_3\n 402: iconst_0\n 403: istore 4\n 405: aload_3\n 406: astore 5\n 408: new #23 // class java/util/ArrayList\n 411: dup\n 412: invokespecial #24 // Method java/util/ArrayList.\"<init>\":()V\n 415: checkcast #53 // class java/util/Collection\n 418: astore 6\n 420: iconst_0\n 421: istore 7\n 423: aload 5\n 425: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 430: astore 8\n 432: aload 8\n 434: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 439: ifeq 482\n 442: aload 8\n 444: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 449: astore 9\n 451: aload 9\n 453: checkcast #31 // class Day07Kt$main$Node\n 456: astore 10\n 458: iconst_0\n 459: istore 11\n 461: aload 10\n 463: invokevirtual #121 // Method Day07Kt$main$Node.getDir:()Z\n 466: ifne 432\n 469: aload 6\n 471: aload 9\n 473: invokeinterface #83, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 478: pop\n 479: goto 432\n 482: aload 6\n 484: checkcast #26 // class java/util/List\n 487: nop\n 488: checkcast #42 // class java/lang/Iterable\n 491: astore_3\n 492: nop\n 493: iconst_0\n 494: istore 4\n 496: aload_3\n 497: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 502: astore 5\n 504: aload 5\n 506: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 511: ifeq 542\n 514: aload 5\n 516: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 521: astore 6\n 523: aload 6\n 525: checkcast #31 // class Day07Kt$main$Node\n 528: astore 7\n 530: iconst_0\n 531: istore 8\n 533: aload 7\n 535: invokevirtual #124 // Method Day07Kt$main$Node.propagateSize:()V\n 538: nop\n 539: goto 504\n 542: nop\n 543: nop\n 544: return\n\n public final java.util.List<java.lang.String> getInput();\n Code:\n 0: aload_0\n 1: getfield #21 // Field input:Ljava/util/List;\n 4: areturn\n\n public final java.util.List<Day07Kt$main$Node> getNodes();\n Code:\n 0: aload_0\n 1: getfield #29 // Field nodes:Ljava/util/List;\n 4: areturn\n\n public final Day07Kt$main$Node getRoot();\n Code:\n 0: aload_0\n 1: getfield #40 // Field root:LDay07Kt$main$Node;\n 4: areturn\n\n public final java.util.List<java.lang.String> component1();\n Code:\n 0: aload_0\n 1: getfield #21 // Field input:Ljava/util/List;\n 4: areturn\n\n public final Day07Kt$main$Common copy(java.util.List<java.lang.String>);\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: new #2 // class Day07Kt$main$Common\n 9: dup\n 10: aload_1\n 11: invokespecial #166 // Method \"<init>\":(Ljava/util/List;)V\n 14: areturn\n\n public static Day07Kt$main$Common copy$default(Day07Kt$main$Common, java.util.List, int, java.lang.Object);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 11\n 6: aload_0\n 7: getfield #21 // Field input:Ljava/util/List;\n 10: astore_1\n 11: aload_0\n 12: aload_1\n 13: invokevirtual #170 // Method copy:(Ljava/util/List;)LDay07Kt$main$Common;\n 16: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #174 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #175 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #177 // String Common(input=\n 9: invokevirtual #181 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #21 // Field input:Ljava/util/List;\n 16: invokevirtual #184 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: bipush 41\n 21: invokevirtual #187 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 24: invokevirtual #189 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 27: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #21 // Field input:Ljava/util/List;\n 4: invokevirtual #193 // Method java/lang/Object.hashCode:()I\n 7: 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 Day07Kt$main$Common\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day07Kt$main$Common\n 20: astore_2\n 21: aload_0\n 22: getfield #21 // Field input:Ljava/util/List;\n 25: aload_2\n 26: getfield #21 // Field input:Ljava/util/List;\n 29: invokestatic #93 // 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: iconst_1\n 38: ireturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day07Kt.class", "javap": "Compiled from \"Day07.kt\"\npublic final class Day07Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/Day07\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 main$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 main$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 private static final boolean isNumber(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #43 // Method kotlin/text/StringsKt.toIntOrNull:(Ljava/lang/String;)Ljava/lang/Integer;\n 4: ifnull 11\n 7: iconst_1\n 8: goto 12\n 11: iconst_0\n 12: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #48 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: new #53 // class Day07Kt$main$Common\n 3: dup\n 4: aload_0\n 5: invokespecial #57 // Method Day07Kt$main$Common.\"<init>\":(Ljava/util/List;)V\n 8: astore_1\n 9: aload_1\n 10: invokevirtual #61 // Method Day07Kt$main$Common.getNodes:()Ljava/util/List;\n 13: checkcast #63 // class java/lang/Iterable\n 16: astore_2\n 17: nop\n 18: iconst_0\n 19: istore_3\n 20: aload_2\n 21: astore 4\n 23: new #65 // class java/util/ArrayList\n 26: dup\n 27: invokespecial #67 // Method java/util/ArrayList.\"<init>\":()V\n 30: checkcast #69 // class java/util/Collection\n 33: astore 5\n 35: iconst_0\n 36: istore 6\n 38: aload 4\n 40: invokeinterface #73, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 7\n 47: aload 7\n 49: invokeinterface #79, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 115\n 57: aload 7\n 59: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 8\n 66: aload 8\n 68: checkcast #85 // class Day07Kt$main$Node\n 71: astore 9\n 73: iconst_0\n 74: istore 10\n 76: aload 9\n 78: invokevirtual #88 // Method Day07Kt$main$Node.getDir:()Z\n 81: ifeq 98\n 84: aload 9\n 86: invokevirtual #92 // Method Day07Kt$main$Node.getSize:()I\n 89: ldc #93 // int 100000\n 91: if_icmpgt 98\n 94: iconst_1\n 95: goto 99\n 98: iconst_0\n 99: ifeq 47\n 102: aload 5\n 104: aload 8\n 106: invokeinterface #97, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 111: pop\n 112: goto 47\n 115: aload 5\n 117: checkcast #99 // class java/util/List\n 120: nop\n 121: checkcast #63 // class java/lang/Iterable\n 124: astore_2\n 125: iconst_0\n 126: istore_3\n 127: aload_2\n 128: invokeinterface #73, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 133: astore 4\n 135: aload 4\n 137: invokeinterface #79, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 142: ifeq 183\n 145: aload 4\n 147: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 152: astore 5\n 154: iload_3\n 155: aload 5\n 157: checkcast #85 // class Day07Kt$main$Node\n 160: astore 6\n 162: istore 11\n 164: iconst_0\n 165: istore 7\n 167: aload 6\n 169: invokevirtual #92 // Method Day07Kt$main$Node.getSize:()I\n 172: istore 12\n 174: iload 11\n 176: iload 12\n 178: iadd\n 179: istore_3\n 180: goto 135\n 183: iload_3\n 184: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: new #53 // class Day07Kt$main$Common\n 3: dup\n 4: aload_0\n 5: invokespecial #57 // Method Day07Kt$main$Common.\"<init>\":(Ljava/util/List;)V\n 8: astore_1\n 9: ldc #116 // int 70000000\n 11: aload_1\n 12: invokevirtual #120 // Method Day07Kt$main$Common.getRoot:()LDay07Kt$main$Node;\n 15: invokevirtual #92 // Method Day07Kt$main$Node.getSize:()I\n 18: isub\n 19: istore_2\n 20: aload_1\n 21: invokevirtual #61 // Method Day07Kt$main$Common.getNodes:()Ljava/util/List;\n 24: checkcast #63 // class java/lang/Iterable\n 27: astore_3\n 28: nop\n 29: iconst_0\n 30: istore 4\n 32: aload_3\n 33: astore 5\n 35: new #65 // class java/util/ArrayList\n 38: dup\n 39: invokespecial #67 // Method java/util/ArrayList.\"<init>\":()V\n 42: checkcast #69 // class java/util/Collection\n 45: astore 6\n 47: iconst_0\n 48: istore 7\n 50: aload 5\n 52: invokeinterface #73, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 57: astore 8\n 59: aload 8\n 61: invokeinterface #79, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 66: ifeq 109\n 69: aload 8\n 71: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 76: astore 9\n 78: aload 9\n 80: checkcast #85 // class Day07Kt$main$Node\n 83: astore 10\n 85: iconst_0\n 86: istore 11\n 88: aload 10\n 90: invokevirtual #88 // Method Day07Kt$main$Node.getDir:()Z\n 93: ifeq 59\n 96: aload 6\n 98: aload 9\n 100: invokeinterface #97, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 105: pop\n 106: goto 59\n 109: aload 6\n 111: checkcast #99 // class java/util/List\n 114: nop\n 115: checkcast #63 // class java/lang/Iterable\n 118: astore_3\n 119: ldc #116 // int 70000000\n 121: istore 4\n 123: iconst_0\n 124: istore 5\n 126: iload 4\n 128: istore 6\n 130: aload_3\n 131: invokeinterface #73, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 136: astore 7\n 138: aload 7\n 140: invokeinterface #79, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 145: ifeq 209\n 148: aload 7\n 150: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 155: astore 8\n 157: iload 6\n 159: aload 8\n 161: checkcast #85 // class Day07Kt$main$Node\n 164: astore 9\n 166: istore 10\n 168: iconst_0\n 169: istore 11\n 171: iload_2\n 172: aload 9\n 174: invokevirtual #92 // Method Day07Kt$main$Node.getSize:()I\n 177: iadd\n 178: ldc #121 // int 30000000\n 180: if_icmplt 201\n 183: iload 10\n 185: aload 9\n 187: invokevirtual #92 // Method Day07Kt$main$Node.getSize:()I\n 190: if_icmple 201\n 193: aload 9\n 195: invokevirtual #92 // Method Day07Kt$main$Node.getSize:()I\n 198: goto 203\n 201: iload 10\n 203: nop\n 204: istore 6\n 206: goto 138\n 209: iload 6\n 211: ireturn\n\n public static final boolean access$isNumber(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #134 // Method isNumber:(Ljava/lang/String;)Z\n 4: ireturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day07Kt$main$Node.class", "javap": "Compiled from \"Day07.kt\"\npublic final class Day07Kt$main$Node {\n private final java.lang.String name;\n\n private int size;\n\n private final boolean dir;\n\n private final Day07Kt$main$Node parent;\n\n public Day07Kt$main$Node(java.lang.String, int, boolean, Day07Kt$main$Node);\n Code:\n 0: aload_1\n 1: ldc #8 // String name\n 3: invokestatic #14 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #17 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #20 // Field name:Ljava/lang/String;\n 15: aload_0\n 16: iload_2\n 17: putfield #24 // Field size:I\n 20: aload_0\n 21: iload_3\n 22: putfield #28 // Field dir:Z\n 25: aload_0\n 26: aload 4\n 28: putfield #32 // Field parent:LDay07Kt$main$Node;\n 31: return\n\n public Day07Kt$main$Node(java.lang.String, int, boolean, Day07Kt$main$Node, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload 5\n 2: iconst_2\n 3: iand\n 4: ifeq 9\n 7: iconst_0\n 8: istore_2\n 9: iload 5\n 11: iconst_4\n 12: iand\n 13: ifeq 18\n 16: iconst_0\n 17: istore_3\n 18: iload 5\n 20: bipush 8\n 22: iand\n 23: ifeq 29\n 26: aconst_null\n 27: astore 4\n 29: aload_0\n 30: aload_1\n 31: iload_2\n 32: iload_3\n 33: aload 4\n 35: invokespecial #36 // Method \"<init>\":(Ljava/lang/String;IZLDay07Kt$main$Node;)V\n 38: return\n\n public final java.lang.String getName();\n Code:\n 0: aload_0\n 1: getfield #20 // Field name:Ljava/lang/String;\n 4: areturn\n\n public final int getSize();\n Code:\n 0: aload_0\n 1: getfield #24 // 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 #24 // Field size:I\n 5: return\n\n public final boolean getDir();\n Code:\n 0: aload_0\n 1: getfield #28 // Field dir:Z\n 4: ireturn\n\n public final Day07Kt$main$Node getParent();\n Code:\n 0: aload_0\n 1: getfield #32 // Field parent:LDay07Kt$main$Node;\n 4: areturn\n\n public final void propagateSize();\n Code:\n 0: aload_0\n 1: getfield #32 // Field parent:LDay07Kt$main$Node;\n 4: astore_1\n 5: aload_1\n 6: ifnull 32\n 9: aload_1\n 10: astore_2\n 11: aload_2\n 12: aload_2\n 13: getfield #24 // Field size:I\n 16: aload_0\n 17: getfield #24 // Field size:I\n 20: iadd\n 21: putfield #24 // Field size:I\n 24: aload_1\n 25: getfield #32 // Field parent:LDay07Kt$main$Node;\n 28: astore_1\n 29: goto 5\n 32: return\n\n public final java.lang.String component1();\n Code:\n 0: aload_0\n 1: getfield #20 // Field name:Ljava/lang/String;\n 4: areturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #24 // Field size:I\n 4: ireturn\n\n public final boolean component3();\n Code:\n 0: aload_0\n 1: getfield #28 // Field dir:Z\n 4: ireturn\n\n public final Day07Kt$main$Node component4();\n Code:\n 0: aload_0\n 1: getfield #32 // Field parent:LDay07Kt$main$Node;\n 4: areturn\n\n public final Day07Kt$main$Node copy(java.lang.String, int, boolean, Day07Kt$main$Node);\n Code:\n 0: aload_1\n 1: ldc #8 // String name\n 3: invokestatic #14 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class Day07Kt$main$Node\n 9: dup\n 10: aload_1\n 11: iload_2\n 12: iload_3\n 13: aload 4\n 15: invokespecial #36 // Method \"<init>\":(Ljava/lang/String;IZLDay07Kt$main$Node;)V\n 18: areturn\n\n public static Day07Kt$main$Node copy$default(Day07Kt$main$Node, java.lang.String, int, boolean, Day07Kt$main$Node, int, java.lang.Object);\n Code:\n 0: iload 5\n 2: iconst_1\n 3: iand\n 4: ifeq 12\n 7: aload_0\n 8: getfield #20 // Field name:Ljava/lang/String;\n 11: astore_1\n 12: iload 5\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #24 // Field size:I\n 23: istore_2\n 24: iload 5\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #28 // Field dir:Z\n 35: istore_3\n 36: iload 5\n 38: bipush 8\n 40: iand\n 41: ifeq 50\n 44: aload_0\n 45: getfield #32 // Field parent:LDay07Kt$main$Node;\n 48: astore 4\n 50: aload_0\n 51: aload_1\n 52: iload_2\n 53: iload_3\n 54: aload 4\n 56: invokevirtual #59 // Method copy:(Ljava/lang/String;IZLDay07Kt$main$Node;)LDay07Kt$main$Node;\n 59: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #62 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #63 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #65 // String Node(name=\n 9: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #20 // Field name:Ljava/lang/String;\n 16: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 19: ldc #71 // String , size=\n 21: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #24 // Field size:I\n 28: invokevirtual #74 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #76 // String , dir=\n 33: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #28 // Field dir:Z\n 40: invokevirtual #79 // Method java/lang/StringBuilder.append:(Z)Ljava/lang/StringBuilder;\n 43: ldc #81 // String , parent=\n 45: invokevirtual #69 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: aload_0\n 49: getfield #32 // Field parent:LDay07Kt$main$Node;\n 52: invokevirtual #84 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 55: bipush 41\n 57: invokevirtual #87 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 60: invokevirtual #89 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 63: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #20 // Field name:Ljava/lang/String;\n 4: invokevirtual #94 // 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 #24 // Field size:I\n 16: invokestatic #99 // 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 dir:Z\n 29: invokestatic #104 // Method java/lang/Boolean.hashCode:(Z)I\n 32: iadd\n 33: istore_1\n 34: iload_1\n 35: bipush 31\n 37: imul\n 38: aload_0\n 39: getfield #32 // Field parent:LDay07Kt$main$Node;\n 42: ifnonnull 49\n 45: iconst_0\n 46: goto 56\n 49: aload_0\n 50: getfield #32 // Field parent:LDay07Kt$main$Node;\n 53: invokevirtual #105 // Method hashCode:()I\n 56: iadd\n 57: istore_1\n 58: iload_1\n 59: 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 Day07Kt$main$Node\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day07Kt$main$Node\n 20: astore_2\n 21: aload_0\n 22: getfield #20 // Field name:Ljava/lang/String;\n 25: aload_2\n 26: getfield #20 // Field name:Ljava/lang/String;\n 29: invokestatic #112 // 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 #24 // Field size:I\n 41: aload_2\n 42: getfield #24 // Field size:I\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: aload_0\n 51: getfield #28 // Field dir:Z\n 54: aload_2\n 55: getfield #28 // Field dir:Z\n 58: if_icmpeq 63\n 61: iconst_0\n 62: ireturn\n 63: aload_0\n 64: getfield #32 // Field parent:LDay07Kt$main$Node;\n 67: aload_2\n 68: getfield #32 // Field parent:LDay07Kt$main$Node;\n 71: invokestatic #112 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 74: ifne 79\n 77: iconst_0\n 78: ireturn\n 79: iconst_1\n 80: ireturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day10.kt
fun main() { data class Step(val cycle: Int, val sum: Int) fun run(input: List<String>): MutableList<Step>{ var cycle = 1 var sum = 1 val steps = mutableListOf<Step>() input.forEach { when (it) { "noop" -> steps.add(Step(cycle++, sum)) else -> { val (_, amount) = it.split(" ") steps += Step(cycle++, sum) steps += Step(cycle++, sum) sum += amount.toInt() } } } return steps } fun part1(input: List<String>): Int { val cycles = List(6) { i -> 20 + i * 40 } return run(input) .filter { it.cycle in cycles } .sumOf { it.cycle * it.sum } } fun part2(input: List<String>) { run(input) .map { val sprite = it.sum - 1..it.sum + 1 if ((it.cycle - 1) % 40 in sprite) "🟨" else "⬛" } .chunked(40) .forEach { println(it.joinToString("")) } } val input = readInput("inputs/Day10") println(part1(input)) part2(input) }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day10Kt$main$Step.class", "javap": "Compiled from \"Day10.kt\"\npublic final class Day10Kt$main$Step {\n private final int cycle;\n\n private final int sum;\n\n public Day10Kt$main$Step(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 cycle:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field sum:I\n 14: return\n\n public final int getCycle();\n Code:\n 0: aload_0\n 1: getfield #13 // Field cycle:I\n 4: ireturn\n\n public final int getSum();\n Code:\n 0: aload_0\n 1: getfield #16 // Field sum:I\n 4: ireturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field cycle:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field sum:I\n 4: ireturn\n\n public final Day10Kt$main$Step copy(int, int);\n Code:\n 0: new #2 // class Day10Kt$main$Step\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: invokespecial #27 // Method \"<init>\":(II)V\n 9: areturn\n\n public static Day10Kt$main$Step copy$default(Day10Kt$main$Step, int, int, 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 #13 // Field cycle:I\n 10: istore_1\n 11: iload_3\n 12: iconst_2\n 13: iand\n 14: ifeq 22\n 17: aload_0\n 18: getfield #16 // Field sum:I\n 21: istore_2\n 22: aload_0\n 23: iload_1\n 24: iload_2\n 25: invokevirtual #31 // Method copy:(II)LDay10Kt$main$Step;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #35 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #36 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #38 // String Step(cycle=\n 9: invokevirtual #42 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field cycle:I\n 16: invokevirtual #45 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #47 // String , sum=\n 21: invokevirtual #42 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field sum:I\n 28: invokevirtual #45 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #50 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #52 // 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 #13 // Field cycle:I\n 4: invokestatic #58 // 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 sum:I\n 16: invokestatic #58 // Method java/lang/Integer.hashCode:(I)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 Day10Kt$main$Step\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day10Kt$main$Step\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field cycle:I\n 25: aload_2\n 26: getfield #13 // Field cycle:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field sum:I\n 38: aload_2\n 39: getfield #16 // Field sum:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: iconst_1\n 48: ireturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day10Kt.class", "javap": "Compiled from \"Day10.kt\"\npublic final class Day10Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/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 main$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 main$part2:(Ljava/util/List;)V\n 22: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #39 // Method main:()V\n 3: return\n\n private static final java.util.List<Day10Kt$main$Step> main$run(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: iconst_0\n 5: istore_2\n 6: iconst_1\n 7: istore_2\n 8: new #46 // class java/util/ArrayList\n 11: dup\n 12: invokespecial #49 // Method java/util/ArrayList.\"<init>\":()V\n 15: checkcast #51 // class java/util/List\n 18: astore_3\n 19: aload_0\n 20: checkcast #53 // class java/lang/Iterable\n 23: astore 4\n 25: iconst_0\n 26: istore 5\n 28: aload 4\n 30: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 35: astore 6\n 37: aload 6\n 39: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 44: ifeq 221\n 47: aload 6\n 49: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 54: astore 7\n 56: aload 7\n 58: checkcast #69 // class java/lang/String\n 61: astore 8\n 63: iconst_0\n 64: istore 9\n 66: aload 8\n 68: ldc #71 // String noop\n 70: invokestatic #77 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 73: ifeq 104\n 76: aload_3\n 77: new #79 // class Day10Kt$main$Step\n 80: dup\n 81: iload_1\n 82: istore 10\n 84: iload 10\n 86: iconst_1\n 87: iadd\n 88: istore_1\n 89: iload 10\n 91: iload_2\n 92: invokespecial #82 // Method Day10Kt$main$Step.\"<init>\":(II)V\n 95: invokeinterface #86, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 100: pop\n 101: goto 216\n 104: aload 8\n 106: checkcast #88 // class java/lang/CharSequence\n 109: iconst_1\n 110: anewarray #69 // class java/lang/String\n 113: astore 11\n 115: aload 11\n 117: iconst_0\n 118: ldc #90 // String\n 120: aastore\n 121: aload 11\n 123: iconst_0\n 124: iconst_0\n 125: bipush 6\n 127: aconst_null\n 128: invokestatic #96 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 131: iconst_1\n 132: invokeinterface #100, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 137: checkcast #69 // class java/lang/String\n 140: astore 11\n 142: aload_3\n 143: checkcast #102 // class java/util/Collection\n 146: astore 12\n 148: new #79 // class Day10Kt$main$Step\n 151: dup\n 152: iload_1\n 153: istore 13\n 155: iload 13\n 157: iconst_1\n 158: iadd\n 159: istore_1\n 160: iload 13\n 162: iload_2\n 163: invokespecial #82 // Method Day10Kt$main$Step.\"<init>\":(II)V\n 166: aload 12\n 168: swap\n 169: invokeinterface #103, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 174: pop\n 175: aload_3\n 176: checkcast #102 // class java/util/Collection\n 179: astore 12\n 181: new #79 // class Day10Kt$main$Step\n 184: dup\n 185: iload_1\n 186: istore 13\n 188: iload 13\n 190: iconst_1\n 191: iadd\n 192: istore_1\n 193: iload 13\n 195: iload_2\n 196: invokespecial #82 // Method Day10Kt$main$Step.\"<init>\":(II)V\n 199: aload 12\n 201: swap\n 202: invokeinterface #103, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 207: pop\n 208: iload_2\n 209: aload 11\n 211: invokestatic #109 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 214: iadd\n 215: istore_2\n 216: nop\n 217: nop\n 218: goto 37\n 221: nop\n 222: aload_3\n 223: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: bipush 6\n 2: istore_2\n 3: new #46 // class java/util/ArrayList\n 6: dup\n 7: iload_2\n 8: invokespecial #125 // Method java/util/ArrayList.\"<init>\":(I)V\n 11: astore_3\n 12: iconst_0\n 13: istore 4\n 15: iload 4\n 17: iload_2\n 18: if_icmpge 59\n 21: iload 4\n 23: istore 5\n 25: aload_3\n 26: iload 5\n 28: istore 6\n 30: astore 11\n 32: iconst_0\n 33: istore 7\n 35: bipush 20\n 37: iload 6\n 39: bipush 40\n 41: imul\n 42: iadd\n 43: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 46: aload 11\n 48: swap\n 49: invokevirtual #130 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 52: pop\n 53: iinc 4, 1\n 56: goto 15\n 59: aload_3\n 60: checkcast #51 // class java/util/List\n 63: astore_1\n 64: aload_0\n 65: invokestatic #132 // Method main$run:(Ljava/util/List;)Ljava/util/List;\n 68: checkcast #53 // class java/lang/Iterable\n 71: astore_2\n 72: nop\n 73: iconst_0\n 74: istore_3\n 75: aload_2\n 76: astore 4\n 78: new #46 // class java/util/ArrayList\n 81: dup\n 82: invokespecial #49 // Method java/util/ArrayList.\"<init>\":()V\n 85: checkcast #102 // class java/util/Collection\n 88: astore 5\n 90: iconst_0\n 91: istore 6\n 93: aload 4\n 95: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 100: astore 7\n 102: aload 7\n 104: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 109: ifeq 161\n 112: aload 7\n 114: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 119: astore 8\n 121: aload 8\n 123: checkcast #79 // class Day10Kt$main$Step\n 126: astore 9\n 128: iconst_0\n 129: istore 10\n 131: aload_1\n 132: aload 9\n 134: invokevirtual #136 // Method Day10Kt$main$Step.getCycle:()I\n 137: invokestatic #129 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 140: invokeinterface #139, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 145: ifeq 102\n 148: aload 5\n 150: aload 8\n 152: invokeinterface #103, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 157: pop\n 158: goto 102\n 161: aload 5\n 163: checkcast #51 // class java/util/List\n 166: nop\n 167: checkcast #53 // class java/lang/Iterable\n 170: astore_2\n 171: iconst_0\n 172: istore_3\n 173: aload_2\n 174: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 179: astore 4\n 181: aload 4\n 183: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 188: ifeq 235\n 191: aload 4\n 193: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 198: astore 5\n 200: iload_3\n 201: aload 5\n 203: checkcast #79 // class Day10Kt$main$Step\n 206: astore 6\n 208: istore 11\n 210: iconst_0\n 211: istore 7\n 213: aload 6\n 215: invokevirtual #136 // Method Day10Kt$main$Step.getCycle:()I\n 218: aload 6\n 220: invokevirtual #142 // Method Day10Kt$main$Step.getSum:()I\n 223: imul\n 224: istore 12\n 226: iload 11\n 228: iload 12\n 230: iadd\n 231: istore_3\n 232: goto 181\n 235: iload_3\n 236: ireturn\n\n private static final void main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #132 // Method main$run:(Ljava/util/List;)Ljava/util/List;\n 4: checkcast #53 // class java/lang/Iterable\n 7: astore_1\n 8: nop\n 9: iconst_0\n 10: istore_2\n 11: aload_1\n 12: astore_3\n 13: new #46 // class java/util/ArrayList\n 16: dup\n 17: aload_1\n 18: bipush 10\n 20: invokestatic #162 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 23: invokespecial #125 // Method java/util/ArrayList.\"<init>\":(I)V\n 26: checkcast #102 // class java/util/Collection\n 29: astore 4\n 31: iconst_0\n 32: istore 5\n 34: aload_3\n 35: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 40: astore 6\n 42: aload 6\n 44: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 49: ifeq 169\n 52: aload 6\n 54: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 59: astore 7\n 61: aload 4\n 63: aload 7\n 65: checkcast #79 // class Day10Kt$main$Step\n 68: astore 8\n 70: astore 14\n 72: iconst_0\n 73: istore 9\n 75: new #164 // class kotlin/ranges/IntRange\n 78: dup\n 79: aload 8\n 81: invokevirtual #142 // Method Day10Kt$main$Step.getSum:()I\n 84: iconst_1\n 85: isub\n 86: aload 8\n 88: invokevirtual #142 // Method Day10Kt$main$Step.getSum:()I\n 91: iconst_1\n 92: iadd\n 93: invokespecial #165 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 96: astore 10\n 98: aload 10\n 100: invokevirtual #168 // Method kotlin/ranges/IntRange.getFirst:()I\n 103: istore 11\n 105: aload 10\n 107: invokevirtual #171 // Method kotlin/ranges/IntRange.getLast:()I\n 110: istore 12\n 112: aload 8\n 114: invokevirtual #136 // Method Day10Kt$main$Step.getCycle:()I\n 117: iconst_1\n 118: isub\n 119: bipush 40\n 121: irem\n 122: istore 13\n 124: iload 11\n 126: iload 13\n 128: if_icmpgt 146\n 131: iload 13\n 133: iload 12\n 135: if_icmpgt 142\n 138: iconst_1\n 139: goto 147\n 142: iconst_0\n 143: goto 147\n 146: iconst_0\n 147: ifeq 155\n 150: ldc #173 // String 🟨\n 152: goto 157\n 155: ldc #175 // String ⬛\n 157: aload 14\n 159: swap\n 160: invokeinterface #103, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 165: pop\n 166: goto 42\n 169: aload 4\n 171: checkcast #51 // class java/util/List\n 174: nop\n 175: checkcast #53 // class java/lang/Iterable\n 178: bipush 40\n 180: invokestatic #179 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 183: checkcast #53 // class java/lang/Iterable\n 186: astore_1\n 187: nop\n 188: iconst_0\n 189: istore_2\n 190: aload_1\n 191: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 196: astore_3\n 197: aload_3\n 198: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 203: ifeq 257\n 206: aload_3\n 207: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 212: astore 4\n 214: aload 4\n 216: checkcast #51 // class java/util/List\n 219: astore 5\n 221: iconst_0\n 222: istore 6\n 224: aload 5\n 226: checkcast #53 // class java/lang/Iterable\n 229: ldc #181 // String\n 231: checkcast #88 // class java/lang/CharSequence\n 234: aconst_null\n 235: aconst_null\n 236: iconst_0\n 237: aconst_null\n 238: aconst_null\n 239: bipush 62\n 241: aconst_null\n 242: invokestatic #185 // 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 245: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 248: swap\n 249: invokevirtual #188 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 252: nop\n 253: nop\n 254: goto 197\n 257: nop\n 258: return\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day18.kt
fun main() { data class Cube(val x: Int, val y: Int, val z: Int) fun Cube.adjacents(): List<Cube> { return 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), ) } fun parse(input: List<String>): Set<Cube> { return input.map { it.split(",").map { n -> n.toInt() } } .map { (x, y, z) -> Cube(x, y, z) } .toSet() } fun part1(input: List<String>): Int { val cubes = parse(input) return cubes.sumOf { (it.adjacents() - cubes).size } } fun part2(input: List<String>): Int { val cubes = parse(input) val xRange = cubes.minOf { it.x } - 1..cubes.maxOf { it.x } + 1 val yRange = cubes.minOf { it.y } - 1..cubes.maxOf { it.y } + 1 val zRange = cubes.minOf { it.z } - 1..cubes.maxOf { it.z } + 1 val queue = ArrayDeque<Cube>().apply { add(Cube(xRange.first, yRange.first, zRange.first)) } val seen = mutableSetOf<Cube>() var sides = 0 queue.forEach { current -> if (current !in seen) { seen += current current.adjacents() .filter { it.x in xRange && it.y in yRange && it.z in zRange } .forEach { adj -> if (adj in cubes) sides++ else queue.add(adj) } } } return sides } val input = readInput("inputs/Day18") println(part1(input)) println(part2(input)) }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day18Kt$main$Cube.class", "javap": "Compiled from \"Day18.kt\"\npublic final class Day18Kt$main$Cube {\n private final int x;\n\n private final int y;\n\n private final int z;\n\n public Day18Kt$main$Cube(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 x:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field y:I\n 14: aload_0\n 15: iload_3\n 16: putfield #19 // Field z:I\n 19: return\n\n public final int getX();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int getY();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public final int getZ();\n Code:\n 0: aload_0\n 1: getfield #19 // Field z:I\n 4: ireturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #19 // Field z:I\n 4: ireturn\n\n public final Day18Kt$main$Cube copy(int, int, int);\n Code:\n 0: new #2 // class Day18Kt$main$Cube\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: iload_3\n 7: invokespecial #32 // Method \"<init>\":(III)V\n 10: areturn\n\n public static Day18Kt$main$Cube copy$default(Day18Kt$main$Cube, 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 x: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 y: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 z:I\n 35: istore_3\n 36: aload_0\n 37: iload_1\n 38: iload_2\n 39: iload_3\n 40: invokevirtual #36 // Method copy:(III)LDay18Kt$main$Cube;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #40 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #41 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #43 // String Cube(x=\n 9: invokevirtual #47 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field x:I\n 16: invokevirtual #50 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #52 // String , y=\n 21: invokevirtual #47 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field y:I\n 28: invokevirtual #50 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #54 // String , z=\n 33: invokevirtual #47 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #19 // Field z:I\n 40: invokevirtual #50 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #57 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #59 // 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 x:I\n 4: invokestatic #65 // 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 y:I\n 16: invokestatic #65 // 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 z:I\n 29: invokestatic #65 // 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 Day18Kt$main$Cube\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day18Kt$main$Cube\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field x:I\n 25: aload_2\n 26: getfield #13 // Field x:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field y:I\n 38: aload_2\n 39: getfield #16 // Field y:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #19 // Field z:I\n 51: aload_2\n 52: getfield #19 // Field z: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": "ambrosil__aoc-2022__ebaacfc/Day18Kt.class", "javap": "Compiled from \"Day18.kt\"\npublic final class Day18Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/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 main$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 main$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 void main(java.lang.String[]);\n Code:\n 0: invokestatic #38 // Method main:()V\n 3: return\n\n private static final java.util.List<Day18Kt$main$Cube> main$adjacents(Day18Kt$main$Cube);\n Code:\n 0: bipush 6\n 2: anewarray #45 // class Day18Kt$main$Cube\n 5: astore_1\n 6: aload_1\n 7: iconst_0\n 8: new #45 // class Day18Kt$main$Cube\n 11: dup\n 12: aload_0\n 13: invokevirtual #49 // Method Day18Kt$main$Cube.getX:()I\n 16: iconst_1\n 17: iadd\n 18: aload_0\n 19: invokevirtual #52 // Method Day18Kt$main$Cube.getY:()I\n 22: aload_0\n 23: invokevirtual #55 // Method Day18Kt$main$Cube.getZ:()I\n 26: invokespecial #59 // Method Day18Kt$main$Cube.\"<init>\":(III)V\n 29: aastore\n 30: aload_1\n 31: iconst_1\n 32: new #45 // class Day18Kt$main$Cube\n 35: dup\n 36: aload_0\n 37: invokevirtual #49 // Method Day18Kt$main$Cube.getX:()I\n 40: iconst_1\n 41: isub\n 42: aload_0\n 43: invokevirtual #52 // Method Day18Kt$main$Cube.getY:()I\n 46: aload_0\n 47: invokevirtual #55 // Method Day18Kt$main$Cube.getZ:()I\n 50: invokespecial #59 // Method Day18Kt$main$Cube.\"<init>\":(III)V\n 53: aastore\n 54: aload_1\n 55: iconst_2\n 56: new #45 // class Day18Kt$main$Cube\n 59: dup\n 60: aload_0\n 61: invokevirtual #49 // Method Day18Kt$main$Cube.getX:()I\n 64: aload_0\n 65: invokevirtual #52 // Method Day18Kt$main$Cube.getY:()I\n 68: iconst_1\n 69: iadd\n 70: aload_0\n 71: invokevirtual #55 // Method Day18Kt$main$Cube.getZ:()I\n 74: invokespecial #59 // Method Day18Kt$main$Cube.\"<init>\":(III)V\n 77: aastore\n 78: aload_1\n 79: iconst_3\n 80: new #45 // class Day18Kt$main$Cube\n 83: dup\n 84: aload_0\n 85: invokevirtual #49 // Method Day18Kt$main$Cube.getX:()I\n 88: aload_0\n 89: invokevirtual #52 // Method Day18Kt$main$Cube.getY:()I\n 92: iconst_1\n 93: isub\n 94: aload_0\n 95: invokevirtual #55 // Method Day18Kt$main$Cube.getZ:()I\n 98: invokespecial #59 // Method Day18Kt$main$Cube.\"<init>\":(III)V\n 101: aastore\n 102: aload_1\n 103: iconst_4\n 104: new #45 // class Day18Kt$main$Cube\n 107: dup\n 108: aload_0\n 109: invokevirtual #49 // Method Day18Kt$main$Cube.getX:()I\n 112: aload_0\n 113: invokevirtual #52 // Method Day18Kt$main$Cube.getY:()I\n 116: aload_0\n 117: invokevirtual #55 // Method Day18Kt$main$Cube.getZ:()I\n 120: iconst_1\n 121: iadd\n 122: invokespecial #59 // Method Day18Kt$main$Cube.\"<init>\":(III)V\n 125: aastore\n 126: aload_1\n 127: iconst_5\n 128: new #45 // class Day18Kt$main$Cube\n 131: dup\n 132: aload_0\n 133: invokevirtual #49 // Method Day18Kt$main$Cube.getX:()I\n 136: aload_0\n 137: invokevirtual #52 // Method Day18Kt$main$Cube.getY:()I\n 140: aload_0\n 141: invokevirtual #55 // Method Day18Kt$main$Cube.getZ:()I\n 144: iconst_1\n 145: isub\n 146: invokespecial #59 // Method Day18Kt$main$Cube.\"<init>\":(III)V\n 149: aastore\n 150: aload_1\n 151: invokestatic #65 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 154: areturn\n\n private static final java.util.Set<Day18Kt$main$Cube> main$parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #72 // 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 #74 // class java/util/ArrayList\n 12: dup\n 13: aload_1\n 14: bipush 10\n 16: invokestatic #78 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 22: checkcast #82 // class java/util/Collection\n 25: astore 4\n 27: iconst_0\n 28: istore 5\n 30: aload_3\n 31: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 6\n 38: aload 6\n 40: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 214\n 48: aload 6\n 50: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 7\n 57: aload 4\n 59: aload 7\n 61: checkcast #98 // class java/lang/String\n 64: astore 8\n 66: astore 20\n 68: iconst_0\n 69: istore 9\n 71: aload 8\n 73: checkcast #100 // class java/lang/CharSequence\n 76: iconst_1\n 77: anewarray #98 // class java/lang/String\n 80: astore 10\n 82: aload 10\n 84: iconst_0\n 85: ldc #102 // 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 #108 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 98: checkcast #72 // class java/lang/Iterable\n 101: astore 10\n 103: iconst_0\n 104: istore 11\n 106: aload 10\n 108: astore 12\n 110: new #74 // class java/util/ArrayList\n 113: dup\n 114: aload 10\n 116: bipush 10\n 118: invokestatic #78 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 121: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 124: checkcast #82 // class java/util/Collection\n 127: astore 13\n 129: iconst_0\n 130: istore 14\n 132: aload 12\n 134: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 139: astore 15\n 141: aload 15\n 143: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 148: ifeq 195\n 151: aload 15\n 153: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 158: astore 16\n 160: aload 13\n 162: aload 16\n 164: checkcast #98 // class java/lang/String\n 167: astore 17\n 169: astore 18\n 171: iconst_0\n 172: istore 19\n 174: aload 17\n 176: invokestatic #114 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 179: nop\n 180: invokestatic #118 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 183: aload 18\n 185: swap\n 186: invokeinterface #122, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 191: pop\n 192: goto 141\n 195: aload 13\n 197: checkcast #124 // class java/util/List\n 200: nop\n 201: nop\n 202: aload 20\n 204: swap\n 205: invokeinterface #122, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 210: pop\n 211: goto 38\n 214: aload 4\n 216: checkcast #124 // class java/util/List\n 219: nop\n 220: checkcast #72 // class java/lang/Iterable\n 223: astore_1\n 224: nop\n 225: iconst_0\n 226: istore_2\n 227: aload_1\n 228: astore_3\n 229: new #74 // class java/util/ArrayList\n 232: dup\n 233: aload_1\n 234: bipush 10\n 236: invokestatic #78 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 239: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 242: checkcast #82 // class java/util/Collection\n 245: astore 4\n 247: iconst_0\n 248: istore 5\n 250: aload_3\n 251: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 256: astore 6\n 258: aload 6\n 260: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 265: ifeq 364\n 268: aload 6\n 270: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 275: astore 7\n 277: aload 4\n 279: aload 7\n 281: checkcast #124 // class java/util/List\n 284: astore 8\n 286: astore 20\n 288: iconst_0\n 289: istore 9\n 291: aload 8\n 293: iconst_0\n 294: invokeinterface #128, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 299: checkcast #130 // class java/lang/Number\n 302: invokevirtual #133 // Method java/lang/Number.intValue:()I\n 305: istore 10\n 307: aload 8\n 309: iconst_1\n 310: invokeinterface #128, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 315: checkcast #130 // class java/lang/Number\n 318: invokevirtual #133 // Method java/lang/Number.intValue:()I\n 321: istore 11\n 323: aload 8\n 325: iconst_2\n 326: invokeinterface #128, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 331: checkcast #130 // class java/lang/Number\n 334: invokevirtual #133 // Method java/lang/Number.intValue:()I\n 337: istore 12\n 339: new #45 // class Day18Kt$main$Cube\n 342: dup\n 343: iload 10\n 345: iload 11\n 347: iload 12\n 349: invokespecial #59 // Method Day18Kt$main$Cube.\"<init>\":(III)V\n 352: aload 20\n 354: swap\n 355: invokeinterface #122, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 360: pop\n 361: goto 258\n 364: aload 4\n 366: checkcast #124 // class java/util/List\n 369: nop\n 370: checkcast #72 // class java/lang/Iterable\n 373: invokestatic #137 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 376: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #159 // Method main$parse:(Ljava/util/List;)Ljava/util/Set;\n 4: astore_1\n 5: aload_1\n 6: checkcast #72 // class java/lang/Iterable\n 9: astore_2\n 10: iconst_0\n 11: istore_3\n 12: aload_2\n 13: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 18: astore 4\n 20: aload 4\n 22: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 27: ifeq 83\n 30: aload 4\n 32: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 37: astore 5\n 39: iload_3\n 40: aload 5\n 42: checkcast #45 // class Day18Kt$main$Cube\n 45: astore 6\n 47: istore 8\n 49: iconst_0\n 50: istore 7\n 52: aload 6\n 54: invokestatic #161 // Method main$adjacents:(LDay18Kt$main$Cube;)Ljava/util/List;\n 57: checkcast #72 // class java/lang/Iterable\n 60: aload_1\n 61: checkcast #72 // class java/lang/Iterable\n 64: invokestatic #165 // Method kotlin/collections/CollectionsKt.minus:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;\n 67: invokeinterface #168, 1 // InterfaceMethod java/util/List.size:()I\n 72: istore 9\n 74: iload 8\n 76: iload 9\n 78: iadd\n 79: istore_3\n 80: goto 20\n 83: iload_3\n 84: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #159 // Method main$parse:(Ljava/util/List;)Ljava/util/Set;\n 4: astore_1\n 5: aload_1\n 6: checkcast #72 // class java/lang/Iterable\n 9: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 14: astore 4\n 16: aload 4\n 18: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 23: ifne 34\n 26: new #175 // class java/util/NoSuchElementException\n 29: dup\n 30: invokespecial #177 // Method java/util/NoSuchElementException.\"<init>\":()V\n 33: athrow\n 34: aload 4\n 36: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 41: checkcast #45 // class Day18Kt$main$Cube\n 44: astore 5\n 46: iconst_0\n 47: istore 6\n 49: aload 5\n 51: invokevirtual #49 // Method Day18Kt$main$Cube.getX:()I\n 54: istore 5\n 56: aload 4\n 58: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 63: ifeq 102\n 66: aload 4\n 68: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 73: checkcast #45 // class Day18Kt$main$Cube\n 76: astore 6\n 78: iconst_0\n 79: istore 7\n 81: aload 6\n 83: invokevirtual #49 // Method Day18Kt$main$Cube.getX:()I\n 86: istore 6\n 88: iload 5\n 90: iload 6\n 92: if_icmple 56\n 95: iload 6\n 97: istore 5\n 99: goto 56\n 102: iload 5\n 104: iconst_1\n 105: isub\n 106: aload_1\n 107: checkcast #72 // class java/lang/Iterable\n 110: astore_3\n 111: istore 26\n 113: aload_3\n 114: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 119: astore 4\n 121: aload 4\n 123: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 128: ifne 139\n 131: new #175 // class java/util/NoSuchElementException\n 134: dup\n 135: invokespecial #177 // Method java/util/NoSuchElementException.\"<init>\":()V\n 138: athrow\n 139: aload 4\n 141: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 146: checkcast #45 // class Day18Kt$main$Cube\n 149: astore 5\n 151: iconst_0\n 152: istore 6\n 154: aload 5\n 156: invokevirtual #49 // Method Day18Kt$main$Cube.getX:()I\n 159: istore 5\n 161: aload 4\n 163: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 168: ifeq 207\n 171: aload 4\n 173: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 178: checkcast #45 // class Day18Kt$main$Cube\n 181: astore 6\n 183: iconst_0\n 184: istore 7\n 186: aload 6\n 188: invokevirtual #49 // Method Day18Kt$main$Cube.getX:()I\n 191: istore 6\n 193: iload 5\n 195: iload 6\n 197: if_icmpge 161\n 200: iload 6\n 202: istore 5\n 204: goto 161\n 207: iload 5\n 209: istore 27\n 211: iload 26\n 213: iload 27\n 215: iconst_1\n 216: iadd\n 217: istore 28\n 219: istore 29\n 221: new #179 // class kotlin/ranges/IntRange\n 224: dup\n 225: iload 29\n 227: iload 28\n 229: invokespecial #182 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 232: astore_2\n 233: aload_1\n 234: checkcast #72 // class java/lang/Iterable\n 237: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 242: astore 5\n 244: aload 5\n 246: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 251: ifne 262\n 254: new #175 // class java/util/NoSuchElementException\n 257: dup\n 258: invokespecial #177 // Method java/util/NoSuchElementException.\"<init>\":()V\n 261: athrow\n 262: aload 5\n 264: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 269: checkcast #45 // class Day18Kt$main$Cube\n 272: astore 6\n 274: iconst_0\n 275: istore 7\n 277: aload 6\n 279: invokevirtual #52 // Method Day18Kt$main$Cube.getY:()I\n 282: istore 6\n 284: aload 5\n 286: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 291: ifeq 330\n 294: aload 5\n 296: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 301: checkcast #45 // class Day18Kt$main$Cube\n 304: astore 7\n 306: iconst_0\n 307: istore 8\n 309: aload 7\n 311: invokevirtual #52 // Method Day18Kt$main$Cube.getY:()I\n 314: istore 7\n 316: iload 6\n 318: iload 7\n 320: if_icmple 284\n 323: iload 7\n 325: istore 6\n 327: goto 284\n 330: iload 6\n 332: iconst_1\n 333: isub\n 334: aload_1\n 335: checkcast #72 // class java/lang/Iterable\n 338: astore 4\n 340: istore 26\n 342: aload 4\n 344: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 349: astore 5\n 351: aload 5\n 353: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 358: ifne 369\n 361: new #175 // class java/util/NoSuchElementException\n 364: dup\n 365: invokespecial #177 // Method java/util/NoSuchElementException.\"<init>\":()V\n 368: athrow\n 369: aload 5\n 371: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 376: checkcast #45 // class Day18Kt$main$Cube\n 379: astore 6\n 381: iconst_0\n 382: istore 7\n 384: aload 6\n 386: invokevirtual #52 // Method Day18Kt$main$Cube.getY:()I\n 389: istore 6\n 391: aload 5\n 393: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 398: ifeq 437\n 401: aload 5\n 403: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 408: checkcast #45 // class Day18Kt$main$Cube\n 411: astore 7\n 413: iconst_0\n 414: istore 8\n 416: aload 7\n 418: invokevirtual #52 // Method Day18Kt$main$Cube.getY:()I\n 421: istore 7\n 423: iload 6\n 425: iload 7\n 427: if_icmpge 391\n 430: iload 7\n 432: istore 6\n 434: goto 391\n 437: iload 6\n 439: istore 27\n 441: iload 26\n 443: iload 27\n 445: iconst_1\n 446: iadd\n 447: istore 30\n 449: istore 31\n 451: new #179 // class kotlin/ranges/IntRange\n 454: dup\n 455: iload 31\n 457: iload 30\n 459: invokespecial #182 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 462: astore_3\n 463: aload_1\n 464: checkcast #72 // class java/lang/Iterable\n 467: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 472: astore 6\n 474: aload 6\n 476: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 481: ifne 492\n 484: new #175 // class java/util/NoSuchElementException\n 487: dup\n 488: invokespecial #177 // Method java/util/NoSuchElementException.\"<init>\":()V\n 491: athrow\n 492: aload 6\n 494: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 499: checkcast #45 // class Day18Kt$main$Cube\n 502: astore 7\n 504: iconst_0\n 505: istore 8\n 507: aload 7\n 509: invokevirtual #55 // Method Day18Kt$main$Cube.getZ:()I\n 512: istore 7\n 514: aload 6\n 516: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 521: ifeq 560\n 524: aload 6\n 526: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 531: checkcast #45 // class Day18Kt$main$Cube\n 534: astore 8\n 536: iconst_0\n 537: istore 9\n 539: aload 8\n 541: invokevirtual #55 // Method Day18Kt$main$Cube.getZ:()I\n 544: istore 8\n 546: iload 7\n 548: iload 8\n 550: if_icmple 514\n 553: iload 8\n 555: istore 7\n 557: goto 514\n 560: iload 7\n 562: iconst_1\n 563: isub\n 564: aload_1\n 565: checkcast #72 // class java/lang/Iterable\n 568: astore 5\n 570: istore 26\n 572: aload 5\n 574: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 579: astore 6\n 581: aload 6\n 583: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 588: ifne 599\n 591: new #175 // class java/util/NoSuchElementException\n 594: dup\n 595: invokespecial #177 // Method java/util/NoSuchElementException.\"<init>\":()V\n 598: athrow\n 599: aload 6\n 601: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 606: checkcast #45 // class Day18Kt$main$Cube\n 609: astore 7\n 611: iconst_0\n 612: istore 8\n 614: aload 7\n 616: invokevirtual #55 // Method Day18Kt$main$Cube.getZ:()I\n 619: istore 7\n 621: aload 6\n 623: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 628: ifeq 667\n 631: aload 6\n 633: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 638: checkcast #45 // class Day18Kt$main$Cube\n 641: astore 8\n 643: iconst_0\n 644: istore 9\n 646: aload 8\n 648: invokevirtual #55 // Method Day18Kt$main$Cube.getZ:()I\n 651: istore 8\n 653: iload 7\n 655: iload 8\n 657: if_icmpge 621\n 660: iload 8\n 662: istore 7\n 664: goto 621\n 667: iload 7\n 669: istore 27\n 671: iload 26\n 673: iload 27\n 675: iconst_1\n 676: iadd\n 677: istore 32\n 679: istore 33\n 681: new #179 // class kotlin/ranges/IntRange\n 684: dup\n 685: iload 33\n 687: iload 32\n 689: invokespecial #182 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 692: astore 4\n 694: new #184 // class kotlin/collections/ArrayDeque\n 697: dup\n 698: invokespecial #185 // Method kotlin/collections/ArrayDeque.\"<init>\":()V\n 701: astore 6\n 703: aload 6\n 705: astore 7\n 707: iconst_0\n 708: istore 8\n 710: aload 7\n 712: new #45 // class Day18Kt$main$Cube\n 715: dup\n 716: aload_2\n 717: invokevirtual #188 // Method kotlin/ranges/IntRange.getFirst:()I\n 720: aload_3\n 721: invokevirtual #188 // Method kotlin/ranges/IntRange.getFirst:()I\n 724: aload 4\n 726: invokevirtual #188 // Method kotlin/ranges/IntRange.getFirst:()I\n 729: invokespecial #59 // Method Day18Kt$main$Cube.\"<init>\":(III)V\n 732: invokevirtual #189 // Method kotlin/collections/ArrayDeque.add:(Ljava/lang/Object;)Z\n 735: pop\n 736: aload 6\n 738: astore 5\n 740: new #191 // class java/util/LinkedHashSet\n 743: dup\n 744: invokespecial #192 // Method java/util/LinkedHashSet.\"<init>\":()V\n 747: checkcast #173 // class java/util/Set\n 750: astore 6\n 752: iconst_0\n 753: istore 7\n 755: aload 5\n 757: checkcast #72 // class java/lang/Iterable\n 760: astore 8\n 762: iconst_0\n 763: istore 9\n 765: aload 8\n 767: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 772: astore 10\n 774: aload 10\n 776: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 781: ifeq 1155\n 784: aload 10\n 786: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 791: astore 11\n 793: aload 11\n 795: checkcast #45 // class Day18Kt$main$Cube\n 798: astore 12\n 800: iconst_0\n 801: istore 13\n 803: aload 6\n 805: aload 12\n 807: invokeinterface #195, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 812: ifne 1150\n 815: aload 6\n 817: checkcast #82 // class java/util/Collection\n 820: aload 12\n 822: invokeinterface #122, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 827: pop\n 828: aload 12\n 830: invokestatic #161 // Method main$adjacents:(LDay18Kt$main$Cube;)Ljava/util/List;\n 833: checkcast #72 // class java/lang/Iterable\n 836: astore 14\n 838: nop\n 839: iconst_0\n 840: istore 15\n 842: aload 14\n 844: astore 16\n 846: new #74 // class java/util/ArrayList\n 849: dup\n 850: invokespecial #196 // Method java/util/ArrayList.\"<init>\":()V\n 853: checkcast #82 // class java/util/Collection\n 856: astore 17\n 858: iconst_0\n 859: istore 18\n 861: aload 16\n 863: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 868: astore 19\n 870: aload 19\n 872: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 877: ifeq 1057\n 880: aload 19\n 882: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 887: astore 20\n 889: aload 20\n 891: checkcast #45 // class Day18Kt$main$Cube\n 894: astore 21\n 896: iconst_0\n 897: istore 22\n 899: aload_2\n 900: invokevirtual #188 // Method kotlin/ranges/IntRange.getFirst:()I\n 903: istore 23\n 905: aload_2\n 906: invokevirtual #199 // Method kotlin/ranges/IntRange.getLast:()I\n 909: istore 24\n 911: aload 21\n 913: invokevirtual #49 // Method Day18Kt$main$Cube.getX:()I\n 916: istore 25\n 918: iload 23\n 920: iload 25\n 922: if_icmpgt 940\n 925: iload 25\n 927: iload 24\n 929: if_icmpgt 936\n 932: iconst_1\n 933: goto 941\n 936: iconst_0\n 937: goto 941\n 940: iconst_0\n 941: ifeq 1040\n 944: aload_3\n 945: invokevirtual #188 // Method kotlin/ranges/IntRange.getFirst:()I\n 948: istore 23\n 950: aload_3\n 951: invokevirtual #199 // Method kotlin/ranges/IntRange.getLast:()I\n 954: istore 24\n 956: aload 21\n 958: invokevirtual #52 // Method Day18Kt$main$Cube.getY:()I\n 961: istore 25\n 963: iload 23\n 965: iload 25\n 967: if_icmpgt 985\n 970: iload 25\n 972: iload 24\n 974: if_icmpgt 981\n 977: iconst_1\n 978: goto 986\n 981: iconst_0\n 982: goto 986\n 985: iconst_0\n 986: ifeq 1040\n 989: aload 4\n 991: invokevirtual #188 // Method kotlin/ranges/IntRange.getFirst:()I\n 994: istore 23\n 996: aload 4\n 998: invokevirtual #199 // Method kotlin/ranges/IntRange.getLast:()I\n 1001: istore 24\n 1003: aload 21\n 1005: invokevirtual #55 // Method Day18Kt$main$Cube.getZ:()I\n 1008: istore 25\n 1010: iload 23\n 1012: iload 25\n 1014: if_icmpgt 1032\n 1017: iload 25\n 1019: iload 24\n 1021: if_icmpgt 1028\n 1024: iconst_1\n 1025: goto 1033\n 1028: iconst_0\n 1029: goto 1033\n 1032: iconst_0\n 1033: ifeq 1040\n 1036: iconst_1\n 1037: goto 1041\n 1040: iconst_0\n 1041: ifeq 870\n 1044: aload 17\n 1046: aload 20\n 1048: invokeinterface #122, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 1053: pop\n 1054: goto 870\n 1057: aload 17\n 1059: checkcast #124 // class java/util/List\n 1062: nop\n 1063: checkcast #72 // class java/lang/Iterable\n 1066: astore 14\n 1068: nop\n 1069: iconst_0\n 1070: istore 15\n 1072: aload 14\n 1074: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1079: astore 16\n 1081: aload 16\n 1083: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1088: ifeq 1149\n 1091: aload 16\n 1093: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1098: astore 17\n 1100: aload 17\n 1102: checkcast #45 // class Day18Kt$main$Cube\n 1105: astore 18\n 1107: iconst_0\n 1108: istore 19\n 1110: aload_1\n 1111: aload 18\n 1113: invokeinterface #195, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 1118: ifeq 1137\n 1121: iload 7\n 1123: istore 20\n 1125: iload 20\n 1127: iconst_1\n 1128: iadd\n 1129: istore 7\n 1131: iload 20\n 1133: pop\n 1134: goto 1145\n 1137: aload 5\n 1139: aload 18\n 1141: invokevirtual #189 // Method kotlin/collections/ArrayDeque.add:(Ljava/lang/Object;)Z\n 1144: pop\n 1145: nop\n 1146: goto 1081\n 1149: nop\n 1150: nop\n 1151: nop\n 1152: goto 774\n 1155: nop\n 1156: iload 7\n 1158: ireturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day11.kt
import kotlin.math.floor fun main() { data class Monkey( val items: MutableList<Long>, val operation: String, val divisor: Long, val trueMonkey: Int, val falseMonkey: Int, var inspections: Long = 0 ) fun parse(input: List<String>) = input .joinToString("\n") .split("\n\n") .map { val (itemsInput, operationInput, testInput, trueInput, falseInput) = it.split("\n").drop(1) val items = itemsInput.substringAfter("items: ") .split(",") .map { s -> s.trim().toLong() } .toMutableList() val operation = operationInput.substringAfter("new =").trim() val divisibleBy = testInput.substringAfter("by ").toLong() val trueMonkey = trueInput.substringAfter("monkey ").toInt() val falseMonkey = falseInput.substringAfter("monkey ").toInt() Monkey(items, operation, divisibleBy, trueMonkey, falseMonkey) } fun operation(operation: String, item: Long): Long { val expression = operation.replace("old", item.toString()) val (n1, op, n2) = expression.split(" ") return when (op) { "+" -> n1.toLong() + n2.toLong() "*" -> n1.toLong() * n2.toLong() else -> error("wrong operation $op") } } fun common(input: List<String>, maxIterations: Int, nextWorryLevel: (operationResult: Long, magicNumber: Long) -> Long): Long { val monkeys = parse(input) val magicNumber = monkeys.map { it.divisor }.reduce { acc, i -> acc * i } repeat(maxIterations) { monkeys.forEach { it.items.forEach { item -> it.inspections++ val operationResult = operation(it.operation, item) val worryLevel = nextWorryLevel(operationResult, magicNumber) if (worryLevel divisibleBy it.divisor) { monkeys[it.trueMonkey].items += worryLevel } else { monkeys[it.falseMonkey].items += worryLevel } } it.items.clear() } } return monkeys .map { it.inspections } .sorted() .takeLast(2) .reduce { acc, i -> acc * i } } fun part1(input: List<String>): Long { return common(input, 20) { operationResult, _ -> floor(operationResult / 3.0).toLong() } } fun part2(input: List<String>): Long { return common(input, 10000) { operationResult, magicNumber -> operationResult % magicNumber } } val input = readInput("inputs/Day11") println(part1(input)) println(part2(input)) } infix fun Long.divisibleBy(divisor: Long) = this % divisor == 0L
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day11Kt$main$Monkey.class", "javap": "Compiled from \"Day11.kt\"\npublic final class Day11Kt$main$Monkey {\n private final java.util.List<java.lang.Long> items;\n\n private final java.lang.String operation;\n\n private final long divisor;\n\n private final int trueMonkey;\n\n private final int falseMonkey;\n\n private long inspections;\n\n public Day11Kt$main$Monkey(java.util.List<java.lang.Long>, java.lang.String, long, int, int, long);\n Code:\n 0: aload_1\n 1: ldc #9 // String items\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 operation\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 items:Ljava/util/List;\n 21: aload_0\n 22: aload_2\n 23: putfield #26 // Field operation:Ljava/lang/String;\n 26: aload_0\n 27: lload_3\n 28: putfield #30 // Field divisor:J\n 31: aload_0\n 32: iload 5\n 34: putfield #34 // Field trueMonkey:I\n 37: aload_0\n 38: iload 6\n 40: putfield #37 // Field falseMonkey:I\n 43: aload_0\n 44: lload 7\n 46: putfield #40 // Field inspections:J\n 49: return\n\n public Day11Kt$main$Monkey(java.util.List, java.lang.String, long, int, int, long, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload 9\n 2: bipush 32\n 4: iand\n 5: ifeq 11\n 8: lconst_0\n 9: lstore 7\n 11: aload_0\n 12: aload_1\n 13: aload_2\n 14: lload_3\n 15: iload 5\n 17: iload 6\n 19: lload 7\n 21: invokespecial #45 // Method \"<init>\":(Ljava/util/List;Ljava/lang/String;JIIJ)V\n 24: return\n\n public final java.util.List<java.lang.Long> getItems();\n Code:\n 0: aload_0\n 1: getfield #23 // Field items:Ljava/util/List;\n 4: areturn\n\n public final java.lang.String getOperation();\n Code:\n 0: aload_0\n 1: getfield #26 // Field operation:Ljava/lang/String;\n 4: areturn\n\n public final long getDivisor();\n Code:\n 0: aload_0\n 1: getfield #30 // Field divisor:J\n 4: lreturn\n\n public final int getTrueMonkey();\n Code:\n 0: aload_0\n 1: getfield #34 // Field trueMonkey:I\n 4: ireturn\n\n public final int getFalseMonkey();\n Code:\n 0: aload_0\n 1: getfield #37 // Field falseMonkey:I\n 4: ireturn\n\n public final long getInspections();\n Code:\n 0: aload_0\n 1: getfield #40 // Field inspections:J\n 4: lreturn\n\n public final void setInspections(long);\n Code:\n 0: aload_0\n 1: lload_1\n 2: putfield #40 // Field inspections:J\n 5: return\n\n public final java.util.List<java.lang.Long> component1();\n Code:\n 0: aload_0\n 1: getfield #23 // Field items:Ljava/util/List;\n 4: areturn\n\n public final java.lang.String component2();\n Code:\n 0: aload_0\n 1: getfield #26 // Field operation:Ljava/lang/String;\n 4: areturn\n\n public final long component3();\n Code:\n 0: aload_0\n 1: getfield #30 // Field divisor:J\n 4: lreturn\n\n public final int component4();\n Code:\n 0: aload_0\n 1: getfield #34 // Field trueMonkey:I\n 4: ireturn\n\n public final int component5();\n Code:\n 0: aload_0\n 1: getfield #37 // Field falseMonkey:I\n 4: ireturn\n\n public final long component6();\n Code:\n 0: aload_0\n 1: getfield #40 // Field inspections:J\n 4: lreturn\n\n public final Day11Kt$main$Monkey copy(java.util.List<java.lang.Long>, java.lang.String, long, int, int, long);\n Code:\n 0: aload_1\n 1: ldc #9 // String items\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 operation\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class Day11Kt$main$Monkey\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: lload_3\n 19: iload 5\n 21: iload 6\n 23: lload 7\n 25: invokespecial #45 // Method \"<init>\":(Ljava/util/List;Ljava/lang/String;JIIJ)V\n 28: areturn\n\n public static Day11Kt$main$Monkey copy$default(Day11Kt$main$Monkey, java.util.List, java.lang.String, long, int, int, long, int, java.lang.Object);\n Code:\n 0: iload 9\n 2: iconst_1\n 3: iand\n 4: ifeq 12\n 7: aload_0\n 8: getfield #23 // Field items:Ljava/util/List;\n 11: astore_1\n 12: iload 9\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #26 // Field operation:Ljava/lang/String;\n 23: astore_2\n 24: iload 9\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #30 // Field divisor:J\n 35: lstore_3\n 36: iload 9\n 38: bipush 8\n 40: iand\n 41: ifeq 50\n 44: aload_0\n 45: getfield #34 // Field trueMonkey:I\n 48: istore 5\n 50: iload 9\n 52: bipush 16\n 54: iand\n 55: ifeq 64\n 58: aload_0\n 59: getfield #37 // Field falseMonkey:I\n 62: istore 6\n 64: iload 9\n 66: bipush 32\n 68: iand\n 69: ifeq 78\n 72: aload_0\n 73: getfield #40 // Field inspections:J\n 76: lstore 7\n 78: aload_0\n 79: aload_1\n 80: aload_2\n 81: lload_3\n 82: iload 5\n 84: iload 6\n 86: lload 7\n 88: invokevirtual #72 // Method copy:(Ljava/util/List;Ljava/lang/String;JIIJ)LDay11Kt$main$Monkey;\n 91: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #75 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #76 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #78 // String Monkey(items=\n 9: invokevirtual #82 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #23 // Field items:Ljava/util/List;\n 16: invokevirtual #85 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #87 // String , operation=\n 21: invokevirtual #82 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #26 // Field operation:Ljava/lang/String;\n 28: invokevirtual #82 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 31: ldc #89 // String , divisor=\n 33: invokevirtual #82 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #30 // Field divisor:J\n 40: invokevirtual #92 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 43: ldc #94 // String , trueMonkey=\n 45: invokevirtual #82 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: aload_0\n 49: getfield #34 // Field trueMonkey:I\n 52: invokevirtual #97 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 55: ldc #99 // String , falseMonkey=\n 57: invokevirtual #82 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 60: aload_0\n 61: getfield #37 // Field falseMonkey:I\n 64: invokevirtual #97 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 67: ldc #101 // String , inspections=\n 69: invokevirtual #82 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 72: aload_0\n 73: getfield #40 // Field inspections:J\n 76: invokevirtual #92 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 79: bipush 41\n 81: invokevirtual #104 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 84: invokevirtual #106 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 87: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #23 // Field items:Ljava/util/List;\n 4: invokevirtual #109 // Method java/lang/Object.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 operation:Ljava/lang/String;\n 16: invokevirtual #112 // Method java/lang/String.hashCode:()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 #30 // Field divisor:J\n 29: invokestatic #117 // Method java/lang/Long.hashCode:(J)I\n 32: iadd\n 33: istore_1\n 34: iload_1\n 35: bipush 31\n 37: imul\n 38: aload_0\n 39: getfield #34 // Field trueMonkey:I\n 42: invokestatic #122 // Method java/lang/Integer.hashCode:(I)I\n 45: iadd\n 46: istore_1\n 47: iload_1\n 48: bipush 31\n 50: imul\n 51: aload_0\n 52: getfield #37 // Field falseMonkey:I\n 55: invokestatic #122 // Method java/lang/Integer.hashCode:(I)I\n 58: iadd\n 59: istore_1\n 60: iload_1\n 61: bipush 31\n 63: imul\n 64: aload_0\n 65: getfield #40 // Field inspections:J\n 68: invokestatic #117 // Method java/lang/Long.hashCode:(J)I\n 71: iadd\n 72: istore_1\n 73: iload_1\n 74: 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 Day11Kt$main$Monkey\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class Day11Kt$main$Monkey\n 20: astore_2\n 21: aload_0\n 22: getfield #23 // Field items:Ljava/util/List;\n 25: aload_2\n 26: getfield #23 // Field items:Ljava/util/List;\n 29: invokestatic #129 // 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 operation:Ljava/lang/String;\n 41: aload_2\n 42: getfield #26 // Field operation:Ljava/lang/String;\n 45: invokestatic #129 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 48: ifne 53\n 51: iconst_0\n 52: ireturn\n 53: aload_0\n 54: getfield #30 // Field divisor:J\n 57: aload_2\n 58: getfield #30 // Field divisor:J\n 61: lcmp\n 62: ifeq 67\n 65: iconst_0\n 66: ireturn\n 67: aload_0\n 68: getfield #34 // Field trueMonkey:I\n 71: aload_2\n 72: getfield #34 // Field trueMonkey:I\n 75: if_icmpeq 80\n 78: iconst_0\n 79: ireturn\n 80: aload_0\n 81: getfield #37 // Field falseMonkey:I\n 84: aload_2\n 85: getfield #37 // Field falseMonkey:I\n 88: if_icmpeq 93\n 91: iconst_0\n 92: ireturn\n 93: aload_0\n 94: getfield #40 // Field inspections:J\n 97: aload_2\n 98: getfield #40 // Field inspections:J\n 101: lcmp\n 102: ifeq 107\n 105: iconst_0\n 106: ireturn\n 107: iconst_1\n 108: ireturn\n}\n", "javap_err": "" }, { "class_path": "ambrosil__aoc-2022__ebaacfc/Day11Kt.class", "javap": "Compiled from \"Day11.kt\"\npublic final class Day11Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/Day11\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 main$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 main$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 boolean divisibleBy(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 public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #43 // Method main:()V\n 3: return\n\n private static final java.util.List<Day11Kt$main$Monkey> main$parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #50 // class java/lang/Iterable\n 4: ldc #52 // String \\n\n 6: checkcast #54 // class java/lang/CharSequence\n 9: aconst_null\n 10: aconst_null\n 11: iconst_0\n 12: aconst_null\n 13: aconst_null\n 14: bipush 62\n 16: aconst_null\n 17: invokestatic #60 // 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 20: checkcast #54 // class java/lang/CharSequence\n 23: iconst_1\n 24: anewarray #62 // class java/lang/String\n 27: astore_1\n 28: aload_1\n 29: iconst_0\n 30: ldc #64 // String \\n\\n\n 32: aastore\n 33: aload_1\n 34: iconst_0\n 35: iconst_0\n 36: bipush 6\n 38: aconst_null\n 39: invokestatic #70 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 42: checkcast #50 // class java/lang/Iterable\n 45: astore_1\n 46: nop\n 47: iconst_0\n 48: istore_2\n 49: aload_1\n 50: astore_3\n 51: new #72 // class java/util/ArrayList\n 54: dup\n 55: aload_1\n 56: bipush 10\n 58: invokestatic #76 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 61: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 64: checkcast #82 // class java/util/Collection\n 67: astore 4\n 69: iconst_0\n 70: istore 5\n 72: aload_3\n 73: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 78: astore 6\n 80: aload 6\n 82: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 87: ifeq 470\n 90: aload 6\n 92: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 97: astore 7\n 99: aload 4\n 101: aload 7\n 103: checkcast #62 // class java/lang/String\n 106: astore 8\n 108: astore 29\n 110: iconst_0\n 111: istore 9\n 113: aload 8\n 115: checkcast #54 // class java/lang/CharSequence\n 118: iconst_1\n 119: anewarray #62 // class java/lang/String\n 122: astore 10\n 124: aload 10\n 126: iconst_0\n 127: ldc #52 // String \\n\n 129: aastore\n 130: aload 10\n 132: iconst_0\n 133: iconst_0\n 134: bipush 6\n 136: aconst_null\n 137: invokestatic #70 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 140: checkcast #50 // class java/lang/Iterable\n 143: iconst_1\n 144: invokestatic #100 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 147: astore 11\n 149: aload 11\n 151: iconst_0\n 152: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 157: checkcast #62 // class java/lang/String\n 160: astore 10\n 162: aload 11\n 164: iconst_1\n 165: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 170: checkcast #62 // class java/lang/String\n 173: astore 12\n 175: aload 11\n 177: iconst_2\n 178: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 183: checkcast #62 // class java/lang/String\n 186: astore 13\n 188: aload 11\n 190: iconst_3\n 191: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 196: checkcast #62 // class java/lang/String\n 199: astore 14\n 201: aload 11\n 203: iconst_4\n 204: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 209: checkcast #62 // class java/lang/String\n 212: astore 15\n 214: aload 10\n 216: ldc #108 // String items:\n 218: aconst_null\n 219: iconst_2\n 220: aconst_null\n 221: invokestatic #112 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 224: checkcast #54 // class java/lang/CharSequence\n 227: iconst_1\n 228: anewarray #62 // class java/lang/String\n 231: astore 16\n 233: aload 16\n 235: iconst_0\n 236: ldc #114 // String ,\n 238: aastore\n 239: aload 16\n 241: iconst_0\n 242: iconst_0\n 243: bipush 6\n 245: aconst_null\n 246: invokestatic #70 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 249: checkcast #50 // class java/lang/Iterable\n 252: astore 16\n 254: nop\n 255: iconst_0\n 256: istore 17\n 258: aload 16\n 260: astore 18\n 262: new #72 // class java/util/ArrayList\n 265: dup\n 266: aload 16\n 268: bipush 10\n 270: invokestatic #76 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 273: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 276: checkcast #82 // class java/util/Collection\n 279: astore 19\n 281: iconst_0\n 282: istore 20\n 284: aload 18\n 286: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 291: astore 21\n 293: aload 21\n 295: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 300: ifeq 357\n 303: aload 21\n 305: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 310: astore 22\n 312: aload 19\n 314: aload 22\n 316: checkcast #62 // class java/lang/String\n 319: astore 23\n 321: astore 24\n 323: iconst_0\n 324: istore 25\n 326: nop\n 327: aload 23\n 329: checkcast #54 // class java/lang/CharSequence\n 332: invokestatic #118 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 335: invokevirtual #122 // Method java/lang/Object.toString:()Ljava/lang/String;\n 338: invokestatic #128 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 341: nop\n 342: invokestatic #132 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 345: aload 24\n 347: swap\n 348: invokeinterface #136, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 353: pop\n 354: goto 293\n 357: aload 19\n 359: checkcast #102 // class java/util/List\n 362: nop\n 363: checkcast #82 // class java/util/Collection\n 366: invokestatic #140 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 369: astore 26\n 371: aload 12\n 373: ldc #142 // String new =\n 375: aconst_null\n 376: iconst_2\n 377: aconst_null\n 378: invokestatic #112 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 381: checkcast #54 // class java/lang/CharSequence\n 384: invokestatic #118 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 387: invokevirtual #122 // Method java/lang/Object.toString:()Ljava/lang/String;\n 390: astore 16\n 392: aload 13\n 394: ldc #144 // String by\n 396: aconst_null\n 397: iconst_2\n 398: aconst_null\n 399: invokestatic #112 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 402: invokestatic #128 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 405: lstore 27\n 407: aload 14\n 409: ldc #146 // String monkey\n 411: aconst_null\n 412: iconst_2\n 413: aconst_null\n 414: invokestatic #112 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 417: invokestatic #152 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 420: istore 19\n 422: aload 15\n 424: ldc #146 // String monkey\n 426: aconst_null\n 427: iconst_2\n 428: aconst_null\n 429: invokestatic #112 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 432: invokestatic #152 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 435: istore 20\n 437: new #154 // class Day11Kt$main$Monkey\n 440: dup\n 441: aload 26\n 443: aload 16\n 445: lload 27\n 447: iload 19\n 449: iload 20\n 451: lconst_0\n 452: bipush 32\n 454: aconst_null\n 455: invokespecial #157 // Method Day11Kt$main$Monkey.\"<init>\":(Ljava/util/List;Ljava/lang/String;JIIJILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 458: aload 29\n 460: swap\n 461: invokeinterface #136, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 466: pop\n 467: goto 80\n 470: aload 4\n 472: checkcast #102 // class java/util/List\n 475: nop\n 476: areturn\n\n private static final long main$operation(java.lang.String, long);\n Code:\n 0: aload_0\n 1: ldc #185 // String old\n 3: lload_1\n 4: invokestatic #188 // Method java/lang/String.valueOf:(J)Ljava/lang/String;\n 7: iconst_0\n 8: iconst_4\n 9: aconst_null\n 10: invokestatic #192 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 13: astore_3\n 14: aload_3\n 15: checkcast #54 // class java/lang/CharSequence\n 18: iconst_1\n 19: anewarray #62 // class java/lang/String\n 22: astore 5\n 24: aload 5\n 26: iconst_0\n 27: ldc #194 // String\n 29: aastore\n 30: aload 5\n 32: iconst_0\n 33: iconst_0\n 34: bipush 6\n 36: aconst_null\n 37: invokestatic #70 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 40: astore 4\n 42: aload 4\n 44: iconst_0\n 45: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 50: checkcast #62 // class java/lang/String\n 53: astore 5\n 55: aload 4\n 57: iconst_1\n 58: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 63: checkcast #62 // class java/lang/String\n 66: astore 6\n 68: aload 4\n 70: iconst_2\n 71: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 76: checkcast #62 // class java/lang/String\n 79: astore 7\n 81: aload 6\n 83: astore 8\n 85: aload 8\n 87: ldc #196 // String +\n 89: invokestatic #202 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 92: ifeq 109\n 95: aload 5\n 97: invokestatic #128 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 100: aload 7\n 102: invokestatic #128 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 105: ladd\n 106: goto 164\n 109: aload 8\n 111: ldc #204 // String *\n 113: invokestatic #202 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 116: ifeq 133\n 119: aload 5\n 121: invokestatic #128 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 124: aload 7\n 126: invokestatic #128 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 129: lmul\n 130: goto 164\n 133: new #206 // class java/lang/IllegalStateException\n 136: dup\n 137: new #208 // class java/lang/StringBuilder\n 140: dup\n 141: invokespecial #210 // Method java/lang/StringBuilder.\"<init>\":()V\n 144: ldc #212 // String wrong operation\n 146: invokevirtual #216 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 149: aload 6\n 151: invokevirtual #216 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 154: invokevirtual #217 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 157: invokevirtual #122 // Method java/lang/Object.toString:()Ljava/lang/String;\n 160: invokespecial #220 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 163: athrow\n 164: lreturn\n\n private static final long main$common(java.util.List<java.lang.String>, int, kotlin.jvm.functions.Function2<? super java.lang.Long, ? super java.lang.Long, java.lang.Long>);\n Code:\n 0: aload_0\n 1: invokestatic #230 // Method main$parse:(Ljava/util/List;)Ljava/util/List;\n 4: astore_3\n 5: aload_3\n 6: checkcast #50 // class java/lang/Iterable\n 9: astore 6\n 11: iconst_0\n 12: istore 7\n 14: aload 6\n 16: astore 8\n 18: new #72 // class java/util/ArrayList\n 21: dup\n 22: aload 6\n 24: bipush 10\n 26: invokestatic #76 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 29: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 32: checkcast #82 // class java/util/Collection\n 35: astore 9\n 37: iconst_0\n 38: istore 10\n 40: aload 8\n 42: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 47: astore 11\n 49: aload 11\n 51: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 56: ifeq 102\n 59: aload 11\n 61: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 66: astore 12\n 68: aload 9\n 70: aload 12\n 72: checkcast #154 // class Day11Kt$main$Monkey\n 75: astore 13\n 77: astore 27\n 79: iconst_0\n 80: istore 14\n 82: aload 13\n 84: invokevirtual #234 // Method Day11Kt$main$Monkey.getDivisor:()J\n 87: invokestatic #132 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 90: aload 27\n 92: swap\n 93: invokeinterface #136, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 98: pop\n 99: goto 49\n 102: aload 9\n 104: checkcast #102 // class java/util/List\n 107: nop\n 108: checkcast #50 // class java/lang/Iterable\n 111: astore 6\n 113: nop\n 114: iconst_0\n 115: istore 7\n 117: aload 6\n 119: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 124: astore 8\n 126: aload 8\n 128: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 133: ifne 146\n 136: new #236 // class java/lang/UnsupportedOperationException\n 139: dup\n 140: ldc #238 // String Empty collection can\\'t be reduced.\n 142: invokespecial #239 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 145: athrow\n 146: aload 8\n 148: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 153: astore 9\n 155: aload 8\n 157: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 162: ifeq 206\n 165: aload 9\n 167: aload 8\n 169: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 174: checkcast #241 // class java/lang/Number\n 177: invokevirtual #244 // Method java/lang/Number.longValue:()J\n 180: lstore 10\n 182: checkcast #241 // class java/lang/Number\n 185: invokevirtual #244 // Method java/lang/Number.longValue:()J\n 188: lstore 12\n 190: iconst_0\n 191: istore 14\n 193: lload 12\n 195: lload 10\n 197: lmul\n 198: invokestatic #132 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 201: astore 9\n 203: goto 155\n 206: aload 9\n 208: checkcast #241 // class java/lang/Number\n 211: invokevirtual #244 // Method java/lang/Number.longValue:()J\n 214: lstore 4\n 216: iconst_0\n 217: istore 6\n 219: iload 6\n 221: iload_1\n 222: if_icmpge 500\n 225: iload 6\n 227: istore 7\n 229: iconst_0\n 230: istore 8\n 232: aload_3\n 233: checkcast #50 // class java/lang/Iterable\n 236: astore 9\n 238: iconst_0\n 239: istore 10\n 241: aload 9\n 243: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 248: astore 11\n 250: aload 11\n 252: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 257: ifeq 492\n 260: aload 11\n 262: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 267: astore 12\n 269: aload 12\n 271: checkcast #154 // class Day11Kt$main$Monkey\n 274: astore 13\n 276: iconst_0\n 277: istore 14\n 279: aload 13\n 281: invokevirtual #248 // Method Day11Kt$main$Monkey.getItems:()Ljava/util/List;\n 284: checkcast #50 // class java/lang/Iterable\n 287: astore 15\n 289: iconst_0\n 290: istore 16\n 292: aload 15\n 294: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 299: astore 17\n 301: aload 17\n 303: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 308: ifeq 476\n 311: aload 17\n 313: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 318: astore 18\n 320: aload 18\n 322: checkcast #241 // class java/lang/Number\n 325: invokevirtual #244 // Method java/lang/Number.longValue:()J\n 328: lstore 19\n 330: iconst_0\n 331: istore 21\n 333: aload 13\n 335: invokevirtual #251 // Method Day11Kt$main$Monkey.getInspections:()J\n 338: lstore 22\n 340: aload 13\n 342: lload 22\n 344: lconst_1\n 345: ladd\n 346: invokevirtual #254 // Method Day11Kt$main$Monkey.setInspections:(J)V\n 349: aload 13\n 351: invokevirtual #257 // Method Day11Kt$main$Monkey.getOperation:()Ljava/lang/String;\n 354: lload 19\n 356: invokestatic #259 // Method main$operation:(Ljava/lang/String;J)J\n 359: lstore 22\n 361: aload_2\n 362: lload 22\n 364: invokestatic #132 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 367: lload 4\n 369: invokestatic #132 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 372: invokeinterface #265, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 377: checkcast #241 // class java/lang/Number\n 380: invokevirtual #244 // Method java/lang/Number.longValue:()J\n 383: lstore 24\n 385: lload 24\n 387: aload 13\n 389: invokevirtual #234 // Method Day11Kt$main$Monkey.getDivisor:()J\n 392: invokestatic #267 // Method divisibleBy:(JJ)Z\n 395: ifeq 436\n 398: lload 24\n 400: invokestatic #132 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 403: astore 26\n 405: aload_3\n 406: aload 13\n 408: invokevirtual #271 // Method Day11Kt$main$Monkey.getTrueMonkey:()I\n 411: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 416: checkcast #154 // class Day11Kt$main$Monkey\n 419: invokevirtual #248 // Method Day11Kt$main$Monkey.getItems:()Ljava/util/List;\n 422: checkcast #82 // class java/util/Collection\n 425: aload 26\n 427: invokeinterface #136, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 432: pop\n 433: goto 471\n 436: lload 24\n 438: invokestatic #132 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 441: astore 26\n 443: aload_3\n 444: aload 13\n 446: invokevirtual #274 // Method Day11Kt$main$Monkey.getFalseMonkey:()I\n 449: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 454: checkcast #154 // class Day11Kt$main$Monkey\n 457: invokevirtual #248 // Method Day11Kt$main$Monkey.getItems:()Ljava/util/List;\n 460: checkcast #82 // class java/util/Collection\n 463: aload 26\n 465: invokeinterface #136, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 470: pop\n 471: nop\n 472: nop\n 473: goto 301\n 476: nop\n 477: aload 13\n 479: invokevirtual #248 // Method Day11Kt$main$Monkey.getItems:()Ljava/util/List;\n 482: invokeinterface #277, 1 // InterfaceMethod java/util/List.clear:()V\n 487: nop\n 488: nop\n 489: goto 250\n 492: nop\n 493: nop\n 494: iinc 6, 1\n 497: goto 219\n 500: aload_3\n 501: checkcast #50 // class java/lang/Iterable\n 504: astore 6\n 506: nop\n 507: iconst_0\n 508: istore 7\n 510: aload 6\n 512: astore 8\n 514: new #72 // class java/util/ArrayList\n 517: dup\n 518: aload 6\n 520: bipush 10\n 522: invokestatic #76 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 525: invokespecial #80 // Method java/util/ArrayList.\"<init>\":(I)V\n 528: checkcast #82 // class java/util/Collection\n 531: astore 9\n 533: iconst_0\n 534: istore 10\n 536: aload 8\n 538: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 543: astore 11\n 545: aload 11\n 547: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 552: ifeq 598\n 555: aload 11\n 557: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 562: astore 12\n 564: aload 9\n 566: aload 12\n 568: checkcast #154 // class Day11Kt$main$Monkey\n 571: astore 13\n 573: astore 27\n 575: iconst_0\n 576: istore 14\n 578: aload 13\n 580: invokevirtual #251 // Method Day11Kt$main$Monkey.getInspections:()J\n 583: invokestatic #132 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 586: aload 27\n 588: swap\n 589: invokeinterface #136, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 594: pop\n 595: goto 545\n 598: aload 9\n 600: checkcast #102 // class java/util/List\n 603: nop\n 604: checkcast #50 // class java/lang/Iterable\n 607: invokestatic #281 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 610: iconst_2\n 611: invokestatic #285 // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;\n 614: checkcast #50 // class java/lang/Iterable\n 617: astore 6\n 619: nop\n 620: iconst_0\n 621: istore 7\n 623: aload 6\n 625: invokeinterface #86, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 630: astore 8\n 632: aload 8\n 634: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 639: ifne 652\n 642: new #236 // class java/lang/UnsupportedOperationException\n 645: dup\n 646: ldc #238 // String Empty collection can\\'t be reduced.\n 648: invokespecial #239 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 651: athrow\n 652: aload 8\n 654: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 659: astore 9\n 661: aload 8\n 663: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 668: ifeq 712\n 671: aload 9\n 673: aload 8\n 675: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 680: checkcast #241 // class java/lang/Number\n 683: invokevirtual #244 // Method java/lang/Number.longValue:()J\n 686: lstore 10\n 688: checkcast #241 // class java/lang/Number\n 691: invokevirtual #244 // Method java/lang/Number.longValue:()J\n 694: lstore 12\n 696: iconst_0\n 697: istore 14\n 699: lload 12\n 701: lload 10\n 703: lmul\n 704: invokestatic #132 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 707: astore 9\n 709: goto 661\n 712: aload 9\n 714: checkcast #241 // class java/lang/Number\n 717: invokevirtual #244 // Method java/lang/Number.longValue:()J\n 720: lreturn\n\n private static final long main$part1$lambda$9(long, long);\n Code:\n 0: lload_0\n 1: l2d\n 2: ldc2_w #313 // double 3.0d\n 5: ddiv\n 6: invokestatic #320 // Method java/lang/Math.floor:(D)D\n 9: d2l\n 10: lreturn\n\n private static final long main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: bipush 20\n 3: invokedynamic #337, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;\n 8: invokestatic #339 // Method main$common:(Ljava/util/List;ILkotlin/jvm/functions/Function2;)J\n 11: lreturn\n\n private static final long main$part2$lambda$10(long, long);\n Code:\n 0: lload_0\n 1: lload_2\n 2: lrem\n 3: lreturn\n\n private static final long main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: sipush 10000\n 4: invokedynamic #344, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function2;\n 9: invokestatic #339 // Method main$common:(Ljava/util/List;ILkotlin/jvm/functions/Function2;)J\n 12: lreturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day13.kt
private sealed class Packet : Comparable<Packet> { companion object { fun of(input: String): Packet = of(input.split("""((?<=[\[\],])|(?=[\[\],]))""".toRegex()) .filter { it.isNotBlank() } .filter { it != "," } .iterator() ) private fun of(input: Iterator<String>): Packet { val packets = mutableListOf<Packet>() while (input.hasNext()) { when (val symbol = input.next()) { "]" -> return ListPacket(packets) "[" -> packets.add(of(input)) else -> packets.add(IntPacket(symbol.toInt())) } } return ListPacket(packets) } } } private class IntPacket(val amount: Int) : Packet() { fun asList(): Packet = ListPacket(listOf(this)) override fun compareTo(other: Packet): Int = when (other) { is IntPacket -> amount.compareTo(other.amount) is ListPacket -> asList().compareTo(other) } } private class ListPacket(val subPackets: List<Packet>) : Packet() { override fun compareTo(other: Packet): Int = when (other) { is IntPacket -> compareTo(other.asList()) is ListPacket -> subPackets.zip(other.subPackets) .map { it.first.compareTo(it.second) } .firstOrNull { it != 0 } ?: subPackets.size.compareTo(other.subPackets.size) } } fun main() { fun parse(input: List<String>): Sequence<Packet> { return input.asSequence().filter { it.isNotBlank() }.map { Packet.of(it) } } fun part1(input: List<String>): Int { return parse(input) .chunked(2) .mapIndexed { index, (first, second) -> if (first < second) index + 1 else 0 }.sum() } fun part2(input: List<String>): Int { val packets = parse(input) val divider1 = Packet.of("[[2]]") val divider2 = Packet.of("[[6]]") val ordered = (packets + divider1 + divider2).sorted() return (ordered.indexOf(divider1) + 1) * (ordered.indexOf(divider2) + 1) } val input = readInput("inputs/Day13") println(part1(input)) println(part2(input)) }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day13Kt.class", "javap": "Compiled from \"Day13.kt\"\npublic final class Day13Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/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 main$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 main$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 void main(java.lang.String[]);\n Code:\n 0: invokestatic #38 // Method main:()V\n 3: return\n\n private static final boolean main$parse$lambda$0(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #44 // String it\n 3: invokestatic #50 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #52 // class java/lang/CharSequence\n 10: invokestatic #58 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 13: ifne 20\n 16: iconst_1\n 17: goto 21\n 20: iconst_0\n 21: ireturn\n\n private static final Packet main$parse$lambda$1(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #44 // String it\n 3: invokestatic #50 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #67 // Field Packet.Companion:LPacket$Companion;\n 9: aload_0\n 10: invokevirtual #72 // Method Packet$Companion.of:(Ljava/lang/String;)LPacket;\n 13: areturn\n\n private static final kotlin.sequences.Sequence<Packet> main$parse(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #77 // class java/lang/Iterable\n 4: invokestatic #83 // Method kotlin/collections/CollectionsKt.asSequence:(Ljava/lang/Iterable;)Lkotlin/sequences/Sequence;\n 7: invokedynamic #101, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 12: invokestatic #107 // Method kotlin/sequences/SequencesKt.filter:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 15: invokedynamic #112, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 20: invokestatic #115 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 23: areturn\n\n private static final int main$part1$lambda$2(int, java.util.List);\n Code:\n 0: aload_1\n 1: ldc #119 // String <destruct>\n 3: invokestatic #50 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: iconst_0\n 8: invokeinterface #125, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 13: checkcast #63 // class Packet\n 16: astore_2\n 17: aload_1\n 18: iconst_1\n 19: invokeinterface #125, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 24: checkcast #63 // class Packet\n 27: astore_3\n 28: aload_2\n 29: aload_3\n 30: invokevirtual #129 // Method Packet.compareTo:(Ljava/lang/Object;)I\n 33: ifge 42\n 36: iload_0\n 37: iconst_1\n 38: iadd\n 39: goto 43\n 42: iconst_0\n 43: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #137 // Method main$parse:(Ljava/util/List;)Lkotlin/sequences/Sequence;\n 4: iconst_2\n 5: invokestatic #141 // Method kotlin/sequences/SequencesKt.chunked:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;\n 8: invokedynamic #151, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function2;\n 13: invokestatic #155 // Method kotlin/sequences/SequencesKt.mapIndexed:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;\n 16: invokestatic #159 // Method kotlin/sequences/SequencesKt.sumOfInt:(Lkotlin/sequences/Sequence;)I\n 19: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #137 // Method main$parse:(Ljava/util/List;)Lkotlin/sequences/Sequence;\n 4: astore_1\n 5: getstatic #67 // Field Packet.Companion:LPacket$Companion;\n 8: ldc #161 // String [[2]]\n 10: invokevirtual #72 // Method Packet$Companion.of:(Ljava/lang/String;)LPacket;\n 13: astore_2\n 14: getstatic #67 // Field Packet.Companion:LPacket$Companion;\n 17: ldc #163 // String [[6]]\n 19: invokevirtual #72 // Method Packet$Companion.of:(Ljava/lang/String;)LPacket;\n 22: astore_3\n 23: aload_1\n 24: aload_2\n 25: invokestatic #167 // Method kotlin/sequences/SequencesKt.plus:(Lkotlin/sequences/Sequence;Ljava/lang/Object;)Lkotlin/sequences/Sequence;\n 28: aload_3\n 29: invokestatic #167 // Method kotlin/sequences/SequencesKt.plus:(Lkotlin/sequences/Sequence;Ljava/lang/Object;)Lkotlin/sequences/Sequence;\n 32: invokestatic #171 // Method kotlin/sequences/SequencesKt.sorted:(Lkotlin/sequences/Sequence;)Lkotlin/sequences/Sequence;\n 35: astore 4\n 37: aload 4\n 39: aload_2\n 40: invokestatic #175 // Method kotlin/sequences/SequencesKt.indexOf:(Lkotlin/sequences/Sequence;Ljava/lang/Object;)I\n 43: iconst_1\n 44: iadd\n 45: aload 4\n 47: aload_3\n 48: invokestatic #175 // Method kotlin/sequences/SequencesKt.indexOf:(Lkotlin/sequences/Sequence;Ljava/lang/Object;)I\n 51: iconst_1\n 52: iadd\n 53: imul\n 54: ireturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day03.kt
fun main() { fun Set<Char>.score(): Int { val c = single() return if (c.isLowerCase()) { 1 + (c - 'a') } else { 27 + (c - 'A') } } fun String.halve(): List<String> { val half = length / 2 return listOf(substring(0, half), substring(half)) } fun part1(input: List<String>) = input.sumOf { item -> val (first, second) = item.halve() (first intersect second).score() } fun part2(input: List<String>) = input .chunked(3) .sumOf { it.fold(it[0].toSet()) { acc, s -> acc intersect s } .score() } val input = readInput("inputs/Day03") println(part1(input)) println(part2(input)) } infix fun String.intersect(o: String) = toSet() intersect o.toSet() infix fun Set<Char>.intersect(o: String) = this intersect o.toSet()
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day03Kt.class", "javap": "Compiled from \"Day03.kt\"\npublic final class Day03Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/Day03\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 main$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 main$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.Set<java.lang.Character> intersect(java.lang.String, java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #41 // String <this>\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #49 // String o\n 9: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: checkcast #51 // class java/lang/CharSequence\n 16: invokestatic #57 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 19: checkcast #59 // class java/lang/Iterable\n 22: aload_1\n 23: checkcast #51 // class java/lang/CharSequence\n 26: invokestatic #57 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 29: checkcast #59 // class java/lang/Iterable\n 32: invokestatic #64 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 35: areturn\n\n public static final java.util.Set<java.lang.Character> intersect(java.util.Set<java.lang.Character>, java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #41 // String <this>\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #49 // String o\n 9: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: checkcast #59 // class java/lang/Iterable\n 16: aload_1\n 17: checkcast #51 // class java/lang/CharSequence\n 20: invokestatic #57 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 23: checkcast #59 // class java/lang/Iterable\n 26: invokestatic #64 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 29: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #72 // Method main:()V\n 3: return\n\n private static final int main$score(java.util.Set<java.lang.Character>);\n Code:\n 0: aload_0\n 1: checkcast #59 // class java/lang/Iterable\n 4: invokestatic #81 // Method kotlin/collections/CollectionsKt.single:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 7: checkcast #83 // class java/lang/Character\n 10: invokevirtual #87 // Method java/lang/Character.charValue:()C\n 13: istore_1\n 14: iload_1\n 15: invokestatic #91 // Method java/lang/Character.isLowerCase:(C)Z\n 18: ifeq 30\n 21: iconst_1\n 22: iload_1\n 23: bipush 97\n 25: isub\n 26: iadd\n 27: goto 37\n 30: bipush 27\n 32: iload_1\n 33: bipush 65\n 35: isub\n 36: iadd\n 37: ireturn\n\n private static final java.util.List<java.lang.String> main$halve(java.lang.String);\n Code:\n 0: aload_0\n 1: invokevirtual #102 // Method java/lang/String.length:()I\n 4: iconst_2\n 5: idiv\n 6: istore_1\n 7: iconst_2\n 8: anewarray #98 // class java/lang/String\n 11: astore_2\n 12: aload_2\n 13: iconst_0\n 14: aload_0\n 15: iconst_0\n 16: iload_1\n 17: invokevirtual #106 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 20: dup\n 21: ldc #108 // String substring(...)\n 23: invokestatic #111 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 26: aastore\n 27: aload_2\n 28: iconst_1\n 29: aload_0\n 30: iload_1\n 31: invokevirtual #114 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 34: dup\n 35: ldc #108 // String substring(...)\n 37: invokestatic #111 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 40: aastore\n 41: aload_2\n 42: invokestatic #118 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 45: areturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #59 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 98\n 23: aload_3\n 24: invokeinterface #136, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 29: astore 4\n 31: iload_2\n 32: aload 4\n 34: checkcast #98 // class java/lang/String\n 37: astore 5\n 39: istore 10\n 41: iconst_0\n 42: istore 6\n 44: aload 5\n 46: invokestatic #138 // Method main$halve:(Ljava/lang/String;)Ljava/util/List;\n 49: astore 7\n 51: aload 7\n 53: iconst_0\n 54: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 59: checkcast #98 // class java/lang/String\n 62: astore 8\n 64: aload 7\n 66: iconst_1\n 67: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 72: checkcast #98 // class java/lang/String\n 75: astore 9\n 77: aload 8\n 79: aload 9\n 81: invokestatic #146 // Method intersect:(Ljava/lang/String;Ljava/lang/String;)Ljava/util/Set;\n 84: invokestatic #148 // Method main$score:(Ljava/util/Set;)I\n 87: istore 11\n 89: iload 10\n 91: iload 11\n 93: iadd\n 94: istore_2\n 95: goto 14\n 98: iload_2\n 99: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #59 // class java/lang/Iterable\n 4: iconst_3\n 5: invokestatic #156 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 8: checkcast #59 // class java/lang/Iterable\n 11: astore_1\n 12: iconst_0\n 13: istore_2\n 14: aload_1\n 15: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 20: astore_3\n 21: aload_3\n 22: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 27: ifeq 151\n 30: aload_3\n 31: invokeinterface #136, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 36: astore 4\n 38: iload_2\n 39: aload 4\n 41: checkcast #140 // class java/util/List\n 44: astore 5\n 46: istore 16\n 48: iconst_0\n 49: istore 6\n 51: aload 5\n 53: checkcast #59 // class java/lang/Iterable\n 56: astore 7\n 58: aload 5\n 60: iconst_0\n 61: invokeinterface #144, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 66: checkcast #51 // class java/lang/CharSequence\n 69: invokestatic #57 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 72: astore 8\n 74: iconst_0\n 75: istore 9\n 77: aload 8\n 79: astore 10\n 81: aload 7\n 83: invokeinterface #126, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 88: astore 11\n 90: aload 11\n 92: invokeinterface #132, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 97: ifeq 135\n 100: aload 11\n 102: invokeinterface #136, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 107: astore 12\n 109: aload 10\n 111: aload 12\n 113: checkcast #98 // class java/lang/String\n 116: astore 13\n 118: astore 14\n 120: iconst_0\n 121: istore 15\n 123: aload 14\n 125: aload 13\n 127: invokestatic #158 // Method intersect:(Ljava/util/Set;Ljava/lang/String;)Ljava/util/Set;\n 130: astore 10\n 132: goto 90\n 135: aload 10\n 137: invokestatic #148 // Method main$score:(Ljava/util/Set;)I\n 140: istore 17\n 142: iload 16\n 144: iload 17\n 146: iadd\n 147: istore_2\n 148: goto 21\n 151: iload_2\n 152: ireturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day02.kt
import Sign.* import java.lang.RuntimeException enum class Sign { ROCK, PAPER, SCISSORS } data class Round(val opponent: Sign, val mine: Sign) { private fun signPoints() = when (mine) { ROCK -> 1 PAPER -> 2 SCISSORS -> 3 } private fun matchPoints() = when (mine) { ROCK -> when (opponent) { ROCK -> 3 PAPER -> 0 SCISSORS -> 6 } PAPER -> when (opponent) { ROCK -> 6 PAPER -> 3 SCISSORS -> 0 } SCISSORS -> when (opponent) { ROCK -> 0 PAPER -> 6 SCISSORS -> 3 } } fun totalPoints() = signPoints() + matchPoints() } fun main() { fun part1(input: List<String>): Int { return input .map { it.split(" ") } .map { it.map { sign -> when (sign) { "A", "X" -> ROCK "B", "Y" -> PAPER "C", "Z" -> SCISSORS else -> throw RuntimeException() } } } .map { (opponent, mine) -> Round(opponent, mine) } .sumOf { it.totalPoints() } } fun part2(input: List<String>): Int { val signs = listOf(ROCK, SCISSORS, PAPER) return input .map { it.split(" ") } .map { (opponentSign, mySign) -> val opponent = when (opponentSign) { "A" -> ROCK "B" -> PAPER "C" -> SCISSORS else -> throw RuntimeException() } val mine = when (mySign) { "X" -> signs[(signs.indexOf(opponent) + 1) % signs.size] "Y" -> opponent "Z" -> signs[(signs.indexOf(opponent) + 2) % signs.size] else -> throw RuntimeException() } Round(opponent, mine) } .sumOf { it.totalPoints() } } val input = readInput("inputs/Day02") println(part1(input)) println(part2(input)) }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day02Kt.class", "javap": "Compiled from \"Day02.kt\"\npublic final class Day02Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/Day02\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 main$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 main$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 void main(java.lang.String[]);\n Code:\n 0: invokestatic #38 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #43 // class java/lang/Iterable\n 4: astore_1\n 5: nop\n 6: iconst_0\n 7: istore_2\n 8: aload_1\n 9: astore_3\n 10: new #45 // class java/util/ArrayList\n 13: dup\n 14: aload_1\n 15: bipush 10\n 17: invokestatic #51 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #54 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #56 // class java/util/Collection\n 26: astore 4\n 28: iconst_0\n 29: istore 5\n 31: aload_3\n 32: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore 6\n 39: aload 6\n 41: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 111\n 49: aload 6\n 51: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 56: astore 7\n 58: aload 4\n 60: aload 7\n 62: checkcast #72 // class java/lang/String\n 65: astore 8\n 67: astore 21\n 69: iconst_0\n 70: istore 9\n 72: aload 8\n 74: checkcast #74 // class java/lang/CharSequence\n 77: iconst_1\n 78: anewarray #72 // class java/lang/String\n 81: astore 10\n 83: aload 10\n 85: iconst_0\n 86: ldc #76 // String\n 88: aastore\n 89: aload 10\n 91: iconst_0\n 92: iconst_0\n 93: bipush 6\n 95: aconst_null\n 96: invokestatic #82 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 99: aload 21\n 101: swap\n 102: invokeinterface #86, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 107: pop\n 108: goto 39\n 111: aload 4\n 113: checkcast #88 // class java/util/List\n 116: nop\n 117: checkcast #43 // class java/lang/Iterable\n 120: astore_1\n 121: nop\n 122: iconst_0\n 123: istore_2\n 124: aload_1\n 125: astore_3\n 126: new #45 // class java/util/ArrayList\n 129: dup\n 130: aload_1\n 131: bipush 10\n 133: invokestatic #51 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 136: invokespecial #54 // Method java/util/ArrayList.\"<init>\":(I)V\n 139: checkcast #56 // class java/util/Collection\n 142: astore 4\n 144: iconst_0\n 145: istore 5\n 147: aload_3\n 148: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 153: astore 6\n 155: aload 6\n 157: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 162: ifeq 468\n 165: aload 6\n 167: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 172: astore 7\n 174: aload 4\n 176: aload 7\n 178: checkcast #88 // class java/util/List\n 181: astore 8\n 183: astore 21\n 185: iconst_0\n 186: istore 9\n 188: aload 8\n 190: checkcast #43 // class java/lang/Iterable\n 193: astore 10\n 195: iconst_0\n 196: istore 11\n 198: aload 10\n 200: astore 12\n 202: new #45 // class java/util/ArrayList\n 205: dup\n 206: aload 10\n 208: bipush 10\n 210: invokestatic #51 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 213: invokespecial #54 // Method java/util/ArrayList.\"<init>\":(I)V\n 216: checkcast #56 // class java/util/Collection\n 219: astore 13\n 221: iconst_0\n 222: istore 14\n 224: aload 12\n 226: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 231: astore 15\n 233: aload 15\n 235: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 240: ifeq 449\n 243: aload 15\n 245: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 250: astore 16\n 252: aload 13\n 254: aload 16\n 256: checkcast #72 // class java/lang/String\n 259: astore 17\n 261: astore 18\n 263: iconst_0\n 264: istore 19\n 266: aload 17\n 268: astore 20\n 270: aload 20\n 272: invokevirtual #92 // Method java/lang/String.hashCode:()I\n 275: lookupswitch { // 6\n 65: 332\n 66: 345\n 67: 358\n 88: 371\n 89: 384\n 90: 397\n default: 428\n }\n 332: aload 20\n 334: ldc #94 // String A\n 336: invokevirtual #97 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 339: ifne 410\n 342: goto 428\n 345: aload 20\n 347: ldc #99 // String B\n 349: invokevirtual #97 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 352: ifne 416\n 355: goto 428\n 358: aload 20\n 360: ldc #101 // String C\n 362: invokevirtual #97 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 365: ifne 422\n 368: goto 428\n 371: aload 20\n 373: ldc #103 // String X\n 375: invokevirtual #97 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 378: ifne 410\n 381: goto 428\n 384: aload 20\n 386: ldc #105 // String Y\n 388: invokevirtual #97 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 391: ifne 416\n 394: goto 428\n 397: aload 20\n 399: ldc #107 // String Z\n 401: invokevirtual #97 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 404: ifne 422\n 407: goto 428\n 410: getstatic #113 // Field Sign.ROCK:LSign;\n 413: goto 436\n 416: getstatic #116 // Field Sign.PAPER:LSign;\n 419: goto 436\n 422: getstatic #119 // Field Sign.SCISSORS:LSign;\n 425: goto 436\n 428: new #121 // class java/lang/RuntimeException\n 431: dup\n 432: invokespecial #123 // Method java/lang/RuntimeException.\"<init>\":()V\n 435: athrow\n 436: nop\n 437: aload 18\n 439: swap\n 440: invokeinterface #86, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 445: pop\n 446: goto 233\n 449: aload 13\n 451: checkcast #88 // class java/util/List\n 454: nop\n 455: nop\n 456: aload 21\n 458: swap\n 459: invokeinterface #86, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 464: pop\n 465: goto 155\n 468: aload 4\n 470: checkcast #88 // class java/util/List\n 473: nop\n 474: checkcast #43 // class java/lang/Iterable\n 477: astore_1\n 478: nop\n 479: iconst_0\n 480: istore_2\n 481: aload_1\n 482: astore_3\n 483: new #45 // class java/util/ArrayList\n 486: dup\n 487: aload_1\n 488: bipush 10\n 490: invokestatic #51 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 493: invokespecial #54 // Method java/util/ArrayList.\"<init>\":(I)V\n 496: checkcast #56 // class java/util/Collection\n 499: astore 4\n 501: iconst_0\n 502: istore 5\n 504: aload_3\n 505: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 510: astore 6\n 512: aload 6\n 514: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 519: ifeq 594\n 522: aload 6\n 524: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 529: astore 7\n 531: aload 4\n 533: aload 7\n 535: checkcast #88 // class java/util/List\n 538: astore 8\n 540: astore 21\n 542: iconst_0\n 543: istore 9\n 545: aload 8\n 547: iconst_0\n 548: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 553: checkcast #109 // class Sign\n 556: astore 10\n 558: aload 8\n 560: iconst_1\n 561: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 566: checkcast #109 // class Sign\n 569: astore 11\n 571: new #129 // class Round\n 574: dup\n 575: aload 10\n 577: aload 11\n 579: invokespecial #132 // Method Round.\"<init>\":(LSign;LSign;)V\n 582: aload 21\n 584: swap\n 585: invokeinterface #86, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 590: pop\n 591: goto 512\n 594: aload 4\n 596: checkcast #88 // class java/util/List\n 599: nop\n 600: checkcast #43 // class java/lang/Iterable\n 603: astore_1\n 604: iconst_0\n 605: istore_2\n 606: aload_1\n 607: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 612: astore_3\n 613: aload_3\n 614: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 619: ifeq 659\n 622: aload_3\n 623: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 628: astore 4\n 630: iload_2\n 631: aload 4\n 633: checkcast #129 // class Round\n 636: astore 5\n 638: istore 21\n 640: iconst_0\n 641: istore 6\n 643: aload 5\n 645: invokevirtual #135 // Method Round.totalPoints:()I\n 648: istore 22\n 650: iload 21\n 652: iload 22\n 654: iadd\n 655: istore_2\n 656: goto 613\n 659: iload_2\n 660: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: iconst_3\n 1: anewarray #109 // class Sign\n 4: astore_2\n 5: aload_2\n 6: iconst_0\n 7: getstatic #113 // Field Sign.ROCK:LSign;\n 10: aastore\n 11: aload_2\n 12: iconst_1\n 13: getstatic #119 // Field Sign.SCISSORS:LSign;\n 16: aastore\n 17: aload_2\n 18: iconst_2\n 19: getstatic #116 // Field Sign.PAPER:LSign;\n 22: aastore\n 23: aload_2\n 24: invokestatic #160 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 27: astore_1\n 28: aload_0\n 29: checkcast #43 // class java/lang/Iterable\n 32: astore_2\n 33: nop\n 34: iconst_0\n 35: istore_3\n 36: aload_2\n 37: astore 4\n 39: new #45 // class java/util/ArrayList\n 42: dup\n 43: aload_2\n 44: bipush 10\n 46: invokestatic #51 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 49: invokespecial #54 // Method java/util/ArrayList.\"<init>\":(I)V\n 52: checkcast #56 // class java/util/Collection\n 55: astore 5\n 57: iconst_0\n 58: istore 6\n 60: aload 4\n 62: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 67: astore 7\n 69: aload 7\n 71: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 76: ifeq 141\n 79: aload 7\n 81: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: astore 8\n 88: aload 5\n 90: aload 8\n 92: checkcast #72 // class java/lang/String\n 95: astore 9\n 97: astore 16\n 99: iconst_0\n 100: istore 10\n 102: aload 9\n 104: checkcast #74 // class java/lang/CharSequence\n 107: iconst_1\n 108: anewarray #72 // class java/lang/String\n 111: astore 11\n 113: aload 11\n 115: iconst_0\n 116: ldc #76 // String\n 118: aastore\n 119: aload 11\n 121: iconst_0\n 122: iconst_0\n 123: bipush 6\n 125: aconst_null\n 126: invokestatic #82 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 129: aload 16\n 131: swap\n 132: invokeinterface #86, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 137: pop\n 138: goto 69\n 141: aload 5\n 143: checkcast #88 // class java/util/List\n 146: nop\n 147: checkcast #43 // class java/lang/Iterable\n 150: astore_2\n 151: nop\n 152: iconst_0\n 153: istore_3\n 154: aload_2\n 155: astore 4\n 157: new #45 // class java/util/ArrayList\n 160: dup\n 161: aload_2\n 162: bipush 10\n 164: invokestatic #51 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 167: invokespecial #54 // Method java/util/ArrayList.\"<init>\":(I)V\n 170: checkcast #56 // class java/util/Collection\n 173: astore 5\n 175: iconst_0\n 176: istore 6\n 178: aload 4\n 180: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 185: astore 7\n 187: aload 7\n 189: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 194: ifeq 519\n 197: aload 7\n 199: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 204: astore 8\n 206: aload 5\n 208: aload 8\n 210: checkcast #88 // class java/util/List\n 213: astore 9\n 215: astore 16\n 217: iconst_0\n 218: istore 10\n 220: aload 9\n 222: iconst_0\n 223: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 228: checkcast #72 // class java/lang/String\n 231: astore 11\n 233: aload 9\n 235: iconst_1\n 236: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 241: checkcast #72 // class java/lang/String\n 244: astore 12\n 246: aload 11\n 248: astore 13\n 250: aload 13\n 252: invokevirtual #92 // Method java/lang/String.hashCode:()I\n 255: tableswitch { // 65 to 67\n 65: 280\n 66: 293\n 67: 306\n default: 337\n }\n 280: aload 13\n 282: ldc #94 // String A\n 284: invokevirtual #97 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 287: ifne 319\n 290: goto 337\n 293: aload 13\n 295: ldc #99 // String B\n 297: invokevirtual #97 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 300: ifne 325\n 303: goto 337\n 306: aload 13\n 308: ldc #101 // String C\n 310: invokevirtual #97 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 313: ifne 331\n 316: goto 337\n 319: getstatic #113 // Field Sign.ROCK:LSign;\n 322: goto 345\n 325: getstatic #116 // Field Sign.PAPER:LSign;\n 328: goto 345\n 331: getstatic #119 // Field Sign.SCISSORS:LSign;\n 334: goto 345\n 337: new #121 // class java/lang/RuntimeException\n 340: dup\n 341: invokespecial #123 // Method java/lang/RuntimeException.\"<init>\":()V\n 344: athrow\n 345: astore 14\n 347: aload 12\n 349: astore 15\n 351: aload 15\n 353: invokevirtual #92 // Method java/lang/String.hashCode:()I\n 356: tableswitch { // 88 to 90\n 88: 384\n 89: 397\n 90: 410\n default: 486\n }\n 384: aload 15\n 386: ldc #103 // String X\n 388: invokevirtual #97 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 391: ifne 423\n 394: goto 486\n 397: aload 15\n 399: ldc #105 // String Y\n 401: invokevirtual #97 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 404: ifne 452\n 407: goto 486\n 410: aload 15\n 412: ldc #107 // String Z\n 414: invokevirtual #97 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 417: ifne 457\n 420: goto 486\n 423: aload_1\n 424: aload_1\n 425: aload 14\n 427: invokeinterface #164, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 432: iconst_1\n 433: iadd\n 434: aload_1\n 435: invokeinterface #167, 1 // InterfaceMethod java/util/List.size:()I\n 440: irem\n 441: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 446: checkcast #109 // class Sign\n 449: goto 494\n 452: aload 14\n 454: goto 494\n 457: aload_1\n 458: aload_1\n 459: aload 14\n 461: invokeinterface #164, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 466: iconst_2\n 467: iadd\n 468: aload_1\n 469: invokeinterface #167, 1 // InterfaceMethod java/util/List.size:()I\n 474: irem\n 475: invokeinterface #127, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 480: checkcast #109 // class Sign\n 483: goto 494\n 486: new #121 // class java/lang/RuntimeException\n 489: dup\n 490: invokespecial #123 // Method java/lang/RuntimeException.\"<init>\":()V\n 493: athrow\n 494: astore 13\n 496: new #129 // class Round\n 499: dup\n 500: aload 14\n 502: aload 13\n 504: invokespecial #132 // Method Round.\"<init>\":(LSign;LSign;)V\n 507: aload 16\n 509: swap\n 510: invokeinterface #86, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 515: pop\n 516: goto 187\n 519: aload 5\n 521: checkcast #88 // class java/util/List\n 524: nop\n 525: checkcast #43 // class java/lang/Iterable\n 528: astore_2\n 529: iconst_0\n 530: istore_3\n 531: aload_2\n 532: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 537: astore 4\n 539: aload 4\n 541: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 546: ifeq 587\n 549: aload 4\n 551: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 556: astore 5\n 558: iload_3\n 559: aload 5\n 561: checkcast #129 // class Round\n 564: astore 6\n 566: istore 16\n 568: iconst_0\n 569: istore 7\n 571: aload 6\n 573: invokevirtual #135 // Method Round.totalPoints:()I\n 576: istore 17\n 578: iload 16\n 580: iload 17\n 582: iadd\n 583: istore_3\n 584: goto 539\n 587: iload_3\n 588: ireturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day09.kt
import kotlin.math.abs import kotlin.math.sign fun main() { infix fun Point.follow(head: Point) { val dx = head.x - x val dy = head.y - y if (abs(dx) > 1 || abs(dy) > 1) { this += Point(dx.sign, dy.sign) } } fun part1(input: List<String>): Int { val head = Point(0, 0) val tail = Point(0, 0) val visited = mutableSetOf<Point>() input.map { it.split(" ") }.forEach { (direction, amount) -> val dirVector = when (direction) { "U" -> Point(0, +1) "D" -> Point(0, -1) "L" -> Point(-1, 0) "R" -> Point(+1, 0) else -> error("wrong direction $direction") } for (i in 0 until amount.toInt()) { head += dirVector tail.follow(head) visited.add(tail.copy()) } } return visited.size } fun part2(input: List<String>): Int { val knots = MutableList(10) { Point(0, 0) } val visited = mutableSetOf<Point>() input.map { it.split(" ") }.forEach { (direction, amount) -> val dirVector = when (direction) { "U" -> Point(0, +1) "D" -> Point(0, -1) "L" -> Point(-1, 0) "R" -> Point(+1, 0) else -> error("wrong direction $direction") } for (i in 0 until amount.toInt()) { knots.forEachIndexed { index, knot -> if (index == 0) { knot += dirVector } else { knot follow knots[index-1] } if (index == 9) { visited.add(knot.copy()) } } } } return visited.size } val input = readInput("inputs/Day09") println(part1(input)) println(part2(input)) }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day09Kt.class", "javap": "Compiled from \"Day09.kt\"\npublic final class Day09Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/Day09\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 main$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 main$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 void main(java.lang.String[]);\n Code:\n 0: invokestatic #38 // Method main:()V\n 3: return\n\n private static final void main$follow(Point, Point);\n Code:\n 0: aload_1\n 1: invokevirtual #48 // Method Point.getX:()I\n 4: aload_0\n 5: invokevirtual #48 // Method Point.getX:()I\n 8: isub\n 9: istore_2\n 10: aload_1\n 11: invokevirtual #51 // Method Point.getY:()I\n 14: aload_0\n 15: invokevirtual #51 // Method Point.getY:()I\n 18: isub\n 19: istore_3\n 20: iload_2\n 21: invokestatic #57 // Method java/lang/Math.abs:(I)I\n 24: iconst_1\n 25: if_icmpgt 36\n 28: iload_3\n 29: invokestatic #57 // Method java/lang/Math.abs:(I)I\n 32: iconst_1\n 33: if_icmple 55\n 36: aload_0\n 37: new #44 // class Point\n 40: dup\n 41: iload_2\n 42: invokestatic #62 // Method kotlin/math/MathKt.getSign:(I)I\n 45: iload_3\n 46: invokestatic #62 // Method kotlin/math/MathKt.getSign:(I)I\n 49: invokespecial #66 // Method Point.\"<init>\":(II)V\n 52: invokevirtual #70 // Method Point.plusAssign:(LPoint;)V\n 55: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: new #44 // class Point\n 3: dup\n 4: iconst_0\n 5: iconst_0\n 6: invokespecial #66 // Method Point.\"<init>\":(II)V\n 9: astore_1\n 10: new #44 // class Point\n 13: dup\n 14: iconst_0\n 15: iconst_0\n 16: invokespecial #66 // Method Point.\"<init>\":(II)V\n 19: astore_2\n 20: new #79 // class java/util/LinkedHashSet\n 23: dup\n 24: invokespecial #81 // Method java/util/LinkedHashSet.\"<init>\":()V\n 27: checkcast #83 // class java/util/Set\n 30: astore_3\n 31: aload_0\n 32: checkcast #85 // class java/lang/Iterable\n 35: astore 4\n 37: iconst_0\n 38: istore 5\n 40: aload 4\n 42: astore 6\n 44: new #87 // class java/util/ArrayList\n 47: dup\n 48: aload 4\n 50: bipush 10\n 52: invokestatic #93 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 55: invokespecial #95 // Method java/util/ArrayList.\"<init>\":(I)V\n 58: checkcast #97 // class java/util/Collection\n 61: astore 7\n 63: iconst_0\n 64: istore 8\n 66: aload 6\n 68: invokeinterface #101, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 73: astore 9\n 75: aload 9\n 77: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 82: ifeq 147\n 85: aload 9\n 87: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 92: astore 10\n 94: aload 7\n 96: aload 10\n 98: checkcast #113 // class java/lang/String\n 101: astore 11\n 103: astore 15\n 105: iconst_0\n 106: istore 12\n 108: aload 11\n 110: checkcast #115 // class java/lang/CharSequence\n 113: iconst_1\n 114: anewarray #113 // class java/lang/String\n 117: astore 13\n 119: aload 13\n 121: iconst_0\n 122: ldc #117 // String\n 124: aastore\n 125: aload 13\n 127: iconst_0\n 128: iconst_0\n 129: bipush 6\n 131: aconst_null\n 132: invokestatic #123 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 135: aload 15\n 137: swap\n 138: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 143: pop\n 144: goto 75\n 147: aload 7\n 149: checkcast #129 // class java/util/List\n 152: nop\n 153: checkcast #85 // class java/lang/Iterable\n 156: astore 4\n 158: nop\n 159: iconst_0\n 160: istore 5\n 162: aload 4\n 164: invokeinterface #101, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 169: astore 6\n 171: aload 6\n 173: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 178: ifeq 463\n 181: aload 6\n 183: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 188: astore 7\n 190: aload 7\n 192: checkcast #129 // class java/util/List\n 195: astore 8\n 197: iconst_0\n 198: istore 9\n 200: aload 8\n 202: iconst_0\n 203: invokeinterface #133, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 208: checkcast #113 // class java/lang/String\n 211: astore 10\n 213: aload 8\n 215: iconst_1\n 216: invokeinterface #133, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 221: checkcast #113 // class java/lang/String\n 224: astore 11\n 226: aload 10\n 228: astore 12\n 230: aload 12\n 232: invokevirtual #136 // Method java/lang/String.hashCode:()I\n 235: lookupswitch { // 4\n 68: 289\n 76: 315\n 82: 276\n 85: 302\n default: 376\n }\n 276: aload 12\n 278: ldc #138 // String R\n 280: invokevirtual #141 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 283: ifne 364\n 286: goto 376\n 289: aload 12\n 291: ldc #143 // String D\n 293: invokevirtual #141 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 296: ifne 340\n 299: goto 376\n 302: aload 12\n 304: ldc #145 // String U\n 306: invokevirtual #141 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 309: ifne 328\n 312: goto 376\n 315: aload 12\n 317: ldc #147 // String L\n 319: invokevirtual #141 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 322: ifne 352\n 325: goto 376\n 328: new #44 // class Point\n 331: dup\n 332: iconst_0\n 333: iconst_1\n 334: invokespecial #66 // Method Point.\"<init>\":(II)V\n 337: goto 407\n 340: new #44 // class Point\n 343: dup\n 344: iconst_0\n 345: iconst_m1\n 346: invokespecial #66 // Method Point.\"<init>\":(II)V\n 349: goto 407\n 352: new #44 // class Point\n 355: dup\n 356: iconst_m1\n 357: iconst_0\n 358: invokespecial #66 // Method Point.\"<init>\":(II)V\n 361: goto 407\n 364: new #44 // class Point\n 367: dup\n 368: iconst_1\n 369: iconst_0\n 370: invokespecial #66 // Method Point.\"<init>\":(II)V\n 373: goto 407\n 376: new #149 // class java/lang/IllegalStateException\n 379: dup\n 380: new #151 // class java/lang/StringBuilder\n 383: dup\n 384: invokespecial #152 // Method java/lang/StringBuilder.\"<init>\":()V\n 387: ldc #154 // String wrong direction\n 389: invokevirtual #158 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 392: aload 10\n 394: invokevirtual #158 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 397: invokevirtual #162 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 400: invokevirtual #163 // Method java/lang/Object.toString:()Ljava/lang/String;\n 403: invokespecial #166 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 406: athrow\n 407: astore 13\n 409: iconst_0\n 410: istore 12\n 412: aload 11\n 414: invokestatic #172 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 417: istore 14\n 419: iload 12\n 421: iload 14\n 423: if_icmpge 458\n 426: aload_1\n 427: aload 13\n 429: invokevirtual #70 // Method Point.plusAssign:(LPoint;)V\n 432: aload_2\n 433: aload_1\n 434: invokestatic #174 // Method main$follow:(LPoint;LPoint;)V\n 437: aload_3\n 438: aload_2\n 439: iconst_0\n 440: iconst_0\n 441: iconst_3\n 442: aconst_null\n 443: invokestatic #178 // Method Point.copy$default:(LPoint;IIILjava/lang/Object;)LPoint;\n 446: invokeinterface #179, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 451: pop\n 452: iinc 12, 1\n 455: goto 419\n 458: nop\n 459: nop\n 460: goto 171\n 463: nop\n 464: aload_3\n 465: invokeinterface #182, 1 // InterfaceMethod java/util/Set.size:()I\n 470: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: bipush 10\n 2: istore_2\n 3: new #87 // class java/util/ArrayList\n 6: dup\n 7: iload_2\n 8: invokespecial #95 // Method java/util/ArrayList.\"<init>\":(I)V\n 11: astore_3\n 12: iconst_0\n 13: istore 4\n 15: iload 4\n 17: iload_2\n 18: if_icmpge 57\n 21: iload 4\n 23: istore 5\n 25: aload_3\n 26: iload 5\n 28: istore 6\n 30: astore 23\n 32: iconst_0\n 33: istore 7\n 35: new #44 // class Point\n 38: dup\n 39: iconst_0\n 40: iconst_0\n 41: invokespecial #66 // Method Point.\"<init>\":(II)V\n 44: aload 23\n 46: swap\n 47: invokevirtual #206 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 50: pop\n 51: iinc 4, 1\n 54: goto 15\n 57: aload_3\n 58: checkcast #129 // class java/util/List\n 61: astore_1\n 62: new #79 // class java/util/LinkedHashSet\n 65: dup\n 66: invokespecial #81 // Method java/util/LinkedHashSet.\"<init>\":()V\n 69: checkcast #83 // class java/util/Set\n 72: astore_2\n 73: aload_0\n 74: checkcast #85 // class java/lang/Iterable\n 77: astore_3\n 78: iconst_0\n 79: istore 4\n 81: aload_3\n 82: astore 5\n 84: new #87 // class java/util/ArrayList\n 87: dup\n 88: aload_3\n 89: bipush 10\n 91: invokestatic #93 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 94: invokespecial #95 // Method java/util/ArrayList.\"<init>\":(I)V\n 97: checkcast #97 // class java/util/Collection\n 100: astore 6\n 102: iconst_0\n 103: istore 7\n 105: aload 5\n 107: invokeinterface #101, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 112: astore 8\n 114: aload 8\n 116: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 121: ifeq 186\n 124: aload 8\n 126: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 131: astore 9\n 133: aload 6\n 135: aload 9\n 137: checkcast #113 // class java/lang/String\n 140: astore 10\n 142: astore 23\n 144: iconst_0\n 145: istore 11\n 147: aload 10\n 149: checkcast #115 // class java/lang/CharSequence\n 152: iconst_1\n 153: anewarray #113 // class java/lang/String\n 156: astore 12\n 158: aload 12\n 160: iconst_0\n 161: ldc #117 // String\n 163: aastore\n 164: aload 12\n 166: iconst_0\n 167: iconst_0\n 168: bipush 6\n 170: aconst_null\n 171: invokestatic #123 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 174: aload 23\n 176: swap\n 177: invokeinterface #127, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 182: pop\n 183: goto 114\n 186: aload 6\n 188: checkcast #129 // class java/util/List\n 191: nop\n 192: checkcast #85 // class java/lang/Iterable\n 195: astore_3\n 196: nop\n 197: iconst_0\n 198: istore 4\n 200: aload_3\n 201: invokeinterface #101, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 206: astore 5\n 208: aload 5\n 210: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 215: ifeq 608\n 218: aload 5\n 220: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 225: astore 6\n 227: aload 6\n 229: checkcast #129 // class java/util/List\n 232: astore 7\n 234: iconst_0\n 235: istore 8\n 237: aload 7\n 239: iconst_0\n 240: invokeinterface #133, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 245: checkcast #113 // class java/lang/String\n 248: astore 9\n 250: aload 7\n 252: iconst_1\n 253: invokeinterface #133, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 258: checkcast #113 // class java/lang/String\n 261: astore 10\n 263: aload 9\n 265: astore 11\n 267: aload 11\n 269: invokevirtual #136 // Method java/lang/String.hashCode:()I\n 272: lookupswitch { // 4\n 68: 329\n 76: 355\n 82: 316\n 85: 342\n default: 416\n }\n 316: aload 11\n 318: ldc #138 // String R\n 320: invokevirtual #141 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 323: ifne 404\n 326: goto 416\n 329: aload 11\n 331: ldc #143 // String D\n 333: invokevirtual #141 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 336: ifne 380\n 339: goto 416\n 342: aload 11\n 344: ldc #145 // String U\n 346: invokevirtual #141 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 349: ifne 368\n 352: goto 416\n 355: aload 11\n 357: ldc #147 // String L\n 359: invokevirtual #141 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 362: ifne 392\n 365: goto 416\n 368: new #44 // class Point\n 371: dup\n 372: iconst_0\n 373: iconst_1\n 374: invokespecial #66 // Method Point.\"<init>\":(II)V\n 377: goto 447\n 380: new #44 // class Point\n 383: dup\n 384: iconst_0\n 385: iconst_m1\n 386: invokespecial #66 // Method Point.\"<init>\":(II)V\n 389: goto 447\n 392: new #44 // class Point\n 395: dup\n 396: iconst_m1\n 397: iconst_0\n 398: invokespecial #66 // Method Point.\"<init>\":(II)V\n 401: goto 447\n 404: new #44 // class Point\n 407: dup\n 408: iconst_1\n 409: iconst_0\n 410: invokespecial #66 // Method Point.\"<init>\":(II)V\n 413: goto 447\n 416: new #149 // class java/lang/IllegalStateException\n 419: dup\n 420: new #151 // class java/lang/StringBuilder\n 423: dup\n 424: invokespecial #152 // Method java/lang/StringBuilder.\"<init>\":()V\n 427: ldc #154 // String wrong direction\n 429: invokevirtual #158 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 432: aload 9\n 434: invokevirtual #158 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 437: invokevirtual #162 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 440: invokevirtual #163 // Method java/lang/Object.toString:()Ljava/lang/String;\n 443: invokespecial #166 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 446: athrow\n 447: astore 12\n 449: iconst_0\n 450: istore 11\n 452: aload 10\n 454: invokestatic #172 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 457: istore 13\n 459: iload 11\n 461: iload 13\n 463: if_icmpge 603\n 466: aload_1\n 467: checkcast #85 // class java/lang/Iterable\n 470: astore 14\n 472: iconst_0\n 473: istore 15\n 475: iconst_0\n 476: istore 16\n 478: aload 14\n 480: invokeinterface #101, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 485: astore 17\n 487: aload 17\n 489: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 494: ifeq 596\n 497: aload 17\n 499: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 504: astore 18\n 506: iload 16\n 508: iinc 16, 1\n 511: istore 19\n 513: iload 19\n 515: ifge 521\n 518: invokestatic #209 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 521: iload 19\n 523: aload 18\n 525: checkcast #44 // class Point\n 528: astore 20\n 530: istore 21\n 532: iconst_0\n 533: istore 22\n 535: iload 21\n 537: ifne 550\n 540: aload 20\n 542: aload 12\n 544: invokevirtual #70 // Method Point.plusAssign:(LPoint;)V\n 547: goto 568\n 550: aload 20\n 552: aload_1\n 553: iload 21\n 555: iconst_1\n 556: isub\n 557: invokeinterface #133, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 562: checkcast #44 // class Point\n 565: invokestatic #174 // Method main$follow:(LPoint;LPoint;)V\n 568: iload 21\n 570: bipush 9\n 572: if_icmpne 591\n 575: aload_2\n 576: aload 20\n 578: iconst_0\n 579: iconst_0\n 580: iconst_3\n 581: aconst_null\n 582: invokestatic #178 // Method Point.copy$default:(LPoint;IIILjava/lang/Object;)LPoint;\n 585: invokeinterface #179, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 590: pop\n 591: nop\n 592: nop\n 593: goto 487\n 596: nop\n 597: iinc 11, 1\n 600: goto 459\n 603: nop\n 604: nop\n 605: goto 208\n 608: nop\n 609: aload_2\n 610: invokeinterface #182, 1 // InterfaceMethod java/util/Set.size:()I\n 615: ireturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day08.kt
fun main() { fun part1(input: List<String>): Int { val matrix = input.map { it.toList() } return matrix.count { row, col -> matrix.visible(row, col) } } fun part2(input: List<String>): Int { val matrix = input.map { it.toList() } return matrix.maxOf { row, col -> matrix.score(row, col) } } val input = readInput("inputs/Day08") println(part1(input)) println(part2(input)) } fun List<List<Char>>.score(row: Int, col: Int) = scoreUp(row, col) * scoreDown(row, col) * scoreLeft(row, col) * scoreRight(row, col) fun List<List<Char>>.scoreUp(row: Int, col: Int): Int { var count = 0 for (i in row-1 downTo 0) { count++ if (this[i][col] >= this[row][col]) { break } } return count } fun List<List<Char>>.scoreDown(row: Int, col: Int): Int { var count = 0 for (i in row+1 until size) { count++ if (this[i][col] >= this[row][col]) { break } } return count } fun List<List<Char>>.scoreLeft(row: Int, col: Int): Int { var count = 0 for (i in col-1 downTo 0) { count++ if (this[row][i] >= this[row][col]) { break } } return count } fun List<List<Char>>.scoreRight(row: Int, col: Int): Int { var count = 0 for (i in col+1 until first().size) { count++ if (this[row][i] >= this[row][col]) { break } } return count } fun List<List<Char>>.visibleUp(row: Int, col: Int): Boolean { for (i in 0 until row) { if (this[i][col] >= this[row][col]) { return false } } return true } fun List<List<Char>>.visibleDown(row: Int, col: Int): Boolean { for (i in row+1 until size) { if (this[i][col] >= this[row][col]) { return false } } return true } fun List<List<Char>>.visibleLeft(row: Int, col: Int): Boolean { for (i in 0 until col) { if (this[row][i] >= this[row][col]) { return false } } return true } fun List<List<Char>>.visibleRight(row: Int, col: Int): Boolean { for (i in col+1 until first().size) { if (this[row][i] >= this[row][col]) { return false } } return true } fun List<List<Char>>.visible(row: Int, col: Int): Boolean { if (row == 0 || col == 0) { return true } else if (row == size-1 || col == first().size-1) { return true } return visibleUp(row, col) || visibleDown(row, col) || visibleRight(row, col) || visibleLeft(row, col) }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day08Kt.class", "javap": "Compiled from \"Day08.kt\"\npublic final class Day08Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/Day08\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 main$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 main$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 score(java.util.List<? extends java.util.List<java.lang.Character>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #41 // String <this>\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iload_1\n 8: iload_2\n 9: invokestatic #50 // Method scoreUp:(Ljava/util/List;II)I\n 12: aload_0\n 13: iload_1\n 14: iload_2\n 15: invokestatic #53 // Method scoreDown:(Ljava/util/List;II)I\n 18: imul\n 19: aload_0\n 20: iload_1\n 21: iload_2\n 22: invokestatic #56 // Method scoreLeft:(Ljava/util/List;II)I\n 25: imul\n 26: aload_0\n 27: iload_1\n 28: iload_2\n 29: invokestatic #59 // Method scoreRight:(Ljava/util/List;II)I\n 32: imul\n 33: ireturn\n\n public static final int scoreUp(java.util.List<? extends java.util.List<java.lang.Character>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #41 // String <this>\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_3\n 8: iload_1\n 9: iconst_1\n 10: isub\n 11: istore 4\n 13: iconst_m1\n 14: iload 4\n 16: if_icmpge 82\n 19: iinc 3, 1\n 22: aload_0\n 23: iload 4\n 25: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 30: checkcast #65 // class java/util/List\n 33: iload_2\n 34: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 39: checkcast #71 // class java/lang/Character\n 42: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 45: aload_0\n 46: iload_1\n 47: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 52: checkcast #65 // class java/util/List\n 55: iload_2\n 56: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 61: checkcast #71 // class java/lang/Character\n 64: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 67: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 70: iflt 76\n 73: goto 82\n 76: iinc 4, -1\n 79: goto 13\n 82: iload_3\n 83: ireturn\n\n public static final int scoreDown(java.util.List<? extends java.util.List<java.lang.Character>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #41 // String <this>\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_3\n 8: iload_1\n 9: iconst_1\n 10: iadd\n 11: istore 4\n 13: aload_0\n 14: invokeinterface #86, 1 // InterfaceMethod java/util/List.size:()I\n 19: istore 5\n 21: iload 4\n 23: iload 5\n 25: if_icmpge 91\n 28: iinc 3, 1\n 31: aload_0\n 32: iload 4\n 34: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 39: checkcast #65 // class java/util/List\n 42: iload_2\n 43: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 48: checkcast #71 // class java/lang/Character\n 51: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 54: aload_0\n 55: iload_1\n 56: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 61: checkcast #65 // class java/util/List\n 64: iload_2\n 65: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 70: checkcast #71 // class java/lang/Character\n 73: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 76: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 79: iflt 85\n 82: goto 91\n 85: iinc 4, 1\n 88: goto 21\n 91: iload_3\n 92: ireturn\n\n public static final int scoreLeft(java.util.List<? extends java.util.List<java.lang.Character>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #41 // String <this>\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_3\n 8: iload_2\n 9: iconst_1\n 10: isub\n 11: istore 4\n 13: iconst_m1\n 14: iload 4\n 16: if_icmpge 82\n 19: iinc 3, 1\n 22: aload_0\n 23: iload_1\n 24: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 29: checkcast #65 // class java/util/List\n 32: iload 4\n 34: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 39: checkcast #71 // class java/lang/Character\n 42: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 45: aload_0\n 46: iload_1\n 47: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 52: checkcast #65 // class java/util/List\n 55: iload_2\n 56: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 61: checkcast #71 // class java/lang/Character\n 64: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 67: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 70: iflt 76\n 73: goto 82\n 76: iinc 4, -1\n 79: goto 13\n 82: iload_3\n 83: ireturn\n\n public static final int scoreRight(java.util.List<? extends java.util.List<java.lang.Character>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #41 // String <this>\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_3\n 8: iload_2\n 9: iconst_1\n 10: iadd\n 11: istore 4\n 13: aload_0\n 14: invokestatic #94 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 17: checkcast #65 // class java/util/List\n 20: invokeinterface #86, 1 // InterfaceMethod java/util/List.size:()I\n 25: istore 5\n 27: iload 4\n 29: iload 5\n 31: if_icmpge 97\n 34: iinc 3, 1\n 37: aload_0\n 38: iload_1\n 39: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 44: checkcast #65 // class java/util/List\n 47: iload 4\n 49: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 54: checkcast #71 // class java/lang/Character\n 57: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 60: aload_0\n 61: iload_1\n 62: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 67: checkcast #65 // class java/util/List\n 70: iload_2\n 71: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 76: checkcast #71 // class java/lang/Character\n 79: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 82: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 85: iflt 91\n 88: goto 97\n 91: iinc 4, 1\n 94: goto 27\n 97: iload_3\n 98: ireturn\n\n public static final boolean visibleUp(java.util.List<? extends java.util.List<java.lang.Character>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #41 // String <this>\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_3\n 8: iload_3\n 9: iload_1\n 10: if_icmpge 71\n 13: aload_0\n 14: iload_3\n 15: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 20: checkcast #65 // class java/util/List\n 23: iload_2\n 24: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 29: checkcast #71 // class java/lang/Character\n 32: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 35: aload_0\n 36: iload_1\n 37: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 42: checkcast #65 // class java/util/List\n 45: iload_2\n 46: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 51: checkcast #71 // class java/lang/Character\n 54: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 57: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 60: iflt 65\n 63: iconst_0\n 64: ireturn\n 65: iinc 3, 1\n 68: goto 8\n 71: iconst_1\n 72: ireturn\n\n public static final boolean visibleDown(java.util.List<? extends java.util.List<java.lang.Character>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #41 // String <this>\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_1\n 7: iconst_1\n 8: iadd\n 9: istore_3\n 10: aload_0\n 11: invokeinterface #86, 1 // InterfaceMethod java/util/List.size:()I\n 16: istore 4\n 18: iload_3\n 19: iload 4\n 21: if_icmpge 82\n 24: aload_0\n 25: iload_3\n 26: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 31: checkcast #65 // class java/util/List\n 34: iload_2\n 35: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 40: checkcast #71 // class java/lang/Character\n 43: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 46: aload_0\n 47: iload_1\n 48: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 53: checkcast #65 // class java/util/List\n 56: iload_2\n 57: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 62: checkcast #71 // class java/lang/Character\n 65: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 68: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 71: iflt 76\n 74: iconst_0\n 75: ireturn\n 76: iinc 3, 1\n 79: goto 18\n 82: iconst_1\n 83: ireturn\n\n public static final boolean visibleLeft(java.util.List<? extends java.util.List<java.lang.Character>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #41 // String <this>\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_3\n 8: iload_3\n 9: iload_2\n 10: if_icmpge 71\n 13: aload_0\n 14: iload_1\n 15: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 20: checkcast #65 // class java/util/List\n 23: iload_3\n 24: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 29: checkcast #71 // class java/lang/Character\n 32: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 35: aload_0\n 36: iload_1\n 37: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 42: checkcast #65 // class java/util/List\n 45: iload_2\n 46: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 51: checkcast #71 // class java/lang/Character\n 54: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 57: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 60: iflt 65\n 63: iconst_0\n 64: ireturn\n 65: iinc 3, 1\n 68: goto 8\n 71: iconst_1\n 72: ireturn\n\n public static final boolean visibleRight(java.util.List<? extends java.util.List<java.lang.Character>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #41 // String <this>\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_2\n 7: iconst_1\n 8: iadd\n 9: istore_3\n 10: aload_0\n 11: invokestatic #94 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 14: checkcast #65 // class java/util/List\n 17: invokeinterface #86, 1 // InterfaceMethod java/util/List.size:()I\n 22: istore 4\n 24: iload_3\n 25: iload 4\n 27: if_icmpge 88\n 30: aload_0\n 31: iload_1\n 32: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 37: checkcast #65 // class java/util/List\n 40: iload_3\n 41: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 46: checkcast #71 // class java/lang/Character\n 49: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 52: aload_0\n 53: iload_1\n 54: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 59: checkcast #65 // class java/util/List\n 62: iload_2\n 63: invokeinterface #69, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 68: checkcast #71 // class java/lang/Character\n 71: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 74: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 77: iflt 82\n 80: iconst_0\n 81: ireturn\n 82: iinc 3, 1\n 85: goto 24\n 88: iconst_1\n 89: ireturn\n\n public static final boolean visible(java.util.List<? extends java.util.List<java.lang.Character>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #41 // String <this>\n 3: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_1\n 7: ifeq 14\n 10: iload_2\n 11: ifne 16\n 14: iconst_1\n 15: ireturn\n 16: iload_1\n 17: aload_0\n 18: invokeinterface #86, 1 // InterfaceMethod java/util/List.size:()I\n 23: iconst_1\n 24: isub\n 25: if_icmpeq 46\n 28: iload_2\n 29: aload_0\n 30: invokestatic #94 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 33: checkcast #65 // class java/util/List\n 36: invokeinterface #86, 1 // InterfaceMethod java/util/List.size:()I\n 41: iconst_1\n 42: isub\n 43: if_icmpne 48\n 46: iconst_1\n 47: ireturn\n 48: aload_0\n 49: iload_1\n 50: iload_2\n 51: invokestatic #108 // Method visibleUp:(Ljava/util/List;II)Z\n 54: ifne 84\n 57: aload_0\n 58: iload_1\n 59: iload_2\n 60: invokestatic #110 // Method visibleDown:(Ljava/util/List;II)Z\n 63: ifne 84\n 66: aload_0\n 67: iload_1\n 68: iload_2\n 69: invokestatic #112 // Method visibleRight:(Ljava/util/List;II)Z\n 72: ifne 84\n 75: aload_0\n 76: iload_1\n 77: iload_2\n 78: invokestatic #114 // Method visibleLeft:(Ljava/util/List;II)Z\n 81: ifeq 88\n 84: iconst_1\n 85: goto 89\n 88: iconst_0\n 89: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #118 // Method main:()V\n 3: return\n\n private static final boolean main$part1$lambda$1(java.util.List, int, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: iload_2\n 3: invokestatic #123 // Method visible:(Ljava/util/List;II)Z\n 6: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #127 // 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 #129 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #133 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #136 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #138 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #142, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #148, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 93\n 50: aload 7\n 52: invokeinterface #152, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #154 // 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: checkcast #156 // class java/lang/CharSequence\n 78: invokestatic #162 // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;\n 81: aload 11\n 83: swap\n 84: invokeinterface #166, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 89: pop\n 90: goto 40\n 93: aload 5\n 95: checkcast #65 // class java/util/List\n 98: nop\n 99: astore_1\n 100: aload_1\n 101: aload_1\n 102: invokedynamic #184, 0 // InvokeDynamic #0:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function2;\n 107: invokestatic #187 // Method UtilsKt.count:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)I\n 110: ireturn\n\n private static final int main$part2$lambda$3(java.util.List, int, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: iload_2\n 3: invokestatic #203 // Method score:(Ljava/util/List;II)I\n 6: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #127 // 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 #129 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #133 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #136 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #138 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #142, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #148, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 93\n 50: aload 7\n 52: invokeinterface #152, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #154 // 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: checkcast #156 // class java/lang/CharSequence\n 78: invokestatic #162 // Method kotlin/text/StringsKt.toList:(Ljava/lang/CharSequence;)Ljava/util/List;\n 81: aload 11\n 83: swap\n 84: invokeinterface #166, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 89: pop\n 90: goto 40\n 93: aload 5\n 95: checkcast #65 // class java/util/List\n 98: nop\n 99: astore_1\n 100: aload_1\n 101: aload_1\n 102: invokedynamic #209, 0 // InvokeDynamic #1:invoke:(Ljava/util/List;)Lkotlin/jvm/functions/Function2;\n 107: invokestatic #212 // Method UtilsKt.maxOf:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)I\n 110: ireturn\n}\n", "javap_err": "" } ]
ambrosil__aoc-2022__ebaacfc/src/Day01.kt
fun main() { fun part1(input: List<String>): Int { var elfNum = 0 return input.groupBy { if (it.isBlank()) elfNum++; elfNum } .map { elf -> elf.value.filterNot { calories -> calories.isBlank() } } .maxOf { it.sumOf { n -> n.toInt() } } } fun part2(input: List<String>): Int { var elfNum = 0 return input.groupBy { if (it.isBlank()) elfNum++; elfNum } .map { elf -> elf.value.filterNot { calories -> calories.isBlank() } } .map { it.sumOf { n -> n.toInt() } } .sortedDescending() .take(3) .sum() } val input = readInput("inputs/Day01") println(part1(input)) println(part2(input)) }
[ { "class_path": "ambrosil__aoc-2022__ebaacfc/Day01Kt.class", "javap": "Compiled from \"Day01.kt\"\npublic final class Day01Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String inputs/Day01\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 main$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 main$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 void main(java.lang.String[]);\n Code:\n 0: invokestatic #38 // Method main:()V\n 3: return\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: aload_0\n 3: checkcast #43 // class java/lang/Iterable\n 6: astore_2\n 7: iconst_0\n 8: istore_3\n 9: aload_2\n 10: astore 4\n 12: new #45 // class java/util/LinkedHashMap\n 15: dup\n 16: invokespecial #48 // Method java/util/LinkedHashMap.\"<init>\":()V\n 19: checkcast #50 // class java/util/Map\n 22: astore 5\n 24: iconst_0\n 25: istore 6\n 27: aload 4\n 29: invokeinterface #54, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 34: astore 7\n 36: aload 7\n 38: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 43: ifeq 162\n 46: aload 7\n 48: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 53: astore 8\n 55: aload 8\n 57: checkcast #66 // class java/lang/String\n 60: astore 9\n 62: iconst_0\n 63: istore 10\n 65: aload 9\n 67: checkcast #68 // class java/lang/CharSequence\n 70: invokestatic #74 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 73: ifeq 80\n 76: iload_1\n 77: iconst_1\n 78: iadd\n 79: istore_1\n 80: iload_1\n 81: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 84: astore 12\n 86: aload 5\n 88: astore 13\n 90: iconst_0\n 91: istore 14\n 93: aload 13\n 95: aload 12\n 97: invokeinterface #84, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 102: astore 15\n 104: aload 15\n 106: ifnonnull 141\n 109: iconst_0\n 110: istore 16\n 112: new #86 // class java/util/ArrayList\n 115: dup\n 116: invokespecial #87 // Method java/util/ArrayList.\"<init>\":()V\n 119: checkcast #89 // class java/util/List\n 122: astore 16\n 124: aload 13\n 126: aload 12\n 128: aload 16\n 130: invokeinterface #93, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 135: pop\n 136: aload 16\n 138: goto 143\n 141: aload 15\n 143: nop\n 144: checkcast #89 // class java/util/List\n 147: astore 17\n 149: aload 17\n 151: aload 8\n 153: invokeinterface #97, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 158: pop\n 159: goto 36\n 162: aload 5\n 164: nop\n 165: astore_2\n 166: nop\n 167: iconst_0\n 168: istore_3\n 169: aload_2\n 170: astore 4\n 172: new #86 // class java/util/ArrayList\n 175: dup\n 176: aload_2\n 177: invokeinterface #101, 1 // InterfaceMethod java/util/Map.size:()I\n 182: invokespecial #103 // Method java/util/ArrayList.\"<init>\":(I)V\n 185: checkcast #105 // class java/util/Collection\n 188: astore 5\n 190: iconst_0\n 191: istore 6\n 193: aload 4\n 195: invokeinterface #109, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 200: invokeinterface #112, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 205: astore 7\n 207: aload 7\n 209: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 214: ifeq 355\n 217: aload 7\n 219: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 224: checkcast #114 // class java/util/Map$Entry\n 227: astore 8\n 229: aload 5\n 231: aload 8\n 233: astore 9\n 235: astore 20\n 237: iconst_0\n 238: istore 10\n 240: aload 9\n 242: invokeinterface #117, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 247: checkcast #43 // class java/lang/Iterable\n 250: astore 11\n 252: iconst_0\n 253: istore 12\n 255: aload 11\n 257: astore 13\n 259: new #86 // class java/util/ArrayList\n 262: dup\n 263: invokespecial #87 // Method java/util/ArrayList.\"<init>\":()V\n 266: checkcast #105 // class java/util/Collection\n 269: astore 14\n 271: iconst_0\n 272: istore 15\n 274: aload 13\n 276: invokeinterface #54, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 281: astore 16\n 283: aload 16\n 285: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 290: ifeq 336\n 293: aload 16\n 295: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 300: astore 17\n 302: aload 17\n 304: checkcast #66 // class java/lang/String\n 307: astore 18\n 309: iconst_0\n 310: istore 19\n 312: aload 18\n 314: checkcast #68 // class java/lang/CharSequence\n 317: invokestatic #74 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 320: ifne 283\n 323: aload 14\n 325: aload 17\n 327: invokeinterface #118, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 332: pop\n 333: goto 283\n 336: aload 14\n 338: checkcast #89 // class java/util/List\n 341: nop\n 342: nop\n 343: aload 20\n 345: swap\n 346: invokeinterface #118, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 351: pop\n 352: goto 207\n 355: aload 5\n 357: checkcast #89 // class java/util/List\n 360: nop\n 361: checkcast #43 // class java/lang/Iterable\n 364: invokeinterface #54, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 369: astore_3\n 370: aload_3\n 371: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 376: ifne 387\n 379: new #120 // class java/util/NoSuchElementException\n 382: dup\n 383: invokespecial #121 // Method java/util/NoSuchElementException.\"<init>\":()V\n 386: athrow\n 387: aload_3\n 388: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 393: checkcast #89 // class java/util/List\n 396: astore 4\n 398: iconst_0\n 399: istore 5\n 401: aload 4\n 403: checkcast #43 // class java/lang/Iterable\n 406: astore 6\n 408: iconst_0\n 409: istore 7\n 411: aload 6\n 413: invokeinterface #54, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 418: astore 8\n 420: aload 8\n 422: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 427: ifeq 471\n 430: aload 8\n 432: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 437: astore 9\n 439: iload 7\n 441: aload 9\n 443: checkcast #66 // class java/lang/String\n 446: astore 10\n 448: istore 11\n 450: iconst_0\n 451: istore 12\n 453: aload 10\n 455: invokestatic #125 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 458: nop\n 459: istore 13\n 461: iload 11\n 463: iload 13\n 465: iadd\n 466: istore 7\n 468: goto 420\n 471: iload 7\n 473: nop\n 474: istore 4\n 476: aload_3\n 477: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 482: ifeq 588\n 485: aload_3\n 486: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 491: checkcast #89 // class java/util/List\n 494: astore 5\n 496: iconst_0\n 497: istore 6\n 499: aload 5\n 501: checkcast #43 // class java/lang/Iterable\n 504: astore 7\n 506: iconst_0\n 507: istore 8\n 509: aload 7\n 511: invokeinterface #54, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 516: astore 9\n 518: aload 9\n 520: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 525: ifeq 569\n 528: aload 9\n 530: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 535: astore 10\n 537: iload 8\n 539: aload 10\n 541: checkcast #66 // class java/lang/String\n 544: astore 11\n 546: istore 12\n 548: iconst_0\n 549: istore 13\n 551: aload 11\n 553: invokestatic #125 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 556: nop\n 557: istore 14\n 559: iload 12\n 561: iload 14\n 563: iadd\n 564: istore 8\n 566: goto 518\n 569: iload 8\n 571: nop\n 572: istore 5\n 574: iload 4\n 576: iload 5\n 578: if_icmpge 476\n 581: iload 5\n 583: istore 4\n 585: goto 476\n 588: iload 4\n 590: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: aload_0\n 3: checkcast #43 // class java/lang/Iterable\n 6: astore_2\n 7: iconst_0\n 8: istore_3\n 9: aload_2\n 10: astore 4\n 12: new #45 // class java/util/LinkedHashMap\n 15: dup\n 16: invokespecial #48 // Method java/util/LinkedHashMap.\"<init>\":()V\n 19: checkcast #50 // class java/util/Map\n 22: astore 5\n 24: iconst_0\n 25: istore 6\n 27: aload 4\n 29: invokeinterface #54, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 34: astore 7\n 36: aload 7\n 38: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 43: ifeq 162\n 46: aload 7\n 48: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 53: astore 8\n 55: aload 8\n 57: checkcast #66 // class java/lang/String\n 60: astore 9\n 62: iconst_0\n 63: istore 10\n 65: aload 9\n 67: checkcast #68 // class java/lang/CharSequence\n 70: invokestatic #74 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 73: ifeq 80\n 76: iload_1\n 77: iconst_1\n 78: iadd\n 79: istore_1\n 80: iload_1\n 81: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 84: astore 12\n 86: aload 5\n 88: astore 13\n 90: iconst_0\n 91: istore 14\n 93: aload 13\n 95: aload 12\n 97: invokeinterface #84, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 102: astore 15\n 104: aload 15\n 106: ifnonnull 141\n 109: iconst_0\n 110: istore 16\n 112: new #86 // class java/util/ArrayList\n 115: dup\n 116: invokespecial #87 // Method java/util/ArrayList.\"<init>\":()V\n 119: checkcast #89 // class java/util/List\n 122: astore 16\n 124: aload 13\n 126: aload 12\n 128: aload 16\n 130: invokeinterface #93, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 135: pop\n 136: aload 16\n 138: goto 143\n 141: aload 15\n 143: nop\n 144: checkcast #89 // class java/util/List\n 147: astore 17\n 149: aload 17\n 151: aload 8\n 153: invokeinterface #97, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 158: pop\n 159: goto 36\n 162: aload 5\n 164: nop\n 165: astore_2\n 166: nop\n 167: iconst_0\n 168: istore_3\n 169: aload_2\n 170: astore 4\n 172: new #86 // class java/util/ArrayList\n 175: dup\n 176: aload_2\n 177: invokeinterface #101, 1 // InterfaceMethod java/util/Map.size:()I\n 182: invokespecial #103 // Method java/util/ArrayList.\"<init>\":(I)V\n 185: checkcast #105 // class java/util/Collection\n 188: astore 5\n 190: iconst_0\n 191: istore 6\n 193: aload 4\n 195: invokeinterface #109, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 200: invokeinterface #112, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 205: astore 7\n 207: aload 7\n 209: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 214: ifeq 355\n 217: aload 7\n 219: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 224: checkcast #114 // class java/util/Map$Entry\n 227: astore 8\n 229: aload 5\n 231: aload 8\n 233: astore 9\n 235: astore 20\n 237: iconst_0\n 238: istore 10\n 240: aload 9\n 242: invokeinterface #117, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 247: checkcast #43 // class java/lang/Iterable\n 250: astore 11\n 252: iconst_0\n 253: istore 12\n 255: aload 11\n 257: astore 13\n 259: new #86 // class java/util/ArrayList\n 262: dup\n 263: invokespecial #87 // Method java/util/ArrayList.\"<init>\":()V\n 266: checkcast #105 // class java/util/Collection\n 269: astore 14\n 271: iconst_0\n 272: istore 15\n 274: aload 13\n 276: invokeinterface #54, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 281: astore 16\n 283: aload 16\n 285: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 290: ifeq 336\n 293: aload 16\n 295: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 300: astore 17\n 302: aload 17\n 304: checkcast #66 // class java/lang/String\n 307: astore 18\n 309: iconst_0\n 310: istore 19\n 312: aload 18\n 314: checkcast #68 // class java/lang/CharSequence\n 317: invokestatic #74 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 320: ifne 283\n 323: aload 14\n 325: aload 17\n 327: invokeinterface #118, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 332: pop\n 333: goto 283\n 336: aload 14\n 338: checkcast #89 // class java/util/List\n 341: nop\n 342: nop\n 343: aload 20\n 345: swap\n 346: invokeinterface #118, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 351: pop\n 352: goto 207\n 355: aload 5\n 357: checkcast #89 // class java/util/List\n 360: nop\n 361: checkcast #43 // class java/lang/Iterable\n 364: astore_2\n 365: nop\n 366: iconst_0\n 367: istore_3\n 368: aload_2\n 369: astore 4\n 371: new #86 // class java/util/ArrayList\n 374: dup\n 375: aload_2\n 376: bipush 10\n 378: invokestatic #170 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 381: invokespecial #103 // Method java/util/ArrayList.\"<init>\":(I)V\n 384: checkcast #105 // class java/util/Collection\n 387: astore 5\n 389: iconst_0\n 390: istore 6\n 392: aload 4\n 394: invokeinterface #54, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 399: astore 7\n 401: aload 7\n 403: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 408: ifeq 522\n 411: aload 7\n 413: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 418: astore 8\n 420: aload 5\n 422: aload 8\n 424: checkcast #89 // class java/util/List\n 427: astore 9\n 429: astore 20\n 431: iconst_0\n 432: istore 10\n 434: aload 9\n 436: checkcast #43 // class java/lang/Iterable\n 439: astore 11\n 441: iconst_0\n 442: istore 12\n 444: aload 11\n 446: invokeinterface #54, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 451: astore 13\n 453: aload 13\n 455: invokeinterface #60, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 460: ifeq 504\n 463: aload 13\n 465: invokeinterface #64, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 470: astore 14\n 472: iload 12\n 474: aload 14\n 476: checkcast #66 // class java/lang/String\n 479: astore 15\n 481: istore 16\n 483: iconst_0\n 484: istore 17\n 486: aload 15\n 488: invokestatic #125 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 491: nop\n 492: istore 18\n 494: iload 16\n 496: iload 18\n 498: iadd\n 499: istore 12\n 501: goto 453\n 504: iload 12\n 506: nop\n 507: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 510: aload 20\n 512: swap\n 513: invokeinterface #118, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 518: pop\n 519: goto 401\n 522: aload 5\n 524: checkcast #89 // class java/util/List\n 527: nop\n 528: checkcast #43 // class java/lang/Iterable\n 531: invokestatic #174 // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;\n 534: checkcast #43 // class java/lang/Iterable\n 537: iconst_3\n 538: invokestatic #178 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 541: checkcast #43 // class java/lang/Iterable\n 544: invokestatic #182 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 547: ireturn\n}\n", "javap_err": "" } ]
jkesanen__adventofcode__e4be057/2023/src/main/kotlin/Advent2306.kt
import java.io.File import kotlin.math.max class Advent2306 { private fun chargeToDistance(charge: Long, duration: Long): Long { val timeLeft = duration - charge return charge * max(0, timeLeft) } private fun getBestResults(filename: String): List<Pair<Long, Long>> { val times = mutableListOf<Long>() val distances = mutableListOf<Long>() File(this::class.java.getResource(filename)!!.file).forEachLine { line -> val parts = line.split(":") when (parts[0]) { "Time" -> times += Regex("""\d+""").findAll(parts[1]).map { it.value.toLong() }.toList() "Distance" -> distances += Regex("""\d+""").findAll(parts[1]).map { it.value.toLong() }.toList() } } assert(times.size == distances.size) val races = mutableListOf<Pair<Long, Long>>() for (i in 0..<times.size) { races += Pair(times[i], distances[i]) } return races } fun getWaysToWin1(filename: String): Int { val races = getBestResults(filename) var waysToWinMultiplied = 0 races.forEach { val duration = it.first val distance = it.second var wins = 0 for (charge in 0..<duration) { if (chargeToDistance(charge, duration) > distance) { wins++ } } waysToWinMultiplied = if (waysToWinMultiplied == 0) { wins } else { waysToWinMultiplied * wins } } return waysToWinMultiplied } private fun getResult(filename: String): Pair<Long, Long> { var duration = 0L var distance = 0L File(this::class.java.getResource(filename)!!.file).forEachLine { line -> val parts = line.split(":") when (parts[0]) { "Time" -> duration = parts[1].replace(" ", "").toLong() "Distance" -> distance = parts[1].replace(" ", "").toLong() } } return Pair(duration, distance) } fun getWaysToWin2(filename: String): Int { val result = getResult(filename) var waysToWin = 0 for (charge in 0..<result.first) { if (chargeToDistance(charge, result.first) > result.second) { ++waysToWin } } return waysToWin } }
[ { "class_path": "jkesanen__adventofcode__e4be057/Advent2306.class", "javap": "Compiled from \"Advent2306.kt\"\npublic final class Advent2306 {\n public Advent2306();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final long chargeToDistance(long, long);\n Code:\n 0: lload_3\n 1: lload_1\n 2: lsub\n 3: lstore 5\n 5: lload_1\n 6: lconst_0\n 7: lload 5\n 9: invokestatic #17 // Method java/lang/Math.max:(JJ)J\n 12: lmul\n 13: lreturn\n\n private final java.util.List<kotlin.Pair<java.lang.Long, java.lang.Long>> getBestResults(java.lang.String);\n Code:\n 0: new #26 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #27 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #29 // class java/util/List\n 10: astore_2\n 11: new #26 // class java/util/ArrayList\n 14: dup\n 15: invokespecial #27 // Method java/util/ArrayList.\"<init>\":()V\n 18: checkcast #29 // class java/util/List\n 21: astore_3\n 22: new #31 // class java/io/File\n 25: dup\n 26: aload_0\n 27: invokevirtual #35 // Method java/lang/Object.getClass:()Ljava/lang/Class;\n 30: aload_1\n 31: invokevirtual #41 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;\n 34: dup\n 35: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 38: invokevirtual #53 // Method java/net/URL.getFile:()Ljava/lang/String;\n 41: invokespecial #56 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 44: aconst_null\n 45: aload_2\n 46: aload_3\n 47: invokedynamic #76, 0 // InvokeDynamic #0:invoke:(Ljava/util/List;Ljava/util/List;)Lkotlin/jvm/functions/Function1;\n 52: iconst_1\n 53: aconst_null\n 54: invokestatic #82 // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V\n 57: aload_2\n 58: invokeinterface #86, 1 // InterfaceMethod java/util/List.size:()I\n 63: aload_3\n 64: invokeinterface #86, 1 // InterfaceMethod java/util/List.size:()I\n 69: if_icmpne 76\n 72: iconst_1\n 73: goto 77\n 76: iconst_0\n 77: istore 4\n 79: getstatic #92 // Field kotlin/_Assertions.ENABLED:Z\n 82: ifeq 104\n 85: iload 4\n 87: ifne 104\n 90: ldc #94 // String Assertion failed\n 92: astore 5\n 94: new #96 // class java/lang/AssertionError\n 97: dup\n 98: aload 5\n 100: invokespecial #98 // Method java/lang/AssertionError.\"<init>\":(Ljava/lang/Object;)V\n 103: athrow\n 104: new #26 // class java/util/ArrayList\n 107: dup\n 108: invokespecial #27 // Method java/util/ArrayList.\"<init>\":()V\n 111: checkcast #29 // class java/util/List\n 114: astore 4\n 116: iconst_0\n 117: istore 5\n 119: aload_2\n 120: invokeinterface #86, 1 // InterfaceMethod java/util/List.size:()I\n 125: istore 6\n 127: iload 5\n 129: iload 6\n 131: if_icmpge 174\n 134: aload 4\n 136: checkcast #100 // class java/util/Collection\n 139: new #102 // class kotlin/Pair\n 142: dup\n 143: aload_2\n 144: iload 5\n 146: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 151: aload_3\n 152: iload 5\n 154: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 159: invokespecial #109 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 162: invokeinterface #113, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 167: pop\n 168: iinc 5, 1\n 171: goto 127\n 174: aload 4\n 176: areturn\n\n public final int getWaysToWin1(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #127 // String filename\n 3: invokestatic #131 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokespecial #133 // Method getBestResults:(Ljava/lang/String;)Ljava/util/List;\n 11: astore_2\n 12: iconst_0\n 13: istore_3\n 14: aload_2\n 15: checkcast #135 // class java/lang/Iterable\n 18: astore 4\n 20: iconst_0\n 21: istore 5\n 23: aload 4\n 25: invokeinterface #139, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 30: astore 6\n 32: aload 6\n 34: invokeinterface #145, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 39: ifeq 146\n 42: aload 6\n 44: invokeinterface #149, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 49: astore 7\n 51: aload 7\n 53: checkcast #102 // class kotlin/Pair\n 56: astore 8\n 58: iconst_0\n 59: istore 9\n 61: aload 8\n 63: invokevirtual #152 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 66: checkcast #154 // class java/lang/Number\n 69: invokevirtual #158 // Method java/lang/Number.longValue:()J\n 72: lstore 10\n 74: aload 8\n 76: invokevirtual #161 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 79: checkcast #154 // class java/lang/Number\n 82: invokevirtual #158 // Method java/lang/Number.longValue:()J\n 85: lstore 12\n 87: iconst_0\n 88: istore 14\n 90: lconst_0\n 91: lstore 15\n 93: lload 15\n 95: lload 10\n 97: lcmp\n 98: ifge 127\n 101: aload_0\n 102: lload 15\n 104: lload 10\n 106: invokespecial #163 // Method chargeToDistance:(JJ)J\n 109: lload 12\n 111: lcmp\n 112: ifle 118\n 115: iinc 14, 1\n 118: lload 15\n 120: lconst_1\n 121: ladd\n 122: lstore 15\n 124: goto 93\n 127: iload_3\n 128: ifne 136\n 131: iload 14\n 133: goto 140\n 136: iload_3\n 137: iload 14\n 139: imul\n 140: istore_3\n 141: nop\n 142: nop\n 143: goto 32\n 146: nop\n 147: iload_3\n 148: ireturn\n\n private final kotlin.Pair<java.lang.Long, java.lang.Long> getResult(java.lang.String);\n Code:\n 0: new #179 // class kotlin/jvm/internal/Ref$LongRef\n 3: dup\n 4: invokespecial #180 // Method kotlin/jvm/internal/Ref$LongRef.\"<init>\":()V\n 7: astore_2\n 8: new #179 // class kotlin/jvm/internal/Ref$LongRef\n 11: dup\n 12: invokespecial #180 // Method kotlin/jvm/internal/Ref$LongRef.\"<init>\":()V\n 15: astore_3\n 16: new #31 // class java/io/File\n 19: dup\n 20: aload_0\n 21: invokevirtual #35 // Method java/lang/Object.getClass:()Ljava/lang/Class;\n 24: aload_1\n 25: invokevirtual #41 // Method java/lang/Class.getResource:(Ljava/lang/String;)Ljava/net/URL;\n 28: dup\n 29: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 32: invokevirtual #53 // Method java/net/URL.getFile:()Ljava/lang/String;\n 35: invokespecial #56 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 38: aconst_null\n 39: aload_2\n 40: aload_3\n 41: invokedynamic #188, 0 // InvokeDynamic #1:invoke:(Lkotlin/jvm/internal/Ref$LongRef;Lkotlin/jvm/internal/Ref$LongRef;)Lkotlin/jvm/functions/Function1;\n 46: iconst_1\n 47: aconst_null\n 48: invokestatic #82 // Method kotlin/io/FilesKt.forEachLine$default:(Ljava/io/File;Ljava/nio/charset/Charset;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)V\n 51: new #102 // class kotlin/Pair\n 54: dup\n 55: aload_2\n 56: getfield #191 // Field kotlin/jvm/internal/Ref$LongRef.element:J\n 59: invokestatic #197 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 62: aload_3\n 63: getfield #191 // Field kotlin/jvm/internal/Ref$LongRef.element:J\n 66: invokestatic #197 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 69: invokespecial #109 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 72: areturn\n\n public final int getWaysToWin2(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #127 // String filename\n 3: invokestatic #131 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokespecial #201 // Method getResult:(Ljava/lang/String;)Lkotlin/Pair;\n 11: astore_2\n 12: iconst_0\n 13: istore_3\n 14: lconst_0\n 15: lstore 4\n 17: aload_2\n 18: invokevirtual #152 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 21: checkcast #154 // class java/lang/Number\n 24: invokevirtual #158 // Method java/lang/Number.longValue:()J\n 27: lstore 6\n 29: lload 4\n 31: lload 6\n 33: lcmp\n 34: ifge 79\n 37: aload_0\n 38: lload 4\n 40: aload_2\n 41: invokevirtual #152 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 44: checkcast #154 // class java/lang/Number\n 47: invokevirtual #158 // Method java/lang/Number.longValue:()J\n 50: invokespecial #163 // Method chargeToDistance:(JJ)J\n 53: aload_2\n 54: invokevirtual #161 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 57: checkcast #154 // class java/lang/Number\n 60: invokevirtual #158 // Method java/lang/Number.longValue:()J\n 63: lcmp\n 64: ifle 70\n 67: iinc 3, 1\n 70: lload 4\n 72: lconst_1\n 73: ladd\n 74: lstore 4\n 76: goto 29\n 79: iload_3\n 80: ireturn\n\n private static final long getBestResults$lambda$2$lambda$0(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc #206 // String it\n 3: invokestatic #131 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #211, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 12: invokestatic #215 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 15: lreturn\n\n private static final long getBestResults$lambda$2$lambda$1(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc #206 // String it\n 3: invokestatic #131 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #211, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 12: invokestatic #215 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 15: lreturn\n\n private static final kotlin.Unit getBestResults$lambda$2(java.util.List, java.util.List, java.lang.String);\n Code:\n 0: aload_2\n 1: ldc #219 // String line\n 3: invokestatic #131 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: checkcast #221 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #123 // class java/lang/String\n 14: astore 4\n 16: aload 4\n 18: iconst_0\n 19: ldc #223 // String :\n 21: aastore\n 22: aload 4\n 24: iconst_0\n 25: iconst_0\n 26: bipush 6\n 28: aconst_null\n 29: invokestatic #229 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 32: astore_3\n 33: aload_3\n 34: iconst_0\n 35: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 40: checkcast #123 // class java/lang/String\n 43: astore 4\n 45: aload 4\n 47: ldc #231 // String Time\n 49: invokestatic #235 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 52: ifeq 105\n 55: aload_0\n 56: checkcast #100 // class java/util/Collection\n 59: new #237 // class kotlin/text/Regex\n 62: dup\n 63: ldc #239 // String \\\\d+\n 65: invokespecial #240 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 68: aload_3\n 69: iconst_1\n 70: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 75: checkcast #221 // class java/lang/CharSequence\n 78: iconst_0\n 79: iconst_2\n 80: aconst_null\n 81: invokestatic #244 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 84: invokedynamic #252, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;\n 89: invokestatic #258 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 92: invokestatic #262 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 95: checkcast #135 // class java/lang/Iterable\n 98: invokestatic #268 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 101: pop\n 102: goto 163\n 105: aload 4\n 107: ldc_w #270 // String Distance\n 110: invokestatic #235 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 113: ifeq 163\n 116: aload_1\n 117: checkcast #100 // class java/util/Collection\n 120: new #237 // class kotlin/text/Regex\n 123: dup\n 124: ldc #239 // String \\\\d+\n 126: invokespecial #240 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 129: aload_3\n 130: iconst_1\n 131: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 136: checkcast #221 // class java/lang/CharSequence\n 139: iconst_0\n 140: iconst_2\n 141: aconst_null\n 142: invokestatic #244 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 145: invokedynamic #274, 0 // InvokeDynamic #3:invoke:()Lkotlin/jvm/functions/Function1;\n 150: invokestatic #258 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 153: invokestatic #262 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 156: checkcast #135 // class java/lang/Iterable\n 159: invokestatic #268 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 162: pop\n 163: getstatic #280 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 166: areturn\n\n private static final kotlin.Unit getResult$lambda$4(kotlin.jvm.internal.Ref$LongRef, kotlin.jvm.internal.Ref$LongRef, java.lang.String);\n Code:\n 0: aload_2\n 1: ldc #219 // String line\n 3: invokestatic #131 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: checkcast #221 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #123 // class java/lang/String\n 14: astore 4\n 16: aload 4\n 18: iconst_0\n 19: ldc #223 // String :\n 21: aastore\n 22: aload 4\n 24: iconst_0\n 25: iconst_0\n 26: bipush 6\n 28: aconst_null\n 29: invokestatic #229 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 32: astore_3\n 33: aload_3\n 34: iconst_0\n 35: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 40: checkcast #123 // class java/lang/String\n 43: astore 4\n 45: aload 4\n 47: ldc #231 // String Time\n 49: invokestatic #235 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 52: ifeq 87\n 55: aload_0\n 56: aload_3\n 57: iconst_1\n 58: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 63: checkcast #123 // class java/lang/String\n 66: ldc_w #285 // String\n 69: ldc_w #287 // String\n 72: iconst_0\n 73: iconst_4\n 74: aconst_null\n 75: invokestatic #291 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 78: invokestatic #215 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 81: putfield #191 // Field kotlin/jvm/internal/Ref$LongRef.element:J\n 84: goto 127\n 87: aload 4\n 89: ldc_w #270 // String Distance\n 92: invokestatic #235 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 95: ifeq 127\n 98: aload_1\n 99: aload_3\n 100: iconst_1\n 101: invokeinterface #106, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 106: checkcast #123 // class java/lang/String\n 109: ldc_w #285 // String\n 112: ldc_w #287 // String\n 115: iconst_0\n 116: iconst_4\n 117: aconst_null\n 118: invokestatic #291 // Method kotlin/text/StringsKt.replace$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Ljava/lang/String;\n 121: invokestatic #215 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 124: putfield #191 // Field kotlin/jvm/internal/Ref$LongRef.element:J\n 127: getstatic #280 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 130: areturn\n}\n", "javap_err": "" } ]
fufaevlad__hyperskill_test_cinema_room_manager__b81d03b/cinema_manager.kt
var ifCount = 0 var elseCount = 0 const val cheapSeatCoast = 8 const val expSeatCoast = 10 fun main() { val (rows,seats) = greeting() val cinema = mutListCreator(rows) boardFiller(cinema,rows,seats) multipleChoise(cinema,rows,seats) } fun greeting(): Pair<Int,Int>{ println("Enter the number of rows:") val rows = readln().toInt() println("Enter the number of seats in each row:") val seats = readln().toInt() return Pair(rows,seats) } fun mutListCreator(rows:Int):MutableList<MutableList<String>>{ val outList = mutableListOf<MutableList<String>>() for(i in 0 until rows){ val a = mutableListOf<String>() outList.add(a) } return outList } fun boardFiller(list: MutableList<MutableList<String>>, rows:Int, columns:Int){ for(j in 0 until columns) { for (i in 0 until rows) { list[i].add("S ") } } } fun boardPrint(list:MutableList<MutableList<String>>,rows:Int,seats:Int){ println("Cinema:") print(" ") for(i in 1 until seats+1){ print("$i ") } println() for(i in 0 until rows) { println("${i+1} ${list[i].joinToString("")}") } } fun seatChoise(list:MutableList<MutableList<String>>,rows:Int,seats:Int){ println("Enter a row number:") val r = readln().toInt() println("Enter a seat number in that row:") val s = readln().toInt() if(r>rows||s>seats) { println("Wrong input!") seatChoise(list, rows, seats) } else if(list[r-1][s-1] == "B "){ println("That ticket has already been purchased!") seatChoise(list,rows,seats) } else { if (rows * seats <= 60) { println("Ticket price: $$expSeatCoast") ifCount++ } else if (rows * seats > 60) { if (r <= rows / 2) { println("Ticket price: $$expSeatCoast") ifCount++ } else if (r > rows / 2) { println("Ticket price: $$cheapSeatCoast") elseCount++ } } list[r - 1][s - 1] = "B " } } fun statistics(rows:Int,seats:Int){ val allTicets = ifCount + elseCount val allSeats = rows*seats val percentage:Double = allTicets.toDouble()/allSeats.toDouble()*100 val formatPercentage = "%.2f".format(percentage) val currentIncome = (ifCount * expSeatCoast) + (elseCount * cheapSeatCoast) var totalIncome = 0 if(rows*seats <= 60) { totalIncome = rows*seats*expSeatCoast } else if(rows*seats > 60){ totalIncome = rows/2*expSeatCoast*seats + (rows - rows/2)*cheapSeatCoast*seats } println("Number of purchased tickets: $allTicets") println("Percentage: $formatPercentage%") println("Current income: $$currentIncome") println("Total income: $$totalIncome") } fun multipleChoise(list:MutableList<MutableList<String>>,rows:Int,seats:Int){ println("1. Show the seats") println("2. Buy a ticket") println("3. Statistics") println("0. Exit") val num = readln().toInt() when(num){ 1 -> { boardPrint(list, rows, seats) multipleChoise(list, rows, seats) } 2 -> { seatChoise(list, rows, seats) boardPrint(list, rows, seats) multipleChoise(list, rows, seats) } 3-> { statistics(rows, seats) multipleChoise(list, rows, seats) } } }
[ { "class_path": "fufaevlad__hyperskill_test_cinema_room_manager__b81d03b/Cinema_managerKt.class", "javap": "Compiled from \"cinema_manager.kt\"\npublic final class Cinema_managerKt {\n private static int ifCount;\n\n private static int elseCount;\n\n public static final int cheapSeatCoast;\n\n public static final int expSeatCoast;\n\n public static final int getIfCount();\n Code:\n 0: getstatic #10 // Field ifCount:I\n 3: ireturn\n\n public static final void setIfCount(int);\n Code:\n 0: iload_0\n 1: putstatic #10 // Field ifCount:I\n 4: return\n\n public static final int getElseCount();\n Code:\n 0: getstatic #17 // Field elseCount:I\n 3: ireturn\n\n public static final void setElseCount(int);\n Code:\n 0: iload_0\n 1: putstatic #17 // Field elseCount:I\n 4: return\n\n public static final void main();\n Code:\n 0: invokestatic #24 // Method greeting:()Lkotlin/Pair;\n 3: astore_0\n 4: aload_0\n 5: invokevirtual #30 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 8: checkcast #32 // class java/lang/Number\n 11: invokevirtual #35 // Method java/lang/Number.intValue:()I\n 14: istore_1\n 15: aload_0\n 16: invokevirtual #38 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 19: checkcast #32 // class java/lang/Number\n 22: invokevirtual #35 // Method java/lang/Number.intValue:()I\n 25: istore_2\n 26: iload_1\n 27: invokestatic #42 // Method mutListCreator:(I)Ljava/util/List;\n 30: astore_3\n 31: aload_3\n 32: iload_1\n 33: iload_2\n 34: invokestatic #46 // Method boardFiller:(Ljava/util/List;II)V\n 37: aload_3\n 38: iload_1\n 39: iload_2\n 40: invokestatic #49 // Method multipleChoise:(Ljava/util/List;II)V\n 43: return\n\n public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> greeting();\n Code:\n 0: ldc #57 // String Enter the number of rows:\n 2: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 5: swap\n 6: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 9: invokestatic #75 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;\n 12: invokestatic #81 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 15: istore_0\n 16: ldc #83 // String Enter the number of seats in each row:\n 18: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 21: swap\n 22: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 25: invokestatic #75 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;\n 28: invokestatic #81 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 31: istore_1\n 32: new #26 // class kotlin/Pair\n 35: dup\n 36: iload_0\n 37: invokestatic #87 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 40: iload_1\n 41: invokestatic #87 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 44: invokespecial #91 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 47: areturn\n\n public static final java.util.List<java.util.List<java.lang.String>> mutListCreator(int);\n Code:\n 0: new #94 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #96 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #98 // class java/util/List\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: iload_2\n 14: iload_0\n 15: if_icmpge 43\n 18: new #94 // class java/util/ArrayList\n 21: dup\n 22: invokespecial #96 // Method java/util/ArrayList.\"<init>\":()V\n 25: checkcast #98 // class java/util/List\n 28: astore_3\n 29: aload_1\n 30: aload_3\n 31: invokeinterface #102, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 36: pop\n 37: iinc 2, 1\n 40: goto 13\n 43: aload_1\n 44: areturn\n\n public static final void boardFiller(java.util.List<java.util.List<java.lang.String>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #108 // String list\n 3: invokestatic #114 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore_3\n 8: iload_3\n 9: iload_2\n 10: if_icmpge 53\n 13: iconst_0\n 14: istore 4\n 16: iload 4\n 18: iload_1\n 19: if_icmpge 47\n 22: aload_0\n 23: iload 4\n 25: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 30: checkcast #98 // class java/util/List\n 33: ldc #120 // String S\n 35: invokeinterface #102, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 40: pop\n 41: iinc 4, 1\n 44: goto 16\n 47: iinc 3, 1\n 50: goto 8\n 53: return\n\n public static final void boardPrint(java.util.List<java.util.List<java.lang.String>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #108 // String list\n 3: invokestatic #114 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #125 // String Cinema:\n 8: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: swap\n 12: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 15: ldc #127 // String\n 17: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 20: swap\n 21: invokevirtual #130 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 24: iconst_1\n 25: istore_3\n 26: iload_2\n 27: iconst_1\n 28: iadd\n 29: istore 4\n 31: iload_3\n 32: iload 4\n 34: if_icmpge 69\n 37: new #132 // class java/lang/StringBuilder\n 40: dup\n 41: invokespecial #133 // Method java/lang/StringBuilder.\"<init>\":()V\n 44: iload_3\n 45: invokevirtual #137 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 48: bipush 32\n 50: invokevirtual #140 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 53: invokevirtual #143 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 56: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: swap\n 60: invokevirtual #130 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 63: iinc 3, 1\n 66: goto 31\n 69: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 72: invokevirtual #145 // Method java/io/PrintStream.println:()V\n 75: iconst_0\n 76: istore_3\n 77: iload_3\n 78: iload_1\n 79: if_icmpge 145\n 82: new #132 // class java/lang/StringBuilder\n 85: dup\n 86: invokespecial #133 // Method java/lang/StringBuilder.\"<init>\":()V\n 89: iload_3\n 90: iconst_1\n 91: iadd\n 92: invokevirtual #137 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 95: bipush 32\n 97: invokevirtual #140 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 100: aload_0\n 101: iload_3\n 102: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 107: checkcast #147 // class java/lang/Iterable\n 110: ldc #149 // String\n 112: checkcast #151 // class java/lang/CharSequence\n 115: aconst_null\n 116: aconst_null\n 117: iconst_0\n 118: aconst_null\n 119: aconst_null\n 120: bipush 62\n 122: aconst_null\n 123: invokestatic #157 // 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 126: invokevirtual #160 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 129: invokevirtual #143 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 132: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 135: swap\n 136: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 139: iinc 3, 1\n 142: goto 77\n 145: return\n\n public static final void seatChoise(java.util.List<java.util.List<java.lang.String>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #108 // String list\n 3: invokestatic #114 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #163 // String Enter a row number:\n 8: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: swap\n 12: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 15: invokestatic #75 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;\n 18: invokestatic #81 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 21: istore_3\n 22: ldc #165 // String Enter a seat number in that row:\n 24: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 27: swap\n 28: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 31: invokestatic #75 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;\n 34: invokestatic #81 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 37: istore 4\n 39: iload_3\n 40: iload_1\n 41: if_icmpgt 50\n 44: iload 4\n 46: iload_2\n 47: if_icmple 68\n 50: ldc #167 // String Wrong input!\n 52: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 55: swap\n 56: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 59: aload_0\n 60: iload_1\n 61: iload_2\n 62: invokestatic #169 // Method seatChoise:(Ljava/util/List;II)V\n 65: goto 238\n 68: aload_0\n 69: iload_3\n 70: iconst_1\n 71: isub\n 72: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 77: checkcast #98 // class java/util/List\n 80: iload 4\n 82: iconst_1\n 83: isub\n 84: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 89: ldc #171 // String B\n 91: invokestatic #175 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 94: ifeq 115\n 97: ldc #177 // String That ticket has already been purchased!\n 99: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 102: swap\n 103: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 106: aload_0\n 107: iload_1\n 108: iload_2\n 109: invokestatic #169 // Method seatChoise:(Ljava/util/List;II)V\n 112: goto 238\n 115: iload_1\n 116: iload_2\n 117: imul\n 118: bipush 60\n 120: if_icmpgt 147\n 123: ldc #179 // String Ticket price: $10\n 125: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 128: swap\n 129: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 132: getstatic #10 // Field ifCount:I\n 135: istore 5\n 137: iload 5\n 139: iconst_1\n 140: iadd\n 141: putstatic #10 // Field ifCount:I\n 144: goto 214\n 147: iload_1\n 148: iload_2\n 149: imul\n 150: bipush 60\n 152: if_icmple 214\n 155: iload_3\n 156: iload_1\n 157: iconst_2\n 158: idiv\n 159: if_icmpgt 186\n 162: ldc #179 // String Ticket price: $10\n 164: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 167: swap\n 168: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 171: getstatic #10 // Field ifCount:I\n 174: istore 5\n 176: iload 5\n 178: iconst_1\n 179: iadd\n 180: putstatic #10 // Field ifCount:I\n 183: goto 214\n 186: iload_3\n 187: iload_1\n 188: iconst_2\n 189: idiv\n 190: if_icmple 214\n 193: ldc #181 // String Ticket price: $8\n 195: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 198: swap\n 199: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 202: getstatic #17 // Field elseCount:I\n 205: istore 5\n 207: iload 5\n 209: iconst_1\n 210: iadd\n 211: putstatic #17 // Field elseCount:I\n 214: aload_0\n 215: iload_3\n 216: iconst_1\n 217: isub\n 218: invokeinterface #118, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 223: checkcast #98 // class java/util/List\n 226: iload 4\n 228: iconst_1\n 229: isub\n 230: ldc #171 // String B\n 232: invokeinterface #185, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 237: pop\n 238: return\n\n public static final void statistics(int, int);\n Code:\n 0: getstatic #10 // Field ifCount:I\n 3: getstatic #17 // Field elseCount:I\n 6: iadd\n 7: istore_2\n 8: iload_0\n 9: iload_1\n 10: imul\n 11: istore_3\n 12: iload_2\n 13: i2d\n 14: iload_3\n 15: i2d\n 16: ddiv\n 17: bipush 100\n 19: i2d\n 20: dmul\n 21: dstore 4\n 23: ldc #191 // String %.2f\n 25: astore 7\n 27: iconst_1\n 28: anewarray #4 // class java/lang/Object\n 31: astore 8\n 33: aload 8\n 35: iconst_0\n 36: dload 4\n 38: invokestatic #196 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 41: aastore\n 42: aload 8\n 44: astore 8\n 46: aload 7\n 48: aload 8\n 50: aload 8\n 52: arraylength\n 53: invokestatic #202 // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;\n 56: invokestatic #208 // Method java/lang/String.format:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;\n 59: dup\n 60: ldc #210 // String format(...)\n 62: invokestatic #213 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 65: astore 6\n 67: getstatic #10 // Field ifCount:I\n 70: bipush 10\n 72: imul\n 73: getstatic #17 // Field elseCount:I\n 76: bipush 8\n 78: imul\n 79: iadd\n 80: istore 7\n 82: iconst_0\n 83: istore 8\n 85: iload_0\n 86: iload_1\n 87: imul\n 88: bipush 60\n 90: if_icmpgt 104\n 93: iload_0\n 94: iload_1\n 95: imul\n 96: bipush 10\n 98: imul\n 99: istore 8\n 101: goto 133\n 104: iload_0\n 105: iload_1\n 106: imul\n 107: bipush 60\n 109: if_icmple 133\n 112: iload_0\n 113: iconst_2\n 114: idiv\n 115: bipush 10\n 117: imul\n 118: iload_1\n 119: imul\n 120: iload_0\n 121: iload_0\n 122: iconst_2\n 123: idiv\n 124: isub\n 125: bipush 8\n 127: imul\n 128: iload_1\n 129: imul\n 130: iadd\n 131: istore 8\n 133: new #132 // class java/lang/StringBuilder\n 136: dup\n 137: invokespecial #133 // Method java/lang/StringBuilder.\"<init>\":()V\n 140: ldc #215 // String Number of purchased tickets:\n 142: invokevirtual #160 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 145: iload_2\n 146: invokevirtual #137 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 149: invokevirtual #143 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 152: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 155: swap\n 156: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 159: new #132 // class java/lang/StringBuilder\n 162: dup\n 163: invokespecial #133 // Method java/lang/StringBuilder.\"<init>\":()V\n 166: ldc #217 // String Percentage:\n 168: invokevirtual #160 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 171: aload 6\n 173: invokevirtual #160 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 176: bipush 37\n 178: invokevirtual #140 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 181: invokevirtual #143 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 184: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 187: swap\n 188: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 191: new #132 // class java/lang/StringBuilder\n 194: dup\n 195: invokespecial #133 // Method java/lang/StringBuilder.\"<init>\":()V\n 198: ldc #219 // String Current income: $\n 200: invokevirtual #160 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 203: iload 7\n 205: invokevirtual #137 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 208: invokevirtual #143 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 211: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 214: swap\n 215: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 218: new #132 // class java/lang/StringBuilder\n 221: dup\n 222: invokespecial #133 // Method java/lang/StringBuilder.\"<init>\":()V\n 225: ldc #221 // String Total income: $\n 227: invokevirtual #160 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 230: iload 8\n 232: invokevirtual #137 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 235: invokevirtual #143 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 238: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 241: swap\n 242: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 245: return\n\n public static final void multipleChoise(java.util.List<java.util.List<java.lang.String>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #108 // String list\n 3: invokestatic #114 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #231 // String 1. Show the seats\n 8: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: swap\n 12: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 15: ldc #233 // String 2. Buy a ticket\n 17: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 20: swap\n 21: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 24: ldc #235 // String 3. Statistics\n 26: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 29: swap\n 30: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 33: ldc #237 // String 0. Exit\n 35: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 38: swap\n 39: invokevirtual #69 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 42: invokestatic #75 // Method kotlin/io/ConsoleKt.readln:()Ljava/lang/String;\n 45: invokestatic #81 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 48: istore_3\n 49: iload_3\n 50: tableswitch { // 1 to 3\n 1: 76\n 2: 91\n 3: 112\n default: 123\n }\n 76: aload_0\n 77: iload_1\n 78: iload_2\n 79: invokestatic #239 // Method boardPrint:(Ljava/util/List;II)V\n 82: aload_0\n 83: iload_1\n 84: iload_2\n 85: invokestatic #49 // Method multipleChoise:(Ljava/util/List;II)V\n 88: goto 123\n 91: aload_0\n 92: iload_1\n 93: iload_2\n 94: invokestatic #169 // Method seatChoise:(Ljava/util/List;II)V\n 97: aload_0\n 98: iload_1\n 99: iload_2\n 100: invokestatic #239 // Method boardPrint:(Ljava/util/List;II)V\n 103: aload_0\n 104: iload_1\n 105: iload_2\n 106: invokestatic #49 // Method multipleChoise:(Ljava/util/List;II)V\n 109: goto 123\n 112: iload_1\n 113: iload_2\n 114: invokestatic #241 // Method statistics:(II)V\n 117: aload_0\n 118: iload_1\n 119: iload_2\n 120: invokestatic #49 // Method multipleChoise:(Ljava/util/List;II)V\n 123: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #245 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: return\n}\n", "javap_err": "" } ]
ersushantsood__kotlinSamples__94aab4e/src/main/kotlin/LambdasCollections.kt
fun main() { val li = listOf<Int>(1,2,3,4) println(li.filter({i:Int -> i%2 ==0})) //Map operation println (li.map { it * 2 }) val lstNumbers = listOf<Number>(Number("one",1),Number("two",2),Number("three",3)) println("Numbers:"+lstNumbers.map { it.name }) //Find and groupBy val list = listOf(1,2,3,4) //The function find returns the first element of the collection that satisfies the condition set in the lambda. // It is the same function as firstOrNull, which is a longer but also clearer name println("Finding the first match as per the lambda condition: "+list.find { it % 2 ==0 }) println("Finding the last match as per the lambda condition: "+list.findLast { it % 2 == 0 }) val animal_collection = listOf(Animal("Lion","carnivore"),Animal("Tiger","carnivore"), Animal("Elephant","herbivore"),Animal("Rabbit","herbivore")) val animal_groups = animal_collection.groupBy { it.type } println("Group of Herbivores and Carnivores:"+animal_groups) //Fold Operation //In the previous example, the first time we start with 0 and added all elements until the end. // In the second case, with start with 15 and subtracted alle elements. // Basically, the provided value is used as argument for start in the first cycle, then start becomes the value returned by the previous cycle. var items_list = listOf<Int>(5,10,25) println("Folding the collection:"+items_list.fold(0, {start,element -> element+start})) println("Folding the collection by Subtracting the items: "+items_list.fold(25,{start,element -> start-element})) //So, in the first case the function behaves like this: // //start = 0, element = 5 -> result 5 //start = 5, element = 10 -> result 15 //start = 15, element = 25 -> result 40 //flatten operation : The function flatten creates one collection from a supplied list of collections. var lists = listOf<List<Int>>(listOf(1,2), listOf(4,5)) var flattened_list = lists.flatten() println("Flattened List: "+flattened_list) //Flatmap operation : flatMap use the provided lambda to map each element of the initial collection to a new collection, // then it merges all the collections into one collection. val lists_numbers = listOf<Number>(Number("one",1),Number("two",2),Number("three",3)) println(lists_numbers.flatMap { listOf(it.value) }) //In this example, we create one list with all the values of the property value of each element of type Number. These are the steps to arrive to this result: // //each element is mapped to a new collection, with these three new lists //listOf(1) //listOf(2) //listOf(3) //then the these three lists are merged in one list, listOf(3,3,5) //Notice that the initial collection does not affect the kind of collection that is returned. That is to say, even if you start with a set you end up with a generic collection } data class Number(val name: String, val value : Int) data class Animal(val name: String, val type: String)
[ { "class_path": "ersushantsood__kotlinSamples__94aab4e/LambdasCollectionsKt.class", "javap": "Compiled from \"LambdasCollections.kt\"\npublic final class LambdasCollectionsKt {\n public static final void main();\n Code:\n 0: iconst_4\n 1: anewarray #8 // class java/lang/Integer\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: iconst_1\n 8: invokestatic #12 // 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 #12 // 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 #12 // 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 #12 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 32: aastore\n 33: aload_1\n 34: invokestatic #18 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 37: astore_0\n 38: aload_0\n 39: checkcast #20 // class java/lang/Iterable\n 42: astore_1\n 43: iconst_0\n 44: istore_2\n 45: aload_1\n 46: astore_3\n 47: new #22 // class java/util/ArrayList\n 50: dup\n 51: invokespecial #25 // Method java/util/ArrayList.\"<init>\":()V\n 54: checkcast #27 // class java/util/Collection\n 57: astore 4\n 59: iconst_0\n 60: istore 5\n 62: aload_3\n 63: invokeinterface #31, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 68: astore 6\n 70: aload 6\n 72: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 77: ifeq 130\n 80: aload 6\n 82: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 87: astore 7\n 89: aload 7\n 91: checkcast #43 // class java/lang/Number\n 94: invokevirtual #47 // Method java/lang/Number.intValue:()I\n 97: istore 8\n 99: iconst_0\n 100: istore 9\n 102: iload 8\n 104: iconst_2\n 105: irem\n 106: ifne 113\n 109: iconst_1\n 110: goto 114\n 113: iconst_0\n 114: ifeq 70\n 117: aload 4\n 119: aload 7\n 121: invokeinterface #51, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 126: pop\n 127: goto 70\n 130: aload 4\n 132: checkcast #53 // class java/util/List\n 135: nop\n 136: astore_1\n 137: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 140: aload_1\n 141: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 144: aload_0\n 145: checkcast #20 // class java/lang/Iterable\n 148: astore_1\n 149: iconst_0\n 150: istore_2\n 151: aload_1\n 152: astore_3\n 153: new #22 // class java/util/ArrayList\n 156: dup\n 157: aload_1\n 158: bipush 10\n 160: invokestatic #69 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 163: invokespecial #72 // Method java/util/ArrayList.\"<init>\":(I)V\n 166: checkcast #27 // class java/util/Collection\n 169: astore 4\n 171: iconst_0\n 172: istore 5\n 174: aload_3\n 175: invokeinterface #31, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 180: astore 6\n 182: aload 6\n 184: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 189: ifeq 237\n 192: aload 6\n 194: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 199: astore 7\n 201: aload 4\n 203: aload 7\n 205: checkcast #43 // class java/lang/Number\n 208: invokevirtual #47 // Method java/lang/Number.intValue:()I\n 211: istore 8\n 213: astore 19\n 215: iconst_0\n 216: istore 9\n 218: iload 8\n 220: iconst_2\n 221: imul\n 222: invokestatic #12 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 225: aload 19\n 227: swap\n 228: invokeinterface #51, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 233: pop\n 234: goto 182\n 237: aload 4\n 239: checkcast #53 // class java/util/List\n 242: nop\n 243: astore_1\n 244: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 247: aload_1\n 248: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 251: iconst_3\n 252: anewarray #74 // class Number\n 255: astore_2\n 256: aload_2\n 257: iconst_0\n 258: new #74 // class Number\n 261: dup\n 262: ldc #76 // String one\n 264: iconst_1\n 265: invokespecial #79 // Method Number.\"<init>\":(Ljava/lang/String;I)V\n 268: aastore\n 269: aload_2\n 270: iconst_1\n 271: new #74 // class Number\n 274: dup\n 275: ldc #81 // String two\n 277: iconst_2\n 278: invokespecial #79 // Method Number.\"<init>\":(Ljava/lang/String;I)V\n 281: aastore\n 282: aload_2\n 283: iconst_2\n 284: new #74 // class Number\n 287: dup\n 288: ldc #83 // String three\n 290: iconst_3\n 291: invokespecial #79 // Method Number.\"<init>\":(Ljava/lang/String;I)V\n 294: aastore\n 295: aload_2\n 296: invokestatic #18 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 299: astore_1\n 300: new #85 // class java/lang/StringBuilder\n 303: dup\n 304: invokespecial #86 // Method java/lang/StringBuilder.\"<init>\":()V\n 307: ldc #88 // String Numbers:\n 309: invokevirtual #92 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 312: aload_1\n 313: checkcast #20 // class java/lang/Iterable\n 316: astore_2\n 317: astore 19\n 319: iconst_0\n 320: istore_3\n 321: aload_2\n 322: astore 4\n 324: new #22 // class java/util/ArrayList\n 327: dup\n 328: aload_2\n 329: bipush 10\n 331: invokestatic #69 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 334: invokespecial #72 // Method java/util/ArrayList.\"<init>\":(I)V\n 337: checkcast #27 // class java/util/Collection\n 340: astore 5\n 342: iconst_0\n 343: istore 6\n 345: aload 4\n 347: invokeinterface #31, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 352: astore 7\n 354: aload 7\n 356: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 361: ifeq 404\n 364: aload 7\n 366: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 371: astore 8\n 373: aload 5\n 375: aload 8\n 377: checkcast #74 // class Number\n 380: astore 9\n 382: astore 20\n 384: iconst_0\n 385: istore 10\n 387: aload 9\n 389: invokevirtual #96 // Method Number.getName:()Ljava/lang/String;\n 392: aload 20\n 394: swap\n 395: invokeinterface #51, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 400: pop\n 401: goto 354\n 404: aload 5\n 406: checkcast #53 // class java/util/List\n 409: nop\n 410: aload 19\n 412: swap\n 413: invokevirtual #99 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 416: invokevirtual #102 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 419: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 422: swap\n 423: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 426: iconst_4\n 427: anewarray #8 // class java/lang/Integer\n 430: astore_3\n 431: aload_3\n 432: iconst_0\n 433: iconst_1\n 434: invokestatic #12 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 437: aastore\n 438: aload_3\n 439: iconst_1\n 440: iconst_2\n 441: invokestatic #12 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 444: aastore\n 445: aload_3\n 446: iconst_2\n 447: iconst_3\n 448: invokestatic #12 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 451: aastore\n 452: aload_3\n 453: iconst_3\n 454: iconst_4\n 455: invokestatic #12 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 458: aastore\n 459: aload_3\n 460: invokestatic #18 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 463: astore_2\n 464: new #85 // class java/lang/StringBuilder\n 467: dup\n 468: invokespecial #86 // Method java/lang/StringBuilder.\"<init>\":()V\n 471: ldc #104 // String Finding the first match as per the lambda condition:\n 473: invokevirtual #92 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 476: aload_2\n 477: checkcast #20 // class java/lang/Iterable\n 480: astore_3\n 481: astore 19\n 483: aload_3\n 484: astore 4\n 486: aload 4\n 488: invokeinterface #31, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 493: astore 5\n 495: aload 5\n 497: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 502: ifeq 547\n 505: aload 5\n 507: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 512: astore 6\n 514: aload 6\n 516: checkcast #43 // class java/lang/Number\n 519: invokevirtual #47 // Method java/lang/Number.intValue:()I\n 522: istore 7\n 524: iconst_0\n 525: istore 8\n 527: iload 7\n 529: iconst_2\n 530: irem\n 531: ifne 538\n 534: iconst_1\n 535: goto 539\n 538: iconst_0\n 539: ifeq 495\n 542: aload 6\n 544: goto 548\n 547: aconst_null\n 548: aload 19\n 550: swap\n 551: invokevirtual #99 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 554: invokevirtual #102 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 557: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 560: swap\n 561: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 564: new #85 // class java/lang/StringBuilder\n 567: dup\n 568: invokespecial #86 // Method java/lang/StringBuilder.\"<init>\":()V\n 571: ldc #106 // String Finding the last match as per the lambda condition:\n 573: invokevirtual #92 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 576: aload_2\n 577: astore_3\n 578: astore 19\n 580: aload_3\n 581: astore 4\n 583: aload 4\n 585: aload 4\n 587: invokeinterface #109, 1 // InterfaceMethod java/util/List.size:()I\n 592: invokeinterface #113, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 597: astore 5\n 599: aload 5\n 601: invokeinterface #118, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 606: ifeq 651\n 609: aload 5\n 611: invokeinterface #121, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 616: astore 6\n 618: aload 6\n 620: checkcast #43 // class java/lang/Number\n 623: invokevirtual #47 // Method java/lang/Number.intValue:()I\n 626: istore 7\n 628: iconst_0\n 629: istore 8\n 631: iload 7\n 633: iconst_2\n 634: irem\n 635: ifne 642\n 638: iconst_1\n 639: goto 643\n 642: iconst_0\n 643: ifeq 599\n 646: aload 6\n 648: goto 652\n 651: aconst_null\n 652: aload 19\n 654: swap\n 655: invokevirtual #99 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 658: invokevirtual #102 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 661: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 664: swap\n 665: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 668: iconst_4\n 669: anewarray #123 // class Animal\n 672: astore 4\n 674: aload 4\n 676: iconst_0\n 677: new #123 // class Animal\n 680: dup\n 681: ldc #125 // String Lion\n 683: ldc #127 // String carnivore\n 685: invokespecial #130 // Method Animal.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 688: aastore\n 689: aload 4\n 691: iconst_1\n 692: new #123 // class Animal\n 695: dup\n 696: ldc #132 // String Tiger\n 698: ldc #127 // String carnivore\n 700: invokespecial #130 // Method Animal.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 703: aastore\n 704: aload 4\n 706: iconst_2\n 707: new #123 // class Animal\n 710: dup\n 711: ldc #134 // String Elephant\n 713: ldc #136 // String herbivore\n 715: invokespecial #130 // Method Animal.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 718: aastore\n 719: aload 4\n 721: iconst_3\n 722: new #123 // class Animal\n 725: dup\n 726: ldc #138 // String Rabbit\n 728: ldc #136 // String herbivore\n 730: invokespecial #130 // Method Animal.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 733: aastore\n 734: aload 4\n 736: invokestatic #18 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 739: astore_3\n 740: aload_3\n 741: checkcast #20 // class java/lang/Iterable\n 744: astore 5\n 746: iconst_0\n 747: istore 6\n 749: aload 5\n 751: astore 7\n 753: new #140 // class java/util/LinkedHashMap\n 756: dup\n 757: invokespecial #141 // Method java/util/LinkedHashMap.\"<init>\":()V\n 760: checkcast #143 // class java/util/Map\n 763: astore 8\n 765: iconst_0\n 766: istore 9\n 768: aload 7\n 770: invokeinterface #31, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 775: astore 10\n 777: aload 10\n 779: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 784: ifeq 889\n 787: aload 10\n 789: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 794: astore 11\n 796: aload 11\n 798: checkcast #123 // class Animal\n 801: astore 12\n 803: iconst_0\n 804: istore 13\n 806: aload 12\n 808: invokevirtual #146 // Method Animal.getType:()Ljava/lang/String;\n 811: astore 14\n 813: aload 8\n 815: astore 15\n 817: iconst_0\n 818: istore 16\n 820: aload 15\n 822: aload 14\n 824: invokeinterface #150, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 829: astore 17\n 831: aload 17\n 833: ifnonnull 868\n 836: iconst_0\n 837: istore 18\n 839: new #22 // class java/util/ArrayList\n 842: dup\n 843: invokespecial #25 // Method java/util/ArrayList.\"<init>\":()V\n 846: checkcast #53 // class java/util/List\n 849: astore 18\n 851: aload 15\n 853: aload 14\n 855: aload 18\n 857: invokeinterface #154, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 862: pop\n 863: aload 18\n 865: goto 870\n 868: aload 17\n 870: nop\n 871: checkcast #53 // class java/util/List\n 874: astore 12\n 876: aload 12\n 878: aload 11\n 880: invokeinterface #155, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 885: pop\n 886: goto 777\n 889: aload 8\n 891: nop\n 892: astore 4\n 894: new #85 // class java/lang/StringBuilder\n 897: dup\n 898: invokespecial #86 // Method java/lang/StringBuilder.\"<init>\":()V\n 901: ldc #157 // String Group of Herbivores and Carnivores:\n 903: invokevirtual #92 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 906: aload 4\n 908: invokevirtual #99 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 911: invokevirtual #102 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 914: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 917: swap\n 918: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 921: iconst_3\n 922: anewarray #8 // class java/lang/Integer\n 925: astore 6\n 927: aload 6\n 929: iconst_0\n 930: iconst_5\n 931: invokestatic #12 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 934: aastore\n 935: aload 6\n 937: iconst_1\n 938: bipush 10\n 940: invokestatic #12 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 943: aastore\n 944: aload 6\n 946: iconst_2\n 947: bipush 25\n 949: invokestatic #12 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 952: aastore\n 953: aload 6\n 955: invokestatic #18 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 958: astore 5\n 960: new #85 // class java/lang/StringBuilder\n 963: dup\n 964: invokespecial #86 // Method java/lang/StringBuilder.\"<init>\":()V\n 967: ldc #159 // String Folding the collection:\n 969: invokevirtual #92 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 972: aload 5\n 974: checkcast #20 // class java/lang/Iterable\n 977: astore 6\n 979: iconst_0\n 980: istore 7\n 982: astore 19\n 984: iconst_0\n 985: istore 8\n 987: iload 7\n 989: istore 9\n 991: aload 6\n 993: invokeinterface #31, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 998: astore 10\n 1000: aload 10\n 1002: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1007: ifeq 1046\n 1010: aload 10\n 1012: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1017: astore 11\n 1019: iload 9\n 1021: aload 11\n 1023: checkcast #43 // class java/lang/Number\n 1026: invokevirtual #47 // Method java/lang/Number.intValue:()I\n 1029: istore 12\n 1031: istore 13\n 1033: iconst_0\n 1034: istore 14\n 1036: iload 12\n 1038: iload 13\n 1040: iadd\n 1041: istore 9\n 1043: goto 1000\n 1046: iload 9\n 1048: istore 20\n 1050: aload 19\n 1052: iload 20\n 1054: invokevirtual #162 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 1057: invokevirtual #102 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 1060: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1063: swap\n 1064: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 1067: new #85 // class java/lang/StringBuilder\n 1070: dup\n 1071: invokespecial #86 // Method java/lang/StringBuilder.\"<init>\":()V\n 1074: ldc #164 // String Folding the collection by Subtracting the items:\n 1076: invokevirtual #92 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 1079: aload 5\n 1081: checkcast #20 // class java/lang/Iterable\n 1084: astore 6\n 1086: bipush 25\n 1088: istore 7\n 1090: astore 19\n 1092: iconst_0\n 1093: istore 8\n 1095: iload 7\n 1097: istore 9\n 1099: aload 6\n 1101: invokeinterface #31, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1106: astore 10\n 1108: aload 10\n 1110: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1115: ifeq 1154\n 1118: aload 10\n 1120: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1125: astore 11\n 1127: iload 9\n 1129: aload 11\n 1131: checkcast #43 // class java/lang/Number\n 1134: invokevirtual #47 // Method java/lang/Number.intValue:()I\n 1137: istore 12\n 1139: istore 13\n 1141: iconst_0\n 1142: istore 14\n 1144: iload 13\n 1146: iload 12\n 1148: isub\n 1149: istore 9\n 1151: goto 1108\n 1154: iload 9\n 1156: istore 20\n 1158: aload 19\n 1160: iload 20\n 1162: invokevirtual #162 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 1165: invokevirtual #102 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 1168: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1171: swap\n 1172: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 1175: iconst_2\n 1176: anewarray #53 // class java/util/List\n 1179: astore 7\n 1181: aload 7\n 1183: iconst_0\n 1184: iconst_2\n 1185: anewarray #8 // class java/lang/Integer\n 1188: astore 8\n 1190: aload 8\n 1192: iconst_0\n 1193: iconst_1\n 1194: invokestatic #12 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1197: aastore\n 1198: aload 8\n 1200: iconst_1\n 1201: iconst_2\n 1202: invokestatic #12 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1205: aastore\n 1206: aload 8\n 1208: invokestatic #18 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 1211: aastore\n 1212: aload 7\n 1214: iconst_1\n 1215: iconst_2\n 1216: anewarray #8 // class java/lang/Integer\n 1219: astore 8\n 1221: aload 8\n 1223: iconst_0\n 1224: iconst_4\n 1225: invokestatic #12 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1228: aastore\n 1229: aload 8\n 1231: iconst_1\n 1232: iconst_5\n 1233: invokestatic #12 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1236: aastore\n 1237: aload 8\n 1239: invokestatic #18 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 1242: aastore\n 1243: aload 7\n 1245: invokestatic #18 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 1248: astore 6\n 1250: aload 6\n 1252: checkcast #20 // class java/lang/Iterable\n 1255: invokestatic #168 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 1258: astore 7\n 1260: new #85 // class java/lang/StringBuilder\n 1263: dup\n 1264: invokespecial #86 // Method java/lang/StringBuilder.\"<init>\":()V\n 1267: ldc #170 // String Flattened List:\n 1269: invokevirtual #92 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 1272: aload 7\n 1274: invokevirtual #99 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 1277: invokevirtual #102 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 1280: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1283: swap\n 1284: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 1287: iconst_3\n 1288: anewarray #74 // class Number\n 1291: astore 9\n 1293: aload 9\n 1295: iconst_0\n 1296: new #74 // class Number\n 1299: dup\n 1300: ldc #76 // String one\n 1302: iconst_1\n 1303: invokespecial #79 // Method Number.\"<init>\":(Ljava/lang/String;I)V\n 1306: aastore\n 1307: aload 9\n 1309: iconst_1\n 1310: new #74 // class Number\n 1313: dup\n 1314: ldc #81 // String two\n 1316: iconst_2\n 1317: invokespecial #79 // Method Number.\"<init>\":(Ljava/lang/String;I)V\n 1320: aastore\n 1321: aload 9\n 1323: iconst_2\n 1324: new #74 // class Number\n 1327: dup\n 1328: ldc #83 // String three\n 1330: iconst_3\n 1331: invokespecial #79 // Method Number.\"<init>\":(Ljava/lang/String;I)V\n 1334: aastore\n 1335: aload 9\n 1337: invokestatic #18 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 1340: astore 8\n 1342: aload 8\n 1344: checkcast #20 // class java/lang/Iterable\n 1347: astore 9\n 1349: iconst_0\n 1350: istore 10\n 1352: aload 9\n 1354: astore 11\n 1356: new #22 // class java/util/ArrayList\n 1359: dup\n 1360: invokespecial #25 // Method java/util/ArrayList.\"<init>\":()V\n 1363: checkcast #27 // class java/util/Collection\n 1366: astore 12\n 1368: iconst_0\n 1369: istore 13\n 1371: aload 11\n 1373: invokeinterface #31, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1378: astore 14\n 1380: aload 14\n 1382: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1387: ifeq 1436\n 1390: aload 14\n 1392: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1397: astore 15\n 1399: aload 15\n 1401: checkcast #74 // class Number\n 1404: astore 16\n 1406: iconst_0\n 1407: istore 17\n 1409: aload 16\n 1411: invokevirtual #173 // Method Number.getValue:()I\n 1414: invokestatic #12 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1417: invokestatic #176 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 1420: checkcast #20 // class java/lang/Iterable\n 1423: astore 16\n 1425: aload 12\n 1427: aload 16\n 1429: invokestatic #180 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 1432: pop\n 1433: goto 1380\n 1436: aload 12\n 1438: checkcast #53 // class java/util/List\n 1441: nop\n 1442: astore 9\n 1444: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 1447: aload 9\n 1449: invokevirtual #65 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 1452: return\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": "" } ]
Lank891__Advent-of-Code-2021__4164b70/Day 05 - Kotlin/source.kt
import java.io.File import kotlin.math.sign const val boardSize: Int = 1000; typealias XY = Pair<Int, Int>; typealias VentPath = Pair<XY, XY>; typealias Board = Array<Array<Int>> fun ventPathToString(path: VentPath): String { return "Path (${path.first.first}, ${path.first.second}) -> (${path.second.first}, ${path.second.second})" } fun printBoard(board: Board) { for(y in 0 until boardSize){ for(x in 0 until boardSize) { print("${if (board[x][y] == 0) '.' else board[x][y]} "); } println(); } } fun isVentPathOblique(path: VentPath): Boolean { return path.first.first != path.second.first && path.first.second != path.second.second; } fun commaSeparatedNumbersToXY(numbers: String): XY { val split: List<Int> = numbers.split(",").map{ str: String -> str.toInt()} return Pair(split[0], split[1]); } fun inputLineToVentPath(line: String): VentPath { val splits: List<String> = line.split("->").map{ str: String -> str.trim()}; return Pair(commaSeparatedNumbersToXY(splits[0]), commaSeparatedNumbersToXY(splits[1])); } fun addNotObliqueVent(board: Board, path: VentPath) { fun getXRange(path: VentPath): IntProgression { return if(path.first.first < path.second.first){ (path.second.first downTo path.first.first) } else { (path.first.first downTo path.second.first) } } fun getYRange(path: VentPath): IntProgression { return if(path.first.second < path.second.second){ (path.second.second downTo path.first.second) } else { (path.first.second downTo path.second.second) } } for(x in getXRange(path)) { for(y in getYRange(path)) { board[x][y]++; } } } fun addObliqueVent(board: Board, path: VentPath) { val (left: XY, right: XY) = if (path.first.first < path.second.first) Pair(path.first, path.second) else Pair(path.second, path.first); var yVal: Int = left.second; val yDiff: Int = -sign((left.second - right.second).toDouble()).toInt(); for(x in left.first..right.first) { board[x][yVal] += 1; yVal += yDiff; } } fun getOverlappedCells(board: Board): Int { var sum: Int = 0; for(column in board) { for(cell in column) { if(cell > 1) { sum++; } } } return sum; } fun main(args: Array<String>) { val vents: List<VentPath> = File("./input.txt").readLines().map{ str: String -> inputLineToVentPath(str)}; val (obliqueVents: List<VentPath>, notObliqueVents: List<VentPath>) = vents.partition { vent: VentPath -> isVentPathOblique(vent) }; /* println("--- OBLIQUE VENTS ---") obliqueVents.forEach { vent: VentPath -> println(ventPathToString(vent))}; println("--- NOT OBLIQUE VENTS ---") notObliqueVents.forEach { vent: VentPath -> println(ventPathToString(vent))}; */ val board: Board = Array(boardSize) { _ -> Array(boardSize) { _ -> 0 } }; // Part 1 notObliqueVents.forEach { vent: VentPath -> addNotObliqueVent(board, vent) }; println("Part 1 overlapped cells: ${getOverlappedCells(board)}"); //printBoard(board); // Part 2 obliqueVents.forEach { vent: VentPath -> addObliqueVent(board, vent) }; println("Part 2 overlapped cells: ${getOverlappedCells(board)}"); //printBoard(board); }
[ { "class_path": "Lank891__Advent-of-Code-2021__4164b70/SourceKt.class", "javap": "Compiled from \"source.kt\"\npublic final class SourceKt {\n public static final int boardSize;\n\n public static final java.lang.String ventPathToString(kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: ldc #10 // String path\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #18 // class java/lang/StringBuilder\n 9: dup\n 10: invokespecial #22 // Method java/lang/StringBuilder.\"<init>\":()V\n 13: ldc #24 // String Path (\n 15: invokevirtual #28 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 18: aload_0\n 19: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 22: checkcast #30 // class kotlin/Pair\n 25: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 28: checkcast #36 // class java/lang/Number\n 31: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 34: invokevirtual #43 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 37: ldc #45 // String ,\n 39: invokevirtual #28 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 42: aload_0\n 43: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 46: checkcast #30 // class kotlin/Pair\n 49: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 52: checkcast #36 // class java/lang/Number\n 55: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 58: invokevirtual #43 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 61: ldc #50 // String ) -> (\n 63: invokevirtual #28 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 66: aload_0\n 67: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 70: checkcast #30 // class kotlin/Pair\n 73: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 76: checkcast #36 // class java/lang/Number\n 79: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 82: invokevirtual #43 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 85: ldc #45 // String ,\n 87: invokevirtual #28 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 90: aload_0\n 91: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 94: checkcast #30 // class kotlin/Pair\n 97: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 100: checkcast #36 // class java/lang/Number\n 103: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 106: invokevirtual #43 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 109: bipush 41\n 111: invokevirtual #53 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 114: invokevirtual #57 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 117: areturn\n\n public static final void printBoard(java.lang.Integer[][]);\n Code:\n 0: aload_0\n 1: ldc #62 // String board\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: iload_1\n 9: sipush 1000\n 12: if_icmpge 91\n 15: iconst_0\n 16: istore_2\n 17: iload_2\n 18: sipush 1000\n 21: if_icmpge 79\n 24: new #18 // class java/lang/StringBuilder\n 27: dup\n 28: invokespecial #22 // Method java/lang/StringBuilder.\"<init>\":()V\n 31: aload_0\n 32: iload_2\n 33: aaload\n 34: iload_1\n 35: aaload\n 36: invokevirtual #65 // Method java/lang/Integer.intValue:()I\n 39: ifne 50\n 42: bipush 46\n 44: invokestatic #71 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 47: goto 55\n 50: aload_0\n 51: iload_2\n 52: aaload\n 53: iload_1\n 54: aaload\n 55: invokevirtual #74 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 58: bipush 32\n 60: invokevirtual #53 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 63: invokevirtual #57 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 66: getstatic #80 // Field java/lang/System.out:Ljava/io/PrintStream;\n 69: swap\n 70: invokevirtual #86 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 73: iinc 2, 1\n 76: goto 17\n 79: getstatic #80 // Field java/lang/System.out:Ljava/io/PrintStream;\n 82: invokevirtual #89 // Method java/io/PrintStream.println:()V\n 85: iinc 1, 1\n 88: goto 8\n 91: return\n\n public static final boolean isVentPathOblique(kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: ldc #10 // String path\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 10: checkcast #30 // class kotlin/Pair\n 13: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 16: checkcast #36 // class java/lang/Number\n 19: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 22: aload_0\n 23: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 26: checkcast #30 // class kotlin/Pair\n 29: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 32: checkcast #36 // class java/lang/Number\n 35: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 38: if_icmpeq 80\n 41: aload_0\n 42: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 45: checkcast #30 // class kotlin/Pair\n 48: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 51: checkcast #36 // class java/lang/Number\n 54: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 57: aload_0\n 58: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 61: checkcast #30 // class kotlin/Pair\n 64: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 67: checkcast #36 // class java/lang/Number\n 70: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 73: if_icmpeq 80\n 76: iconst_1\n 77: goto 81\n 80: iconst_0\n 81: ireturn\n\n public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> commaSeparatedNumbersToXY(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #102 // String numbers\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #104 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #106 // class java/lang/String\n 14: astore_2\n 15: aload_2\n 16: iconst_0\n 17: ldc #108 // String ,\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 #114 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: checkcast #116 // class java/lang/Iterable\n 32: astore_2\n 33: iconst_0\n 34: istore_3\n 35: aload_2\n 36: astore 4\n 38: new #118 // class java/util/ArrayList\n 41: dup\n 42: aload_2\n 43: bipush 10\n 45: invokestatic #124 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 48: invokespecial #127 // Method java/util/ArrayList.\"<init>\":(I)V\n 51: checkcast #129 // class java/util/Collection\n 54: astore 5\n 56: iconst_0\n 57: istore 6\n 59: aload 4\n 61: invokeinterface #133, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 66: astore 7\n 68: aload 7\n 70: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 75: ifeq 122\n 78: aload 7\n 80: invokeinterface #142, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 85: astore 8\n 87: aload 5\n 89: aload 8\n 91: checkcast #106 // class java/lang/String\n 94: astore 9\n 96: astore 11\n 98: iconst_0\n 99: istore 10\n 101: aload 9\n 103: invokestatic #146 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 106: nop\n 107: invokestatic #149 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 110: aload 11\n 112: swap\n 113: invokeinterface #153, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 118: pop\n 119: goto 68\n 122: aload 5\n 124: checkcast #155 // class java/util/List\n 127: nop\n 128: astore_1\n 129: new #30 // class kotlin/Pair\n 132: dup\n 133: aload_1\n 134: iconst_0\n 135: invokeinterface #159, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 140: aload_1\n 141: iconst_1\n 142: invokeinterface #159, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 147: invokespecial #162 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 150: areturn\n\n public static final kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>> inputLineToVentPath(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #180 // String line\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #104 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #106 // class java/lang/String\n 14: astore_2\n 15: aload_2\n 16: iconst_0\n 17: ldc #182 // String ->\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 #114 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: checkcast #116 // class java/lang/Iterable\n 32: astore_2\n 33: iconst_0\n 34: istore_3\n 35: aload_2\n 36: astore 4\n 38: new #118 // class java/util/ArrayList\n 41: dup\n 42: aload_2\n 43: bipush 10\n 45: invokestatic #124 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 48: invokespecial #127 // Method java/util/ArrayList.\"<init>\":(I)V\n 51: checkcast #129 // class java/util/Collection\n 54: astore 5\n 56: iconst_0\n 57: istore 6\n 59: aload 4\n 61: invokeinterface #133, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 66: astore 7\n 68: aload 7\n 70: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 75: ifeq 125\n 78: aload 7\n 80: invokeinterface #142, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 85: astore 8\n 87: aload 5\n 89: aload 8\n 91: checkcast #106 // class java/lang/String\n 94: astore 9\n 96: astore 11\n 98: iconst_0\n 99: istore 10\n 101: aload 9\n 103: checkcast #104 // class java/lang/CharSequence\n 106: invokestatic #186 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 109: invokevirtual #187 // Method java/lang/Object.toString:()Ljava/lang/String;\n 112: nop\n 113: aload 11\n 115: swap\n 116: invokeinterface #153, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 121: pop\n 122: goto 68\n 125: aload 5\n 127: checkcast #155 // class java/util/List\n 130: nop\n 131: astore_1\n 132: new #30 // class kotlin/Pair\n 135: dup\n 136: aload_1\n 137: iconst_0\n 138: invokeinterface #159, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 143: checkcast #106 // class java/lang/String\n 146: invokestatic #189 // Method commaSeparatedNumbersToXY:(Ljava/lang/String;)Lkotlin/Pair;\n 149: aload_1\n 150: iconst_1\n 151: invokeinterface #159, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 156: checkcast #106 // class java/lang/String\n 159: invokestatic #189 // Method commaSeparatedNumbersToXY:(Ljava/lang/String;)Lkotlin/Pair;\n 162: invokespecial #162 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 165: areturn\n\n public static final void addNotObliqueVent(java.lang.Integer[][], kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: ldc #62 // String board\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 path\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: invokestatic #198 // Method addNotObliqueVent$getXRange:(Lkotlin/Pair;)Lkotlin/ranges/IntProgression;\n 16: astore_2\n 17: aload_2\n 18: invokevirtual #202 // Method kotlin/ranges/IntProgression.getFirst:()I\n 21: istore_3\n 22: aload_2\n 23: invokevirtual #205 // Method kotlin/ranges/IntProgression.getLast:()I\n 26: istore 4\n 28: aload_2\n 29: invokevirtual #208 // Method kotlin/ranges/IntProgression.getStep:()I\n 32: istore 5\n 34: iload 5\n 36: ifle 45\n 39: iload_3\n 40: iload 4\n 42: if_icmple 56\n 45: iload 5\n 47: ifge 169\n 50: iload 4\n 52: iload_3\n 53: if_icmpgt 169\n 56: aload_1\n 57: invokestatic #211 // Method addNotObliqueVent$getYRange:(Lkotlin/Pair;)Lkotlin/ranges/IntProgression;\n 60: astore 6\n 62: aload 6\n 64: invokevirtual #202 // Method kotlin/ranges/IntProgression.getFirst:()I\n 67: istore 7\n 69: aload 6\n 71: invokevirtual #205 // Method kotlin/ranges/IntProgression.getLast:()I\n 74: istore 8\n 76: aload 6\n 78: invokevirtual #208 // Method kotlin/ranges/IntProgression.getStep:()I\n 81: istore 9\n 83: iload 9\n 85: ifle 95\n 88: iload 7\n 90: iload 8\n 92: if_icmple 107\n 95: iload 9\n 97: ifge 155\n 100: iload 8\n 102: iload 7\n 104: if_icmpgt 155\n 107: aload_0\n 108: iload_3\n 109: aaload\n 110: astore 10\n 112: iload 7\n 114: istore 11\n 116: aload 10\n 118: iload 11\n 120: aaload\n 121: invokevirtual #65 // Method java/lang/Integer.intValue:()I\n 124: istore 12\n 126: aload 10\n 128: iload 11\n 130: iload 12\n 132: iconst_1\n 133: iadd\n 134: invokestatic #149 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 137: aastore\n 138: iload 7\n 140: iload 8\n 142: if_icmpeq 155\n 145: iload 7\n 147: iload 9\n 149: iadd\n 150: istore 7\n 152: goto 107\n 155: iload_3\n 156: iload 4\n 158: if_icmpeq 169\n 161: iload_3\n 162: iload 5\n 164: iadd\n 165: istore_3\n 166: goto 56\n 169: return\n\n public static final void addObliqueVent(java.lang.Integer[][], kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: ldc #62 // String board\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 path\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 16: checkcast #30 // class kotlin/Pair\n 19: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 22: checkcast #36 // class java/lang/Number\n 25: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 28: aload_1\n 29: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 32: checkcast #30 // class kotlin/Pair\n 35: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 38: checkcast #36 // class java/lang/Number\n 41: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 44: if_icmpge 65\n 47: new #30 // class kotlin/Pair\n 50: dup\n 51: aload_1\n 52: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 55: aload_1\n 56: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 59: invokespecial #162 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 62: goto 80\n 65: new #30 // class kotlin/Pair\n 68: dup\n 69: aload_1\n 70: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 73: aload_1\n 74: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 77: invokespecial #162 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 80: astore_2\n 81: aload_2\n 82: invokevirtual #215 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 85: checkcast #30 // class kotlin/Pair\n 88: astore_3\n 89: aload_2\n 90: invokevirtual #218 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 93: checkcast #30 // class kotlin/Pair\n 96: astore 4\n 98: aload_3\n 99: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 102: checkcast #36 // class java/lang/Number\n 105: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 108: istore 5\n 110: aload_3\n 111: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 114: checkcast #36 // class java/lang/Number\n 117: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 120: aload 4\n 122: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 125: checkcast #36 // class java/lang/Number\n 128: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 131: isub\n 132: i2d\n 133: invokestatic #224 // Method java/lang/Math.signum:(D)D\n 136: d2i\n 137: ineg\n 138: istore 6\n 140: aload_3\n 141: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 144: checkcast #36 // class java/lang/Number\n 147: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 150: istore 7\n 152: aload 4\n 154: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 157: checkcast #36 // class java/lang/Number\n 160: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 163: istore 8\n 165: iload 7\n 167: iload 8\n 169: if_icmpgt 220\n 172: aload_0\n 173: iload 7\n 175: aaload\n 176: astore 9\n 178: iload 5\n 180: istore 10\n 182: aload 9\n 184: iload 10\n 186: aload 9\n 188: iload 10\n 190: aaload\n 191: invokevirtual #65 // Method java/lang/Integer.intValue:()I\n 194: iconst_1\n 195: iadd\n 196: invokestatic #149 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 199: aastore\n 200: iload 5\n 202: iload 6\n 204: iadd\n 205: istore 5\n 207: iload 7\n 209: iload 8\n 211: if_icmpeq 220\n 214: iinc 7, 1\n 217: goto 172\n 220: return\n\n public static final int getOverlappedCells(java.lang.Integer[][]);\n Code:\n 0: aload_0\n 1: ldc #62 // String board\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: iconst_0\n 9: istore_2\n 10: aload_0\n 11: checkcast #232 // class \"[Ljava/lang/Object;\"\n 14: arraylength\n 15: istore_3\n 16: iload_2\n 17: iload_3\n 18: if_icmpge 72\n 21: aload_0\n 22: iload_2\n 23: aaload\n 24: astore 4\n 26: iconst_0\n 27: istore 5\n 29: aload 4\n 31: arraylength\n 32: istore 6\n 34: iload 5\n 36: iload 6\n 38: if_icmpge 66\n 41: aload 4\n 43: iload 5\n 45: aaload\n 46: invokevirtual #65 // Method java/lang/Integer.intValue:()I\n 49: istore 7\n 51: iload 7\n 53: iconst_1\n 54: if_icmple 60\n 57: iinc 1, 1\n 60: iinc 5, 1\n 63: goto 34\n 66: iinc 2, 1\n 69: goto 16\n 72: iload_1\n 73: ireturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #241 // String args\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #243 // class java/io/File\n 9: dup\n 10: ldc #245 // String ./input.txt\n 12: invokespecial #248 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 15: aconst_null\n 16: iconst_1\n 17: aconst_null\n 18: invokestatic #254 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 21: checkcast #116 // class java/lang/Iterable\n 24: astore_2\n 25: iconst_0\n 26: istore_3\n 27: aload_2\n 28: astore 4\n 30: new #118 // class java/util/ArrayList\n 33: dup\n 34: aload_2\n 35: bipush 10\n 37: invokestatic #124 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 40: invokespecial #127 // Method java/util/ArrayList.\"<init>\":(I)V\n 43: checkcast #129 // class java/util/Collection\n 46: astore 5\n 48: iconst_0\n 49: istore 6\n 51: aload 4\n 53: invokeinterface #133, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 58: astore 7\n 60: aload 7\n 62: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 67: ifeq 110\n 70: aload 7\n 72: invokeinterface #142, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 77: astore 8\n 79: aload 5\n 81: aload 8\n 83: checkcast #106 // class java/lang/String\n 86: astore 9\n 88: astore 12\n 90: iconst_0\n 91: istore 10\n 93: aload 9\n 95: invokestatic #256 // Method inputLineToVentPath:(Ljava/lang/String;)Lkotlin/Pair;\n 98: aload 12\n 100: swap\n 101: invokeinterface #153, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 106: pop\n 107: goto 60\n 110: aload 5\n 112: checkcast #155 // class java/util/List\n 115: nop\n 116: astore_1\n 117: aload_1\n 118: checkcast #116 // class java/lang/Iterable\n 121: astore_3\n 122: iconst_0\n 123: istore 4\n 125: new #118 // class java/util/ArrayList\n 128: dup\n 129: invokespecial #257 // Method java/util/ArrayList.\"<init>\":()V\n 132: astore 5\n 134: new #118 // class java/util/ArrayList\n 137: dup\n 138: invokespecial #257 // Method java/util/ArrayList.\"<init>\":()V\n 141: astore 6\n 143: aload_3\n 144: invokeinterface #133, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 149: astore 7\n 151: aload 7\n 153: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 158: ifeq 209\n 161: aload 7\n 163: invokeinterface #142, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 168: astore 8\n 170: aload 8\n 172: checkcast #30 // class kotlin/Pair\n 175: astore 9\n 177: iconst_0\n 178: istore 10\n 180: aload 9\n 182: invokestatic #259 // Method isVentPathOblique:(Lkotlin/Pair;)Z\n 185: ifeq 198\n 188: aload 5\n 190: aload 8\n 192: invokevirtual #260 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 195: goto 205\n 198: aload 6\n 200: aload 8\n 202: invokevirtual #260 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 205: pop\n 206: goto 151\n 209: new #30 // class kotlin/Pair\n 212: dup\n 213: aload 5\n 215: aload 6\n 217: invokespecial #162 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 220: astore_2\n 221: aload_2\n 222: invokevirtual #215 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 225: checkcast #155 // class java/util/List\n 228: astore_3\n 229: aload_2\n 230: invokevirtual #218 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 233: checkcast #155 // class java/util/List\n 236: astore 4\n 238: iconst_0\n 239: istore 6\n 241: sipush 1000\n 244: anewarray #237 // class \"[Ljava/lang/Integer;\"\n 247: astore 7\n 249: iload 6\n 251: sipush 1000\n 254: if_icmpge 320\n 257: iload 6\n 259: istore 8\n 261: aload 7\n 263: iload 8\n 265: iconst_0\n 266: istore 9\n 268: sipush 1000\n 271: anewarray #64 // class java/lang/Integer\n 274: astore 10\n 276: istore 13\n 278: astore 12\n 280: iload 9\n 282: sipush 1000\n 285: if_icmpge 307\n 288: iload 9\n 290: istore 11\n 292: aload 10\n 294: iload 11\n 296: iconst_0\n 297: invokestatic #149 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 300: aastore\n 301: iinc 9, 1\n 304: goto 280\n 307: aload 12\n 309: iload 13\n 311: aload 10\n 313: aastore\n 314: iinc 6, 1\n 317: goto 249\n 320: aload 7\n 322: astore 5\n 324: aload 4\n 326: checkcast #116 // class java/lang/Iterable\n 329: astore 6\n 331: iconst_0\n 332: istore 7\n 334: aload 6\n 336: invokeinterface #133, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 341: astore 8\n 343: aload 8\n 345: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 350: ifeq 383\n 353: aload 8\n 355: invokeinterface #142, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 360: astore 9\n 362: aload 9\n 364: checkcast #30 // class kotlin/Pair\n 367: astore 10\n 369: iconst_0\n 370: istore 11\n 372: aload 5\n 374: aload 10\n 376: invokestatic #262 // Method addNotObliqueVent:([[Ljava/lang/Integer;Lkotlin/Pair;)V\n 379: nop\n 380: goto 343\n 383: nop\n 384: new #18 // class java/lang/StringBuilder\n 387: dup\n 388: invokespecial #22 // Method java/lang/StringBuilder.\"<init>\":()V\n 391: ldc_w #264 // String Part 1 overlapped cells:\n 394: invokevirtual #28 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 397: aload 5\n 399: invokestatic #266 // Method getOverlappedCells:([[Ljava/lang/Integer;)I\n 402: invokevirtual #43 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 405: invokevirtual #57 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 408: getstatic #80 // Field java/lang/System.out:Ljava/io/PrintStream;\n 411: swap\n 412: invokevirtual #268 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 415: aload_3\n 416: checkcast #116 // class java/lang/Iterable\n 419: astore 6\n 421: iconst_0\n 422: istore 7\n 424: aload 6\n 426: invokeinterface #133, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 431: astore 8\n 433: aload 8\n 435: invokeinterface #139, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 440: ifeq 473\n 443: aload 8\n 445: invokeinterface #142, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 450: astore 9\n 452: aload 9\n 454: checkcast #30 // class kotlin/Pair\n 457: astore 10\n 459: iconst_0\n 460: istore 11\n 462: aload 5\n 464: aload 10\n 466: invokestatic #270 // Method addObliqueVent:([[Ljava/lang/Integer;Lkotlin/Pair;)V\n 469: nop\n 470: goto 433\n 473: nop\n 474: new #18 // class java/lang/StringBuilder\n 477: dup\n 478: invokespecial #22 // Method java/lang/StringBuilder.\"<init>\":()V\n 481: ldc_w #272 // String Part 2 overlapped cells:\n 484: invokevirtual #28 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 487: aload 5\n 489: invokestatic #266 // Method getOverlappedCells:([[Ljava/lang/Integer;)I\n 492: invokevirtual #43 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 495: invokevirtual #57 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 498: getstatic #80 // Field java/lang/System.out:Ljava/io/PrintStream;\n 501: swap\n 502: invokevirtual #268 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 505: return\n\n private static final kotlin.ranges.IntProgression addNotObliqueVent$getXRange(kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 4: checkcast #30 // class kotlin/Pair\n 7: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 10: checkcast #36 // class java/lang/Number\n 13: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 16: aload_0\n 17: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 20: checkcast #30 // class kotlin/Pair\n 23: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 26: checkcast #36 // class java/lang/Number\n 29: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 32: if_icmpge 73\n 35: aload_0\n 36: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 39: checkcast #30 // class kotlin/Pair\n 42: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 45: checkcast #36 // class java/lang/Number\n 48: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 51: aload_0\n 52: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 55: checkcast #30 // class kotlin/Pair\n 58: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 61: checkcast #36 // class java/lang/Number\n 64: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 67: invokestatic #297 // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;\n 70: goto 108\n 73: aload_0\n 74: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 77: checkcast #30 // class kotlin/Pair\n 80: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 83: checkcast #36 // class java/lang/Number\n 86: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 89: aload_0\n 90: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 93: checkcast #30 // class kotlin/Pair\n 96: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 99: checkcast #36 // class java/lang/Number\n 102: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 105: invokestatic #297 // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;\n 108: areturn\n\n private static final kotlin.ranges.IntProgression addNotObliqueVent$getYRange(kotlin.Pair<kotlin.Pair<java.lang.Integer, java.lang.Integer>, kotlin.Pair<java.lang.Integer, java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 4: checkcast #30 // class kotlin/Pair\n 7: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 10: checkcast #36 // class java/lang/Number\n 13: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 16: aload_0\n 17: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 20: checkcast #30 // class kotlin/Pair\n 23: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 26: checkcast #36 // class java/lang/Number\n 29: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 32: if_icmpge 73\n 35: aload_0\n 36: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 39: checkcast #30 // class kotlin/Pair\n 42: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 45: checkcast #36 // class java/lang/Number\n 48: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 51: aload_0\n 52: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 55: checkcast #30 // class kotlin/Pair\n 58: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 61: checkcast #36 // class java/lang/Number\n 64: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 67: invokestatic #297 // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;\n 70: goto 108\n 73: aload_0\n 74: invokevirtual #34 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 77: checkcast #30 // class kotlin/Pair\n 80: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 83: checkcast #36 // class java/lang/Number\n 86: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 89: aload_0\n 90: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 93: checkcast #30 // class kotlin/Pair\n 96: invokevirtual #48 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 99: checkcast #36 // class java/lang/Number\n 102: invokevirtual #40 // Method java/lang/Number.intValue:()I\n 105: invokestatic #297 // Method kotlin/ranges/RangesKt.downTo:(II)Lkotlin/ranges/IntProgression;\n 108: areturn\n}\n", "javap_err": "" } ]
Matheus-Inacioal__AtividadesKotlinQualificaResolucao__9ce1df3/AtvRevisao/Atv3.kt
fun main() { val numbers = mutableListOf<Int>() println("Digite uma série de números separados por espaços (ou '0' para sair):") while (true) { val input = readLine() if (input == "0") { break } val number = input?.toIntOrNull() if (number != null) { numbers.add(number) } else { println("Entrada inválida. Por favor, digite um número válido ou 'q' para sair.") } } if (numbers.isEmpty()) { println("Nenhum número foi inserido.") } else { println("Média: ${calculateAverage(numbers)}") val (max, min) = findMaxAndMin(numbers) println("Maior número: $max") println("Menor número: $min") val (evenCount, oddCount) = countEvenAndOdd(numbers) println("Quantidade de números pares: $evenCount") println("Quantidade de números ímpares: $oddCount") } } fun calculateAverage(numbers: List<Int>): Double { val sum = numbers.sum() return sum.toDouble() / numbers.size } fun findMaxAndMin(numbers: List<Int>): Pair<Int, Int> { val max = numbers.maxOrNull() ?: Int.MIN_VALUE val min = numbers.minOrNull() ?: Int.MAX_VALUE return Pair(max, min) } fun countEvenAndOdd(numbers: List<Int>): Pair<Int, Int> { val evenCount = numbers.count { it % 2 == 0 } val oddCount = numbers.size - evenCount return Pair(evenCount, oddCount) }
[ { "class_path": "Matheus-Inacioal__AtividadesKotlinQualificaResolucao__9ce1df3/Atv3Kt.class", "javap": "Compiled from \"Atv3.kt\"\npublic final class Atv3Kt {\n public static final void main();\n Code:\n 0: new #8 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #11 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #13 // class java/util/List\n 10: astore_0\n 11: ldc #15 // String Digite uma série de números separados por espaços (ou \\'0\\' para sair):\n 13: getstatic #21 // Field java/lang/System.out:Ljava/io/PrintStream;\n 16: swap\n 17: invokevirtual #27 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 20: nop\n 21: invokestatic #33 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 24: astore_1\n 25: aload_1\n 26: ldc #35 // String 0\n 28: invokestatic #41 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 31: ifeq 37\n 34: goto 78\n 37: aload_1\n 38: dup\n 39: ifnull 48\n 42: invokestatic #47 // Method kotlin/text/StringsKt.toIntOrNull:(Ljava/lang/String;)Ljava/lang/Integer;\n 45: goto 50\n 48: pop\n 49: aconst_null\n 50: astore_2\n 51: aload_2\n 52: ifnull 66\n 55: aload_0\n 56: aload_2\n 57: invokeinterface #51, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 62: pop\n 63: goto 20\n 66: ldc #53 // String Entrada inválida. Por favor, digite um número válido ou \\'q\\' para sair.\n 68: getstatic #21 // Field java/lang/System.out:Ljava/io/PrintStream;\n 71: swap\n 72: invokevirtual #27 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 75: goto 20\n 78: aload_0\n 79: invokeinterface #57, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 84: ifeq 99\n 87: ldc #59 // String Nenhum número foi inserido.\n 89: getstatic #21 // Field java/lang/System.out:Ljava/io/PrintStream;\n 92: swap\n 93: invokevirtual #27 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 96: goto 293\n 99: new #61 // class java/lang/StringBuilder\n 102: dup\n 103: invokespecial #62 // Method java/lang/StringBuilder.\"<init>\":()V\n 106: ldc #64 // String Média:\n 108: invokevirtual #68 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 111: aload_0\n 112: invokestatic #72 // Method calculateAverage:(Ljava/util/List;)D\n 115: invokevirtual #75 // Method java/lang/StringBuilder.append:(D)Ljava/lang/StringBuilder;\n 118: invokevirtual #78 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 121: getstatic #21 // Field java/lang/System.out:Ljava/io/PrintStream;\n 124: swap\n 125: invokevirtual #27 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 128: aload_0\n 129: invokestatic #82 // Method findMaxAndMin:(Ljava/util/List;)Lkotlin/Pair;\n 132: astore_1\n 133: aload_1\n 134: invokevirtual #88 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 137: checkcast #90 // class java/lang/Number\n 140: invokevirtual #94 // Method java/lang/Number.intValue:()I\n 143: istore_2\n 144: aload_1\n 145: invokevirtual #97 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 148: checkcast #90 // class java/lang/Number\n 151: invokevirtual #94 // Method java/lang/Number.intValue:()I\n 154: istore_3\n 155: new #61 // class java/lang/StringBuilder\n 158: dup\n 159: invokespecial #62 // Method java/lang/StringBuilder.\"<init>\":()V\n 162: ldc #99 // String Maior número:\n 164: invokevirtual #68 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 167: iload_2\n 168: invokevirtual #102 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 171: invokevirtual #78 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 174: getstatic #21 // Field java/lang/System.out:Ljava/io/PrintStream;\n 177: swap\n 178: invokevirtual #27 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 181: new #61 // class java/lang/StringBuilder\n 184: dup\n 185: invokespecial #62 // Method java/lang/StringBuilder.\"<init>\":()V\n 188: ldc #104 // String Menor número:\n 190: invokevirtual #68 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 193: iload_3\n 194: invokevirtual #102 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 197: invokevirtual #78 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 200: getstatic #21 // Field java/lang/System.out:Ljava/io/PrintStream;\n 203: swap\n 204: invokevirtual #27 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 207: aload_0\n 208: invokestatic #107 // Method countEvenAndOdd:(Ljava/util/List;)Lkotlin/Pair;\n 211: astore 4\n 213: aload 4\n 215: invokevirtual #88 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 218: checkcast #90 // class java/lang/Number\n 221: invokevirtual #94 // Method java/lang/Number.intValue:()I\n 224: istore 5\n 226: aload 4\n 228: invokevirtual #97 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 231: checkcast #90 // class java/lang/Number\n 234: invokevirtual #94 // Method java/lang/Number.intValue:()I\n 237: istore 6\n 239: new #61 // class java/lang/StringBuilder\n 242: dup\n 243: invokespecial #62 // Method java/lang/StringBuilder.\"<init>\":()V\n 246: ldc #109 // String Quantidade de números pares:\n 248: invokevirtual #68 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 251: iload 5\n 253: invokevirtual #102 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 256: invokevirtual #78 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 259: getstatic #21 // Field java/lang/System.out:Ljava/io/PrintStream;\n 262: swap\n 263: invokevirtual #27 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 266: new #61 // class java/lang/StringBuilder\n 269: dup\n 270: invokespecial #62 // Method java/lang/StringBuilder.\"<init>\":()V\n 273: ldc #111 // String Quantidade de números ímpares:\n 275: invokevirtual #68 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 278: iload 6\n 280: invokevirtual #102 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 283: invokevirtual #78 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 286: getstatic #21 // Field java/lang/System.out:Ljava/io/PrintStream;\n 289: swap\n 290: invokevirtual #27 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 293: return\n\n public static final double calculateAverage(java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #129 // String numbers\n 3: invokestatic #133 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #135 // class java/lang/Iterable\n 10: invokestatic #141 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 13: istore_1\n 14: iload_1\n 15: i2d\n 16: aload_0\n 17: invokeinterface #144, 1 // InterfaceMethod java/util/List.size:()I\n 22: i2d\n 23: ddiv\n 24: dreturn\n\n public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> findMaxAndMin(java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #129 // String numbers\n 3: invokestatic #133 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #135 // class java/lang/Iterable\n 10: invokestatic #150 // Method kotlin/collections/CollectionsKt.maxOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 13: checkcast #126 // class java/lang/Integer\n 16: dup\n 17: ifnull 26\n 20: invokevirtual #151 // Method java/lang/Integer.intValue:()I\n 23: goto 29\n 26: pop\n 27: ldc #152 // int -2147483648\n 29: istore_1\n 30: aload_0\n 31: checkcast #135 // class java/lang/Iterable\n 34: invokestatic #155 // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 37: checkcast #126 // class java/lang/Integer\n 40: dup\n 41: ifnull 50\n 44: invokevirtual #151 // Method java/lang/Integer.intValue:()I\n 47: goto 53\n 50: pop\n 51: ldc #156 // int 2147483647\n 53: istore_2\n 54: new #84 // class kotlin/Pair\n 57: dup\n 58: iload_1\n 59: invokestatic #160 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 62: iload_2\n 63: invokestatic #160 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 66: invokespecial #163 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 69: areturn\n\n public static final kotlin.Pair<java.lang.Integer, java.lang.Integer> countEvenAndOdd(java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #129 // String numbers\n 3: invokestatic #133 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #135 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: instanceof #165 // class java/util/Collection\n 17: ifeq 36\n 20: aload_2\n 21: checkcast #165 // class java/util/Collection\n 24: invokeinterface #166, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 29: ifeq 36\n 32: iconst_0\n 33: goto 110\n 36: iconst_0\n 37: istore 4\n 39: aload_2\n 40: invokeinterface #170, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 5\n 47: aload 5\n 49: invokeinterface #175, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 108\n 57: aload 5\n 59: invokeinterface #178, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 6\n 66: aload 6\n 68: checkcast #90 // class java/lang/Number\n 71: invokevirtual #94 // Method java/lang/Number.intValue:()I\n 74: istore 7\n 76: iconst_0\n 77: istore 8\n 79: iload 7\n 81: iconst_2\n 82: irem\n 83: ifne 90\n 86: iconst_1\n 87: goto 91\n 90: iconst_0\n 91: ifeq 47\n 94: iinc 4, 1\n 97: iload 4\n 99: ifge 47\n 102: invokestatic #181 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 105: goto 47\n 108: iload 4\n 110: istore_1\n 111: aload_0\n 112: invokeinterface #144, 1 // InterfaceMethod java/util/List.size:()I\n 117: iload_1\n 118: isub\n 119: istore_2\n 120: new #84 // class kotlin/Pair\n 123: dup\n 124: iload_1\n 125: invokestatic #160 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 128: iload_2\n 129: invokestatic #160 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 132: invokespecial #163 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 135: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #192 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
ReciHub__FunnyAlgorithms__24518dd/Rat Maze Problem/RatMaze.kt
/** * @created October 2, 2019 * Kotlin Program that solves Rat in a maze problem using backtracking. */ class RatMaze { // Size of the maze. private var n: Int = 0 // Just in case. Primitive types cannot be lateinit. private lateinit var solution: Array<IntArray> private lateinit var maze: Array<IntArray> /** * This function solves the Maze problem using * Backtracking. It mainly uses solveMazeUtil() * to solve the problem. It returns false if no * path is possible, otherwise return true and * prints the path in the form of 1s. Please note * that there may be more than one solutions, this * function prints one of the feasible solutions. */ fun solve(maze: Array<IntArray>): Boolean { n = maze.size this.maze = maze solution = Array(n) { IntArray(n) } if (!solveMazeUtil(0, 0)) { println("Solution does not exist.") return false } printSolution() return true } /** * A recursive utility function to solve Maze problem. */ private fun solveMazeUtil(row: Int, column: Int): Boolean { // if (row ; column) is the goal then return true if (row == n - 1 && column == n - 1) { solution[row][column] = 1 return true } // Check if maze[row][column] is valid. if (isSafe(row, column)) { solution[row][column] = 1 // Move horizontally if (solveMazeUtil(row, column + 1)) { return true } // Move vertically if (solveMazeUtil(row + 1, column)) { return true } // If none of the above movements works then // BACKTRACK: remove mark on row, column as part of solution path solution[row][column] = 0 return false } return false } /** * Checks that the coordinates "row" and "column" are valid. */ private fun isSafe(row: Int, column: Int): Boolean { return row in 0..(n - 1) && column in 0..(n - 1) && maze[row][column] == 1 } /** * A utility function to print solution matrix. * solution[n][n] */ private fun printSolution() { (0..(n - 1)).forEach { row -> (0..(n - 1)).forEach { column -> print(" ${solution[row][column]}") } println() } } } fun main() { // Valid Maze val maze01 = arrayOf( intArrayOf(1, 0, 0, 0), intArrayOf(1, 1, 0, 1), intArrayOf(0, 1, 0, 0), intArrayOf(1, 1, 1, 1) ) // Valid Maze val maze02 = arrayOf( intArrayOf(1, 0, 0), intArrayOf(1, 1, 0), intArrayOf(0, 1, 1) ) // Invalid Maze val maze03 = arrayOf( intArrayOf(1, 0, 0), intArrayOf(0, 0, 0), intArrayOf(0, 0, 1) ) val mazes = arrayListOf<Array<IntArray>>() mazes.add(maze01) mazes.add(maze02) mazes.add(maze03) val ratMaze = RatMaze() for (i in 0 until mazes.size) { println("Solving Maze ${i + 1}") println() ratMaze.solve(mazes[i]) println() } }
[ { "class_path": "ReciHub__FunnyAlgorithms__24518dd/RatMaze.class", "javap": "Compiled from \"RatMaze.kt\"\npublic final class RatMaze {\n private int n;\n\n private int[][] solution;\n\n private int[][] maze;\n\n public RatMaze();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final boolean solve(int[][]);\n Code:\n 0: aload_1\n 1: ldc #15 // String maze\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: checkcast #23 // class \"[Ljava/lang/Object;\"\n 11: arraylength\n 12: putfield #27 // Field n:I\n 15: aload_0\n 16: aload_1\n 17: putfield #30 // Field maze:[[I\n 20: aload_0\n 21: iconst_0\n 22: istore_2\n 23: aload_0\n 24: getfield #27 // Field n:I\n 27: istore_3\n 28: iload_3\n 29: anewarray #32 // class \"[I\"\n 32: astore 4\n 34: astore 6\n 36: iload_2\n 37: iload_3\n 38: if_icmpge 61\n 41: iload_2\n 42: istore 5\n 44: aload 4\n 46: iload 5\n 48: aload_0\n 49: getfield #27 // Field n:I\n 52: newarray int\n 54: aastore\n 55: iinc 2, 1\n 58: goto 36\n 61: aload 6\n 63: aload 4\n 65: putfield #35 // Field solution:[[I\n 68: aload_0\n 69: iconst_0\n 70: iconst_0\n 71: invokespecial #39 // Method solveMazeUtil:(II)Z\n 74: ifne 88\n 77: ldc #41 // String Solution does not exist.\n 79: getstatic #47 // Field java/lang/System.out:Ljava/io/PrintStream;\n 82: swap\n 83: invokevirtual #53 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 86: iconst_0\n 87: ireturn\n 88: aload_0\n 89: invokespecial #56 // Method printSolution:()V\n 92: iconst_1\n 93: ireturn\n\n private final boolean solveMazeUtil(int, int);\n Code:\n 0: iload_1\n 1: aload_0\n 2: getfield #27 // Field n:I\n 5: iconst_1\n 6: isub\n 7: if_icmpne 42\n 10: iload_2\n 11: aload_0\n 12: getfield #27 // Field n:I\n 15: iconst_1\n 16: isub\n 17: if_icmpne 42\n 20: aload_0\n 21: getfield #35 // Field solution:[[I\n 24: dup\n 25: ifnonnull 35\n 28: pop\n 29: ldc #58 // String solution\n 31: invokestatic #62 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V\n 34: aconst_null\n 35: iload_1\n 36: aaload\n 37: iload_2\n 38: iconst_1\n 39: iastore\n 40: iconst_1\n 41: ireturn\n 42: aload_0\n 43: iload_1\n 44: iload_2\n 45: invokespecial #65 // Method isSafe:(II)Z\n 48: ifeq 119\n 51: aload_0\n 52: getfield #35 // Field solution:[[I\n 55: dup\n 56: ifnonnull 66\n 59: pop\n 60: ldc #58 // String solution\n 62: invokestatic #62 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V\n 65: aconst_null\n 66: iload_1\n 67: aaload\n 68: iload_2\n 69: iconst_1\n 70: iastore\n 71: aload_0\n 72: iload_1\n 73: iload_2\n 74: iconst_1\n 75: iadd\n 76: invokespecial #39 // Method solveMazeUtil:(II)Z\n 79: ifeq 84\n 82: iconst_1\n 83: ireturn\n 84: aload_0\n 85: iload_1\n 86: iconst_1\n 87: iadd\n 88: iload_2\n 89: invokespecial #39 // Method solveMazeUtil:(II)Z\n 92: ifeq 97\n 95: iconst_1\n 96: ireturn\n 97: aload_0\n 98: getfield #35 // Field solution:[[I\n 101: dup\n 102: ifnonnull 112\n 105: pop\n 106: ldc #58 // String solution\n 108: invokestatic #62 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V\n 111: aconst_null\n 112: iload_1\n 113: aaload\n 114: iload_2\n 115: iconst_0\n 116: iastore\n 117: iconst_0\n 118: ireturn\n 119: iconst_0\n 120: ireturn\n\n private final boolean isSafe(int, int);\n Code:\n 0: iconst_0\n 1: iload_1\n 2: if_icmpgt 23\n 5: iload_1\n 6: aload_0\n 7: getfield #27 // Field n:I\n 10: iconst_1\n 11: isub\n 12: if_icmpgt 19\n 15: iconst_1\n 16: goto 24\n 19: iconst_0\n 20: goto 24\n 23: iconst_0\n 24: ifeq 81\n 27: iconst_0\n 28: iload_2\n 29: if_icmpgt 50\n 32: iload_2\n 33: aload_0\n 34: getfield #27 // Field n:I\n 37: iconst_1\n 38: isub\n 39: if_icmpgt 46\n 42: iconst_1\n 43: goto 51\n 46: iconst_0\n 47: goto 51\n 50: iconst_0\n 51: ifeq 81\n 54: aload_0\n 55: getfield #30 // Field maze:[[I\n 58: dup\n 59: ifnonnull 69\n 62: pop\n 63: ldc #15 // String maze\n 65: invokestatic #62 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V\n 68: aconst_null\n 69: iload_1\n 70: aaload\n 71: iload_2\n 72: iaload\n 73: iconst_1\n 74: if_icmpne 81\n 77: iconst_1\n 78: goto 82\n 81: iconst_0\n 82: ireturn\n\n private final void printSolution();\n Code:\n 0: new #69 // class kotlin/ranges/IntRange\n 3: dup\n 4: iconst_0\n 5: aload_0\n 6: getfield #27 // Field n:I\n 9: iconst_1\n 10: isub\n 11: invokespecial #72 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 14: checkcast #74 // class java/lang/Iterable\n 17: astore_1\n 18: iconst_0\n 19: istore_2\n 20: aload_1\n 21: invokeinterface #78, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 26: astore_3\n 27: aload_3\n 28: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 33: ifeq 173\n 36: aload_3\n 37: checkcast #86 // class kotlin/collections/IntIterator\n 40: invokevirtual #90 // Method kotlin/collections/IntIterator.nextInt:()I\n 43: istore 4\n 45: iload 4\n 47: istore 5\n 49: iconst_0\n 50: istore 6\n 52: new #69 // class kotlin/ranges/IntRange\n 55: dup\n 56: iconst_0\n 57: aload_0\n 58: getfield #27 // Field n:I\n 61: iconst_1\n 62: isub\n 63: invokespecial #72 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 66: checkcast #74 // class java/lang/Iterable\n 69: astore 7\n 71: iconst_0\n 72: istore 8\n 74: aload 7\n 76: invokeinterface #78, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 81: astore 9\n 83: aload 9\n 85: invokeinterface #84, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 90: ifeq 161\n 93: aload 9\n 95: checkcast #86 // class kotlin/collections/IntIterator\n 98: invokevirtual #90 // Method kotlin/collections/IntIterator.nextInt:()I\n 101: istore 10\n 103: iload 10\n 105: istore 11\n 107: iconst_0\n 108: istore 12\n 110: new #92 // class java/lang/StringBuilder\n 113: dup\n 114: invokespecial #93 // Method java/lang/StringBuilder.\"<init>\":()V\n 117: bipush 32\n 119: invokevirtual #97 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 122: aload_0\n 123: getfield #35 // Field solution:[[I\n 126: dup\n 127: ifnonnull 137\n 130: pop\n 131: ldc #58 // String solution\n 133: invokestatic #62 // Method kotlin/jvm/internal/Intrinsics.throwUninitializedPropertyAccessException:(Ljava/lang/String;)V\n 136: aconst_null\n 137: iload 5\n 139: aaload\n 140: iload 11\n 142: iaload\n 143: invokevirtual #100 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 146: invokevirtual #104 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 149: getstatic #47 // Field java/lang/System.out:Ljava/io/PrintStream;\n 152: swap\n 153: invokevirtual #107 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 156: nop\n 157: nop\n 158: goto 83\n 161: nop\n 162: getstatic #47 // Field java/lang/System.out:Ljava/io/PrintStream;\n 165: invokevirtual #109 // Method java/io/PrintStream.println:()V\n 168: nop\n 169: nop\n 170: goto 27\n 173: nop\n 174: return\n}\n", "javap_err": "" }, { "class_path": "ReciHub__FunnyAlgorithms__24518dd/RatMazeKt.class", "javap": "Compiled from \"RatMaze.kt\"\npublic final class RatMazeKt {\n public static final void main();\n Code:\n 0: iconst_4\n 1: anewarray #8 // class \"[I\"\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: iconst_4\n 8: newarray int\n 10: astore_2\n 11: aload_2\n 12: iconst_0\n 13: iconst_1\n 14: iastore\n 15: aload_2\n 16: iconst_1\n 17: iconst_0\n 18: iastore\n 19: aload_2\n 20: iconst_2\n 21: iconst_0\n 22: iastore\n 23: aload_2\n 24: iconst_3\n 25: iconst_0\n 26: iastore\n 27: aload_2\n 28: aastore\n 29: aload_1\n 30: iconst_1\n 31: iconst_4\n 32: newarray int\n 34: astore_2\n 35: aload_2\n 36: iconst_0\n 37: iconst_1\n 38: iastore\n 39: aload_2\n 40: iconst_1\n 41: iconst_1\n 42: iastore\n 43: aload_2\n 44: iconst_2\n 45: iconst_0\n 46: iastore\n 47: aload_2\n 48: iconst_3\n 49: iconst_1\n 50: iastore\n 51: aload_2\n 52: aastore\n 53: aload_1\n 54: iconst_2\n 55: iconst_4\n 56: newarray int\n 58: astore_2\n 59: aload_2\n 60: iconst_0\n 61: iconst_0\n 62: iastore\n 63: aload_2\n 64: iconst_1\n 65: iconst_1\n 66: iastore\n 67: aload_2\n 68: iconst_2\n 69: iconst_0\n 70: iastore\n 71: aload_2\n 72: iconst_3\n 73: iconst_0\n 74: iastore\n 75: aload_2\n 76: aastore\n 77: aload_1\n 78: iconst_3\n 79: iconst_4\n 80: newarray int\n 82: astore_2\n 83: aload_2\n 84: iconst_0\n 85: iconst_1\n 86: iastore\n 87: aload_2\n 88: iconst_1\n 89: iconst_1\n 90: iastore\n 91: aload_2\n 92: iconst_2\n 93: iconst_1\n 94: iastore\n 95: aload_2\n 96: iconst_3\n 97: iconst_1\n 98: iastore\n 99: aload_2\n 100: aastore\n 101: aload_1\n 102: astore_0\n 103: iconst_3\n 104: anewarray #8 // class \"[I\"\n 107: astore_2\n 108: aload_2\n 109: iconst_0\n 110: iconst_3\n 111: newarray int\n 113: astore_3\n 114: aload_3\n 115: iconst_0\n 116: iconst_1\n 117: iastore\n 118: aload_3\n 119: iconst_1\n 120: iconst_0\n 121: iastore\n 122: aload_3\n 123: iconst_2\n 124: iconst_0\n 125: iastore\n 126: aload_3\n 127: aastore\n 128: aload_2\n 129: iconst_1\n 130: iconst_3\n 131: newarray int\n 133: astore_3\n 134: aload_3\n 135: iconst_0\n 136: iconst_1\n 137: iastore\n 138: aload_3\n 139: iconst_1\n 140: iconst_1\n 141: iastore\n 142: aload_3\n 143: iconst_2\n 144: iconst_0\n 145: iastore\n 146: aload_3\n 147: aastore\n 148: aload_2\n 149: iconst_2\n 150: iconst_3\n 151: newarray int\n 153: astore_3\n 154: aload_3\n 155: iconst_0\n 156: iconst_0\n 157: iastore\n 158: aload_3\n 159: iconst_1\n 160: iconst_1\n 161: iastore\n 162: aload_3\n 163: iconst_2\n 164: iconst_1\n 165: iastore\n 166: aload_3\n 167: aastore\n 168: aload_2\n 169: astore_1\n 170: iconst_3\n 171: anewarray #8 // class \"[I\"\n 174: astore_3\n 175: aload_3\n 176: iconst_0\n 177: iconst_3\n 178: newarray int\n 180: astore 4\n 182: aload 4\n 184: iconst_0\n 185: iconst_1\n 186: iastore\n 187: aload 4\n 189: iconst_1\n 190: iconst_0\n 191: iastore\n 192: aload 4\n 194: iconst_2\n 195: iconst_0\n 196: iastore\n 197: aload 4\n 199: aastore\n 200: aload_3\n 201: iconst_1\n 202: iconst_3\n 203: newarray int\n 205: astore 4\n 207: aload 4\n 209: iconst_0\n 210: iconst_0\n 211: iastore\n 212: aload 4\n 214: iconst_1\n 215: iconst_0\n 216: iastore\n 217: aload 4\n 219: iconst_2\n 220: iconst_0\n 221: iastore\n 222: aload 4\n 224: aastore\n 225: aload_3\n 226: iconst_2\n 227: iconst_3\n 228: newarray int\n 230: astore 4\n 232: aload 4\n 234: iconst_0\n 235: iconst_0\n 236: iastore\n 237: aload 4\n 239: iconst_1\n 240: iconst_0\n 241: iastore\n 242: aload 4\n 244: iconst_2\n 245: iconst_1\n 246: iastore\n 247: aload 4\n 249: aastore\n 250: aload_3\n 251: astore_2\n 252: new #10 // class java/util/ArrayList\n 255: dup\n 256: invokespecial #13 // Method java/util/ArrayList.\"<init>\":()V\n 259: astore_3\n 260: aload_3\n 261: aload_0\n 262: invokevirtual #17 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 265: pop\n 266: aload_3\n 267: aload_1\n 268: invokevirtual #17 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 271: pop\n 272: aload_3\n 273: aload_2\n 274: invokevirtual #17 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 277: pop\n 278: new #19 // class RatMaze\n 281: dup\n 282: invokespecial #20 // Method RatMaze.\"<init>\":()V\n 285: astore 4\n 287: iconst_0\n 288: istore 5\n 290: aload_3\n 291: invokevirtual #24 // Method java/util/ArrayList.size:()I\n 294: istore 6\n 296: iload 5\n 298: iload 6\n 300: if_icmpge 371\n 303: new #26 // class java/lang/StringBuilder\n 306: dup\n 307: invokespecial #27 // Method java/lang/StringBuilder.\"<init>\":()V\n 310: ldc #29 // String Solving Maze\n 312: invokevirtual #33 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 315: iload 5\n 317: iconst_1\n 318: iadd\n 319: invokevirtual #36 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 322: invokevirtual #40 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 325: getstatic #46 // Field java/lang/System.out:Ljava/io/PrintStream;\n 328: swap\n 329: invokevirtual #52 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 332: getstatic #46 // Field java/lang/System.out:Ljava/io/PrintStream;\n 335: invokevirtual #54 // Method java/io/PrintStream.println:()V\n 338: aload 4\n 340: aload_3\n 341: iload 5\n 343: invokevirtual #58 // Method java/util/ArrayList.get:(I)Ljava/lang/Object;\n 346: dup\n 347: ldc #60 // String get(...)\n 349: invokestatic #66 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 352: checkcast #68 // class \"[[I\"\n 355: invokevirtual #72 // Method RatMaze.solve:([[I)Z\n 358: pop\n 359: getstatic #46 // Field java/lang/System.out:Ljava/io/PrintStream;\n 362: invokevirtual #54 // Method java/io/PrintStream.println:()V\n 365: iinc 5, 1\n 368: goto 296\n 371: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #84 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
ReciHub__FunnyAlgorithms__24518dd/BellmanFord/bellmanford.kt
class Edge(val source: Int, val destination: Int, val weight: Int) class Graph(val vertices: Int, val edges: List<Edge>) { fun bellmanFord(startVertex: Int) { val distance = IntArray(vertices) { Int.MAX_VALUE } distance[startVertex] = 0 for (i in 1 until vertices) { for (edge in edges) { if (distance[edge.source] != Int.MAX_VALUE && distance[edge.source] + edge.weight < distance[edge.destination]) { distance[edge.destination] = distance[edge.source] + edge.weight } } } for (edge in edges) { if (distance[edge.source] != Int.MAX_VALUE && distance[edge.source] + edge.weight < distance[edge.destination]) { println("Graph contains a negative-weight cycle.") return } } for (i in 0 until vertices) { println("Shortest distance from vertex $startVertex to vertex $i is ${distance[i]}") } } } fun main() { val vertices = 5 val edges = listOf( Edge(0, 1, -1), Edge(0, 2, 4), Edge(1, 2, 3), Edge(1, 3, 2), Edge(1, 4, 2), Edge(3, 2, 5), Edge(3, 1, 1), Edge(4, 3, -3) ) val graph = Graph(vertices, edges) val startVertex = 0 graph.bellmanFord(startVertex) }
[ { "class_path": "ReciHub__FunnyAlgorithms__24518dd/BellmanfordKt.class", "javap": "Compiled from \"bellmanford.kt\"\npublic final class BellmanfordKt {\n public static final void main();\n Code:\n 0: iconst_5\n 1: istore_0\n 2: bipush 8\n 4: anewarray #8 // class Edge\n 7: astore_2\n 8: aload_2\n 9: iconst_0\n 10: new #8 // class Edge\n 13: dup\n 14: iconst_0\n 15: iconst_1\n 16: iconst_m1\n 17: invokespecial #12 // Method Edge.\"<init>\":(III)V\n 20: aastore\n 21: aload_2\n 22: iconst_1\n 23: new #8 // class Edge\n 26: dup\n 27: iconst_0\n 28: iconst_2\n 29: iconst_4\n 30: invokespecial #12 // Method Edge.\"<init>\":(III)V\n 33: aastore\n 34: aload_2\n 35: iconst_2\n 36: new #8 // class Edge\n 39: dup\n 40: iconst_1\n 41: iconst_2\n 42: iconst_3\n 43: invokespecial #12 // Method Edge.\"<init>\":(III)V\n 46: aastore\n 47: aload_2\n 48: iconst_3\n 49: new #8 // class Edge\n 52: dup\n 53: iconst_1\n 54: iconst_3\n 55: iconst_2\n 56: invokespecial #12 // Method Edge.\"<init>\":(III)V\n 59: aastore\n 60: aload_2\n 61: iconst_4\n 62: new #8 // class Edge\n 65: dup\n 66: iconst_1\n 67: iconst_4\n 68: iconst_2\n 69: invokespecial #12 // Method Edge.\"<init>\":(III)V\n 72: aastore\n 73: aload_2\n 74: iconst_5\n 75: new #8 // class Edge\n 78: dup\n 79: iconst_3\n 80: iconst_2\n 81: iconst_5\n 82: invokespecial #12 // Method Edge.\"<init>\":(III)V\n 85: aastore\n 86: aload_2\n 87: bipush 6\n 89: new #8 // class Edge\n 92: dup\n 93: iconst_3\n 94: iconst_1\n 95: iconst_1\n 96: invokespecial #12 // Method Edge.\"<init>\":(III)V\n 99: aastore\n 100: aload_2\n 101: bipush 7\n 103: new #8 // class Edge\n 106: dup\n 107: iconst_4\n 108: iconst_3\n 109: bipush -3\n 111: invokespecial #12 // Method Edge.\"<init>\":(III)V\n 114: aastore\n 115: aload_2\n 116: invokestatic #18 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 119: astore_1\n 120: new #20 // class Graph\n 123: dup\n 124: iload_0\n 125: aload_1\n 126: invokespecial #23 // Method Graph.\"<init>\":(ILjava/util/List;)V\n 129: astore_2\n 130: iconst_0\n 131: istore_3\n 132: aload_2\n 133: iload_3\n 134: invokevirtual #27 // Method Graph.bellmanFord:(I)V\n 137: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #37 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
emergent__ProjectEuler__d04f502/Kotlin/problem021.kt
// Problem 21 - Project Euler // http://projecteuler.net/index.php?section=problems&id=21 import kotlin.math.* fun divisors(x: Int): List<Int> { val lim = ceil(sqrt(x.toDouble())).toInt() return (1..lim) .map { n -> if (x % n == 0) listOf(n, x/n) else null } .filterNotNull() .flatten() .distinct() .toList() } fun d(x: Int) = divisors(x).sum() - x fun amicable_pair(x: Int): Int? { val dx = d(x) return if (d(dx) == x && dx != x) dx else null } fun main(args: Array<String>) { val ans = (1..10000-1).map { amicable_pair(it) } .filterNotNull() .filter { it < 10000 } .sum() println(ans) }
[ { "class_path": "emergent__ProjectEuler__d04f502/Problem021Kt.class", "javap": "Compiled from \"problem021.kt\"\npublic final class Problem021Kt {\n public static final java.util.List<java.lang.Integer> divisors(int);\n Code:\n 0: iload_0\n 1: i2d\n 2: invokestatic #14 // Method java/lang/Math.sqrt:(D)D\n 5: invokestatic #17 // Method java/lang/Math.ceil:(D)D\n 8: d2i\n 9: istore_1\n 10: new #19 // class kotlin/ranges/IntRange\n 13: dup\n 14: iconst_1\n 15: iload_1\n 16: invokespecial #23 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 19: checkcast #25 // class java/lang/Iterable\n 22: astore_2\n 23: nop\n 24: iconst_0\n 25: istore_3\n 26: aload_2\n 27: astore 4\n 29: new #27 // class java/util/ArrayList\n 32: dup\n 33: aload_2\n 34: bipush 10\n 36: invokestatic #33 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 39: invokespecial #36 // Method java/util/ArrayList.\"<init>\":(I)V\n 42: checkcast #38 // class java/util/Collection\n 45: astore 5\n 47: iconst_0\n 48: istore 6\n 50: aload 4\n 52: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 57: astore 7\n 59: aload 7\n 61: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 66: ifeq 144\n 69: aload 7\n 71: checkcast #50 // class kotlin/collections/IntIterator\n 74: invokevirtual #54 // Method kotlin/collections/IntIterator.nextInt:()I\n 77: istore 8\n 79: aload 5\n 81: iload 8\n 83: istore 9\n 85: astore 12\n 87: iconst_0\n 88: istore 10\n 90: iload_0\n 91: iload 9\n 93: irem\n 94: ifne 131\n 97: iconst_2\n 98: anewarray #56 // class java/lang/Integer\n 101: astore 11\n 103: aload 11\n 105: iconst_0\n 106: iload 9\n 108: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 111: aastore\n 112: aload 11\n 114: iconst_1\n 115: iload_0\n 116: iload 9\n 118: idiv\n 119: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 122: aastore\n 123: aload 11\n 125: invokestatic #64 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 128: goto 132\n 131: aconst_null\n 132: aload 12\n 134: swap\n 135: invokeinterface #68, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 140: pop\n 141: goto 59\n 144: aload 5\n 146: checkcast #70 // class java/util/List\n 149: nop\n 150: checkcast #25 // class java/lang/Iterable\n 153: invokestatic #74 // Method kotlin/collections/CollectionsKt.filterNotNull:(Ljava/lang/Iterable;)Ljava/util/List;\n 156: checkcast #25 // class java/lang/Iterable\n 159: invokestatic #77 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 162: checkcast #25 // class java/lang/Iterable\n 165: invokestatic #80 // Method kotlin/collections/CollectionsKt.distinct:(Ljava/lang/Iterable;)Ljava/util/List;\n 168: checkcast #25 // class java/lang/Iterable\n 171: invokestatic #83 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 174: areturn\n\n public static final int d(int);\n Code:\n 0: iload_0\n 1: invokestatic #100 // Method divisors:(I)Ljava/util/List;\n 4: checkcast #25 // class java/lang/Iterable\n 7: invokestatic #104 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 10: iload_0\n 11: isub\n 12: ireturn\n\n public static final java.lang.Integer amicable_pair(int);\n Code:\n 0: iload_0\n 1: invokestatic #108 // Method d:(I)I\n 4: istore_1\n 5: iload_1\n 6: invokestatic #108 // Method d:(I)I\n 9: iload_0\n 10: if_icmpne 25\n 13: iload_1\n 14: iload_0\n 15: if_icmpeq 25\n 18: iload_1\n 19: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 22: goto 26\n 25: aconst_null\n 26: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #113 // String args\n 3: invokestatic #119 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #19 // class kotlin/ranges/IntRange\n 9: dup\n 10: iconst_1\n 11: sipush 9999\n 14: invokespecial #23 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 17: checkcast #25 // class java/lang/Iterable\n 20: astore_2\n 21: iconst_0\n 22: istore_3\n 23: aload_2\n 24: astore 4\n 26: new #27 // class java/util/ArrayList\n 29: dup\n 30: aload_2\n 31: bipush 10\n 33: invokestatic #33 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 36: invokespecial #36 // Method java/util/ArrayList.\"<init>\":(I)V\n 39: checkcast #38 // class java/util/Collection\n 42: astore 5\n 44: iconst_0\n 45: istore 6\n 47: aload 4\n 49: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 54: astore 7\n 56: aload 7\n 58: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 63: ifeq 104\n 66: aload 7\n 68: checkcast #50 // class kotlin/collections/IntIterator\n 71: invokevirtual #54 // Method kotlin/collections/IntIterator.nextInt:()I\n 74: istore 8\n 76: aload 5\n 78: iload 8\n 80: istore 9\n 82: astore 11\n 84: iconst_0\n 85: istore 10\n 87: iload 9\n 89: invokestatic #121 // Method amicable_pair:(I)Ljava/lang/Integer;\n 92: aload 11\n 94: swap\n 95: invokeinterface #68, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 100: pop\n 101: goto 56\n 104: aload 5\n 106: checkcast #70 // class java/util/List\n 109: nop\n 110: checkcast #25 // class java/lang/Iterable\n 113: invokestatic #74 // Method kotlin/collections/CollectionsKt.filterNotNull:(Ljava/lang/Iterable;)Ljava/util/List;\n 116: checkcast #25 // class java/lang/Iterable\n 119: astore_2\n 120: nop\n 121: iconst_0\n 122: istore_3\n 123: aload_2\n 124: astore 4\n 126: new #27 // class java/util/ArrayList\n 129: dup\n 130: invokespecial #124 // Method java/util/ArrayList.\"<init>\":()V\n 133: checkcast #38 // class java/util/Collection\n 136: astore 5\n 138: iconst_0\n 139: istore 6\n 141: aload 4\n 143: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 148: astore 7\n 150: aload 7\n 152: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 157: ifeq 211\n 160: aload 7\n 162: invokeinterface #128, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 167: astore 8\n 169: aload 8\n 171: checkcast #130 // class java/lang/Number\n 174: invokevirtual #133 // Method java/lang/Number.intValue:()I\n 177: istore 9\n 179: iconst_0\n 180: istore 10\n 182: iload 9\n 184: sipush 10000\n 187: if_icmpge 194\n 190: iconst_1\n 191: goto 195\n 194: iconst_0\n 195: ifeq 150\n 198: aload 5\n 200: aload 8\n 202: invokeinterface #68, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 207: pop\n 208: goto 150\n 211: aload 5\n 213: checkcast #70 // class java/util/List\n 216: nop\n 217: checkcast #25 // class java/lang/Iterable\n 220: invokestatic #104 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 223: istore_1\n 224: getstatic #139 // Field java/lang/System.out:Ljava/io/PrintStream;\n 227: iload_1\n 228: invokevirtual #144 // Method java/io/PrintStream.println:(I)V\n 231: return\n}\n", "javap_err": "" } ]
emergent__ProjectEuler__d04f502/Kotlin/problem011.kt
// Problem 11 - Project Euler // http://projecteuler.net/index.php?section=problems&id=11 fun main(args: Array<String>) { val d = """ 08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08 49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00 81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65 52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91 22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80 24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50 32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70 67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21 24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72 21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95 78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92 16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57 86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58 19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40 04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66 88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69 04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36 20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16 20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54 01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48 """ .trim() .split("\n") .map { it.split(" ").map { it.toInt() } } var ans = 0; for (i in 0..20-1) { for (j in 0..20-1) { val right = if (j < 17) d[i][j] * d[i][j+1] * d[i][j+2] * d[i][j+3] else 0 val down = if (i < 17) d[i][j] * d[i+1][j] * d[i+2][j] * d[i+3][j] else 0 val dr = if (i < 17 && j < 17) d[i][j] * d[i+1][j+1] * d[i+2][j+2] * d[i+3][j+3] else 0 val dl = if (i < 17 && j >= 3) d[i][j] * d[i+1][j-1] * d[i+2][j-2] * d[i+3][j-3] else 0 ans = listOf(right, down, dr, dl, ans).max() ?: ans } } println(ans) }
[ { "class_path": "emergent__ProjectEuler__d04f502/Problem011Kt.class", "javap": "Compiled from \"problem011.kt\"\npublic final class Problem011Kt {\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: nop\n 7: ldc #17 // String \\n08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08\\n49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00\\n81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65\\n52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91\\n22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80\\n24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50\\n32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70\\n67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21\\n24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72\\n21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95\\n78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92\\n16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57\\n86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58\\n19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40\\n04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66\\n88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69\\n04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36\\n20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16\\n20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54\\n01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48\\n\n 9: checkcast #19 // class java/lang/CharSequence\n 12: invokestatic #25 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 15: invokevirtual #29 // Method java/lang/Object.toString:()Ljava/lang/String;\n 18: checkcast #19 // class java/lang/CharSequence\n 21: iconst_1\n 22: anewarray #31 // class java/lang/String\n 25: astore_2\n 26: aload_2\n 27: iconst_0\n 28: ldc #33 // String \\n\n 30: aastore\n 31: aload_2\n 32: iconst_0\n 33: iconst_0\n 34: bipush 6\n 36: aconst_null\n 37: invokestatic #37 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 40: checkcast #39 // class java/lang/Iterable\n 43: astore_2\n 44: nop\n 45: iconst_0\n 46: istore_3\n 47: aload_2\n 48: astore 4\n 50: new #41 // class java/util/ArrayList\n 53: dup\n 54: aload_2\n 55: bipush 10\n 57: invokestatic #47 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 60: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 63: checkcast #53 // class java/util/Collection\n 66: astore 5\n 68: iconst_0\n 69: istore 6\n 71: aload 4\n 73: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 78: astore 7\n 80: aload 7\n 82: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 87: ifeq 256\n 90: aload 7\n 92: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 97: astore 8\n 99: aload 5\n 101: aload 8\n 103: checkcast #31 // class java/lang/String\n 106: astore 9\n 108: astore 21\n 110: iconst_0\n 111: istore 10\n 113: aload 9\n 115: checkcast #19 // class java/lang/CharSequence\n 118: iconst_1\n 119: anewarray #31 // class java/lang/String\n 122: astore 11\n 124: aload 11\n 126: iconst_0\n 127: ldc #69 // String\n 129: aastore\n 130: aload 11\n 132: iconst_0\n 133: iconst_0\n 134: bipush 6\n 136: aconst_null\n 137: invokestatic #37 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 140: checkcast #39 // class java/lang/Iterable\n 143: astore 11\n 145: iconst_0\n 146: istore 12\n 148: aload 11\n 150: astore 13\n 152: new #41 // class java/util/ArrayList\n 155: dup\n 156: aload 11\n 158: bipush 10\n 160: invokestatic #47 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 163: invokespecial #51 // Method java/util/ArrayList.\"<init>\":(I)V\n 166: checkcast #53 // class java/util/Collection\n 169: astore 14\n 171: iconst_0\n 172: istore 15\n 174: aload 13\n 176: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 181: astore 16\n 183: aload 16\n 185: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 190: ifeq 237\n 193: aload 16\n 195: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 200: astore 17\n 202: aload 14\n 204: aload 17\n 206: checkcast #31 // class java/lang/String\n 209: astore 18\n 211: astore 19\n 213: iconst_0\n 214: istore 20\n 216: aload 18\n 218: invokestatic #75 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 221: nop\n 222: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 225: aload 19\n 227: swap\n 228: invokeinterface #83, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 233: pop\n 234: goto 183\n 237: aload 14\n 239: checkcast #85 // class java/util/List\n 242: nop\n 243: nop\n 244: aload 21\n 246: swap\n 247: invokeinterface #83, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 252: pop\n 253: goto 80\n 256: aload 5\n 258: checkcast #85 // class java/util/List\n 261: nop\n 262: astore_1\n 263: iconst_0\n 264: istore_2\n 265: iconst_0\n 266: istore_3\n 267: iload_3\n 268: bipush 20\n 270: if_icmpge 841\n 273: iconst_0\n 274: istore 4\n 276: iload 4\n 278: bipush 20\n 280: if_icmpge 835\n 283: iload 4\n 285: bipush 17\n 287: if_icmpge 394\n 290: aload_1\n 291: iload_3\n 292: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 297: checkcast #85 // class java/util/List\n 300: iload 4\n 302: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 307: checkcast #91 // class java/lang/Number\n 310: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 313: aload_1\n 314: iload_3\n 315: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 320: checkcast #85 // class java/util/List\n 323: iload 4\n 325: iconst_1\n 326: iadd\n 327: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 332: checkcast #91 // class java/lang/Number\n 335: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 338: imul\n 339: aload_1\n 340: iload_3\n 341: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 346: checkcast #85 // class java/util/List\n 349: iload 4\n 351: iconst_2\n 352: iadd\n 353: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 358: checkcast #91 // class java/lang/Number\n 361: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 364: imul\n 365: aload_1\n 366: iload_3\n 367: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 372: checkcast #85 // class java/util/List\n 375: iload 4\n 377: iconst_3\n 378: iadd\n 379: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 384: checkcast #91 // class java/lang/Number\n 387: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 390: imul\n 391: goto 395\n 394: iconst_0\n 395: istore 5\n 397: iload_3\n 398: bipush 17\n 400: if_icmpge 507\n 403: aload_1\n 404: iload_3\n 405: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 410: checkcast #85 // class java/util/List\n 413: iload 4\n 415: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 420: checkcast #91 // class java/lang/Number\n 423: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 426: aload_1\n 427: iload_3\n 428: iconst_1\n 429: iadd\n 430: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 435: checkcast #85 // class java/util/List\n 438: iload 4\n 440: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 445: checkcast #91 // class java/lang/Number\n 448: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 451: imul\n 452: aload_1\n 453: iload_3\n 454: iconst_2\n 455: iadd\n 456: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 461: checkcast #85 // class java/util/List\n 464: iload 4\n 466: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 471: checkcast #91 // class java/lang/Number\n 474: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 477: imul\n 478: aload_1\n 479: iload_3\n 480: iconst_3\n 481: iadd\n 482: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 487: checkcast #85 // class java/util/List\n 490: iload 4\n 492: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 497: checkcast #91 // class java/lang/Number\n 500: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 503: imul\n 504: goto 508\n 507: iconst_0\n 508: istore 6\n 510: iload_3\n 511: bipush 17\n 513: if_icmpge 633\n 516: iload 4\n 518: bipush 17\n 520: if_icmpge 633\n 523: aload_1\n 524: iload_3\n 525: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 530: checkcast #85 // class java/util/List\n 533: iload 4\n 535: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 540: checkcast #91 // class java/lang/Number\n 543: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 546: aload_1\n 547: iload_3\n 548: iconst_1\n 549: iadd\n 550: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 555: checkcast #85 // class java/util/List\n 558: iload 4\n 560: iconst_1\n 561: iadd\n 562: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 567: checkcast #91 // class java/lang/Number\n 570: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 573: imul\n 574: aload_1\n 575: iload_3\n 576: iconst_2\n 577: iadd\n 578: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 583: checkcast #85 // class java/util/List\n 586: iload 4\n 588: iconst_2\n 589: iadd\n 590: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 595: checkcast #91 // class java/lang/Number\n 598: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 601: imul\n 602: aload_1\n 603: iload_3\n 604: iconst_3\n 605: iadd\n 606: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 611: checkcast #85 // class java/util/List\n 614: iload 4\n 616: iconst_3\n 617: iadd\n 618: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 623: checkcast #91 // class java/lang/Number\n 626: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 629: imul\n 630: goto 634\n 633: iconst_0\n 634: istore 7\n 636: iload_3\n 637: bipush 17\n 639: if_icmpge 758\n 642: iload 4\n 644: iconst_3\n 645: if_icmplt 758\n 648: aload_1\n 649: iload_3\n 650: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 655: checkcast #85 // class java/util/List\n 658: iload 4\n 660: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 665: checkcast #91 // class java/lang/Number\n 668: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 671: aload_1\n 672: iload_3\n 673: iconst_1\n 674: iadd\n 675: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 680: checkcast #85 // class java/util/List\n 683: iload 4\n 685: iconst_1\n 686: isub\n 687: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 692: checkcast #91 // class java/lang/Number\n 695: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 698: imul\n 699: aload_1\n 700: iload_3\n 701: iconst_2\n 702: iadd\n 703: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 708: checkcast #85 // class java/util/List\n 711: iload 4\n 713: iconst_2\n 714: isub\n 715: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 720: checkcast #91 // class java/lang/Number\n 723: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 726: imul\n 727: aload_1\n 728: iload_3\n 729: iconst_3\n 730: iadd\n 731: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 736: checkcast #85 // class java/util/List\n 739: iload 4\n 741: iconst_3\n 742: isub\n 743: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 748: checkcast #91 // class java/lang/Number\n 751: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 754: imul\n 755: goto 759\n 758: iconst_0\n 759: istore 8\n 761: iconst_5\n 762: anewarray #71 // class java/lang/Integer\n 765: astore 10\n 767: aload 10\n 769: iconst_0\n 770: iload 5\n 772: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 775: aastore\n 776: aload 10\n 778: iconst_1\n 779: iload 6\n 781: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 784: aastore\n 785: aload 10\n 787: iconst_2\n 788: iload 7\n 790: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 793: aastore\n 794: aload 10\n 796: iconst_3\n 797: iload 8\n 799: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 802: aastore\n 803: aload 10\n 805: iconst_4\n 806: iload_2\n 807: invokestatic #79 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 810: aastore\n 811: aload 10\n 813: invokestatic #99 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 816: checkcast #39 // class java/lang/Iterable\n 819: invokestatic #103 // Method kotlin/collections/CollectionsKt.maxOrThrow:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 822: checkcast #91 // class java/lang/Number\n 825: invokevirtual #95 // Method java/lang/Number.intValue:()I\n 828: istore_2\n 829: iinc 4, 1\n 832: goto 276\n 835: iinc 3, 1\n 838: goto 267\n 841: getstatic #109 // Field java/lang/System.out:Ljava/io/PrintStream;\n 844: iload_2\n 845: invokevirtual #114 // Method java/io/PrintStream.println:(I)V\n 848: return\n}\n", "javap_err": "" } ]
alexy2008__HelloPrime__dac2f59/original/Kotlin/KtHelloPrime.kt
import kotlin.math.ceil import kotlin.math.pow fun primeByEuler(page: Int, prime: KtPrime) { val num = BooleanArray(page) for (i in 2 until page) { if (!num[i]) prime.add(i.toLong()) for (j in 0 until prime.size() ){ if (i.toLong() * prime.getitem(j) >= page) break num[(i * prime.getitem(j)).toInt()] = true if (i % prime.getitem(j) == 0L) break } } } fun primeByEratosthenesInterval(pos: Long, page: Int, prime: KtPrime) { val num = BooleanArray(page) for (i in 0 until prime.size()) { val p = prime.getitem(i) if (p * p >= pos + page) break for (j in ceil(pos * 1.0 / p).toLong() until ((pos + page - 1) / p).toLong() + 1) num[(j * p - pos).toInt()] = true } for (i in num.indices) if (!num[i]) prime.add(pos + i) } fun main(args: Array<String>) { println("Hello sample.Prime! I'm Kotlin :-)") val limit = args[0].toLong() val page = args[1].toInt() val mode = args[2].toInt() val prime = KtPrime(limit, page, mode) println("使用分区埃拉托色尼筛选法计算${prime.getDfString(limit)}以内素数:") val costTime = kotlin.system.measureTimeMillis { //首先使用欧拉法得到种子素数组 primeByEuler(page, prime) prime.generateResults(page.toLong()) //循环使用埃拉托色尼法计算分区 for (i in 1 until limit/page) { val pos = page * i primeByEratosthenesInterval(pos, page, prime) prime.generateResults(pos + page) } } prime.printTable() System.out.printf("Kotline finished within %.0e the %dth prime is %d; time cost: %d ms \n", limit.toDouble(), prime.maxInd, prime.maxPrime, costTime) } class KtPrime(limit: Long, page: Int, private val mode: Int) { var maxInd: Long = 0 var maxPrime: Long = 0 private val maxKeep: Int = (Math.sqrt(limit.toDouble()) / Math.log(Math.sqrt(limit.toDouble())) * 1.3).toInt() var reserve = ((Math.sqrt(limit.toDouble()) + page) / Math.log(Math.sqrt(limit.toDouble()) + page) * 1.3).toInt() private val primeList: ArrayList<Long> = ArrayList(reserve) private val seqList = ArrayList<String>() private val interList = ArrayList<String>() private var prevNo: Long = 0 fun getitem(index: Int): Long { return primeList[index] } fun size(): Int { return primeList.size } fun add(p: Long) { primeList.add(p) maxInd++ } fun generateResults(inter: Long) { if (mode > 0) { putSequence(prevNo) putInterval(inter) prevNo = maxInd } maxPrime = primeList[primeList.size - 1] freeUp() } private fun putInterval(inter: Long) { val s: String if (inter % 10.0.pow(inter.toString().length - 1.toDouble()) == 0.0) { s = "${getDfString(inter)}|$maxInd|${getitem(size() - 1)}" interList.add(s) if (mode > 1) println("[In:]$s") } } private fun putSequence(beginNo: Long) { for (i in beginNo.toString().length - 1 until maxInd.toString().length) { for (j in 1..9) { val seq = (j * 10.0.pow(i.toDouble())).toLong() if (seq < beginNo) continue if (seq >= maxInd) return val l = getitem(size() - 1 - (maxInd - seq).toInt()) var s = getDfString(seq) + "|" + l seqList.add(s) if (mode > 1) println("==>[No:]$s") } } } private fun freeUp() { if (maxInd > maxKeep) primeList.subList(maxKeep, primeList.size - 1).clear() } fun printTable() { if (mode < 1) return println("## 素数序列表") println("序号|数值") println("---|---") seqList.forEach { x: String? -> println(x) } println("## 素数区间表") println("区间|个数|最大值") println("---|---|---") interList.forEach { x: String? -> println(x) } } fun getDfString(l: Long): String { var s = l.toString() when { l % 1000000000000L == 0L -> { s = s.substring(0, s.length - 12) + "万亿" } l % 100000000L == 0L -> { s = s.substring(0, s.length - 8) + "亿" } l % 10000 == 0L -> { s = s.substring(0, s.length - 4) + "万" } } return s } init { println("内存分配:$reserve") } }
[ { "class_path": "alexy2008__HelloPrime__dac2f59/KtHelloPrimeKt.class", "javap": "Compiled from \"KtHelloPrime.kt\"\npublic final class KtHelloPrimeKt {\n public static final void primeByEuler(int, KtPrime);\n Code:\n 0: aload_1\n 1: ldc #9 // String prime\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_0\n 7: newarray boolean\n 9: astore_2\n 10: iconst_2\n 11: istore_3\n 12: iload_3\n 13: iload_0\n 14: if_icmpge 99\n 17: aload_2\n 18: iload_3\n 19: baload\n 20: ifne 29\n 23: aload_1\n 24: iload_3\n 25: i2l\n 26: invokevirtual #21 // Method KtPrime.add:(J)V\n 29: iconst_0\n 30: istore 4\n 32: aload_1\n 33: invokevirtual #25 // Method KtPrime.size:()I\n 36: istore 5\n 38: iload 4\n 40: iload 5\n 42: if_icmpge 93\n 45: iload_3\n 46: i2l\n 47: aload_1\n 48: iload 4\n 50: invokevirtual #29 // Method KtPrime.getitem:(I)J\n 53: lmul\n 54: iload_0\n 55: i2l\n 56: lcmp\n 57: ifge 93\n 60: aload_2\n 61: iload_3\n 62: i2l\n 63: aload_1\n 64: iload 4\n 66: invokevirtual #29 // Method KtPrime.getitem:(I)J\n 69: lmul\n 70: l2i\n 71: iconst_1\n 72: bastore\n 73: iload_3\n 74: i2l\n 75: aload_1\n 76: iload 4\n 78: invokevirtual #29 // Method KtPrime.getitem:(I)J\n 81: lrem\n 82: lconst_0\n 83: lcmp\n 84: ifeq 93\n 87: iinc 4, 1\n 90: goto 38\n 93: iinc 3, 1\n 96: goto 12\n 99: return\n\n public static final void primeByEratosthenesInterval(long, int, KtPrime);\n Code:\n 0: aload_3\n 1: ldc #9 // String prime\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_2\n 7: newarray boolean\n 9: astore 4\n 11: iconst_0\n 12: istore 5\n 14: aload_3\n 15: invokevirtual #25 // Method KtPrime.size:()I\n 18: istore 6\n 20: iload 5\n 22: iload 6\n 24: if_icmpge 110\n 27: aload_3\n 28: iload 5\n 30: invokevirtual #29 // Method KtPrime.getitem:(I)J\n 33: lstore 7\n 35: lload 7\n 37: lload 7\n 39: lmul\n 40: lload_0\n 41: iload_2\n 42: i2l\n 43: ladd\n 44: lcmp\n 45: ifge 110\n 48: lload_0\n 49: l2d\n 50: dconst_1\n 51: dmul\n 52: lload 7\n 54: l2d\n 55: ddiv\n 56: invokestatic #45 // Method java/lang/Math.ceil:(D)D\n 59: d2l\n 60: lstore 9\n 62: lload_0\n 63: iload_2\n 64: i2l\n 65: ladd\n 66: lconst_1\n 67: lsub\n 68: lload 7\n 70: ldiv\n 71: lconst_1\n 72: ladd\n 73: lstore 11\n 75: lload 9\n 77: lload 11\n 79: lcmp\n 80: ifge 104\n 83: aload 4\n 85: lload 9\n 87: lload 7\n 89: lmul\n 90: lload_0\n 91: lsub\n 92: l2i\n 93: iconst_1\n 94: bastore\n 95: lload 9\n 97: lconst_1\n 98: ladd\n 99: lstore 9\n 101: goto 75\n 104: iinc 5, 1\n 107: goto 20\n 110: iconst_0\n 111: istore 5\n 113: aload 4\n 115: arraylength\n 116: istore 6\n 118: iload 5\n 120: iload 6\n 122: if_icmpge 148\n 125: aload 4\n 127: iload 5\n 129: baload\n 130: ifne 142\n 133: aload_3\n 134: lload_0\n 135: iload 5\n 137: i2l\n 138: ladd\n 139: invokevirtual #21 // Method KtPrime.add:(J)V\n 142: iinc 5, 1\n 145: goto 118\n 148: return\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #52 // String args\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #54 // String Hello sample.Prime! I\\'m Kotlin :-)\n 8: getstatic #60 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: swap\n 12: invokevirtual #66 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 15: aload_0\n 16: iconst_0\n 17: aaload\n 18: invokestatic #72 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 21: lstore_1\n 22: aload_0\n 23: iconst_1\n 24: aaload\n 25: invokestatic #78 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 28: istore_3\n 29: aload_0\n 30: iconst_2\n 31: aaload\n 32: invokestatic #78 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 35: istore 4\n 37: new #17 // class KtPrime\n 40: dup\n 41: lload_1\n 42: iload_3\n 43: iload 4\n 45: invokespecial #82 // Method KtPrime.\"<init>\":(JII)V\n 48: astore 5\n 50: new #84 // class java/lang/StringBuilder\n 53: dup\n 54: invokespecial #87 // Method java/lang/StringBuilder.\"<init>\":()V\n 57: ldc #89 // String 使用分区埃拉托色尼筛选法计算\n 59: invokevirtual #93 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 62: aload 5\n 64: lload_1\n 65: invokevirtual #97 // Method KtPrime.getDfString:(J)Ljava/lang/String;\n 68: invokevirtual #93 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 71: ldc #99 // String 以内素数:\n 73: invokevirtual #93 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 76: invokevirtual #103 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 79: getstatic #60 // Field java/lang/System.out:Ljava/io/PrintStream;\n 82: swap\n 83: invokevirtual #66 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 86: iconst_0\n 87: istore 8\n 89: invokestatic #107 // Method java/lang/System.currentTimeMillis:()J\n 92: lstore 9\n 94: iconst_0\n 95: istore 11\n 97: iload_3\n 98: aload 5\n 100: invokestatic #109 // Method primeByEuler:(ILKtPrime;)V\n 103: aload 5\n 105: iload_3\n 106: i2l\n 107: invokevirtual #112 // Method KtPrime.generateResults:(J)V\n 110: lconst_1\n 111: lstore 12\n 113: lload_1\n 114: iload_3\n 115: i2l\n 116: ldiv\n 117: lstore 14\n 119: lload 12\n 121: lload 14\n 123: lcmp\n 124: ifge 161\n 127: iload_3\n 128: i2l\n 129: lload 12\n 131: lmul\n 132: lstore 16\n 134: lload 16\n 136: iload_3\n 137: aload 5\n 139: invokestatic #114 // Method primeByEratosthenesInterval:(JILKtPrime;)V\n 142: aload 5\n 144: lload 16\n 146: iload_3\n 147: i2l\n 148: ladd\n 149: invokevirtual #112 // Method KtPrime.generateResults:(J)V\n 152: lload 12\n 154: lconst_1\n 155: ladd\n 156: lstore 12\n 158: goto 119\n 161: nop\n 162: nop\n 163: invokestatic #107 // Method java/lang/System.currentTimeMillis:()J\n 166: lload 9\n 168: lsub\n 169: lstore 6\n 171: aload 5\n 173: invokevirtual #117 // Method KtPrime.printTable:()V\n 176: getstatic #60 // Field java/lang/System.out:Ljava/io/PrintStream;\n 179: ldc #119 // String Kotline finished within %.0e the %dth prime is %d; time cost: %d ms \\n\n 181: iconst_4\n 182: anewarray #4 // class java/lang/Object\n 185: astore 8\n 187: aload 8\n 189: iconst_0\n 190: lload_1\n 191: l2d\n 192: invokestatic #125 // Method java/lang/Double.valueOf:(D)Ljava/lang/Double;\n 195: aastore\n 196: aload 8\n 198: iconst_1\n 199: aload 5\n 201: invokevirtual #128 // Method KtPrime.getMaxInd:()J\n 204: invokestatic #131 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 207: aastore\n 208: aload 8\n 210: iconst_2\n 211: aload 5\n 213: invokevirtual #134 // Method KtPrime.getMaxPrime:()J\n 216: invokestatic #131 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 219: aastore\n 220: aload 8\n 222: iconst_3\n 223: lload 6\n 225: invokestatic #131 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 228: aastore\n 229: aload 8\n 231: invokevirtual #138 // Method java/io/PrintStream.printf:(Ljava/lang/String;[Ljava/lang/Object;)Ljava/io/PrintStream;\n 234: pop\n 235: return\n}\n", "javap_err": "" } ]
gavq__kakuro-kotlin__413f26d/src/main/kotlin/main.kt
fun pad2(n: Int): String { val s = "$n" return if (s.length < 2) " $s" else s } interface ICell { fun draw(): String } interface IDown { val down: Int } interface IAcross { val across: Int } // singleton object EmptyCell : ICell { override fun toString() = "EmptyCell" override fun draw() = " ----- " } data class DownCell(override val down: Int) : ICell, IDown { override fun draw() = " ${pad2(down)}\\-- " } data class AcrossCell(override val across: Int) : ICell, IAcross { override fun draw() = " --\\${pad2(across)} " } data class DownAcrossCell(override val down: Int, override val across: Int) : ICell, IDown, IAcross { override fun draw() = " ${pad2(down)}\\${pad2(across)} " } data class ValueCell(val values: Set<Int>) : ICell { override fun draw(): String { return when (values.size) { 1 -> " ${values.first()} " else -> (1..9).joinToString(separator = "", prefix = " ", transform = ::drawOneValue) } } fun isPossible(n: Int) = values.contains(n) private fun drawOneValue(it: Int) = if (it in values) "$it" else "." } fun da(d: Int, a: Int) = DownAcrossCell(d, a) fun d(d: Int) = DownCell(d) fun a(a: Int) = AcrossCell(a) fun e() = EmptyCell fun v() = ValueCell(setOf(1, 2, 3, 4, 5, 6, 7, 8, 9)) fun v(vararg args: Int) = ValueCell(args.toSet()) fun v(args: List<Int>) = ValueCell(args.toSet()) data class SimplePair<T>(val first: T, val second: T) fun drawRow(row: Collection<ICell>): String { return row.joinToString(separator = "", postfix = "\n", transform = ICell::draw) } fun drawGrid(grid: Collection<Collection<ICell>>): String { return grid.joinToString(transform = ::drawRow) } fun <T> allDifferent(nums: Collection<T>): Boolean { return nums.size == HashSet(nums).size } fun <T> product(colls: List<Set<T>>): List<List<T>> { return when (colls.size) { 0 -> emptyList() 1 -> colls[0].map { listOf(it) } else -> { val head = colls[0] val tail = colls.drop(1) val tailProd = product(tail) return head.flatMap { x -> tailProd.map { listOf(x) + it } } } } } fun permuteAll(vs: List<ValueCell>, target: Int): List<List<Int>> { val values = vs.map { it.values } return product(values) .filter { target == it.sum() } } fun <T> transpose(m: List<List<T>>): List<List<T>> { return when { m.isEmpty() -> emptyList() else -> { (1..m[0].size) .map { m.map { col -> col[it - 1] } } } } } fun <T> partitionBy(f: (T) -> Boolean, coll: List<T>): List<List<T>> { return when { coll.isEmpty() -> emptyList() else -> { val head = coll[0] val fx = f(head) val group = coll.takeWhile { fx == f(it) } listOf(group) + partitionBy(f, coll.drop(group.size)) } } } fun <T> partitionAll(n: Int, step: Int, coll: List<T>): List<List<T>> { return when { coll.isEmpty() -> emptyList() else -> { listOf(coll.take(n)) + partitionAll(n, step, coll.drop(step)) } } } fun <T> partitionN(n: Int, coll: List<T>): List<List<T>> = partitionAll(n, n, coll) fun solveStep(cells: List<ValueCell>, total: Int): List<ValueCell> { val finalIndex = cells.size - 1 val perms = permuteAll(cells, total) .filter { cells.last().isPossible(it[finalIndex]) } .filter { allDifferent(it) } return transpose(perms).map { v(it) } } fun gatherValues(line: List<ICell>): List<List<ICell>> { return partitionBy({ it is ValueCell }, line) } fun pairTargetsWithValues(line: List<ICell>): List<SimplePair<List<ICell>>> { return partitionN(2, gatherValues(line)) .map { SimplePair(it[0], if (1 == it.size) emptyList() else it[1]) } } fun solvePair(accessor: (ICell) -> Int, pair: SimplePair<List<ICell>>): List<ICell> { val notValueCells = pair.first return when { pair.second.isEmpty() -> notValueCells else -> { val valueCells = pair.second.map { it as ValueCell } val total = accessor(notValueCells.last()) val newValueCells = solveStep(valueCells, total) notValueCells + newValueCells } } } fun solveLine(line: List<ICell>, f: (ICell) -> Int): List<ICell> { return pairTargetsWithValues(line) .map { solvePair(f, it) } .flatten() } fun solveRow(row: List<ICell>): List<ICell> { return solveLine(row, { (it as IAcross).across }) } fun solveColumn(column: List<ICell>): List<ICell> { return solveLine(column, { (it as IDown).down }) } fun solveGrid(grid: List<List<ICell>>): List<List<ICell>> { val rowsDone = grid.map(::solveRow) val colsDone = transpose(rowsDone).map(::solveColumn) return transpose(colsDone) } fun solver(grid: List<List<ICell>>): List<List<ICell>> { println(drawGrid(grid)) val g = solveGrid(grid) return if (g == grid) g else solver(g) }
[ { "class_path": "gavq__kakuro-kotlin__413f26d/MainKt$drawRow$1.class", "javap": "Compiled from \"main.kt\"\nfinal class MainKt$drawRow$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<ICell, java.lang.String> {\n public static final MainKt$drawRow$1 INSTANCE;\n\n MainKt$drawRow$1();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class ICell\n 4: ldc #13 // String draw\n 6: ldc #15 // String draw()Ljava/lang/String;\n 8: iconst_0\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.String invoke(ICell);\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_1\n 7: invokeinterface #33, 1 // InterfaceMethod ICell.draw:()Ljava/lang/String;\n 12: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #11 // class ICell\n 5: invokevirtual #37 // Method invoke:(LICell;)Ljava/lang/String;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class MainKt$drawRow$1\n 3: dup\n 4: invokespecial #42 // Method \"<init>\":()V\n 7: putstatic #45 // Field INSTANCE:LMainKt$drawRow$1;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "gavq__kakuro-kotlin__413f26d/MainKt$drawGrid$1.class", "javap": "Compiled from \"main.kt\"\nfinal class MainKt$drawGrid$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.util.Collection<? extends ICell>, java.lang.String> {\n public static final MainKt$drawGrid$1 INSTANCE;\n\n MainKt$drawGrid$1();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class MainKt\n 4: ldc #13 // String drawRow\n 6: ldc #15 // String drawRow(Ljava/util/Collection;)Ljava/lang/String;\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.String invoke(java.util.Collection<? extends ICell>);\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 MainKt.drawRow:(Ljava/util/Collection;)Ljava/lang/String;\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 java/util/Collection\n 5: invokevirtual #39 // Method invoke:(Ljava/util/Collection;)Ljava/lang/String;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class MainKt$drawGrid$1\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:LMainKt$drawGrid$1;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "gavq__kakuro-kotlin__413f26d/MainKt.class", "javap": "Compiled from \"main.kt\"\npublic final class MainKt {\n public static final java.lang.String pad2(int);\n Code:\n 0: iload_0\n 1: invokestatic #12 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 4: astore_1\n 5: aload_1\n 6: invokevirtual #16 // Method java/lang/String.length:()I\n 9: iconst_2\n 10: if_icmpge 35\n 13: new #18 // class java/lang/StringBuilder\n 16: dup\n 17: invokespecial #22 // Method java/lang/StringBuilder.\"<init>\":()V\n 20: bipush 32\n 22: invokevirtual #26 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 25: aload_1\n 26: invokevirtual #29 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 29: invokevirtual #33 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 32: goto 36\n 35: aload_1\n 36: areturn\n\n public static final DownAcrossCell da(int, int);\n Code:\n 0: new #41 // class DownAcrossCell\n 3: dup\n 4: iload_0\n 5: iload_1\n 6: invokespecial #44 // Method DownAcrossCell.\"<init>\":(II)V\n 9: areturn\n\n public static final DownCell d(int);\n Code:\n 0: new #49 // class DownCell\n 3: dup\n 4: iload_0\n 5: invokespecial #52 // Method DownCell.\"<init>\":(I)V\n 8: areturn\n\n public static final AcrossCell a(int);\n Code:\n 0: new #55 // class AcrossCell\n 3: dup\n 4: iload_0\n 5: invokespecial #56 // Method AcrossCell.\"<init>\":(I)V\n 8: areturn\n\n public static final EmptyCell e();\n Code:\n 0: getstatic #64 // Field EmptyCell.INSTANCE:LEmptyCell;\n 3: areturn\n\n public static final ValueCell v();\n Code:\n 0: new #68 // class ValueCell\n 3: dup\n 4: bipush 9\n 6: anewarray #70 // class java/lang/Integer\n 9: astore_0\n 10: aload_0\n 11: iconst_0\n 12: iconst_1\n 13: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 16: aastore\n 17: aload_0\n 18: iconst_1\n 19: iconst_2\n 20: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 23: aastore\n 24: aload_0\n 25: iconst_2\n 26: iconst_3\n 27: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 30: aastore\n 31: aload_0\n 32: iconst_3\n 33: iconst_4\n 34: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 37: aastore\n 38: aload_0\n 39: iconst_4\n 40: iconst_5\n 41: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 44: aastore\n 45: aload_0\n 46: iconst_5\n 47: bipush 6\n 49: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 52: aastore\n 53: aload_0\n 54: bipush 6\n 56: bipush 7\n 58: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 61: aastore\n 62: aload_0\n 63: bipush 7\n 65: bipush 8\n 67: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 70: aastore\n 71: aload_0\n 72: bipush 8\n 74: bipush 9\n 76: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 79: aastore\n 80: aload_0\n 81: invokestatic #79 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 84: invokespecial #82 // Method ValueCell.\"<init>\":(Ljava/util/Set;)V\n 87: areturn\n\n public static final ValueCell v(int...);\n Code:\n 0: aload_0\n 1: ldc #85 // String args\n 3: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #68 // class ValueCell\n 9: dup\n 10: aload_0\n 11: invokestatic #97 // Method kotlin/collections/ArraysKt.toSet:([I)Ljava/util/Set;\n 14: invokespecial #82 // Method ValueCell.\"<init>\":(Ljava/util/Set;)V\n 17: areturn\n\n public static final ValueCell v(java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #85 // String args\n 3: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #68 // class ValueCell\n 9: dup\n 10: aload_0\n 11: checkcast #102 // class java/lang/Iterable\n 14: invokestatic #107 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 17: invokespecial #82 // Method ValueCell.\"<init>\":(Ljava/util/Set;)V\n 20: areturn\n\n public static final java.lang.String drawRow(java.util.Collection<? extends ICell>);\n Code:\n 0: aload_0\n 1: ldc #113 // String row\n 3: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #102 // class java/lang/Iterable\n 10: ldc #115 // String\n 12: checkcast #117 // class java/lang/CharSequence\n 15: aconst_null\n 16: ldc #119 // String \\n\n 18: checkcast #117 // class java/lang/CharSequence\n 21: iconst_0\n 22: aconst_null\n 23: getstatic #124 // Field MainKt$drawRow$1.INSTANCE:LMainKt$drawRow$1;\n 26: checkcast #126 // class kotlin/jvm/functions/Function1\n 29: bipush 26\n 31: aconst_null\n 32: invokestatic #130 // 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 35: areturn\n\n public static final java.lang.String drawGrid(java.util.Collection<? extends java.util.Collection<? extends ICell>>);\n Code:\n 0: aload_0\n 1: ldc #135 // String grid\n 3: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #102 // class java/lang/Iterable\n 10: aconst_null\n 11: aconst_null\n 12: aconst_null\n 13: iconst_0\n 14: aconst_null\n 15: getstatic #140 // Field MainKt$drawGrid$1.INSTANCE:LMainKt$drawGrid$1;\n 18: checkcast #126 // class kotlin/jvm/functions/Function1\n 21: bipush 31\n 23: aconst_null\n 24: invokestatic #130 // 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 27: areturn\n\n public static final <T> boolean allDifferent(java.util.Collection<? extends T>);\n Code:\n 0: aload_0\n 1: ldc #145 // String nums\n 3: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #150, 1 // InterfaceMethod java/util/Collection.size:()I\n 12: new #152 // class java/util/HashSet\n 15: dup\n 16: aload_0\n 17: invokespecial #155 // Method java/util/HashSet.\"<init>\":(Ljava/util/Collection;)V\n 20: invokevirtual #156 // Method java/util/HashSet.size:()I\n 23: if_icmpne 30\n 26: iconst_1\n 27: goto 31\n 30: iconst_0\n 31: ireturn\n\n public static final <T> java.util.List<java.util.List<T>> product(java.util.List<? extends java.util.Set<? extends T>>);\n Code:\n 0: aload_0\n 1: ldc #161 // String colls\n 3: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #164, 1 // InterfaceMethod java/util/List.size:()I\n 12: tableswitch { // 0 to 1\n 0: 36\n 1: 42\n default: 142\n }\n 36: invokestatic #168 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 39: goto 365\n 42: aload_0\n 43: iconst_0\n 44: invokeinterface #172, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 49: checkcast #102 // class java/lang/Iterable\n 52: astore_1\n 53: iconst_0\n 54: istore_2\n 55: aload_1\n 56: astore_3\n 57: new #174 // class java/util/ArrayList\n 60: dup\n 61: aload_1\n 62: bipush 10\n 64: invokestatic #178 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 67: invokespecial #179 // Method java/util/ArrayList.\"<init>\":(I)V\n 70: checkcast #147 // class java/util/Collection\n 73: astore 4\n 75: iconst_0\n 76: istore 5\n 78: aload_3\n 79: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 84: astore 6\n 86: aload 6\n 88: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 93: ifeq 133\n 96: aload 6\n 98: invokeinterface #193, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 103: astore 7\n 105: aload 4\n 107: aload 7\n 109: astore 8\n 111: astore 23\n 113: iconst_0\n 114: istore 9\n 116: aload 8\n 118: invokestatic #197 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 121: aload 23\n 123: swap\n 124: invokeinterface #201, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 129: pop\n 130: goto 86\n 133: aload 4\n 135: checkcast #163 // class java/util/List\n 138: nop\n 139: goto 365\n 142: aload_0\n 143: iconst_0\n 144: invokeinterface #172, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 149: checkcast #203 // class java/util/Set\n 152: astore_1\n 153: aload_0\n 154: checkcast #102 // class java/lang/Iterable\n 157: iconst_1\n 158: invokestatic #207 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 161: astore_2\n 162: aload_2\n 163: invokestatic #209 // Method product:(Ljava/util/List;)Ljava/util/List;\n 166: astore_3\n 167: aload_1\n 168: checkcast #102 // class java/lang/Iterable\n 171: astore 4\n 173: iconst_0\n 174: istore 5\n 176: aload 4\n 178: astore 6\n 180: new #174 // class java/util/ArrayList\n 183: dup\n 184: invokespecial #210 // Method java/util/ArrayList.\"<init>\":()V\n 187: checkcast #147 // class java/util/Collection\n 190: astore 7\n 192: iconst_0\n 193: istore 8\n 195: aload 6\n 197: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 202: astore 9\n 204: aload 9\n 206: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 211: ifeq 358\n 214: aload 9\n 216: invokeinterface #193, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 221: astore 10\n 223: aload 10\n 225: astore 11\n 227: iconst_0\n 228: istore 12\n 230: aload_3\n 231: checkcast #102 // class java/lang/Iterable\n 234: astore 13\n 236: iconst_0\n 237: istore 14\n 239: aload 13\n 241: astore 15\n 243: new #174 // class java/util/ArrayList\n 246: dup\n 247: aload 13\n 249: bipush 10\n 251: invokestatic #178 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 254: invokespecial #179 // Method java/util/ArrayList.\"<init>\":(I)V\n 257: checkcast #147 // class java/util/Collection\n 260: astore 16\n 262: iconst_0\n 263: istore 17\n 265: aload 15\n 267: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 272: astore 18\n 274: aload 18\n 276: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 281: ifeq 335\n 284: aload 18\n 286: invokeinterface #193, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 291: astore 19\n 293: aload 16\n 295: aload 19\n 297: checkcast #163 // class java/util/List\n 300: astore 20\n 302: astore 21\n 304: iconst_0\n 305: istore 22\n 307: aload 11\n 309: invokestatic #197 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 312: checkcast #147 // class java/util/Collection\n 315: aload 20\n 317: checkcast #102 // class java/lang/Iterable\n 320: invokestatic #214 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 323: aload 21\n 325: swap\n 326: invokeinterface #201, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 331: pop\n 332: goto 274\n 335: aload 16\n 337: checkcast #163 // class java/util/List\n 340: nop\n 341: checkcast #102 // class java/lang/Iterable\n 344: nop\n 345: astore 11\n 347: aload 7\n 349: aload 11\n 351: invokestatic #218 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 354: pop\n 355: goto 204\n 358: aload 7\n 360: checkcast #163 // class java/util/List\n 363: nop\n 364: areturn\n 365: areturn\n\n public static final java.util.List<java.util.List<java.lang.Integer>> permuteAll(java.util.List<ValueCell>, int);\n Code:\n 0: aload_0\n 1: ldc #246 // String vs\n 3: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #102 // 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 #174 // class java/util/ArrayList\n 20: dup\n 21: aload_3\n 22: bipush 10\n 24: invokestatic #178 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 27: invokespecial #179 // Method java/util/ArrayList.\"<init>\":(I)V\n 30: checkcast #147 // class java/util/Collection\n 33: astore 6\n 35: iconst_0\n 36: istore 7\n 38: aload 5\n 40: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 8\n 47: aload 8\n 49: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 97\n 57: aload 8\n 59: invokeinterface #193, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 9\n 66: aload 6\n 68: aload 9\n 70: checkcast #68 // class ValueCell\n 73: astore 10\n 75: astore 12\n 77: iconst_0\n 78: istore 11\n 80: aload 10\n 82: invokevirtual #250 // Method ValueCell.getValues:()Ljava/util/Set;\n 85: aload 12\n 87: swap\n 88: invokeinterface #201, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 93: pop\n 94: goto 47\n 97: aload 6\n 99: checkcast #163 // class java/util/List\n 102: nop\n 103: astore_2\n 104: aload_2\n 105: invokestatic #209 // Method product:(Ljava/util/List;)Ljava/util/List;\n 108: checkcast #102 // class java/lang/Iterable\n 111: astore_3\n 112: nop\n 113: iconst_0\n 114: istore 4\n 116: aload_3\n 117: astore 5\n 119: new #174 // class java/util/ArrayList\n 122: dup\n 123: invokespecial #210 // Method java/util/ArrayList.\"<init>\":()V\n 126: checkcast #147 // class java/util/Collection\n 129: astore 6\n 131: iconst_0\n 132: istore 7\n 134: aload 5\n 136: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 141: astore 8\n 143: aload 8\n 145: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 150: ifeq 205\n 153: aload 8\n 155: invokeinterface #193, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 160: astore 9\n 162: aload 9\n 164: checkcast #163 // class java/util/List\n 167: astore 10\n 169: iconst_0\n 170: istore 11\n 172: iload_1\n 173: aload 10\n 175: checkcast #102 // class java/lang/Iterable\n 178: invokestatic #254 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 181: if_icmpne 188\n 184: iconst_1\n 185: goto 189\n 188: iconst_0\n 189: ifeq 143\n 192: aload 6\n 194: aload 9\n 196: invokeinterface #201, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 201: pop\n 202: goto 143\n 205: aload 6\n 207: checkcast #163 // class java/util/List\n 210: nop\n 211: areturn\n\n public static final <T> java.util.List<java.util.List<T>> transpose(java.util.List<? extends java.util.List<? extends T>>);\n Code:\n 0: aload_0\n 1: ldc_w #267 // String m\n 4: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: nop\n 8: aload_0\n 9: invokeinterface #270, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 14: ifeq 23\n 17: invokestatic #168 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 20: goto 240\n 23: new #272 // class kotlin/ranges/IntRange\n 26: dup\n 27: iconst_1\n 28: aload_0\n 29: iconst_0\n 30: invokeinterface #172, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 35: checkcast #163 // class java/util/List\n 38: invokeinterface #164, 1 // InterfaceMethod java/util/List.size:()I\n 43: invokespecial #273 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 46: checkcast #102 // class java/lang/Iterable\n 49: astore_1\n 50: nop\n 51: iconst_0\n 52: istore_2\n 53: aload_1\n 54: astore_3\n 55: new #174 // class java/util/ArrayList\n 58: dup\n 59: aload_1\n 60: bipush 10\n 62: invokestatic #178 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 65: invokespecial #179 // Method java/util/ArrayList.\"<init>\":(I)V\n 68: checkcast #147 // class java/util/Collection\n 71: astore 4\n 73: iconst_0\n 74: istore 5\n 76: aload_3\n 77: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 82: astore 6\n 84: aload 6\n 86: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 91: ifeq 234\n 94: aload 6\n 96: checkcast #275 // class kotlin/collections/IntIterator\n 99: invokevirtual #278 // Method kotlin/collections/IntIterator.nextInt:()I\n 102: istore 7\n 104: aload 4\n 106: iload 7\n 108: istore 8\n 110: astore 20\n 112: iconst_0\n 113: istore 9\n 115: aload_0\n 116: checkcast #102 // class java/lang/Iterable\n 119: astore 10\n 121: iconst_0\n 122: istore 11\n 124: aload 10\n 126: astore 12\n 128: new #174 // class java/util/ArrayList\n 131: dup\n 132: aload 10\n 134: bipush 10\n 136: invokestatic #178 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 139: invokespecial #179 // Method java/util/ArrayList.\"<init>\":(I)V\n 142: checkcast #147 // class java/util/Collection\n 145: astore 13\n 147: iconst_0\n 148: istore 14\n 150: aload 12\n 152: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 157: astore 15\n 159: aload 15\n 161: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 166: ifeq 215\n 169: aload 15\n 171: invokeinterface #193, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 176: astore 16\n 178: aload 13\n 180: aload 16\n 182: checkcast #163 // class java/util/List\n 185: astore 17\n 187: astore 18\n 189: iconst_0\n 190: istore 19\n 192: aload 17\n 194: iload 8\n 196: iconst_1\n 197: isub\n 198: invokeinterface #172, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 203: aload 18\n 205: swap\n 206: invokeinterface #201, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 211: pop\n 212: goto 159\n 215: aload 13\n 217: checkcast #163 // class java/util/List\n 220: nop\n 221: nop\n 222: aload 20\n 224: swap\n 225: invokeinterface #201, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 230: pop\n 231: goto 84\n 234: aload 4\n 236: checkcast #163 // class java/util/List\n 239: nop\n 240: areturn\n\n public static final <T> java.util.List<java.util.List<T>> partitionBy(kotlin.jvm.functions.Function1<? super T, java.lang.Boolean>, java.util.List<? extends T>);\n Code:\n 0: aload_0\n 1: ldc_w #286 // String f\n 4: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: ldc_w #288 // String coll\n 11: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: nop\n 15: aload_1\n 16: invokeinterface #270, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 21: ifeq 30\n 24: invokestatic #168 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 27: goto 184\n 30: aload_1\n 31: iconst_0\n 32: invokeinterface #172, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 37: astore_2\n 38: aload_0\n 39: aload_2\n 40: invokeinterface #292, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 45: checkcast #294 // class java/lang/Boolean\n 48: invokevirtual #297 // Method java/lang/Boolean.booleanValue:()Z\n 51: istore_3\n 52: aload_1\n 53: checkcast #102 // class java/lang/Iterable\n 56: astore 5\n 58: iconst_0\n 59: istore 6\n 61: new #174 // class java/util/ArrayList\n 64: dup\n 65: invokespecial #210 // Method java/util/ArrayList.\"<init>\":()V\n 68: astore 7\n 70: aload 5\n 72: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 77: astore 8\n 79: aload 8\n 81: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 86: ifeq 145\n 89: aload 8\n 91: invokeinterface #193, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 96: astore 9\n 98: aload 9\n 100: astore 10\n 102: iconst_0\n 103: istore 11\n 105: iload_3\n 106: aload_0\n 107: aload 10\n 109: invokeinterface #292, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 114: checkcast #294 // class java/lang/Boolean\n 117: invokevirtual #297 // Method java/lang/Boolean.booleanValue:()Z\n 120: if_icmpne 127\n 123: iconst_1\n 124: goto 128\n 127: iconst_0\n 128: ifne 134\n 131: goto 145\n 134: aload 7\n 136: aload 9\n 138: invokevirtual #298 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 141: pop\n 142: goto 79\n 145: aload 7\n 147: checkcast #163 // class java/util/List\n 150: astore 4\n 152: aload 4\n 154: invokestatic #197 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 157: checkcast #147 // class java/util/Collection\n 160: aload_0\n 161: aload_1\n 162: checkcast #102 // class java/lang/Iterable\n 165: aload 4\n 167: invokeinterface #164, 1 // InterfaceMethod java/util/List.size:()I\n 172: invokestatic #207 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 175: invokestatic #300 // Method partitionBy:(Lkotlin/jvm/functions/Function1;Ljava/util/List;)Ljava/util/List;\n 178: checkcast #102 // class java/lang/Iterable\n 181: invokestatic #214 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 184: areturn\n\n public static final <T> java.util.List<java.util.List<T>> partitionAll(int, int, java.util.List<? extends T>);\n Code:\n 0: aload_2\n 1: ldc_w #288 // String coll\n 4: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: nop\n 8: aload_2\n 9: invokeinterface #270, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 14: ifeq 23\n 17: invokestatic #168 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 20: goto 56\n 23: aload_2\n 24: checkcast #102 // class java/lang/Iterable\n 27: iload_0\n 28: invokestatic #316 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 31: invokestatic #197 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 34: checkcast #147 // class java/util/Collection\n 37: iload_0\n 38: iload_1\n 39: aload_2\n 40: checkcast #102 // class java/lang/Iterable\n 43: iload_1\n 44: invokestatic #207 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 47: invokestatic #318 // Method partitionAll:(IILjava/util/List;)Ljava/util/List;\n 50: checkcast #102 // class java/lang/Iterable\n 53: invokestatic #214 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 56: areturn\n\n public static final <T> java.util.List<java.util.List<T>> partitionN(int, java.util.List<? extends T>);\n Code:\n 0: aload_1\n 1: ldc_w #288 // String coll\n 4: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: iload_0\n 8: iload_0\n 9: aload_1\n 10: invokestatic #318 // Method partitionAll:(IILjava/util/List;)Ljava/util/List;\n 13: areturn\n\n public static final java.util.List<ValueCell> solveStep(java.util.List<ValueCell>, int);\n Code:\n 0: aload_0\n 1: ldc_w #326 // String cells\n 4: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokeinterface #164, 1 // InterfaceMethod java/util/List.size:()I\n 13: iconst_1\n 14: isub\n 15: istore_2\n 16: aload_0\n 17: iload_1\n 18: invokestatic #328 // Method permuteAll:(Ljava/util/List;I)Ljava/util/List;\n 21: checkcast #102 // class java/lang/Iterable\n 24: astore 4\n 26: nop\n 27: iconst_0\n 28: istore 5\n 30: aload 4\n 32: astore 6\n 34: new #174 // class java/util/ArrayList\n 37: dup\n 38: invokespecial #210 // Method java/util/ArrayList.\"<init>\":()V\n 41: checkcast #147 // class java/util/Collection\n 44: astore 7\n 46: iconst_0\n 47: istore 8\n 49: aload 6\n 51: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 56: astore 9\n 58: aload 9\n 60: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 65: ifeq 127\n 68: aload 9\n 70: invokeinterface #193, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 75: astore 10\n 77: aload 10\n 79: checkcast #163 // class java/util/List\n 82: astore 11\n 84: iconst_0\n 85: istore 12\n 87: aload_0\n 88: invokestatic #332 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 91: checkcast #68 // class ValueCell\n 94: aload 11\n 96: iload_2\n 97: invokeinterface #172, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 102: checkcast #334 // class java/lang/Number\n 105: invokevirtual #337 // Method java/lang/Number.intValue:()I\n 108: invokevirtual #341 // Method ValueCell.isPossible:(I)Z\n 111: ifeq 58\n 114: aload 7\n 116: aload 10\n 118: invokeinterface #201, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 123: pop\n 124: goto 58\n 127: aload 7\n 129: checkcast #163 // class java/util/List\n 132: nop\n 133: checkcast #102 // class java/lang/Iterable\n 136: astore 4\n 138: nop\n 139: iconst_0\n 140: istore 5\n 142: aload 4\n 144: astore 6\n 146: new #174 // class java/util/ArrayList\n 149: dup\n 150: invokespecial #210 // Method java/util/ArrayList.\"<init>\":()V\n 153: checkcast #147 // class java/util/Collection\n 156: astore 7\n 158: iconst_0\n 159: istore 8\n 161: aload 6\n 163: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 168: astore 9\n 170: aload 9\n 172: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 177: ifeq 223\n 180: aload 9\n 182: invokeinterface #193, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 187: astore 10\n 189: aload 10\n 191: checkcast #163 // class java/util/List\n 194: astore 11\n 196: iconst_0\n 197: istore 12\n 199: aload 11\n 201: checkcast #147 // class java/util/Collection\n 204: invokestatic #343 // Method allDifferent:(Ljava/util/Collection;)Z\n 207: ifeq 170\n 210: aload 7\n 212: aload 10\n 214: invokeinterface #201, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 219: pop\n 220: goto 170\n 223: aload 7\n 225: checkcast #163 // class java/util/List\n 228: nop\n 229: astore_3\n 230: aload_3\n 231: invokestatic #345 // Method transpose:(Ljava/util/List;)Ljava/util/List;\n 234: checkcast #102 // class java/lang/Iterable\n 237: astore 4\n 239: iconst_0\n 240: istore 5\n 242: aload 4\n 244: astore 6\n 246: new #174 // class java/util/ArrayList\n 249: dup\n 250: aload 4\n 252: bipush 10\n 254: invokestatic #178 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 257: invokespecial #179 // Method java/util/ArrayList.\"<init>\":(I)V\n 260: checkcast #147 // class java/util/Collection\n 263: astore 7\n 265: iconst_0\n 266: istore 8\n 268: aload 6\n 270: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 275: astore 9\n 277: aload 9\n 279: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 284: ifeq 327\n 287: aload 9\n 289: invokeinterface #193, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 294: astore 10\n 296: aload 7\n 298: aload 10\n 300: checkcast #163 // class java/util/List\n 303: astore 11\n 305: astore 13\n 307: iconst_0\n 308: istore 12\n 310: aload 11\n 312: invokestatic #347 // Method v:(Ljava/util/List;)LValueCell;\n 315: aload 13\n 317: swap\n 318: invokeinterface #201, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 323: pop\n 324: goto 277\n 327: aload 7\n 329: checkcast #163 // class java/util/List\n 332: nop\n 333: areturn\n\n public static final java.util.List<java.util.List<ICell>> gatherValues(java.util.List<? extends ICell>);\n Code:\n 0: aload_0\n 1: ldc_w #357 // String line\n 4: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: invokedynamic #375, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 12: aload_0\n 13: invokestatic #300 // Method partitionBy:(Lkotlin/jvm/functions/Function1;Ljava/util/List;)Ljava/util/List;\n 16: areturn\n\n public static final java.util.List<SimplePair<java.util.List<ICell>>> pairTargetsWithValues(java.util.List<? extends ICell>);\n Code:\n 0: aload_0\n 1: ldc_w #357 // String line\n 4: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: iconst_2\n 8: aload_0\n 9: invokestatic #379 // Method gatherValues:(Ljava/util/List;)Ljava/util/List;\n 12: invokestatic #381 // Method partitionN:(ILjava/util/List;)Ljava/util/List;\n 15: checkcast #102 // 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 #174 // class java/util/ArrayList\n 27: dup\n 28: aload_1\n 29: bipush 10\n 31: invokestatic #178 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 34: invokespecial #179 // Method java/util/ArrayList.\"<init>\":(I)V\n 37: checkcast #147 // class java/util/Collection\n 40: astore 4\n 42: iconst_0\n 43: istore 5\n 45: aload_3\n 46: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 51: astore 6\n 53: aload 6\n 55: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 60: ifeq 141\n 63: aload 6\n 65: invokeinterface #193, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 70: astore 7\n 72: aload 4\n 74: aload 7\n 76: checkcast #163 // class java/util/List\n 79: astore 8\n 81: astore 10\n 83: iconst_0\n 84: istore 9\n 86: new #383 // class SimplePair\n 89: dup\n 90: aload 8\n 92: iconst_0\n 93: invokeinterface #172, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 98: iconst_1\n 99: aload 8\n 101: invokeinterface #164, 1 // InterfaceMethod java/util/List.size:()I\n 106: if_icmpne 115\n 109: invokestatic #168 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 112: goto 126\n 115: aload 8\n 117: iconst_1\n 118: invokeinterface #172, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 123: checkcast #163 // class java/util/List\n 126: invokespecial #386 // Method SimplePair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 129: aload 10\n 131: swap\n 132: invokeinterface #201, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 137: pop\n 138: goto 53\n 141: aload 4\n 143: checkcast #163 // class java/util/List\n 146: nop\n 147: areturn\n\n public static final java.util.List<ICell> solvePair(kotlin.jvm.functions.Function1<? super ICell, java.lang.Integer>, SimplePair<java.util.List<ICell>>);\n Code:\n 0: aload_0\n 1: ldc_w #392 // String accessor\n 4: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: ldc_w #394 // String pair\n 11: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: aload_1\n 15: invokevirtual #397 // Method SimplePair.getFirst:()Ljava/lang/Object;\n 18: checkcast #163 // class java/util/List\n 21: astore_2\n 22: nop\n 23: aload_1\n 24: invokevirtual #400 // Method SimplePair.getSecond:()Ljava/lang/Object;\n 27: checkcast #163 // class java/util/List\n 30: invokeinterface #270, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 35: ifeq 42\n 38: aload_2\n 39: goto 192\n 42: aload_1\n 43: invokevirtual #400 // Method SimplePair.getSecond:()Ljava/lang/Object;\n 46: checkcast #102 // class java/lang/Iterable\n 49: astore 4\n 51: iconst_0\n 52: istore 5\n 54: aload 4\n 56: astore 6\n 58: new #174 // class java/util/ArrayList\n 61: dup\n 62: aload 4\n 64: bipush 10\n 66: invokestatic #178 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 69: invokespecial #179 // Method java/util/ArrayList.\"<init>\":(I)V\n 72: checkcast #147 // class java/util/Collection\n 75: astore 7\n 77: iconst_0\n 78: istore 8\n 80: aload 6\n 82: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 87: astore 9\n 89: aload 9\n 91: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 96: ifeq 147\n 99: aload 9\n 101: invokeinterface #193, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 106: astore 10\n 108: aload 7\n 110: aload 10\n 112: checkcast #402 // class ICell\n 115: astore 11\n 117: astore 13\n 119: iconst_0\n 120: istore 12\n 122: aload 11\n 124: ldc_w #404 // String null cannot be cast to non-null type <root>.ValueCell\n 127: invokestatic #407 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V\n 130: aload 11\n 132: checkcast #68 // class ValueCell\n 135: aload 13\n 137: swap\n 138: invokeinterface #201, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 143: pop\n 144: goto 89\n 147: aload 7\n 149: checkcast #163 // class java/util/List\n 152: nop\n 153: astore_3\n 154: aload_0\n 155: aload_2\n 156: invokestatic #332 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 159: invokeinterface #292, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 164: checkcast #334 // class java/lang/Number\n 167: invokevirtual #337 // Method java/lang/Number.intValue:()I\n 170: istore 4\n 172: aload_3\n 173: iload 4\n 175: invokestatic #409 // Method solveStep:(Ljava/util/List;I)Ljava/util/List;\n 178: astore 5\n 180: aload_2\n 181: checkcast #147 // class java/util/Collection\n 184: aload 5\n 186: checkcast #102 // class java/lang/Iterable\n 189: invokestatic #214 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 192: areturn\n\n public static final java.util.List<ICell> solveLine(java.util.List<? extends ICell>, kotlin.jvm.functions.Function1<? super ICell, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc_w #357 // String line\n 4: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: ldc_w #286 // String f\n 11: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: aload_0\n 15: invokestatic #420 // Method pairTargetsWithValues:(Ljava/util/List;)Ljava/util/List;\n 18: checkcast #102 // class java/lang/Iterable\n 21: astore_2\n 22: nop\n 23: iconst_0\n 24: istore_3\n 25: aload_2\n 26: astore 4\n 28: new #174 // class java/util/ArrayList\n 31: dup\n 32: aload_2\n 33: bipush 10\n 35: invokestatic #178 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 38: invokespecial #179 // Method java/util/ArrayList.\"<init>\":(I)V\n 41: checkcast #147 // class java/util/Collection\n 44: astore 5\n 46: iconst_0\n 47: istore 6\n 49: aload 4\n 51: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 56: astore 7\n 58: aload 7\n 60: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 65: ifeq 109\n 68: aload 7\n 70: invokeinterface #193, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 75: astore 8\n 77: aload 5\n 79: aload 8\n 81: checkcast #383 // class SimplePair\n 84: astore 9\n 86: astore 11\n 88: iconst_0\n 89: istore 10\n 91: aload_1\n 92: aload 9\n 94: invokestatic #422 // Method solvePair:(Lkotlin/jvm/functions/Function1;LSimplePair;)Ljava/util/List;\n 97: aload 11\n 99: swap\n 100: invokeinterface #201, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 105: pop\n 106: goto 58\n 109: aload 5\n 111: checkcast #163 // class java/util/List\n 114: nop\n 115: checkcast #102 // class java/lang/Iterable\n 118: invokestatic #426 // Method kotlin/collections/CollectionsKt.flatten:(Ljava/lang/Iterable;)Ljava/util/List;\n 121: areturn\n\n public static final java.util.List<ICell> solveRow(java.util.List<? extends ICell>);\n Code:\n 0: aload_0\n 1: ldc #113 // String row\n 3: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokedynamic #437, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 12: invokestatic #439 // Method solveLine:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 15: areturn\n\n public static final java.util.List<ICell> solveColumn(java.util.List<? extends ICell>);\n Code:\n 0: aload_0\n 1: ldc_w #442 // String column\n 4: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokedynamic #447, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;\n 13: invokestatic #439 // Method solveLine:(Ljava/util/List;Lkotlin/jvm/functions/Function1;)Ljava/util/List;\n 16: areturn\n\n public static final java.util.List<java.util.List<ICell>> solveGrid(java.util.List<? extends java.util.List<? extends ICell>>);\n Code:\n 0: aload_0\n 1: ldc #135 // String grid\n 3: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #102 // 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 #174 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #178 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #179 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #147 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 96\n 56: aload 7\n 58: invokeinterface #193, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #163 // class java/util/List\n 72: astore 9\n 74: astore 12\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: invokestatic #451 // Method solveRow:(Ljava/util/List;)Ljava/util/List;\n 84: aload 12\n 86: swap\n 87: invokeinterface #201, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 92: pop\n 93: goto 46\n 96: aload 5\n 98: checkcast #163 // class java/util/List\n 101: nop\n 102: astore_1\n 103: aload_1\n 104: invokestatic #345 // Method transpose:(Ljava/util/List;)Ljava/util/List;\n 107: checkcast #102 // class java/lang/Iterable\n 110: astore_3\n 111: iconst_0\n 112: istore 4\n 114: aload_3\n 115: astore 5\n 117: new #174 // class java/util/ArrayList\n 120: dup\n 121: aload_3\n 122: bipush 10\n 124: invokestatic #178 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 127: invokespecial #179 // Method java/util/ArrayList.\"<init>\":(I)V\n 130: checkcast #147 // class java/util/Collection\n 133: astore 6\n 135: iconst_0\n 136: istore 7\n 138: aload 5\n 140: invokeinterface #183, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 145: astore 8\n 147: aload 8\n 149: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 154: ifeq 197\n 157: aload 8\n 159: invokeinterface #193, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 164: astore 9\n 166: aload 6\n 168: aload 9\n 170: checkcast #163 // class java/util/List\n 173: astore 10\n 175: astore 12\n 177: iconst_0\n 178: istore 11\n 180: aload 10\n 182: invokestatic #453 // Method solveColumn:(Ljava/util/List;)Ljava/util/List;\n 185: aload 12\n 187: swap\n 188: invokeinterface #201, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 193: pop\n 194: goto 147\n 197: aload 6\n 199: checkcast #163 // class java/util/List\n 202: nop\n 203: astore_2\n 204: aload_2\n 205: invokestatic #345 // Method transpose:(Ljava/util/List;)Ljava/util/List;\n 208: areturn\n\n public static final java.util.List<java.util.List<ICell>> solver(java.util.List<? extends java.util.List<? extends ICell>>);\n Code:\n 0: aload_0\n 1: ldc #135 // String grid\n 3: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #147 // class java/util/Collection\n 10: invokestatic #461 // Method drawGrid:(Ljava/util/Collection;)Ljava/lang/String;\n 13: getstatic #467 // Field java/lang/System.out:Ljava/io/PrintStream;\n 16: swap\n 17: invokevirtual #473 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 20: aload_0\n 21: invokestatic #475 // Method solveGrid:(Ljava/util/List;)Ljava/util/List;\n 24: astore_1\n 25: aload_1\n 26: aload_0\n 27: invokestatic #479 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 30: ifeq 37\n 33: aload_1\n 34: goto 41\n 37: aload_1\n 38: invokestatic #481 // Method solver:(Ljava/util/List;)Ljava/util/List;\n 41: areturn\n\n private static final boolean gatherValues$lambda$11(ICell);\n Code:\n 0: aload_0\n 1: ldc_w #483 // String it\n 4: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: instanceof #68 // class ValueCell\n 11: ireturn\n\n private static final int solveRow$lambda$15(ICell);\n Code:\n 0: aload_0\n 1: ldc_w #483 // String it\n 4: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: checkcast #485 // class IAcross\n 11: invokeinterface #488, 1 // InterfaceMethod IAcross.getAcross:()I\n 16: ireturn\n\n private static final int solveColumn$lambda$16(ICell);\n Code:\n 0: aload_0\n 1: ldc_w #483 // String it\n 4: invokestatic #91 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: checkcast #490 // class IDown\n 11: invokeinterface #493, 1 // InterfaceMethod IDown.getDown:()I\n 16: ireturn\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/CombinationSumII.kt
/** * Given a collection of candidate numbers (C) and a target number (T), * find all unique combinations in C where the candidate numbers sums to T. * * Each number in C may only be used once in the combination. * * Note: * All numbers (including target) will be positive integers. * The solution set must not contain duplicate combinations. * For example, given candidate set [10, 1, 2, 7, 6, 1, 5] and target 8, * A solution set is: * [ * [1, 7], * [1, 2, 5], * [2, 6], * [1, 1, 6] * ] * * Accepted. */ class CombinationSumII { fun combinationSum2(candidates: IntArray, target: Int): List<List<Int>> { if (candidates.isEmpty()) { return emptyList() } val lists = mutableListOf<List<Int>>() candidates.sort() dfs(candidates, target, ArrayList(), lists, 0) return lists } private fun dfs(candidates: IntArray, target: Int, path: MutableList<Int>, ret: MutableList<List<Int>>, index: Int) { if (target < 0) { return } if (target == 0) { ret.add(ArrayList(path)) return } for (i in index until candidates.size) { if (i != index && candidates[i] == candidates[i - 1]) { continue } path.add(candidates[i]) dfs(candidates, target - candidates[i], path, ret, i + 1) path.removeAt(path.size - 1) } } }
[ { "class_path": "TonnyL__Windary__39f85cd/CombinationSumII.class", "javap": "Compiled from \"CombinationSumII.kt\"\npublic final class CombinationSumII {\n public CombinationSumII();\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.List<java.util.List<java.lang.Integer>> combinationSum2(int[], int);\n Code:\n 0: aload_1\n 1: ldc #16 // String candidates\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: ifne 15\n 11: iconst_1\n 12: goto 16\n 15: iconst_0\n 16: ifeq 23\n 19: invokestatic #28 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 22: areturn\n 23: new #30 // class java/util/ArrayList\n 26: dup\n 27: invokespecial #31 // Method java/util/ArrayList.\"<init>\":()V\n 30: checkcast #33 // class java/util/List\n 33: astore_3\n 34: aload_1\n 35: invokestatic #39 // Method kotlin/collections/ArraysKt.sort:([I)V\n 38: aload_0\n 39: aload_1\n 40: iload_2\n 41: new #30 // class java/util/ArrayList\n 44: dup\n 45: invokespecial #31 // Method java/util/ArrayList.\"<init>\":()V\n 48: checkcast #33 // class java/util/List\n 51: aload_3\n 52: iconst_0\n 53: invokespecial #43 // Method dfs:([IILjava/util/List;Ljava/util/List;I)V\n 56: aload_3\n 57: areturn\n\n private final void dfs(int[], int, java.util.List<java.lang.Integer>, java.util.List<java.util.List<java.lang.Integer>>, int);\n Code:\n 0: iload_2\n 1: ifge 5\n 4: return\n 5: iload_2\n 6: ifne 29\n 9: aload 4\n 11: new #30 // class java/util/ArrayList\n 14: dup\n 15: aload_3\n 16: checkcast #51 // class java/util/Collection\n 19: invokespecial #54 // Method java/util/ArrayList.\"<init>\":(Ljava/util/Collection;)V\n 22: invokeinterface #58, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 27: pop\n 28: return\n 29: iload 5\n 31: istore 6\n 33: aload_1\n 34: arraylength\n 35: istore 7\n 37: iload 6\n 39: iload 7\n 41: if_icmpge 120\n 44: iload 6\n 46: iload 5\n 48: if_icmpeq 67\n 51: aload_1\n 52: iload 6\n 54: iaload\n 55: aload_1\n 56: iload 6\n 58: iconst_1\n 59: isub\n 60: iaload\n 61: if_icmpne 67\n 64: goto 114\n 67: aload_3\n 68: aload_1\n 69: iload 6\n 71: iaload\n 72: invokestatic #64 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 75: invokeinterface #58, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 80: pop\n 81: aload_0\n 82: aload_1\n 83: iload_2\n 84: aload_1\n 85: iload 6\n 87: iaload\n 88: isub\n 89: aload_3\n 90: aload 4\n 92: iload 6\n 94: iconst_1\n 95: iadd\n 96: invokespecial #43 // Method dfs:([IILjava/util/List;Ljava/util/List;I)V\n 99: aload_3\n 100: aload_3\n 101: invokeinterface #68, 1 // InterfaceMethod java/util/List.size:()I\n 106: iconst_1\n 107: isub\n 108: invokeinterface #72, 2 // InterfaceMethod java/util/List.remove:(I)Ljava/lang/Object;\n 113: pop\n 114: iinc 6, 1\n 117: goto 37\n 120: return\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/UniqueBinarySearchTreesII.kt
/** * Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n. * * For example, * Given n = 3, your program should return all 5 unique BST's shown below. * * 1 3 3 2 1 * \ / / / \ \ * 3 2 1 1 3 2 * / / \ \ * 2 1 2 3 * * Accepted. */ class UniqueBinarySearchTreesII { fun generateTrees(n: Int): List<TreeNode?> { val list = mutableListOf<TreeNode>() return if (n <= 0) { list } else gen(1, n) } private fun gen(start: Int, end: Int): List<TreeNode?> { val list = mutableListOf<TreeNode?>() if (start > end) { list.add(null) return list } if (start == end) { list.add(TreeNode(start)) return list } for (i in start..end) { for (m in gen(start, i - 1)) { gen(i + 1, end).mapTo(list) { TreeNode(i).apply { left = m right = it } } } } return list } data class TreeNode( var `val`: Int, var left: TreeNode? = null, var right: TreeNode? = null ) }
[ { "class_path": "TonnyL__Windary__39f85cd/UniqueBinarySearchTreesII.class", "javap": "Compiled from \"UniqueBinarySearchTreesII.kt\"\npublic final class UniqueBinarySearchTreesII {\n public UniqueBinarySearchTreesII();\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.List<UniqueBinarySearchTreesII$TreeNode> generateTrees(int);\n Code:\n 0: new #16 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #17 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #19 // class java/util/List\n 10: astore_2\n 11: iload_1\n 12: ifgt 19\n 15: aload_2\n 16: goto 25\n 19: aload_0\n 20: iconst_1\n 21: iload_1\n 22: invokespecial #23 // Method gen:(II)Ljava/util/List;\n 25: areturn\n\n private final java.util.List<UniqueBinarySearchTreesII$TreeNode> gen(int, int);\n Code:\n 0: new #16 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #17 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #19 // class java/util/List\n 10: astore_3\n 11: iload_1\n 12: iload_2\n 13: if_icmple 26\n 16: aload_3\n 17: aconst_null\n 18: invokeinterface #32, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 23: pop\n 24: aload_3\n 25: areturn\n 26: iload_1\n 27: iload_2\n 28: if_icmpne 53\n 31: aload_3\n 32: new #34 // class UniqueBinarySearchTreesII$TreeNode\n 35: dup\n 36: iload_1\n 37: aconst_null\n 38: aconst_null\n 39: bipush 6\n 41: aconst_null\n 42: invokespecial #37 // Method UniqueBinarySearchTreesII$TreeNode.\"<init>\":(ILUniqueBinarySearchTreesII$TreeNode;LUniqueBinarySearchTreesII$TreeNode;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 45: invokeinterface #32, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 50: pop\n 51: aload_3\n 52: areturn\n 53: iload_1\n 54: istore 4\n 56: iload 4\n 58: iload_2\n 59: if_icmpgt 234\n 62: aload_0\n 63: iload_1\n 64: iload 4\n 66: iconst_1\n 67: isub\n 68: invokespecial #23 // Method gen:(II)Ljava/util/List;\n 71: invokeinterface #41, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 76: astore 5\n 78: aload 5\n 80: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 85: ifeq 222\n 88: aload 5\n 90: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 95: checkcast #34 // class UniqueBinarySearchTreesII$TreeNode\n 98: astore 6\n 100: aload_0\n 101: iload 4\n 103: iconst_1\n 104: iadd\n 105: iload_2\n 106: invokespecial #23 // Method gen:(II)Ljava/util/List;\n 109: checkcast #53 // class java/lang/Iterable\n 112: astore 7\n 114: iconst_0\n 115: istore 8\n 117: aload 7\n 119: invokeinterface #54, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 124: astore 9\n 126: aload 9\n 128: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 133: ifeq 214\n 136: aload 9\n 138: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 143: astore 10\n 145: aload_3\n 146: checkcast #56 // class java/util/Collection\n 149: aload 10\n 151: checkcast #34 // class UniqueBinarySearchTreesII$TreeNode\n 154: astore 11\n 156: astore 16\n 158: iconst_0\n 159: istore 12\n 161: new #34 // class UniqueBinarySearchTreesII$TreeNode\n 164: dup\n 165: iload 4\n 167: aconst_null\n 168: aconst_null\n 169: bipush 6\n 171: aconst_null\n 172: invokespecial #37 // Method UniqueBinarySearchTreesII$TreeNode.\"<init>\":(ILUniqueBinarySearchTreesII$TreeNode;LUniqueBinarySearchTreesII$TreeNode;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 175: astore 13\n 177: aload 13\n 179: astore 14\n 181: iconst_0\n 182: istore 15\n 184: aload 14\n 186: aload 6\n 188: invokevirtual #60 // Method UniqueBinarySearchTreesII$TreeNode.setLeft:(LUniqueBinarySearchTreesII$TreeNode;)V\n 191: aload 14\n 193: aload 11\n 195: invokevirtual #63 // Method UniqueBinarySearchTreesII$TreeNode.setRight:(LUniqueBinarySearchTreesII$TreeNode;)V\n 198: nop\n 199: aload 13\n 201: nop\n 202: aload 16\n 204: swap\n 205: invokeinterface #64, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 210: pop\n 211: goto 126\n 214: aload_3\n 215: checkcast #56 // class java/util/Collection\n 218: pop\n 219: goto 78\n 222: iload 4\n 224: iload_2\n 225: if_icmpeq 234\n 228: iinc 4, 1\n 231: goto 62\n 234: aload_3\n 235: areturn\n}\n", "javap_err": "" }, { "class_path": "TonnyL__Windary__39f85cd/UniqueBinarySearchTreesII$TreeNode.class", "javap": "Compiled from \"UniqueBinarySearchTreesII.kt\"\npublic final class UniqueBinarySearchTreesII$TreeNode {\n private int val;\n\n private UniqueBinarySearchTreesII$TreeNode left;\n\n private UniqueBinarySearchTreesII$TreeNode right;\n\n public UniqueBinarySearchTreesII$TreeNode(int, UniqueBinarySearchTreesII$TreeNode, UniqueBinarySearchTreesII$TreeNode);\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 val:I\n 9: aload_0\n 10: aload_2\n 11: putfield #18 // Field left:LUniqueBinarySearchTreesII$TreeNode;\n 14: aload_0\n 15: aload_3\n 16: putfield #21 // Field right:LUniqueBinarySearchTreesII$TreeNode;\n 19: return\n\n public UniqueBinarySearchTreesII$TreeNode(int, UniqueBinarySearchTreesII$TreeNode, UniqueBinarySearchTreesII$TreeNode, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload 4\n 2: iconst_2\n 3: iand\n 4: ifeq 9\n 7: aconst_null\n 8: astore_2\n 9: iload 4\n 11: iconst_4\n 12: iand\n 13: ifeq 18\n 16: aconst_null\n 17: astore_3\n 18: aload_0\n 19: iload_1\n 20: aload_2\n 21: aload_3\n 22: invokespecial #25 // Method \"<init>\":(ILUniqueBinarySearchTreesII$TreeNode;LUniqueBinarySearchTreesII$TreeNode;)V\n 25: return\n\n public final int getVal();\n Code:\n 0: aload_0\n 1: getfield #14 // 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 #14 // Field val:I\n 5: return\n\n public final UniqueBinarySearchTreesII$TreeNode getLeft();\n Code:\n 0: aload_0\n 1: getfield #18 // Field left:LUniqueBinarySearchTreesII$TreeNode;\n 4: areturn\n\n public final void setLeft(UniqueBinarySearchTreesII$TreeNode);\n Code:\n 0: aload_0\n 1: aload_1\n 2: putfield #18 // Field left:LUniqueBinarySearchTreesII$TreeNode;\n 5: return\n\n public final UniqueBinarySearchTreesII$TreeNode getRight();\n Code:\n 0: aload_0\n 1: getfield #21 // Field right:LUniqueBinarySearchTreesII$TreeNode;\n 4: areturn\n\n public final void setRight(UniqueBinarySearchTreesII$TreeNode);\n Code:\n 0: aload_0\n 1: aload_1\n 2: putfield #21 // Field right:LUniqueBinarySearchTreesII$TreeNode;\n 5: return\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #14 // Field val:I\n 4: ireturn\n\n public final UniqueBinarySearchTreesII$TreeNode component2();\n Code:\n 0: aload_0\n 1: getfield #18 // Field left:LUniqueBinarySearchTreesII$TreeNode;\n 4: areturn\n\n public final UniqueBinarySearchTreesII$TreeNode component3();\n Code:\n 0: aload_0\n 1: getfield #21 // Field right:LUniqueBinarySearchTreesII$TreeNode;\n 4: areturn\n\n public final UniqueBinarySearchTreesII$TreeNode copy(int, UniqueBinarySearchTreesII$TreeNode, UniqueBinarySearchTreesII$TreeNode);\n Code:\n 0: new #2 // class UniqueBinarySearchTreesII$TreeNode\n 3: dup\n 4: iload_1\n 5: aload_2\n 6: aload_3\n 7: invokespecial #25 // Method \"<init>\":(ILUniqueBinarySearchTreesII$TreeNode;LUniqueBinarySearchTreesII$TreeNode;)V\n 10: areturn\n\n public static UniqueBinarySearchTreesII$TreeNode copy$default(UniqueBinarySearchTreesII$TreeNode, int, UniqueBinarySearchTreesII$TreeNode, UniqueBinarySearchTreesII$TreeNode, 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 #14 // Field val: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 #18 // Field left:LUniqueBinarySearchTreesII$TreeNode;\n 23: astore_2\n 24: iload 4\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #21 // Field right:LUniqueBinarySearchTreesII$TreeNode;\n 35: astore_3\n 36: aload_0\n 37: iload_1\n 38: aload_2\n 39: aload_3\n 40: invokevirtual #46 // Method copy:(ILUniqueBinarySearchTreesII$TreeNode;LUniqueBinarySearchTreesII$TreeNode;)LUniqueBinarySearchTreesII$TreeNode;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #50 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #51 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #53 // String TreeNode(val=\n 9: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #14 // Field val:I\n 16: invokevirtual #60 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #62 // String , left=\n 21: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #18 // Field left:LUniqueBinarySearchTreesII$TreeNode;\n 28: invokevirtual #65 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: ldc #67 // String , right=\n 33: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #21 // Field right:LUniqueBinarySearchTreesII$TreeNode;\n 40: invokevirtual #65 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #70 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #72 // 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 #14 // Field val:I\n 4: invokestatic #78 // 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 #18 // Field left:LUniqueBinarySearchTreesII$TreeNode;\n 16: ifnonnull 23\n 19: iconst_0\n 20: goto 30\n 23: aload_0\n 24: getfield #18 // Field left:LUniqueBinarySearchTreesII$TreeNode;\n 27: invokevirtual #80 // Method hashCode:()I\n 30: iadd\n 31: istore_1\n 32: iload_1\n 33: bipush 31\n 35: imul\n 36: aload_0\n 37: getfield #21 // Field right:LUniqueBinarySearchTreesII$TreeNode;\n 40: ifnonnull 47\n 43: iconst_0\n 44: goto 54\n 47: aload_0\n 48: getfield #21 // Field right:LUniqueBinarySearchTreesII$TreeNode;\n 51: invokevirtual #80 // Method hashCode:()I\n 54: iadd\n 55: istore_1\n 56: iload_1\n 57: 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 UniqueBinarySearchTreesII$TreeNode\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class UniqueBinarySearchTreesII$TreeNode\n 20: astore_2\n 21: aload_0\n 22: getfield #14 // Field val:I\n 25: aload_2\n 26: getfield #14 // Field val:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #18 // Field left:LUniqueBinarySearchTreesII$TreeNode;\n 38: aload_2\n 39: getfield #18 // Field left:LUniqueBinarySearchTreesII$TreeNode;\n 42: invokestatic #89 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 45: ifne 50\n 48: iconst_0\n 49: ireturn\n 50: aload_0\n 51: getfield #21 // Field right:LUniqueBinarySearchTreesII$TreeNode;\n 54: aload_2\n 55: getfield #21 // Field right:LUniqueBinarySearchTreesII$TreeNode;\n 58: invokestatic #89 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 61: ifne 66\n 64: iconst_0\n 65: ireturn\n 66: iconst_1\n 67: ireturn\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/ThreeSum.kt
/** * Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? * Find all unique triplets in the array which gives the sum of zero. * * Note: The solution set must not contain duplicate triplets. * * For example, given array S = [-1, 0, 1, 2, -1, -4], * * A solution set is: * [ * [-1, 0, 1], * [-1, -1, 2] * ] * * Accepted. */ class ThreeSum { fun threeSum(nums: IntArray): List<List<Int>> { nums.sort() val set = mutableSetOf<Triple>() for (first in 0 until nums.size - 2) { if (nums[first] > 0) { break } val target = 0 - nums[first] var second = first + 1 var third = nums.size - 1 while (second < third) { when { nums[second] + nums[third] == target -> { set.add(Triple(nums[first], nums[second], nums[third])) while (second < third && nums[second] == nums[second + 1]) { second++ } while (second < third && nums[third] == nums[third - 1]) { third-- } second++ third-- } nums[second] + nums[third] < target -> second++ else -> third-- } } } return mutableListOf<List<Int>>().apply { addAll(set.map { arrayListOf(it.a, it.b, it.c) }) } } internal data class Triple( val a: Int, val b: Int, val c: Int ) }
[ { "class_path": "TonnyL__Windary__39f85cd/ThreeSum.class", "javap": "Compiled from \"ThreeSum.kt\"\npublic final class ThreeSum {\n public ThreeSum();\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.List<java.util.List<java.lang.Integer>> threeSum(int[]);\n Code:\n 0: aload_1\n 1: ldc #16 // String nums\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #28 // Method kotlin/collections/ArraysKt.sort:([I)V\n 10: new #30 // class java/util/LinkedHashSet\n 13: dup\n 14: invokespecial #31 // Method java/util/LinkedHashSet.\"<init>\":()V\n 17: checkcast #33 // class java/util/Set\n 20: astore_2\n 21: iconst_0\n 22: istore_3\n 23: aload_1\n 24: arraylength\n 25: iconst_2\n 26: isub\n 27: istore 4\n 29: iload_3\n 30: iload 4\n 32: if_icmpge 202\n 35: aload_1\n 36: iload_3\n 37: iaload\n 38: ifle 44\n 41: goto 202\n 44: iconst_0\n 45: aload_1\n 46: iload_3\n 47: iaload\n 48: isub\n 49: istore 5\n 51: iload_3\n 52: iconst_1\n 53: iadd\n 54: istore 6\n 56: aload_1\n 57: arraylength\n 58: iconst_1\n 59: isub\n 60: istore 7\n 62: iload 6\n 64: iload 7\n 66: if_icmpge 196\n 69: nop\n 70: aload_1\n 71: iload 6\n 73: iaload\n 74: aload_1\n 75: iload 7\n 77: iaload\n 78: iadd\n 79: iload 5\n 81: if_icmpne 170\n 84: aload_2\n 85: new #35 // class ThreeSum$Triple\n 88: dup\n 89: aload_1\n 90: iload_3\n 91: iaload\n 92: aload_1\n 93: iload 6\n 95: iaload\n 96: aload_1\n 97: iload 7\n 99: iaload\n 100: invokespecial #38 // Method ThreeSum$Triple.\"<init>\":(III)V\n 103: invokeinterface #42, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 108: pop\n 109: iload 6\n 111: iload 7\n 113: if_icmpge 135\n 116: aload_1\n 117: iload 6\n 119: iaload\n 120: aload_1\n 121: iload 6\n 123: iconst_1\n 124: iadd\n 125: iaload\n 126: if_icmpne 135\n 129: iinc 6, 1\n 132: goto 109\n 135: iload 6\n 137: iload 7\n 139: if_icmpge 161\n 142: aload_1\n 143: iload 7\n 145: iaload\n 146: aload_1\n 147: iload 7\n 149: iconst_1\n 150: isub\n 151: iaload\n 152: if_icmpne 161\n 155: iinc 7, -1\n 158: goto 135\n 161: iinc 6, 1\n 164: iinc 7, -1\n 167: goto 62\n 170: aload_1\n 171: iload 6\n 173: iaload\n 174: aload_1\n 175: iload 7\n 177: iaload\n 178: iadd\n 179: iload 5\n 181: if_icmpge 190\n 184: iinc 6, 1\n 187: goto 62\n 190: iinc 7, -1\n 193: goto 62\n 196: iinc 3, 1\n 199: goto 29\n 202: new #44 // class java/util/ArrayList\n 205: dup\n 206: invokespecial #45 // Method java/util/ArrayList.\"<init>\":()V\n 209: checkcast #47 // class java/util/List\n 212: astore_3\n 213: aload_3\n 214: astore 4\n 216: iconst_0\n 217: istore 5\n 219: aload 4\n 221: aload_2\n 222: checkcast #49 // class java/lang/Iterable\n 225: astore 6\n 227: astore 7\n 229: iconst_0\n 230: istore 8\n 232: aload 6\n 234: astore 9\n 236: new #44 // class java/util/ArrayList\n 239: dup\n 240: aload 6\n 242: bipush 10\n 244: invokestatic #55 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 247: invokespecial #58 // Method java/util/ArrayList.\"<init>\":(I)V\n 250: checkcast #60 // class java/util/Collection\n 253: astore 10\n 255: iconst_0\n 256: istore 11\n 258: aload 9\n 260: invokeinterface #64, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 265: astore 12\n 267: aload 12\n 269: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 274: ifeq 359\n 277: aload 12\n 279: invokeinterface #74, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 284: astore 13\n 286: aload 10\n 288: aload 13\n 290: checkcast #35 // class ThreeSum$Triple\n 293: astore 14\n 295: astore 15\n 297: iconst_0\n 298: istore 16\n 300: iconst_3\n 301: anewarray #76 // class java/lang/Integer\n 304: astore 17\n 306: aload 17\n 308: iconst_0\n 309: aload 14\n 311: invokevirtual #80 // Method ThreeSum$Triple.getA:()I\n 314: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 317: aastore\n 318: aload 17\n 320: iconst_1\n 321: aload 14\n 323: invokevirtual #87 // Method ThreeSum$Triple.getB:()I\n 326: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 329: aastore\n 330: aload 17\n 332: iconst_2\n 333: aload 14\n 335: invokevirtual #90 // Method ThreeSum$Triple.getC:()I\n 338: invokestatic #84 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 341: aastore\n 342: aload 17\n 344: invokestatic #94 // Method kotlin/collections/CollectionsKt.arrayListOf:([Ljava/lang/Object;)Ljava/util/ArrayList;\n 347: aload 15\n 349: swap\n 350: invokeinterface #95, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 355: pop\n 356: goto 267\n 359: aload 10\n 361: checkcast #47 // class java/util/List\n 364: nop\n 365: aload 7\n 367: swap\n 368: checkcast #60 // class java/util/Collection\n 371: invokeinterface #99, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 376: pop\n 377: nop\n 378: aload_3\n 379: areturn\n}\n", "javap_err": "" }, { "class_path": "TonnyL__Windary__39f85cd/ThreeSum$Triple.class", "javap": "Compiled from \"ThreeSum.kt\"\npublic final class ThreeSum$Triple {\n private final int a;\n\n private final int b;\n\n private final int c;\n\n public ThreeSum$Triple(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 a:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field b:I\n 14: aload_0\n 15: iload_3\n 16: putfield #19 // Field c:I\n 19: return\n\n public final int getA();\n Code:\n 0: aload_0\n 1: getfield #13 // Field a:I\n 4: ireturn\n\n public final int getB();\n Code:\n 0: aload_0\n 1: getfield #16 // Field b:I\n 4: ireturn\n\n public final int getC();\n Code:\n 0: aload_0\n 1: getfield #19 // Field c:I\n 4: ireturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field a:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field b:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #19 // Field c:I\n 4: ireturn\n\n public final ThreeSum$Triple copy(int, int, int);\n Code:\n 0: new #2 // class ThreeSum$Triple\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: iload_3\n 7: invokespecial #33 // Method \"<init>\":(III)V\n 10: areturn\n\n public static ThreeSum$Triple copy$default(ThreeSum$Triple, 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 a: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 b: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 c:I\n 35: istore_3\n 36: aload_0\n 37: iload_1\n 38: iload_2\n 39: iload_3\n 40: invokevirtual #37 // Method copy:(III)LThreeSum$Triple;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #41 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #42 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #44 // String Triple(a=\n 9: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field a:I\n 16: invokevirtual #51 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #53 // String , b=\n 21: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field b:I\n 28: invokevirtual #51 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #55 // String , c=\n 33: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #19 // Field c:I\n 40: invokevirtual #51 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #58 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #60 // 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 a:I\n 4: invokestatic #66 // 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 b:I\n 16: invokestatic #66 // 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 c:I\n 29: invokestatic #66 // 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 ThreeSum$Triple\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class ThreeSum$Triple\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field a:I\n 25: aload_2\n 26: getfield #13 // Field a:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field b:I\n 38: aload_2\n 39: getfield #16 // Field b:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #19 // Field c:I\n 51: aload_2\n 52: getfield #19 // Field c:I\n 55: if_icmpeq 60\n 58: iconst_0\n 59: ireturn\n 60: iconst_1\n 61: ireturn\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/SubsetsII.kt
/** * Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set). * * Note: The solution set must not contain duplicate subsets. * * For example, * If nums = [1,2,2], a solution is: * * [ * [2], * [1], * [1,2,2], * [2,2], * [1,2], * [] * ] * * Accepted. */ class SubsetsII { fun subsetsWithDup(nums: IntArray): List<List<Int>> { if (nums.isEmpty()) { return emptyList() } val lists = mutableListOf<List<Int>>() if (nums.size == 1) { // Add the empty list. lists.add(emptyList()) lists.add(listOf(nums[0])) return lists } nums.sort() for (list in subsetsWithDup(nums.copyOfRange(0, nums.size - 1))) { val l = mutableListOf(nums[nums.size - 1]) l.addAll(list) if (!lists.contains(l)) { lists.add(l) } if (!lists.contains(list)) { lists.add(list) } } return lists } }
[ { "class_path": "TonnyL__Windary__39f85cd/SubsetsII.class", "javap": "Compiled from \"SubsetsII.kt\"\npublic final class SubsetsII {\n public SubsetsII();\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.List<java.util.List<java.lang.Integer>> subsetsWithDup(int[]);\n Code:\n 0: aload_1\n 1: ldc #16 // String nums\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: ifne 15\n 11: iconst_1\n 12: goto 16\n 15: iconst_0\n 16: ifeq 23\n 19: invokestatic #28 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 22: areturn\n 23: new #30 // class java/util/ArrayList\n 26: dup\n 27: invokespecial #31 // Method java/util/ArrayList.\"<init>\":()V\n 30: checkcast #33 // class java/util/List\n 33: astore_2\n 34: aload_1\n 35: arraylength\n 36: iconst_1\n 37: if_icmpne 68\n 40: aload_2\n 41: invokestatic #28 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 44: invokeinterface #37, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 49: pop\n 50: aload_2\n 51: aload_1\n 52: iconst_0\n 53: iaload\n 54: invokestatic #43 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 57: invokestatic #47 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 60: invokeinterface #37, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 65: pop\n 66: aload_2\n 67: areturn\n 68: aload_1\n 69: invokestatic #53 // Method kotlin/collections/ArraysKt.sort:([I)V\n 72: aload_0\n 73: aload_1\n 74: iconst_0\n 75: aload_1\n 76: arraylength\n 77: iconst_1\n 78: isub\n 79: invokestatic #57 // Method kotlin/collections/ArraysKt.copyOfRange:([III)[I\n 82: invokevirtual #59 // Method subsetsWithDup:([I)Ljava/util/List;\n 85: invokeinterface #63, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 90: astore_3\n 91: aload_3\n 92: invokeinterface #69, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 97: ifeq 193\n 100: aload_3\n 101: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 106: checkcast #33 // class java/util/List\n 109: astore 4\n 111: iconst_1\n 112: anewarray #39 // class java/lang/Integer\n 115: astore 6\n 117: aload 6\n 119: iconst_0\n 120: aload_1\n 121: aload_1\n 122: arraylength\n 123: iconst_1\n 124: isub\n 125: iaload\n 126: invokestatic #43 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 129: aastore\n 130: aload 6\n 132: invokestatic #77 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 135: astore 5\n 137: aload 5\n 139: aload 4\n 141: checkcast #79 // class java/util/Collection\n 144: invokeinterface #83, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 149: pop\n 150: aload_2\n 151: aload 5\n 153: invokeinterface #86, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 158: ifne 170\n 161: aload_2\n 162: aload 5\n 164: invokeinterface #37, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 169: pop\n 170: aload_2\n 171: aload 4\n 173: invokeinterface #86, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 178: ifne 91\n 181: aload_2\n 182: aload 4\n 184: invokeinterface #37, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 189: pop\n 190: goto 91\n 193: aload_2\n 194: areturn\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/ThreeSumClosest.kt
/** * Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. * Return the sum of the three integers. * You may assume that each input would have exactly one solution. * * For example, given array S = {-1 2 1 -4}, and target = 1. * * The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). * * Accepted. */ class ThreeSumClosest { fun threeSumClosest(nums: IntArray, target: Int): Int { nums.sort() var result = nums[0] + nums[1] + nums[2] for (i in 0 until nums.size - 2) { var l = i + 1 var r = nums.size - 1 while (l < r) { val tmp = nums[i] + nums[l] + nums[r] if (tmp == target) { return tmp } if (Math.abs(tmp - target) < Math.abs(result - target)) { result = tmp } if (tmp < target) { l++ } else if (tmp > target) { r-- } } } return result } }
[ { "class_path": "TonnyL__Windary__39f85cd/ThreeSumClosest.class", "javap": "Compiled from \"ThreeSumClosest.kt\"\npublic final class ThreeSumClosest {\n public ThreeSumClosest();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int threeSumClosest(int[], int);\n Code:\n 0: aload_1\n 1: ldc #15 // String nums\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokestatic #27 // Method kotlin/collections/ArraysKt.sort:([I)V\n 10: aload_1\n 11: iconst_0\n 12: iaload\n 13: aload_1\n 14: iconst_1\n 15: iaload\n 16: iadd\n 17: aload_1\n 18: iconst_2\n 19: iaload\n 20: iadd\n 21: istore_3\n 22: iconst_0\n 23: istore 4\n 25: aload_1\n 26: arraylength\n 27: iconst_2\n 28: isub\n 29: istore 5\n 31: iload 4\n 33: iload 5\n 35: if_icmpge 131\n 38: iload 4\n 40: iconst_1\n 41: iadd\n 42: istore 6\n 44: aload_1\n 45: arraylength\n 46: iconst_1\n 47: isub\n 48: istore 7\n 50: iload 6\n 52: iload 7\n 54: if_icmpge 125\n 57: aload_1\n 58: iload 4\n 60: iaload\n 61: aload_1\n 62: iload 6\n 64: iaload\n 65: iadd\n 66: aload_1\n 67: iload 7\n 69: iaload\n 70: iadd\n 71: istore 8\n 73: iload 8\n 75: iload_2\n 76: if_icmpne 82\n 79: iload 8\n 81: ireturn\n 82: iload 8\n 84: iload_2\n 85: isub\n 86: invokestatic #33 // Method java/lang/Math.abs:(I)I\n 89: iload_3\n 90: iload_2\n 91: isub\n 92: invokestatic #33 // Method java/lang/Math.abs:(I)I\n 95: if_icmpge 101\n 98: iload 8\n 100: istore_3\n 101: iload 8\n 103: iload_2\n 104: if_icmpge 113\n 107: iinc 6, 1\n 110: goto 50\n 113: iload 8\n 115: iload_2\n 116: if_icmple 50\n 119: iinc 7, -1\n 122: goto 50\n 125: iinc 4, 1\n 128: goto 31\n 131: iload_3\n 132: ireturn\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/LetterCombinationsOfAPhoneNumber.kt
/** * Given a digit string, return all possible letter combinations that the number could represent. * * A mapping of digit to letters (just like on the telephone buttons) is given below. * * Input:Digit string "23" * Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]. * Note: * Although the above answer is in lexicographical order, your answer could be in any order you want. * * Accepted. */ class LetterCombinationsOfAPhoneNumber { fun letterCombinations(digits: String): List<String> { val dict = arrayOf(" ", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz") val results = mutableListOf<String>() if (digits.isEmpty()) { return emptyList() } if (digits.length == 1) { dict[Integer.valueOf(digits)].toCharArray() .mapTo(results) { it.toString() } return results } val list = letterCombinations(digits.substring(1, digits.length)) val sb = StringBuilder() for (c in dict[Integer.valueOf(digits.substring(0, 1))].toCharArray()) { for (s in list) { sb.append(c.toString()).append(s) results.add(sb.toString()) sb.setLength(0) } } return results } }
[ { "class_path": "TonnyL__Windary__39f85cd/LetterCombinationsOfAPhoneNumber.class", "javap": "Compiled from \"LetterCombinationsOfAPhoneNumber.kt\"\npublic final class LetterCombinationsOfAPhoneNumber {\n public LetterCombinationsOfAPhoneNumber();\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.List<java.lang.String> letterCombinations(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #16 // String digits\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: bipush 10\n 8: anewarray #24 // class java/lang/String\n 11: astore_3\n 12: aload_3\n 13: iconst_0\n 14: ldc #26 // String\n 16: aastore\n 17: aload_3\n 18: iconst_1\n 19: ldc #28 // String\n 21: aastore\n 22: aload_3\n 23: iconst_2\n 24: ldc #30 // String abc\n 26: aastore\n 27: aload_3\n 28: iconst_3\n 29: ldc #32 // String def\n 31: aastore\n 32: aload_3\n 33: iconst_4\n 34: ldc #34 // String ghi\n 36: aastore\n 37: aload_3\n 38: iconst_5\n 39: ldc #36 // String jkl\n 41: aastore\n 42: aload_3\n 43: bipush 6\n 45: ldc #38 // String mno\n 47: aastore\n 48: aload_3\n 49: bipush 7\n 51: ldc #40 // String pqrs\n 53: aastore\n 54: aload_3\n 55: bipush 8\n 57: ldc #42 // String tuv\n 59: aastore\n 60: aload_3\n 61: bipush 9\n 63: ldc #44 // String wxyz\n 65: aastore\n 66: aload_3\n 67: astore_2\n 68: new #46 // class java/util/ArrayList\n 71: dup\n 72: invokespecial #47 // Method java/util/ArrayList.\"<init>\":()V\n 75: checkcast #49 // class java/util/List\n 78: astore_3\n 79: aload_1\n 80: checkcast #51 // class java/lang/CharSequence\n 83: invokeinterface #55, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 88: ifne 95\n 91: iconst_1\n 92: goto 96\n 95: iconst_0\n 96: ifeq 103\n 99: invokestatic #61 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 102: areturn\n 103: aload_1\n 104: invokevirtual #62 // Method java/lang/String.length:()I\n 107: iconst_1\n 108: if_icmpne 206\n 111: aload_2\n 112: aload_1\n 113: invokestatic #68 // Method java/lang/Integer.valueOf:(Ljava/lang/String;)Ljava/lang/Integer;\n 116: dup\n 117: ldc #70 // String valueOf(...)\n 119: invokestatic #73 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 122: checkcast #75 // class java/lang/Number\n 125: invokevirtual #78 // Method java/lang/Number.intValue:()I\n 128: aaload\n 129: invokevirtual #82 // Method java/lang/String.toCharArray:()[C\n 132: dup\n 133: ldc #84 // String toCharArray(...)\n 135: invokestatic #73 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 138: astore 4\n 140: nop\n 141: iconst_0\n 142: istore 5\n 144: iconst_0\n 145: istore 6\n 147: aload 4\n 149: arraylength\n 150: istore 7\n 152: iload 6\n 154: iload 7\n 156: if_icmpge 199\n 159: aload 4\n 161: iload 6\n 163: caload\n 164: istore 8\n 166: aload_3\n 167: checkcast #86 // class java/util/Collection\n 170: iload 8\n 172: istore 9\n 174: astore 12\n 176: iconst_0\n 177: istore 10\n 179: iload 9\n 181: invokestatic #89 // Method java/lang/String.valueOf:(C)Ljava/lang/String;\n 184: aload 12\n 186: swap\n 187: invokeinterface #93, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 192: pop\n 193: iinc 6, 1\n 196: goto 152\n 199: aload_3\n 200: checkcast #86 // class java/util/Collection\n 203: pop\n 204: aload_3\n 205: areturn\n 206: aload_0\n 207: aload_1\n 208: iconst_1\n 209: aload_1\n 210: invokevirtual #62 // Method java/lang/String.length:()I\n 213: invokevirtual #97 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 216: dup\n 217: ldc #99 // String substring(...)\n 219: invokestatic #73 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 222: invokevirtual #101 // Method letterCombinations:(Ljava/lang/String;)Ljava/util/List;\n 225: astore 4\n 227: new #103 // class java/lang/StringBuilder\n 230: dup\n 231: invokespecial #104 // Method java/lang/StringBuilder.\"<init>\":()V\n 234: astore 5\n 236: aload_2\n 237: aload_1\n 238: iconst_0\n 239: iconst_1\n 240: invokevirtual #97 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 243: dup\n 244: ldc #99 // String substring(...)\n 246: invokestatic #73 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 249: invokestatic #68 // Method java/lang/Integer.valueOf:(Ljava/lang/String;)Ljava/lang/Integer;\n 252: dup\n 253: ldc #70 // String valueOf(...)\n 255: invokestatic #73 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 258: checkcast #75 // class java/lang/Number\n 261: invokevirtual #78 // Method java/lang/Number.intValue:()I\n 264: aaload\n 265: invokevirtual #82 // Method java/lang/String.toCharArray:()[C\n 268: dup\n 269: ldc #84 // String toCharArray(...)\n 271: invokestatic #73 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 274: astore 6\n 276: iconst_0\n 277: istore 7\n 279: aload 6\n 281: arraylength\n 282: istore 8\n 284: iload 7\n 286: iload 8\n 288: if_icmpge 378\n 291: aload 6\n 293: iload 7\n 295: caload\n 296: istore 9\n 298: aload 4\n 300: invokeinterface #108, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 305: astore 10\n 307: aload 10\n 309: invokeinterface #114, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 314: ifeq 372\n 317: aload 10\n 319: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 324: checkcast #24 // class java/lang/String\n 327: astore 11\n 329: aload 5\n 331: iload 9\n 333: invokestatic #89 // Method java/lang/String.valueOf:(C)Ljava/lang/String;\n 336: invokevirtual #122 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 339: aload 11\n 341: invokevirtual #122 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 344: pop\n 345: aload_3\n 346: aload 5\n 348: invokevirtual #126 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 351: dup\n 352: ldc #128 // String toString(...)\n 354: invokestatic #73 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 357: invokeinterface #129, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 362: pop\n 363: aload 5\n 365: iconst_0\n 366: invokevirtual #133 // Method java/lang/StringBuilder.setLength:(I)V\n 369: goto 307\n 372: iinc 7, 1\n 375: goto 284\n 378: aload_3\n 379: areturn\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/SearchInRotatedSortedArrayII.kt
import java.util.Arrays /** * Follow up for "Search in Rotated Sorted Array": * What if duplicates are allowed? * * Would this affect the run-time complexity? How and why? * * Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. * * (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). * * Write nums function to determine if nums given target is in the array. * * The array may contain duplicates. * * Accepted. */ class SearchInRotatedSortedArrayII { fun search(nums: IntArray, target: Int): Boolean { if (nums.isEmpty()) { return false } var start = 0 var end = nums.size - 1 while (start <= end) { val mid = start + (end - start) / 2 if (nums[mid] == target) { return true } if (nums[mid] < nums[end]) { // right half sorted if (target > nums[mid] && target <= nums[end]) { return Arrays.binarySearch(nums, mid, end + 1, target) >= 0 } else { end = mid - 1 } } else if (nums[mid] > nums[end]) { // left half sorted if (target >= nums[start] && target < nums[mid]) { return Arrays.binarySearch(nums, start, mid + 1, target) >= 0 } else { start = mid + 1 } } else { end-- } } return false } }
[ { "class_path": "TonnyL__Windary__39f85cd/SearchInRotatedSortedArrayII.class", "javap": "Compiled from \"SearchInRotatedSortedArrayII.kt\"\npublic final class SearchInRotatedSortedArrayII {\n public SearchInRotatedSortedArrayII();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final boolean search(int[], int);\n Code:\n 0: aload_1\n 1: ldc #15 // String nums\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: arraylength\n 8: ifne 15\n 11: iconst_1\n 12: goto 16\n 15: iconst_0\n 16: ifeq 21\n 19: iconst_0\n 20: ireturn\n 21: iconst_0\n 22: istore_3\n 23: aload_1\n 24: arraylength\n 25: iconst_1\n 26: isub\n 27: istore 4\n 29: iload_3\n 30: iload 4\n 32: if_icmpgt 173\n 35: iload_3\n 36: iload 4\n 38: iload_3\n 39: isub\n 40: iconst_2\n 41: idiv\n 42: iadd\n 43: istore 5\n 45: aload_1\n 46: iload 5\n 48: iaload\n 49: iload_2\n 50: if_icmpne 55\n 53: iconst_1\n 54: ireturn\n 55: aload_1\n 56: iload 5\n 58: iaload\n 59: aload_1\n 60: iload 4\n 62: iaload\n 63: if_icmpge 111\n 66: iload_2\n 67: aload_1\n 68: iload 5\n 70: iaload\n 71: if_icmple 102\n 74: iload_2\n 75: aload_1\n 76: iload 4\n 78: iaload\n 79: if_icmpgt 102\n 82: aload_1\n 83: iload 5\n 85: iload 4\n 87: iconst_1\n 88: iadd\n 89: iload_2\n 90: invokestatic #27 // Method java/util/Arrays.binarySearch:([IIII)I\n 93: iflt 100\n 96: iconst_1\n 97: goto 101\n 100: iconst_0\n 101: ireturn\n 102: iload 5\n 104: iconst_1\n 105: isub\n 106: istore 4\n 108: goto 29\n 111: aload_1\n 112: iload 5\n 114: iaload\n 115: aload_1\n 116: iload 4\n 118: iaload\n 119: if_icmple 164\n 122: iload_2\n 123: aload_1\n 124: iload_3\n 125: iaload\n 126: if_icmplt 156\n 129: iload_2\n 130: aload_1\n 131: iload 5\n 133: iaload\n 134: if_icmpge 156\n 137: aload_1\n 138: iload_3\n 139: iload 5\n 141: iconst_1\n 142: iadd\n 143: iload_2\n 144: invokestatic #27 // Method java/util/Arrays.binarySearch:([IIII)I\n 147: iflt 154\n 150: iconst_1\n 151: goto 155\n 154: iconst_0\n 155: ireturn\n 156: iload 5\n 158: iconst_1\n 159: iadd\n 160: istore_3\n 161: goto 29\n 164: iload 4\n 166: iinc 4, -1\n 169: pop\n 170: goto 29\n 173: iconst_0\n 174: ireturn\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/Permutations.kt
/** * Given a collection of distinct numbers, return all possible permutations. * * For example, * [1,2,3] have the following permutations: * [ * [1,2,3], * [1,3,2], * [2,1,3], * [2,3,1], * [3,1,2], * [3,2,1] * ] * * Accepted. */ class Permutations { fun permute(nums: IntArray): List<List<Int>> { val results = mutableListOf<List<Int>>() if (nums.isEmpty()) { return results } if (nums.size == 1) { return results.apply { add(mutableListOf(nums[0])) } } val ints = IntArray(nums.size - 1) System.arraycopy(nums, 0, ints, 0, nums.size - 1) for (list in permute(ints)) { for (i in 0..list.size) { val tmp = mutableListOf<Int>() tmp.addAll(list) tmp.add(i, nums[nums.size - 1]) results.add(tmp) } } return results } }
[ { "class_path": "TonnyL__Windary__39f85cd/Permutations.class", "javap": "Compiled from \"Permutations.kt\"\npublic final class Permutations {\n public Permutations();\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.List<java.util.List<java.lang.Integer>> permute(int[]);\n Code:\n 0: aload_1\n 1: ldc #16 // String nums\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #24 // class java/util/ArrayList\n 9: dup\n 10: invokespecial #25 // Method java/util/ArrayList.\"<init>\":()V\n 13: checkcast #27 // class java/util/List\n 16: astore_2\n 17: aload_1\n 18: arraylength\n 19: ifne 26\n 22: iconst_1\n 23: goto 27\n 26: iconst_0\n 27: ifeq 32\n 30: aload_2\n 31: areturn\n 32: aload_1\n 33: arraylength\n 34: iconst_1\n 35: if_icmpne 78\n 38: aload_2\n 39: astore_3\n 40: aload_3\n 41: astore 4\n 43: iconst_0\n 44: istore 5\n 46: aload 4\n 48: iconst_1\n 49: anewarray #29 // class java/lang/Integer\n 52: astore 6\n 54: aload 6\n 56: iconst_0\n 57: aload_1\n 58: iconst_0\n 59: iaload\n 60: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 63: aastore\n 64: aload 6\n 66: invokestatic #39 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 69: invokeinterface #43, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 74: pop\n 75: nop\n 76: aload_3\n 77: areturn\n 78: aload_1\n 79: arraylength\n 80: iconst_1\n 81: isub\n 82: newarray int\n 84: astore_3\n 85: aload_1\n 86: iconst_0\n 87: aload_3\n 88: iconst_0\n 89: aload_1\n 90: arraylength\n 91: iconst_1\n 92: isub\n 93: invokestatic #49 // Method java/lang/System.arraycopy:(Ljava/lang/Object;ILjava/lang/Object;II)V\n 96: aload_0\n 97: aload_3\n 98: invokevirtual #51 // Method permute:([I)Ljava/util/List;\n 101: invokeinterface #55, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 106: astore 4\n 108: aload 4\n 110: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 115: ifeq 214\n 118: aload 4\n 120: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 125: checkcast #27 // class java/util/List\n 128: astore 5\n 130: iconst_0\n 131: istore 6\n 133: aload 5\n 135: invokeinterface #69, 1 // InterfaceMethod java/util/List.size:()I\n 140: istore 7\n 142: iload 6\n 144: iload 7\n 146: if_icmpgt 108\n 149: new #24 // class java/util/ArrayList\n 152: dup\n 153: invokespecial #25 // Method java/util/ArrayList.\"<init>\":()V\n 156: checkcast #27 // class java/util/List\n 159: astore 8\n 161: aload 8\n 163: aload 5\n 165: checkcast #71 // class java/util/Collection\n 168: invokeinterface #75, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 173: pop\n 174: aload 8\n 176: iload 6\n 178: aload_1\n 179: aload_1\n 180: arraylength\n 181: iconst_1\n 182: isub\n 183: iaload\n 184: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 187: invokeinterface #78, 3 // InterfaceMethod java/util/List.add:(ILjava/lang/Object;)V\n 192: aload_2\n 193: aload 8\n 195: invokeinterface #43, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 200: pop\n 201: iload 6\n 203: iload 7\n 205: if_icmpeq 108\n 208: iinc 6, 1\n 211: goto 149\n 214: aload_2\n 215: areturn\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/MinimumPathSum.kt
/** * Given a m x n grid filled with non-negative numbers, * find a path from top left to bottom right which minimizes the sum of all numbers along its path. * * Note: You can only move either down or right at any point in time. * * Example 1: * [[1,3,1], * [1,5,1], * [4,2,1]] * Given the above grid map, return 7. Because the path 1→3→1→1→1 minimizes the sum. * * Accepted. */ class MinimumPathSum { fun minPathSum(grid: Array<IntArray>): Int { if (grid.isEmpty()) { return 0 } if (grid.size == 1) { if (grid[0].isEmpty()) { return 0 } if (grid[0].size == 1) { return grid[0][0] } } val matrix = Array(grid.size) { IntArray(grid[0].size) } matrix[0][0] = grid[0][0] (1 until grid.size).forEach { matrix[it][0] = matrix[it - 1][0] + grid[it][0] } (1 until grid[0].size).forEach { matrix[0][it] = matrix[0][it - 1] + grid[0][it] } (1 until grid.size).forEach { i -> (1 until grid[0].size).forEach { matrix[i][it] = Math.min(matrix[i - 1][it] + grid[i][it], matrix[i][it - 1] + grid[i][it]) } } return matrix[grid.size - 1][grid[0].size - 1] } }
[ { "class_path": "TonnyL__Windary__39f85cd/MinimumPathSum.class", "javap": "Compiled from \"MinimumPathSum.kt\"\npublic final class MinimumPathSum {\n public MinimumPathSum();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int minPathSum(int[][]);\n Code:\n 0: aload_1\n 1: ldc #15 // String grid\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #23 // class \"[Ljava/lang/Object;\"\n 10: arraylength\n 11: ifne 18\n 14: iconst_1\n 15: goto 19\n 18: iconst_0\n 19: ifeq 24\n 22: iconst_0\n 23: ireturn\n 24: aload_1\n 25: checkcast #23 // class \"[Ljava/lang/Object;\"\n 28: arraylength\n 29: iconst_1\n 30: if_icmpne 64\n 33: aload_1\n 34: iconst_0\n 35: aaload\n 36: arraylength\n 37: ifne 44\n 40: iconst_1\n 41: goto 45\n 44: iconst_0\n 45: ifeq 50\n 48: iconst_0\n 49: ireturn\n 50: aload_1\n 51: iconst_0\n 52: aaload\n 53: arraylength\n 54: iconst_1\n 55: if_icmpne 64\n 58: aload_1\n 59: iconst_0\n 60: aaload\n 61: iconst_0\n 62: iaload\n 63: ireturn\n 64: iconst_0\n 65: istore_3\n 66: aload_1\n 67: checkcast #23 // class \"[Ljava/lang/Object;\"\n 70: arraylength\n 71: istore 4\n 73: iload 4\n 75: anewarray #25 // class \"[I\"\n 78: astore 5\n 80: iload_3\n 81: iload 4\n 83: if_icmpge 106\n 86: iload_3\n 87: istore 6\n 89: aload 5\n 91: iload 6\n 93: aload_1\n 94: iconst_0\n 95: aaload\n 96: arraylength\n 97: newarray int\n 99: aastore\n 100: iinc 3, 1\n 103: goto 80\n 106: aload 5\n 108: astore_2\n 109: aload_2\n 110: iconst_0\n 111: aaload\n 112: iconst_0\n 113: aload_1\n 114: iconst_0\n 115: aaload\n 116: iconst_0\n 117: iaload\n 118: iastore\n 119: iconst_1\n 120: aload_1\n 121: checkcast #23 // class \"[Ljava/lang/Object;\"\n 124: arraylength\n 125: invokestatic #31 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 128: checkcast #33 // class java/lang/Iterable\n 131: astore_3\n 132: iconst_0\n 133: istore 4\n 135: aload_3\n 136: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 141: astore 5\n 143: aload 5\n 145: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 150: ifeq 196\n 153: aload 5\n 155: checkcast #45 // class kotlin/collections/IntIterator\n 158: invokevirtual #49 // Method kotlin/collections/IntIterator.nextInt:()I\n 161: istore 6\n 163: iload 6\n 165: istore 7\n 167: iconst_0\n 168: istore 8\n 170: aload_2\n 171: iload 7\n 173: aaload\n 174: iconst_0\n 175: aload_2\n 176: iload 7\n 178: iconst_1\n 179: isub\n 180: aaload\n 181: iconst_0\n 182: iaload\n 183: aload_1\n 184: iload 7\n 186: aaload\n 187: iconst_0\n 188: iaload\n 189: iadd\n 190: iastore\n 191: nop\n 192: nop\n 193: goto 143\n 196: nop\n 197: iconst_1\n 198: aload_1\n 199: iconst_0\n 200: aaload\n 201: arraylength\n 202: invokestatic #31 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 205: checkcast #33 // class java/lang/Iterable\n 208: astore_3\n 209: iconst_0\n 210: istore 4\n 212: aload_3\n 213: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 218: astore 5\n 220: aload 5\n 222: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 227: ifeq 273\n 230: aload 5\n 232: checkcast #45 // class kotlin/collections/IntIterator\n 235: invokevirtual #49 // Method kotlin/collections/IntIterator.nextInt:()I\n 238: istore 6\n 240: iload 6\n 242: istore 7\n 244: iconst_0\n 245: istore 8\n 247: aload_2\n 248: iconst_0\n 249: aaload\n 250: iload 7\n 252: aload_2\n 253: iconst_0\n 254: aaload\n 255: iload 7\n 257: iconst_1\n 258: isub\n 259: iaload\n 260: aload_1\n 261: iconst_0\n 262: aaload\n 263: iload 7\n 265: iaload\n 266: iadd\n 267: iastore\n 268: nop\n 269: nop\n 270: goto 220\n 273: nop\n 274: iconst_1\n 275: aload_1\n 276: checkcast #23 // class \"[Ljava/lang/Object;\"\n 279: arraylength\n 280: invokestatic #31 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 283: checkcast #33 // class java/lang/Iterable\n 286: astore_3\n 287: iconst_0\n 288: istore 4\n 290: aload_3\n 291: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 296: astore 5\n 298: aload 5\n 300: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 305: ifeq 432\n 308: aload 5\n 310: checkcast #45 // class kotlin/collections/IntIterator\n 313: invokevirtual #49 // Method kotlin/collections/IntIterator.nextInt:()I\n 316: istore 6\n 318: iload 6\n 320: istore 7\n 322: iconst_0\n 323: istore 8\n 325: iconst_1\n 326: aload_1\n 327: iconst_0\n 328: aaload\n 329: arraylength\n 330: invokestatic #31 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 333: checkcast #33 // class java/lang/Iterable\n 336: astore 9\n 338: iconst_0\n 339: istore 10\n 341: aload 9\n 343: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 348: astore 11\n 350: aload 11\n 352: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 357: ifeq 426\n 360: aload 11\n 362: checkcast #45 // class kotlin/collections/IntIterator\n 365: invokevirtual #49 // Method kotlin/collections/IntIterator.nextInt:()I\n 368: istore 12\n 370: iload 12\n 372: istore 13\n 374: iconst_0\n 375: istore 14\n 377: aload_2\n 378: iload 7\n 380: aaload\n 381: iload 13\n 383: aload_2\n 384: iload 7\n 386: iconst_1\n 387: isub\n 388: aaload\n 389: iload 13\n 391: iaload\n 392: aload_1\n 393: iload 7\n 395: aaload\n 396: iload 13\n 398: iaload\n 399: iadd\n 400: aload_2\n 401: iload 7\n 403: aaload\n 404: iload 13\n 406: iconst_1\n 407: isub\n 408: iaload\n 409: aload_1\n 410: iload 7\n 412: aaload\n 413: iload 13\n 415: iaload\n 416: iadd\n 417: invokestatic #55 // Method java/lang/Math.min:(II)I\n 420: iastore\n 421: nop\n 422: nop\n 423: goto 350\n 426: nop\n 427: nop\n 428: nop\n 429: goto 298\n 432: nop\n 433: aload_2\n 434: aload_1\n 435: checkcast #23 // class \"[Ljava/lang/Object;\"\n 438: arraylength\n 439: iconst_1\n 440: isub\n 441: aaload\n 442: aload_1\n 443: iconst_0\n 444: aaload\n 445: arraylength\n 446: iconst_1\n 447: isub\n 448: iaload\n 449: ireturn\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/NextPermutation.kt
/** * Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. * * If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order). * * The replacement must be in-place, do not allocate extra memory. * * Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column. * 1,2,3 → 1,3,2 * 3,2,1 → 1,2,3 * 1,1,5 → 1,5,1 * * Accepted. */ class NextPermutation { fun nextPermutation(nums: IntArray) { var i = nums.size - 2 while (i >= 0 && nums[i] >= nums[i + 1]) { i-- } if (i >= 0) { var j = nums.size - 1 while (nums[j] <= nums[i]) { j-- } swap(nums, i, j) } reverse(nums, i + 1, nums.size - 1) } private fun swap(nums: IntArray, i: Int, j: Int) { val tmp = nums[i] nums[i] = nums[j] nums[j] = tmp } private fun reverse(nums: IntArray, i: Int, j: Int) { var tmpI = i var tmpJ = j while (tmpI < tmpJ) { swap(nums, tmpI++, tmpJ--) } } }
[ { "class_path": "TonnyL__Windary__39f85cd/NextPermutation.class", "javap": "Compiled from \"NextPermutation.kt\"\npublic final class NextPermutation {\n public NextPermutation();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final void nextPermutation(int[]);\n Code:\n 0: aload_1\n 1: ldc #15 // String nums\n 3: invokestatic #21 // 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: isub\n 10: istore_2\n 11: iload_2\n 12: iflt 32\n 15: aload_1\n 16: iload_2\n 17: iaload\n 18: aload_1\n 19: iload_2\n 20: iconst_1\n 21: iadd\n 22: iaload\n 23: if_icmplt 32\n 26: iinc 2, -1\n 29: goto 11\n 32: iload_2\n 33: iflt 63\n 36: aload_1\n 37: arraylength\n 38: iconst_1\n 39: isub\n 40: istore_3\n 41: aload_1\n 42: iload_3\n 43: iaload\n 44: aload_1\n 45: iload_2\n 46: iaload\n 47: if_icmpgt 56\n 50: iinc 3, -1\n 53: goto 41\n 56: aload_0\n 57: aload_1\n 58: iload_2\n 59: iload_3\n 60: invokespecial #25 // Method swap:([III)V\n 63: aload_0\n 64: aload_1\n 65: iload_2\n 66: iconst_1\n 67: iadd\n 68: aload_1\n 69: arraylength\n 70: iconst_1\n 71: isub\n 72: invokespecial #28 // Method reverse:([III)V\n 75: return\n\n private final void swap(int[], int, int);\n Code:\n 0: aload_1\n 1: iload_2\n 2: iaload\n 3: istore 4\n 5: aload_1\n 6: iload_2\n 7: aload_1\n 8: iload_3\n 9: iaload\n 10: iastore\n 11: aload_1\n 12: iload_3\n 13: iload 4\n 15: iastore\n 16: return\n\n private final void reverse(int[], int, int);\n Code:\n 0: iload_2\n 1: istore 4\n 3: iload_3\n 4: istore 5\n 6: iload 4\n 8: iload 5\n 10: if_icmpge 31\n 13: aload_0\n 14: aload_1\n 15: iload 4\n 17: iinc 4, 1\n 20: iload 5\n 22: iinc 5, -1\n 25: invokespecial #25 // Method swap:([III)V\n 28: goto 6\n 31: return\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/UniqueBinarySearchTrees.kt
/** * Given n, how many structurally unique BST's (binary search trees) that store values 1...n? * * For example, * Given n = 3, there are a total of 5 unique BST's. * * 1 3 3 2 1 * \ / / / \ \ * 3 2 1 1 3 2 * / / \ \ * 2 1 2 3 * * Two solutions are all accepted. */ class UniqueBinarySearchTrees { // Recursive solution. Accepted. /*fun numTrees(n: Int): Int { if (n == 0 || n == 1) return 1 return (1..n).sumBy { numTrees(it - 1) * numTrees(n - it) } }*/ // Dynamic programming. fun numTrees(n: Int): Int { val array = IntArray(n + 2, { 0 }) array[0] = 1 array[1] = 1 for (i in 2..n) { for (j in 0 until i) { array[i] += array[j] * array[i - j - 1] } } return array[n] } }
[ { "class_path": "TonnyL__Windary__39f85cd/UniqueBinarySearchTrees.class", "javap": "Compiled from \"UniqueBinarySearchTrees.kt\"\npublic final class UniqueBinarySearchTrees {\n public UniqueBinarySearchTrees();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int numTrees(int);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: iload_1\n 3: iconst_2\n 4: iadd\n 5: istore 4\n 7: iload 4\n 9: newarray int\n 11: astore 5\n 13: iload_3\n 14: iload 4\n 16: if_icmpge 34\n 19: iload_3\n 20: istore 6\n 22: aload 5\n 24: iload 6\n 26: iconst_0\n 27: iastore\n 28: iinc 3, 1\n 31: goto 13\n 34: aload 5\n 36: astore_2\n 37: aload_2\n 38: iconst_0\n 39: iconst_1\n 40: iastore\n 41: aload_2\n 42: iconst_1\n 43: iconst_1\n 44: iastore\n 45: iconst_2\n 46: istore_3\n 47: iload_3\n 48: iload_1\n 49: if_icmpgt 103\n 52: iconst_0\n 53: istore 4\n 55: iload 4\n 57: iload_3\n 58: if_icmpge 92\n 61: iload_3\n 62: istore 5\n 64: aload_2\n 65: iload 5\n 67: aload_2\n 68: iload 5\n 70: iaload\n 71: aload_2\n 72: iload 4\n 74: iaload\n 75: aload_2\n 76: iload_3\n 77: iload 4\n 79: isub\n 80: iconst_1\n 81: isub\n 82: iaload\n 83: imul\n 84: iadd\n 85: iastore\n 86: iinc 4, 1\n 89: goto 55\n 92: iload_3\n 93: iload_1\n 94: if_icmpeq 103\n 97: iinc 3, 1\n 100: goto 52\n 103: aload_2\n 104: iload_1\n 105: iaload\n 106: ireturn\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/Combinations.kt
/** * Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. * * For example, * If n = 4 and k = 2, a solution is: * * [ * [2,4], * [3,4], * [2,3], * [1,2], * [1,3], * [1,4], * ] */ class Combinations { // Iterative solution. // Accepted. fun combine(n: Int, k: Int): List<List<Int>> { var results = mutableListOf<List<Int>>() if (n == 0 || k == 0 || k > n) { return results } (1..n + 1 - k).mapTo(results) { listOf(it) } for (i in 2..k) { val tmp = mutableListOf<List<Int>>() for (list in results) { for (m in list[list.size - 1] + 1..n - (k - i)) { val newList = mutableListOf<Int>() newList.addAll(list) newList.add(m) tmp.add(newList) } } results = tmp } return results } // Recursive solution. // Accepted. /*fun combine(n: Int, k: Int): List<List<Int>> { val results = mutableListOf<List<Int>>() if (n == 0 || k == 0 || k > n) { return results } if (k == 1) { (1..n).mapTo(results) { listOf(it) } return results } for (list in combine(n, k - 1)) { for (i in list[list.size - 1] until n) { val tmp = mutableListOf<Int>() tmp.addAll(list) tmp.add(i + 1) results.add(tmp) } } return results*/ }
[ { "class_path": "TonnyL__Windary__39f85cd/Combinations.class", "javap": "Compiled from \"Combinations.kt\"\npublic final class Combinations {\n public Combinations();\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.List<java.util.List<java.lang.Integer>> combine(int, int);\n Code:\n 0: new #16 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #17 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #19 // class java/util/List\n 10: astore_3\n 11: iload_1\n 12: ifeq 24\n 15: iload_2\n 16: ifeq 24\n 19: iload_2\n 20: iload_1\n 21: if_icmple 26\n 24: aload_3\n 25: areturn\n 26: new #21 // class kotlin/ranges/IntRange\n 29: dup\n 30: iconst_1\n 31: iload_1\n 32: iconst_1\n 33: iadd\n 34: iload_2\n 35: isub\n 36: invokespecial #24 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 39: checkcast #26 // class java/lang/Iterable\n 42: astore 4\n 44: iconst_0\n 45: istore 5\n 47: aload 4\n 49: invokeinterface #30, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 54: astore 6\n 56: aload 6\n 58: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 63: ifeq 109\n 66: aload 6\n 68: checkcast #38 // class kotlin/collections/IntIterator\n 71: invokevirtual #42 // Method kotlin/collections/IntIterator.nextInt:()I\n 74: istore 7\n 76: aload_3\n 77: checkcast #44 // class java/util/Collection\n 80: iload 7\n 82: istore 8\n 84: astore 11\n 86: iconst_0\n 87: istore 9\n 89: iload 8\n 91: invokestatic #50 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 94: invokestatic #56 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 97: aload 11\n 99: swap\n 100: invokeinterface #60, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 105: pop\n 106: goto 56\n 109: aload_3\n 110: checkcast #44 // class java/util/Collection\n 113: pop\n 114: iconst_2\n 115: istore 4\n 117: iload 4\n 119: iload_2\n 120: if_icmpgt 282\n 123: new #16 // class java/util/ArrayList\n 126: dup\n 127: invokespecial #17 // Method java/util/ArrayList.\"<init>\":()V\n 130: checkcast #19 // class java/util/List\n 133: astore 5\n 135: aload_3\n 136: invokeinterface #61, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 141: astore 6\n 143: aload 6\n 145: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 150: ifeq 267\n 153: aload 6\n 155: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 160: checkcast #19 // class java/util/List\n 163: astore 7\n 165: aload 7\n 167: aload 7\n 169: invokeinterface #68, 1 // InterfaceMethod java/util/List.size:()I\n 174: iconst_1\n 175: isub\n 176: invokeinterface #72, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 181: checkcast #74 // class java/lang/Number\n 184: invokevirtual #77 // Method java/lang/Number.intValue:()I\n 187: iconst_1\n 188: iadd\n 189: istore 8\n 191: iload_1\n 192: iload_2\n 193: iload 4\n 195: isub\n 196: isub\n 197: istore 9\n 199: iload 8\n 201: iload 9\n 203: if_icmpgt 143\n 206: new #16 // class java/util/ArrayList\n 209: dup\n 210: invokespecial #17 // Method java/util/ArrayList.\"<init>\":()V\n 213: checkcast #19 // class java/util/List\n 216: astore 10\n 218: aload 10\n 220: aload 7\n 222: checkcast #44 // class java/util/Collection\n 225: invokeinterface #81, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 230: pop\n 231: aload 10\n 233: iload 8\n 235: invokestatic #50 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 238: invokeinterface #82, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 243: pop\n 244: aload 5\n 246: aload 10\n 248: invokeinterface #82, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 253: pop\n 254: iload 8\n 256: iload 9\n 258: if_icmpeq 143\n 261: iinc 8, 1\n 264: goto 206\n 267: aload 5\n 269: astore_3\n 270: iload 4\n 272: iload_2\n 273: if_icmpeq 282\n 276: iinc 4, 1\n 279: goto 123\n 282: aload_3\n 283: areturn\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/FourSum.kt
/** * Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? * Find all unique quadruplets in the array which gives the sum of target. * * Note: The solution set must not contain duplicate quadruplets. * * For example, given array S = [1, 0, -1, 0, -2, 2], and target = 0. * * A solution set is: * [ * [-1, 0, 0, 1], * [-2, -1, 1, 2], * [-2, 0, 0, 2] * ] * * Accepted. */ class FourSum { // Accepted. 1600ms. /*fun fourSum(nums: IntArray, target: Int): List<List<Int>> { val set = mutableSetOf<List<Int>>() nums.sort() for (i in 0 until nums.size - 3) { for (j in i + 1 until nums.size - 2) { for (k in j + 1 until nums.size - 1) { for (m in k + 1 until nums.size) { val sum = nums[i] + nums[j] + nums[k] + nums[m] if (sum > target) { continue } if (sum == target) { set.add(listOf(nums[i], nums[j], nums[k], nums[m])) } } } } } return ArrayList(set) }*/ fun fourSum(nums: IntArray, target: Int): List<List<Int>> { val results = mutableListOf<List<Int>>() nums.sort() for (i in 0 until nums.size - 3) { for (j in i + 1 until nums.size - 2) { var left = j + 1 var right = nums.size - 1 while (left < right) { val sum = nums[i] + nums[j] + nums[left] + nums[right] when { sum == target -> { val tmp = ArrayList<Int>(4) tmp.add(nums[i]) tmp.add(nums[j]) tmp.add(nums[left]) tmp.add(nums[right]) if (!results.contains(tmp)) { results.add(tmp) } left++ right-- } sum < target -> left++ else -> right-- } } } } return results } }
[ { "class_path": "TonnyL__Windary__39f85cd/FourSum.class", "javap": "Compiled from \"FourSum.kt\"\npublic final class FourSum {\n public FourSum();\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.List<java.util.List<java.lang.Integer>> fourSum(int[], int);\n Code:\n 0: aload_1\n 1: ldc #16 // String nums\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #24 // class java/util/ArrayList\n 9: dup\n 10: invokespecial #25 // Method java/util/ArrayList.\"<init>\":()V\n 13: checkcast #27 // class java/util/List\n 16: astore_3\n 17: aload_1\n 18: invokestatic #33 // Method kotlin/collections/ArraysKt.sort:([I)V\n 21: iconst_0\n 22: istore 4\n 24: aload_1\n 25: arraylength\n 26: iconst_3\n 27: isub\n 28: istore 5\n 30: iload 4\n 32: iload 5\n 34: if_icmpge 224\n 37: iload 4\n 39: iconst_1\n 40: iadd\n 41: istore 6\n 43: aload_1\n 44: arraylength\n 45: iconst_2\n 46: isub\n 47: istore 7\n 49: iload 6\n 51: iload 7\n 53: if_icmpge 218\n 56: iload 6\n 58: iconst_1\n 59: iadd\n 60: istore 8\n 62: aload_1\n 63: arraylength\n 64: iconst_1\n 65: isub\n 66: istore 9\n 68: iload 8\n 70: iload 9\n 72: if_icmpge 212\n 75: aload_1\n 76: iload 4\n 78: iaload\n 79: aload_1\n 80: iload 6\n 82: iaload\n 83: iadd\n 84: aload_1\n 85: iload 8\n 87: iaload\n 88: iadd\n 89: aload_1\n 90: iload 9\n 92: iaload\n 93: iadd\n 94: istore 10\n 96: nop\n 97: iload 10\n 99: iload_2\n 100: if_icmpne 194\n 103: new #24 // class java/util/ArrayList\n 106: dup\n 107: iconst_4\n 108: invokespecial #36 // Method java/util/ArrayList.\"<init>\":(I)V\n 111: astore 11\n 113: aload 11\n 115: aload_1\n 116: iload 4\n 118: iaload\n 119: invokestatic #42 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 122: invokevirtual #46 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 125: pop\n 126: aload 11\n 128: aload_1\n 129: iload 6\n 131: iaload\n 132: invokestatic #42 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 135: invokevirtual #46 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 138: pop\n 139: aload 11\n 141: aload_1\n 142: iload 8\n 144: iaload\n 145: invokestatic #42 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 148: invokevirtual #46 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 151: pop\n 152: aload 11\n 154: aload_1\n 155: iload 9\n 157: iaload\n 158: invokestatic #42 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 161: invokevirtual #46 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 164: pop\n 165: aload_3\n 166: aload 11\n 168: invokeinterface #49, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 173: ifne 185\n 176: aload_3\n 177: aload 11\n 179: invokeinterface #50, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 184: pop\n 185: iinc 8, 1\n 188: iinc 9, -1\n 191: goto 68\n 194: iload 10\n 196: iload_2\n 197: if_icmpge 206\n 200: iinc 8, 1\n 203: goto 68\n 206: iinc 9, -1\n 209: goto 68\n 212: iinc 6, 1\n 215: goto 49\n 218: iinc 4, 1\n 221: goto 30\n 224: aload_3\n 225: areturn\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/WordSearch.kt
/** * Given a 2D board and a word, find if the word exists in the grid. * * The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. * The same letter cell may not be used more than once. * * For example, * Given board = * * [ * ['A','B','C','E'], * ['S','F','C','S'], * ['A','D','E','E'] * ] * word = "ABCCED", -> returns true, * word = "SEE", -> returns true, * word = "ABCB", -> returns false. * * Accepted. */ class WordSearch { fun exist(board: Array<CharArray>, word: String): Boolean { if (board.isEmpty() || board[0].isEmpty()) { return false } for (i in board.indices) { (0 until board[0].size) .filter { search(board, i, it, word, 0) } .forEach { return true } } return false } private fun search(board: Array<CharArray>, i: Int, j: Int, word: String, index: Int): Boolean { if (index >= word.length) { return true } if (i < 0 || i >= board.size || j < 0 || j >= board[0].size || board[i][j] != word[index]) { return false } board[i][j] = (board[i][j].toInt() xor 255).toChar() val res = (search(board, i - 1, j, word, index + 1) || search(board, i + 1, j, word, index + 1) || search(board, i, j - 1, word, index + 1) || search(board, i, j + 1, word, index + 1)) board[i][j] = (board[i][j].toInt() xor 255).toChar() return res } }
[ { "class_path": "TonnyL__Windary__39f85cd/WordSearch.class", "javap": "Compiled from \"WordSearch.kt\"\npublic final class WordSearch {\n public WordSearch();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final boolean exist(char[][], java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String board\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 word\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 \"[Ljava/lang/Object;\"\n 16: arraylength\n 17: ifne 24\n 20: iconst_1\n 21: goto 25\n 24: iconst_0\n 25: ifne 43\n 28: aload_1\n 29: iconst_0\n 30: aaload\n 31: arraylength\n 32: ifne 39\n 35: iconst_1\n 36: goto 40\n 39: iconst_0\n 40: ifeq 45\n 43: iconst_0\n 44: ireturn\n 45: iconst_0\n 46: istore_3\n 47: aload_1\n 48: checkcast #25 // class \"[Ljava/lang/Object;\"\n 51: arraylength\n 52: istore 4\n 54: iload_3\n 55: iload 4\n 57: if_icmpge 228\n 60: iconst_0\n 61: aload_1\n 62: iconst_0\n 63: aaload\n 64: arraylength\n 65: invokestatic #31 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 68: checkcast #33 // class java/lang/Iterable\n 71: astore 5\n 73: nop\n 74: iconst_0\n 75: istore 6\n 77: aload 5\n 79: astore 7\n 81: new #35 // class java/util/ArrayList\n 84: dup\n 85: invokespecial #36 // Method java/util/ArrayList.\"<init>\":()V\n 88: checkcast #38 // class java/util/Collection\n 91: astore 8\n 93: iconst_0\n 94: istore 9\n 96: aload 7\n 98: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 103: astore 10\n 105: aload 10\n 107: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 112: ifeq 163\n 115: aload 10\n 117: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 122: astore 11\n 124: aload 11\n 126: checkcast #54 // class java/lang/Number\n 129: invokevirtual #58 // Method java/lang/Number.intValue:()I\n 132: istore 12\n 134: iconst_0\n 135: istore 13\n 137: aload_0\n 138: aload_1\n 139: iload_3\n 140: iload 12\n 142: aload_2\n 143: iconst_0\n 144: invokespecial #62 // Method search:([[CIILjava/lang/String;I)Z\n 147: ifeq 105\n 150: aload 8\n 152: aload 11\n 154: invokeinterface #66, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 159: pop\n 160: goto 105\n 163: aload 8\n 165: checkcast #68 // class java/util/List\n 168: nop\n 169: checkcast #33 // class java/lang/Iterable\n 172: astore 5\n 174: nop\n 175: iconst_0\n 176: istore 6\n 178: aload 5\n 180: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 185: astore 7\n 187: aload 7\n 189: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 194: ifeq 221\n 197: aload 7\n 199: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 204: astore 8\n 206: aload 8\n 208: checkcast #54 // class java/lang/Number\n 211: invokevirtual #58 // Method java/lang/Number.intValue:()I\n 214: istore 9\n 216: iconst_0\n 217: istore 10\n 219: iconst_1\n 220: ireturn\n 221: nop\n 222: iinc 3, 1\n 225: goto 54\n 228: iconst_0\n 229: ireturn\n\n private final boolean search(char[][], int, int, java.lang.String, int);\n Code:\n 0: iload 5\n 2: aload 4\n 4: invokevirtual #93 // Method java/lang/String.length:()I\n 7: if_icmplt 12\n 10: iconst_1\n 11: ireturn\n 12: iload_2\n 13: iflt 52\n 16: iload_2\n 17: aload_1\n 18: checkcast #25 // class \"[Ljava/lang/Object;\"\n 21: arraylength\n 22: if_icmpge 52\n 25: iload_3\n 26: iflt 52\n 29: iload_3\n 30: aload_1\n 31: iconst_0\n 32: aaload\n 33: arraylength\n 34: if_icmpge 52\n 37: aload_1\n 38: iload_2\n 39: aaload\n 40: iload_3\n 41: caload\n 42: aload 4\n 44: iload 5\n 46: invokevirtual #97 // Method java/lang/String.charAt:(I)C\n 49: if_icmpeq 54\n 52: iconst_0\n 53: ireturn\n 54: aload_1\n 55: iload_2\n 56: aaload\n 57: iload_3\n 58: aload_1\n 59: iload_2\n 60: aaload\n 61: iload_3\n 62: caload\n 63: sipush 255\n 66: ixor\n 67: i2c\n 68: castore\n 69: aload_0\n 70: aload_1\n 71: iload_2\n 72: iconst_1\n 73: isub\n 74: iload_3\n 75: aload 4\n 77: iload 5\n 79: iconst_1\n 80: iadd\n 81: invokespecial #62 // Method search:([[CIILjava/lang/String;I)Z\n 84: ifne 141\n 87: aload_0\n 88: aload_1\n 89: iload_2\n 90: iconst_1\n 91: iadd\n 92: iload_3\n 93: aload 4\n 95: iload 5\n 97: iconst_1\n 98: iadd\n 99: invokespecial #62 // Method search:([[CIILjava/lang/String;I)Z\n 102: ifne 141\n 105: aload_0\n 106: aload_1\n 107: iload_2\n 108: iload_3\n 109: iconst_1\n 110: isub\n 111: aload 4\n 113: iload 5\n 115: iconst_1\n 116: iadd\n 117: invokespecial #62 // Method search:([[CIILjava/lang/String;I)Z\n 120: ifne 141\n 123: aload_0\n 124: aload_1\n 125: iload_2\n 126: iload_3\n 127: iconst_1\n 128: iadd\n 129: aload 4\n 131: iload 5\n 133: iconst_1\n 134: iadd\n 135: invokespecial #62 // Method search:([[CIILjava/lang/String;I)Z\n 138: ifeq 145\n 141: iconst_1\n 142: goto 146\n 145: iconst_0\n 146: istore 6\n 148: aload_1\n 149: iload_2\n 150: aaload\n 151: iload_3\n 152: aload_1\n 153: iload_2\n 154: aaload\n 155: iload_3\n 156: caload\n 157: sipush 255\n 160: ixor\n 161: i2c\n 162: castore\n 163: iload 6\n 165: ireturn\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/CombinationSum.kt
/** * Given a set of candidate numbers (C) (without duplicates) and a target number (T), * find all unique combinations in C where the candidate numbers sums to T. * * The same repeated number may be chosen from C unlimited number of times. * * Note: * All numbers (including target) will be positive integers. * The solution set must not contain duplicate combinations. * For example, given candidate set [2, 3, 6, 7] and target 7, * A solution set is: * [ * [7], * [2, 2, 3] * ] * * Accepted. */ class CombinationSum { fun combinationSum(candidates: IntArray, target: Int): List<List<Int>> { if (candidates.isEmpty()) { return emptyList() } val lists = mutableListOf<List<Int>>() candidates.sort() dfs(candidates, target, mutableListOf(), lists, 0) return lists } private fun dfs(candidates: IntArray, target: Int, path: MutableList<Int>, ret: MutableList<List<Int>>, index: Int) { if (target < 0) { return } if (target == 0) { ret.add(ArrayList(path)) return } for (i in index until candidates.size) { path.add(candidates[i]) dfs(candidates, target - candidates[i], path, ret, i) path.removeAt(path.size - 1) } } }
[ { "class_path": "TonnyL__Windary__39f85cd/CombinationSum.class", "javap": "Compiled from \"CombinationSum.kt\"\npublic final class CombinationSum {\n public CombinationSum();\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.List<java.util.List<java.lang.Integer>> combinationSum(int[], int);\n Code:\n 0: aload_1\n 1: ldc #16 // String candidates\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: ifne 15\n 11: iconst_1\n 12: goto 16\n 15: iconst_0\n 16: ifeq 23\n 19: invokestatic #28 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 22: areturn\n 23: new #30 // class java/util/ArrayList\n 26: dup\n 27: invokespecial #31 // Method java/util/ArrayList.\"<init>\":()V\n 30: checkcast #33 // class java/util/List\n 33: astore_3\n 34: aload_1\n 35: invokestatic #39 // Method kotlin/collections/ArraysKt.sort:([I)V\n 38: aload_0\n 39: aload_1\n 40: iload_2\n 41: new #30 // class java/util/ArrayList\n 44: dup\n 45: invokespecial #31 // Method java/util/ArrayList.\"<init>\":()V\n 48: checkcast #33 // class java/util/List\n 51: aload_3\n 52: iconst_0\n 53: invokespecial #43 // Method dfs:([IILjava/util/List;Ljava/util/List;I)V\n 56: aload_3\n 57: areturn\n\n private final void dfs(int[], int, java.util.List<java.lang.Integer>, java.util.List<java.util.List<java.lang.Integer>>, int);\n Code:\n 0: iload_2\n 1: ifge 5\n 4: return\n 5: iload_2\n 6: ifne 29\n 9: aload 4\n 11: new #30 // class java/util/ArrayList\n 14: dup\n 15: aload_3\n 16: checkcast #51 // class java/util/Collection\n 19: invokespecial #54 // Method java/util/ArrayList.\"<init>\":(Ljava/util/Collection;)V\n 22: invokeinterface #58, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 27: pop\n 28: return\n 29: iload 5\n 31: istore 6\n 33: aload_1\n 34: arraylength\n 35: istore 7\n 37: iload 6\n 39: iload 7\n 41: if_icmpge 95\n 44: aload_3\n 45: aload_1\n 46: iload 6\n 48: iaload\n 49: invokestatic #64 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 52: invokeinterface #58, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 57: pop\n 58: aload_0\n 59: aload_1\n 60: iload_2\n 61: aload_1\n 62: iload 6\n 64: iaload\n 65: isub\n 66: aload_3\n 67: aload 4\n 69: iload 6\n 71: invokespecial #43 // Method dfs:([IILjava/util/List;Ljava/util/List;I)V\n 74: aload_3\n 75: aload_3\n 76: invokeinterface #68, 1 // InterfaceMethod java/util/List.size:()I\n 81: iconst_1\n 82: isub\n 83: invokeinterface #72, 2 // InterfaceMethod java/util/List.remove:(I)Ljava/lang/Object;\n 88: pop\n 89: iinc 6, 1\n 92: goto 37\n 95: return\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/PermutationsII.kt
/** * Given a collection of numbers that might contain duplicates, return all possible unique permutations. * * For example, * [1,1,2] have the following unique permutations: * [ * [1,1,2], * [1,2,1], * [2,1,1] * ] * * Accepted. */ class PermutationsII { fun permuteUnique(nums: IntArray): List<List<Int>> { val results = mutableListOf<List<Int>>() if (nums.isEmpty()) { return results } if (nums.size == 1) { return results.apply { add(mutableListOf(nums[0])) } } val ints = IntArray(nums.size - 1) System.arraycopy(nums, 0, ints, 0, nums.size - 1) val set = mutableSetOf<List<Int>>() for (list in permuteUnique(ints)) { for (i in 0..list.size) { val tmp = mutableListOf<Int>() tmp.addAll(list) tmp.add(i, nums[nums.size - 1]) set.add(tmp) } } return results.apply { addAll(set) } } }
[ { "class_path": "TonnyL__Windary__39f85cd/PermutationsII.class", "javap": "Compiled from \"PermutationsII.kt\"\npublic final class PermutationsII {\n public PermutationsII();\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.List<java.util.List<java.lang.Integer>> permuteUnique(int[]);\n Code:\n 0: aload_1\n 1: ldc #16 // String nums\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #24 // class java/util/ArrayList\n 9: dup\n 10: invokespecial #25 // Method java/util/ArrayList.\"<init>\":()V\n 13: checkcast #27 // class java/util/List\n 16: astore_2\n 17: aload_1\n 18: arraylength\n 19: ifne 26\n 22: iconst_1\n 23: goto 27\n 26: iconst_0\n 27: ifeq 32\n 30: aload_2\n 31: areturn\n 32: aload_1\n 33: arraylength\n 34: iconst_1\n 35: if_icmpne 78\n 38: aload_2\n 39: astore_3\n 40: aload_3\n 41: astore 4\n 43: iconst_0\n 44: istore 5\n 46: aload 4\n 48: iconst_1\n 49: anewarray #29 // class java/lang/Integer\n 52: astore 6\n 54: aload 6\n 56: iconst_0\n 57: aload_1\n 58: iconst_0\n 59: iaload\n 60: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 63: aastore\n 64: aload 6\n 66: invokestatic #39 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;\n 69: invokeinterface #43, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 74: pop\n 75: nop\n 76: aload_3\n 77: areturn\n 78: aload_1\n 79: arraylength\n 80: iconst_1\n 81: isub\n 82: newarray int\n 84: astore_3\n 85: aload_1\n 86: iconst_0\n 87: aload_3\n 88: iconst_0\n 89: aload_1\n 90: arraylength\n 91: iconst_1\n 92: isub\n 93: invokestatic #49 // Method java/lang/System.arraycopy:(Ljava/lang/Object;ILjava/lang/Object;II)V\n 96: new #51 // class java/util/LinkedHashSet\n 99: dup\n 100: invokespecial #52 // Method java/util/LinkedHashSet.\"<init>\":()V\n 103: checkcast #54 // class java/util/Set\n 106: astore 4\n 108: aload_0\n 109: aload_3\n 110: invokevirtual #56 // Method permuteUnique:([I)Ljava/util/List;\n 113: invokeinterface #60, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 118: astore 5\n 120: aload 5\n 122: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 127: ifeq 227\n 130: aload 5\n 132: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 137: checkcast #27 // class java/util/List\n 140: astore 6\n 142: iconst_0\n 143: istore 7\n 145: aload 6\n 147: invokeinterface #74, 1 // InterfaceMethod java/util/List.size:()I\n 152: istore 8\n 154: iload 7\n 156: iload 8\n 158: if_icmpgt 120\n 161: new #24 // class java/util/ArrayList\n 164: dup\n 165: invokespecial #25 // Method java/util/ArrayList.\"<init>\":()V\n 168: checkcast #27 // class java/util/List\n 171: astore 9\n 173: aload 9\n 175: aload 6\n 177: checkcast #76 // class java/util/Collection\n 180: invokeinterface #80, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 185: pop\n 186: aload 9\n 188: iload 7\n 190: aload_1\n 191: aload_1\n 192: arraylength\n 193: iconst_1\n 194: isub\n 195: iaload\n 196: invokestatic #33 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 199: invokeinterface #83, 3 // InterfaceMethod java/util/List.add:(ILjava/lang/Object;)V\n 204: aload 4\n 206: aload 9\n 208: invokeinterface #84, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 213: pop\n 214: iload 7\n 216: iload 8\n 218: if_icmpeq 120\n 221: iinc 7, 1\n 224: goto 161\n 227: aload_2\n 228: astore 5\n 230: aload 5\n 232: astore 6\n 234: iconst_0\n 235: istore 7\n 237: aload 6\n 239: aload 4\n 241: checkcast #76 // class java/util/Collection\n 244: invokeinterface #80, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 249: pop\n 250: aload 5\n 252: areturn\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/LongestPalindromicSubstring.kt
/** * Given a string s, find the longest palindromic substring in s. * You may assume that the maximum length of s is 1000. * * Example: * * Input: "babad" * * Output: "bab" * * Note: "aba" is also a valid answer. * Example: * * Input: "cbbd" * * Output: "bb" * * Accepted. */ class LongestPalindromicSubstring { fun longestPalindrome(s: String?): String? { if (s == null || s.length <= 1) { return s } var maxLength = 0 var startIndex = 0 for (index in 0 until s.length) { var leftIndex = index var rightIndex = index while (leftIndex >= 0 && rightIndex < s.length && s[leftIndex] == s[rightIndex]) { val current = rightIndex - leftIndex + 1 if (current > maxLength) { maxLength = current startIndex = leftIndex } leftIndex-- rightIndex++ } leftIndex = index rightIndex = index + 1 while (leftIndex >= 0 && rightIndex < s.length && s[leftIndex] == s[rightIndex]) { val current = rightIndex - leftIndex + 1 if (current > maxLength) { maxLength = current startIndex = leftIndex } leftIndex-- rightIndex++ } } return s.substring(startIndex, maxLength + startIndex) } }
[ { "class_path": "TonnyL__Windary__39f85cd/LongestPalindromicSubstring.class", "javap": "Compiled from \"LongestPalindromicSubstring.kt\"\npublic final class LongestPalindromicSubstring {\n public LongestPalindromicSubstring();\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: ifnull 12\n 4: aload_1\n 5: invokevirtual #19 // Method java/lang/String.length:()I\n 8: iconst_1\n 9: if_icmpgt 14\n 12: aload_1\n 13: areturn\n 14: iconst_0\n 15: istore_2\n 16: iconst_0\n 17: istore_3\n 18: iconst_0\n 19: istore 4\n 21: aload_1\n 22: invokevirtual #19 // Method java/lang/String.length:()I\n 25: istore 5\n 27: iload 4\n 29: iload 5\n 31: if_icmpge 176\n 34: iload 4\n 36: istore 6\n 38: iload 4\n 40: istore 7\n 42: iload 6\n 44: iflt 101\n 47: iload 7\n 49: aload_1\n 50: invokevirtual #19 // Method java/lang/String.length:()I\n 53: if_icmpge 101\n 56: aload_1\n 57: iload 6\n 59: invokevirtual #23 // Method java/lang/String.charAt:(I)C\n 62: aload_1\n 63: iload 7\n 65: invokevirtual #23 // Method java/lang/String.charAt:(I)C\n 68: if_icmpne 101\n 71: iload 7\n 73: iload 6\n 75: isub\n 76: iconst_1\n 77: iadd\n 78: istore 8\n 80: iload 8\n 82: iload_2\n 83: if_icmple 92\n 86: iload 8\n 88: istore_2\n 89: iload 6\n 91: istore_3\n 92: iinc 6, -1\n 95: iinc 7, 1\n 98: goto 42\n 101: iload 4\n 103: istore 6\n 105: iload 4\n 107: iconst_1\n 108: iadd\n 109: istore 7\n 111: iload 6\n 113: iflt 170\n 116: iload 7\n 118: aload_1\n 119: invokevirtual #19 // Method java/lang/String.length:()I\n 122: if_icmpge 170\n 125: aload_1\n 126: iload 6\n 128: invokevirtual #23 // Method java/lang/String.charAt:(I)C\n 131: aload_1\n 132: iload 7\n 134: invokevirtual #23 // Method java/lang/String.charAt:(I)C\n 137: if_icmpne 170\n 140: iload 7\n 142: iload 6\n 144: isub\n 145: iconst_1\n 146: iadd\n 147: istore 8\n 149: iload 8\n 151: iload_2\n 152: if_icmple 161\n 155: iload 8\n 157: istore_2\n 158: iload 6\n 160: istore_3\n 161: iinc 6, -1\n 164: iinc 7, 1\n 167: goto 111\n 170: iinc 4, 1\n 173: goto 27\n 176: aload_1\n 177: iload_3\n 178: iload_2\n 179: iload_3\n 180: iadd\n 181: invokevirtual #27 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 184: dup\n 185: ldc #29 // String substring(...)\n 187: invokestatic #35 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 190: areturn\n}\n", "javap_err": "" } ]
TonnyL__Windary__39f85cd/Kotlin/src/SearchA2DMatrix.kt
/** * Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: * * Integers in each row are sorted from left to right. * The first integer of each row is greater than the last integer of the previous row. * For example, * * Consider the following matrix: * * [ * [1, 3, 5, 7], * [10, 11, 16, 20], * [23, 30, 34, 50] * ] * Given target = 3, return true. * * Accepted. */ class SearchA2DMatrix { fun searchMatrix(matrix: Array<IntArray>, target: Int): Boolean { if (matrix.isEmpty() || matrix[0].isEmpty()) { return false } for (i in 0 until matrix.size - 1) { if (matrix[i][0] == target || matrix[i + 1][0] == target) { return true } else if (matrix[i][0] < target && matrix[i + 1][0] > target) { return matrix[i].binarySearch(target) >= 0 } } return matrix[matrix.size - 1].binarySearch(target) >= 0 } }
[ { "class_path": "TonnyL__Windary__39f85cd/SearchA2DMatrix.class", "javap": "Compiled from \"SearchA2DMatrix.kt\"\npublic final class SearchA2DMatrix {\n public SearchA2DMatrix();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final boolean searchMatrix(int[][], int);\n Code:\n 0: aload_1\n 1: ldc #15 // String matrix\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #23 // class \"[Ljava/lang/Object;\"\n 10: arraylength\n 11: ifne 18\n 14: iconst_1\n 15: goto 19\n 18: iconst_0\n 19: ifne 37\n 22: aload_1\n 23: iconst_0\n 24: aaload\n 25: arraylength\n 26: ifne 33\n 29: iconst_1\n 30: goto 34\n 33: iconst_0\n 34: ifeq 39\n 37: iconst_0\n 38: ireturn\n 39: iconst_0\n 40: istore_3\n 41: aload_1\n 42: checkcast #23 // class \"[Ljava/lang/Object;\"\n 45: arraylength\n 46: iconst_1\n 47: isub\n 48: istore 4\n 50: iload_3\n 51: iload 4\n 53: if_icmpge 125\n 56: aload_1\n 57: iload_3\n 58: aaload\n 59: iconst_0\n 60: iaload\n 61: iload_2\n 62: if_icmpeq 76\n 65: aload_1\n 66: iload_3\n 67: iconst_1\n 68: iadd\n 69: aaload\n 70: iconst_0\n 71: iaload\n 72: iload_2\n 73: if_icmpne 78\n 76: iconst_1\n 77: ireturn\n 78: aload_1\n 79: iload_3\n 80: aaload\n 81: iconst_0\n 82: iaload\n 83: iload_2\n 84: if_icmpge 119\n 87: aload_1\n 88: iload_3\n 89: iconst_1\n 90: iadd\n 91: aaload\n 92: iconst_0\n 93: iaload\n 94: iload_2\n 95: if_icmple 119\n 98: aload_1\n 99: iload_3\n 100: aaload\n 101: iload_2\n 102: iconst_0\n 103: iconst_0\n 104: bipush 6\n 106: aconst_null\n 107: invokestatic #29 // Method kotlin/collections/ArraysKt.binarySearch$default:([IIIIILjava/lang/Object;)I\n 110: iflt 117\n 113: iconst_1\n 114: goto 118\n 117: iconst_0\n 118: ireturn\n 119: iinc 3, 1\n 122: goto 50\n 125: aload_1\n 126: aload_1\n 127: checkcast #23 // class \"[Ljava/lang/Object;\"\n 130: arraylength\n 131: iconst_1\n 132: isub\n 133: aaload\n 134: iload_2\n 135: iconst_0\n 136: iconst_0\n 137: bipush 6\n 139: aconst_null\n 140: invokestatic #29 // Method kotlin/collections/ArraysKt.binarySearch$default:([IIIIILjava/lang/Object;)I\n 143: iflt 150\n 146: iconst_1\n 147: goto 151\n 150: iconst_0\n 151: ireturn\n}\n", "javap_err": "" } ]
InertExpert2911__Kotlin-Projects__9ec619b/listFunctions.kt
// GATHERING A LIST OF VALUES fun getListOfNumbers() : List<Int> { var myList = mutableListOf <Int> () for(i in 1..7){ println("Enter a number:") var Number = Integer.valueOf(readLine()) myList.add(Number) } return myList } // FINDING THE MAX VALUE fun findMax(maxList : List<Int>) : Int { var largestNumber = maxList[0] // The loop runs for every element in the list and compares it with the largest number. If the conditional is true then, the largest number is updated. for(j in maxList){ if(j > largestNumber){ largestNumber = j } } return largestNumber } // FINDING THE MIN VALUE fun findMin(minList : List<Int>) : Int { var smallestNumber = minList[0] // The loop runs for every element in the list and compares it with the smallest number. If the conditional is true then, the smallest number is updated. for(k in minList){ if(k < smallestNumber){ smallestNumber = k } } return smallestNumber } // FINDING THE AVERAGE fun findAverage(listAvg : List<Int>) : Int { var sum = 0 for(l in listAvg){ sum += l } return sum / listAvg.size } // FINDING IF A LIST CONTAINS A VALUE fun checkIfListContains(checkList : List<Int>, numToCheck : Int) : Boolean { for(m in checkList){ if(m == numToCheck){ return true } } return false } // MAIN FUNCTION fun main() { // OUTPUT OF THE LIST var values = getListOfNumbers() println(values) // OUTPUT FOR THE MAX VALUE var largestValue = findMax(values) println("The largest number is $largestValue") // OUTPUT FOR THE MIN VALUE var smallestValue = findMin(values) println("The smallest number is $smallestValue") // OUTPUT OF THE AVERAGE var average = findAverage(values) println("The average is $average") // TO CHECK IF A VALUE CONTAINS println("Enter the number you want to check:") var numToFind = Integer.valueOf(readLine()) var containsValue = checkIfListContains(values, numToFind) if(containsValue == true){ println("Number Found !!!!") } else { println("Number Not Found ???? WTF !!!") } } // ADDITIONAL CHALLENGES // 1. Create a function that returns the difference between the largest and smallest number in the list. // ANS: For the first prompt, use the logic from findMin() and findMax() to find the smallest and largest numbers. Then, return the difference between the two. /* // FUNC THAT RETURNS THE DIFF BW MIN AND MAX fun minMaxDiff(minMaxDiffList : List<Int>) : Int{ //LARGEST var largest = findMax(minMaxDiffList) //SMALLEST var smallest = findMin(minMaxDiffList) // DIFF var difference = largest - smallest return difference } fun main() { // LARGEST - SMALLEST var diff = minMaxDiff(values) println("The minMaxDiff is $diff") } */ // 2. Create a function that takes in a list of numbers and returns a list with all the values squared. // ANS: For the second prompt, create an empty list. Then, loop through each element of the list argument; inside the loop, add the value of the element multiplied by itself. /* //SQUARE fun squareNum(sqList : List<Int>) : List<Int> { for(z in sqList){ // sqList[z] = z * z var num = z * z // sqList[0] // sqList.remove() sqList.add(num) } return sqList } EROORS WORK IT OUT */
[ { "class_path": "InertExpert2911__Kotlin-Projects__9ec619b/ListFunctionsKt.class", "javap": "Compiled from \"listFunctions.kt\"\npublic final class ListFunctionsKt {\n public static final java.util.List<java.lang.Integer> getListOfNumbers();\n Code:\n 0: new #10 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #14 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #16 // class java/util/List\n 10: astore_0\n 11: iconst_1\n 12: istore_1\n 13: iload_1\n 14: bipush 8\n 16: if_icmpge 55\n 19: ldc #18 // String Enter a number:\n 21: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 24: swap\n 25: invokevirtual #30 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 28: invokestatic #36 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 31: invokestatic #42 // Method java/lang/Integer.valueOf:(Ljava/lang/String;)Ljava/lang/Integer;\n 34: astore_2\n 35: aload_0\n 36: aload_2\n 37: astore_3\n 38: aload_3\n 39: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 42: aload_3\n 43: invokeinterface #51, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 48: pop\n 49: iinc 1, 1\n 52: goto 13\n 55: aload_0\n 56: areturn\n\n public static final int findMax(java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #62 // String maxList\n 3: invokestatic #66 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iconst_0\n 8: invokeinterface #70, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 13: checkcast #72 // class java/lang/Number\n 16: invokevirtual #76 // Method java/lang/Number.intValue:()I\n 19: istore_1\n 20: aload_0\n 21: invokeinterface #80, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 26: astore_2\n 27: aload_2\n 28: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 33: ifeq 59\n 36: aload_2\n 37: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 42: checkcast #72 // class java/lang/Number\n 45: invokevirtual #76 // Method java/lang/Number.intValue:()I\n 48: istore_3\n 49: iload_3\n 50: iload_1\n 51: if_icmple 27\n 54: iload_3\n 55: istore_1\n 56: goto 27\n 59: iload_1\n 60: ireturn\n\n public static final int findMin(java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #95 // String minList\n 3: invokestatic #66 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iconst_0\n 8: invokeinterface #70, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 13: checkcast #72 // class java/lang/Number\n 16: invokevirtual #76 // Method java/lang/Number.intValue:()I\n 19: istore_1\n 20: aload_0\n 21: invokeinterface #80, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 26: astore_2\n 27: aload_2\n 28: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 33: ifeq 59\n 36: aload_2\n 37: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 42: checkcast #72 // class java/lang/Number\n 45: invokevirtual #76 // Method java/lang/Number.intValue:()I\n 48: istore_3\n 49: iload_3\n 50: iload_1\n 51: if_icmpge 27\n 54: iload_3\n 55: istore_1\n 56: goto 27\n 59: iload_1\n 60: ireturn\n\n public static final int findAverage(java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #100 // String listAvg\n 3: invokestatic #66 // 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: invokeinterface #80, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 14: astore_2\n 15: aload_2\n 16: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 21: ifeq 44\n 24: aload_2\n 25: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 30: checkcast #72 // class java/lang/Number\n 33: invokevirtual #76 // Method java/lang/Number.intValue:()I\n 36: istore_3\n 37: iload_1\n 38: iload_3\n 39: iadd\n 40: istore_1\n 41: goto 15\n 44: iload_1\n 45: aload_0\n 46: invokeinterface #103, 1 // InterfaceMethod java/util/List.size:()I\n 51: idiv\n 52: ireturn\n\n public static final boolean checkIfListContains(java.util.List<java.lang.Integer>, int);\n Code:\n 0: aload_0\n 1: ldc #110 // String checkList\n 3: invokestatic #66 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #80, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 12: astore_2\n 13: aload_2\n 14: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 19: ifeq 42\n 22: aload_2\n 23: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 28: checkcast #72 // class java/lang/Number\n 31: invokevirtual #76 // Method java/lang/Number.intValue:()I\n 34: istore_3\n 35: iload_3\n 36: iload_1\n 37: if_icmpne 13\n 40: iconst_1\n 41: ireturn\n 42: iconst_0\n 43: ireturn\n\n public static final void main();\n Code:\n 0: invokestatic #115 // Method getListOfNumbers:()Ljava/util/List;\n 3: astore_0\n 4: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 7: aload_0\n 8: invokevirtual #30 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 11: aload_0\n 12: invokestatic #117 // Method findMax:(Ljava/util/List;)I\n 15: istore_1\n 16: new #119 // class java/lang/StringBuilder\n 19: dup\n 20: invokespecial #120 // Method java/lang/StringBuilder.\"<init>\":()V\n 23: ldc #122 // String The largest number is\n 25: invokevirtual #126 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 28: iload_1\n 29: invokevirtual #129 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 32: invokevirtual #132 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 35: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 38: swap\n 39: invokevirtual #30 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 42: aload_0\n 43: invokestatic #134 // Method findMin:(Ljava/util/List;)I\n 46: istore_2\n 47: new #119 // class java/lang/StringBuilder\n 50: dup\n 51: invokespecial #120 // Method java/lang/StringBuilder.\"<init>\":()V\n 54: ldc #136 // String The smallest number is\n 56: invokevirtual #126 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 59: iload_2\n 60: invokevirtual #129 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 63: invokevirtual #132 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 66: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 69: swap\n 70: invokevirtual #30 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 73: aload_0\n 74: invokestatic #138 // Method findAverage:(Ljava/util/List;)I\n 77: istore_3\n 78: new #119 // class java/lang/StringBuilder\n 81: dup\n 82: invokespecial #120 // Method java/lang/StringBuilder.\"<init>\":()V\n 85: ldc #140 // String The average is\n 87: invokevirtual #126 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 90: iload_3\n 91: invokevirtual #129 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 94: invokevirtual #132 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 97: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 100: swap\n 101: invokevirtual #30 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 104: ldc #142 // String Enter the number you want to check:\n 106: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 109: swap\n 110: invokevirtual #30 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 113: invokestatic #36 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 116: invokestatic #42 // Method java/lang/Integer.valueOf:(Ljava/lang/String;)Ljava/lang/Integer;\n 119: astore 4\n 121: aload_0\n 122: aload 4\n 124: astore 6\n 126: aload 6\n 128: invokestatic #47 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 131: aload 6\n 133: checkcast #72 // class java/lang/Number\n 136: invokevirtual #76 // Method java/lang/Number.intValue:()I\n 139: invokestatic #144 // Method checkIfListContains:(Ljava/util/List;I)Z\n 142: istore 5\n 144: iload 5\n 146: iconst_1\n 147: if_icmpne 162\n 150: ldc #146 // String Number Found !!!!\n 152: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 155: swap\n 156: invokevirtual #30 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 159: goto 171\n 162: ldc #148 // String Number Not Found ???? WTF !!!\n 164: getstatic #24 // Field java/lang/System.out:Ljava/io/PrintStream;\n 167: swap\n 168: invokevirtual #30 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 171: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #158 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
codinasion__codinasion__98267f3/program/program/find-the-adjoint-of-a-matrix/FindTheAdjointOfAMatrix.kt
fun main() { val matrixA = listOf( listOf(1, 2, 3), listOf(4, 5, 6), listOf(7, 8, 9) ) val matrixAdjoint = calculateAdjoint(matrixA) println("Input (A): $matrixA") println("Matrix of Adjoint (A*): $matrixAdjoint") } fun calculateAdjoint(matrix: List<List<Int>>): List<List<Int>> { val matrixCofactors = calculateCofactors(matrix) return transpose(matrixCofactors) } fun calculateCofactors(matrix: List<List<Int>>): List<List<Int>> { return matrix.mapIndexed { i, row -> row.indices.map { j -> getCofactor(matrix, i, j) } } } fun transpose(matrix: List<List<Int>>): List<List<Int>> { if (matrix.isEmpty() || matrix[0].isEmpty()) return emptyList() val numRows = matrix.size val numCols = matrix[0].size return List(numCols) { col -> List(numRows) { row -> matrix[row][col] } } } fun getCofactor(matrix: List<List<Int>>, row: Int, col: Int): Int { val sign = if ((row + col) % 2 == 0) 1 else -1 val subMatrix = getSubMatrix(matrix, row, col) return sign * determinant(subMatrix) } fun getSubMatrix(matrix: List<List<Int>>, rowToRemove: Int, colToRemove: Int): List<List<Int>> { return matrix .filterIndexed { i, _ -> i != rowToRemove } .map { row -> row.filterIndexed { j, _ -> j != colToRemove } } } fun determinant(matrix: List<List<Int>>): Int { if (matrix.size == 2) return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0] return matrix.indices.sumOf { i -> val sign = if (i % 2 == 0) 1 else -1 val subMatrix = getSubMatrix(matrix, 0, i) sign * matrix[0][i] * determinant(subMatrix) } }
[ { "class_path": "codinasion__codinasion__98267f3/FindTheAdjointOfAMatrixKt.class", "javap": "Compiled from \"FindTheAdjointOfAMatrix.kt\"\npublic final class FindTheAdjointOfAMatrixKt {\n public static final void main();\n Code:\n 0: iconst_3\n 1: anewarray #8 // class java/util/List\n 4: astore_1\n 5: aload_1\n 6: iconst_0\n 7: iconst_3\n 8: anewarray #10 // class java/lang/Integer\n 11: astore_2\n 12: aload_2\n 13: iconst_0\n 14: iconst_1\n 15: invokestatic #14 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 18: aastore\n 19: aload_2\n 20: iconst_1\n 21: iconst_2\n 22: invokestatic #14 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 25: aastore\n 26: aload_2\n 27: iconst_2\n 28: iconst_3\n 29: invokestatic #14 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 32: aastore\n 33: aload_2\n 34: invokestatic #20 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 37: aastore\n 38: aload_1\n 39: iconst_1\n 40: iconst_3\n 41: anewarray #10 // class java/lang/Integer\n 44: astore_2\n 45: aload_2\n 46: iconst_0\n 47: iconst_4\n 48: invokestatic #14 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 51: aastore\n 52: aload_2\n 53: iconst_1\n 54: iconst_5\n 55: invokestatic #14 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 58: aastore\n 59: aload_2\n 60: iconst_2\n 61: bipush 6\n 63: invokestatic #14 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 66: aastore\n 67: aload_2\n 68: invokestatic #20 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 71: aastore\n 72: aload_1\n 73: iconst_2\n 74: iconst_3\n 75: anewarray #10 // class java/lang/Integer\n 78: astore_2\n 79: aload_2\n 80: iconst_0\n 81: bipush 7\n 83: invokestatic #14 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 86: aastore\n 87: aload_2\n 88: iconst_1\n 89: bipush 8\n 91: invokestatic #14 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 94: aastore\n 95: aload_2\n 96: iconst_2\n 97: bipush 9\n 99: invokestatic #14 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 102: aastore\n 103: aload_2\n 104: invokestatic #20 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 107: aastore\n 108: aload_1\n 109: invokestatic #20 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 112: astore_0\n 113: aload_0\n 114: invokestatic #24 // Method calculateAdjoint:(Ljava/util/List;)Ljava/util/List;\n 117: astore_1\n 118: new #26 // class java/lang/StringBuilder\n 121: dup\n 122: invokespecial #29 // Method java/lang/StringBuilder.\"<init>\":()V\n 125: ldc #31 // String Input (A):\n 127: invokevirtual #35 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 130: aload_0\n 131: invokevirtual #38 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 134: invokevirtual #42 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 137: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 140: swap\n 141: invokevirtual #54 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 144: new #26 // class java/lang/StringBuilder\n 147: dup\n 148: invokespecial #29 // Method java/lang/StringBuilder.\"<init>\":()V\n 151: ldc #56 // String Matrix of Adjoint (A*):\n 153: invokevirtual #35 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 156: aload_1\n 157: invokevirtual #38 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 160: invokevirtual #42 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 163: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 166: swap\n 167: invokevirtual #54 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 170: return\n\n public static final java.util.List<java.util.List<java.lang.Integer>> calculateAdjoint(java.util.List<? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: ldc #63 // String matrix\n 3: invokestatic #69 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #72 // Method calculateCofactors:(Ljava/util/List;)Ljava/util/List;\n 10: astore_1\n 11: aload_1\n 12: invokestatic #75 // Method transpose:(Ljava/util/List;)Ljava/util/List;\n 15: areturn\n\n public static final java.util.List<java.util.List<java.lang.Integer>> calculateCofactors(java.util.List<? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: ldc #63 // String matrix\n 3: invokestatic #69 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #78 // 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 #80 // class java/util/ArrayList\n 18: dup\n 19: aload_1\n 20: bipush 10\n 22: invokestatic #84 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 25: invokespecial #87 // Method java/util/ArrayList.\"<init>\":(I)V\n 28: checkcast #89 // 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: aload_3\n 40: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 7\n 47: aload 7\n 49: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 223\n 57: aload 7\n 59: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 8\n 66: aload 4\n 68: iload 6\n 70: iinc 6, 1\n 73: istore 9\n 75: iload 9\n 77: ifge 83\n 80: invokestatic #106 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 83: iload 9\n 85: aload 8\n 87: checkcast #8 // class java/util/List\n 90: astore 10\n 92: istore 11\n 94: astore 23\n 96: iconst_0\n 97: istore 12\n 99: aload 10\n 101: checkcast #89 // class java/util/Collection\n 104: invokestatic #110 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 107: checkcast #78 // class java/lang/Iterable\n 110: astore 13\n 112: iconst_0\n 113: istore 14\n 115: aload 13\n 117: astore 15\n 119: new #80 // class java/util/ArrayList\n 122: dup\n 123: aload 13\n 125: bipush 10\n 127: invokestatic #84 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 130: invokespecial #87 // Method java/util/ArrayList.\"<init>\":(I)V\n 133: checkcast #89 // class java/util/Collection\n 136: astore 16\n 138: iconst_0\n 139: istore 17\n 141: aload 15\n 143: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 148: astore 18\n 150: aload 18\n 152: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 157: ifeq 204\n 160: aload 18\n 162: checkcast #112 // class kotlin/collections/IntIterator\n 165: invokevirtual #116 // Method kotlin/collections/IntIterator.nextInt:()I\n 168: istore 19\n 170: aload 16\n 172: iload 19\n 174: istore 20\n 176: astore 21\n 178: iconst_0\n 179: istore 22\n 181: aload_0\n 182: iload 11\n 184: iload 20\n 186: invokestatic #120 // Method getCofactor:(Ljava/util/List;II)I\n 189: invokestatic #14 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 192: aload 21\n 194: swap\n 195: invokeinterface #124, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 200: pop\n 201: goto 150\n 204: aload 16\n 206: checkcast #8 // class java/util/List\n 209: nop\n 210: nop\n 211: aload 23\n 213: swap\n 214: invokeinterface #124, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 219: pop\n 220: goto 47\n 223: aload 4\n 225: checkcast #8 // class java/util/List\n 228: nop\n 229: areturn\n\n public static final java.util.List<java.util.List<java.lang.Integer>> transpose(java.util.List<? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: ldc #63 // String matrix\n 3: invokestatic #69 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #147, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 12: ifne 33\n 15: aload_0\n 16: iconst_0\n 17: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 22: checkcast #8 // class java/util/List\n 25: invokeinterface #147, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 30: ifeq 37\n 33: invokestatic #155 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 36: areturn\n 37: aload_0\n 38: invokeinterface #158, 1 // InterfaceMethod java/util/List.size:()I\n 43: istore_1\n 44: aload_0\n 45: iconst_0\n 46: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 51: checkcast #8 // class java/util/List\n 54: invokeinterface #158, 1 // InterfaceMethod java/util/List.size:()I\n 59: istore_2\n 60: new #80 // class java/util/ArrayList\n 63: dup\n 64: iload_2\n 65: invokespecial #87 // Method java/util/ArrayList.\"<init>\":(I)V\n 68: astore_3\n 69: iconst_0\n 70: istore 4\n 72: iload 4\n 74: iload_2\n 75: if_icmpge 185\n 78: iload 4\n 80: istore 5\n 82: aload_3\n 83: iload 5\n 85: istore 6\n 87: astore 14\n 89: iconst_0\n 90: istore 7\n 92: new #80 // class java/util/ArrayList\n 95: dup\n 96: iload_1\n 97: invokespecial #87 // Method java/util/ArrayList.\"<init>\":(I)V\n 100: astore 8\n 102: iconst_0\n 103: istore 9\n 105: iload 9\n 107: iload_1\n 108: if_icmpge 166\n 111: iload 9\n 113: istore 10\n 115: aload 8\n 117: iload 10\n 119: istore 11\n 121: astore 12\n 123: iconst_0\n 124: istore 13\n 126: aload_0\n 127: iload 11\n 129: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 134: checkcast #8 // class java/util/List\n 137: iload 6\n 139: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 144: checkcast #160 // class java/lang/Number\n 147: invokevirtual #163 // Method java/lang/Number.intValue:()I\n 150: invokestatic #14 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 153: aload 12\n 155: swap\n 156: invokevirtual #164 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 159: pop\n 160: iinc 9, 1\n 163: goto 105\n 166: aload 8\n 168: checkcast #8 // class java/util/List\n 171: nop\n 172: aload 14\n 174: swap\n 175: invokevirtual #164 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 178: pop\n 179: iinc 4, 1\n 182: goto 72\n 185: aload_3\n 186: checkcast #8 // class java/util/List\n 189: areturn\n\n public static final int getCofactor(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #63 // String matrix\n 3: invokestatic #69 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_1\n 7: iload_2\n 8: iadd\n 9: iconst_2\n 10: irem\n 11: ifne 18\n 14: iconst_1\n 15: goto 19\n 18: iconst_m1\n 19: istore_3\n 20: aload_0\n 21: iload_1\n 22: iload_2\n 23: invokestatic #174 // Method getSubMatrix:(Ljava/util/List;II)Ljava/util/List;\n 26: astore 4\n 28: iload_3\n 29: aload 4\n 31: invokestatic #178 // Method determinant:(Ljava/util/List;)I\n 34: imul\n 35: ireturn\n\n public static final java.util.List<java.util.List<java.lang.Integer>> getSubMatrix(java.util.List<? extends java.util.List<java.lang.Integer>>, int, int);\n Code:\n 0: aload_0\n 1: ldc #63 // String matrix\n 3: invokestatic #69 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: checkcast #78 // class java/lang/Iterable\n 10: astore_3\n 11: nop\n 12: iconst_0\n 13: istore 4\n 15: aload_3\n 16: astore 5\n 18: new #80 // class java/util/ArrayList\n 21: dup\n 22: invokespecial #182 // Method java/util/ArrayList.\"<init>\":()V\n 25: checkcast #89 // class java/util/Collection\n 28: astore 6\n 30: iconst_0\n 31: istore 7\n 33: aload 5\n 35: astore 8\n 37: iconst_0\n 38: istore 9\n 40: iconst_0\n 41: istore 10\n 43: aload 8\n 45: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 11\n 52: aload 11\n 54: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 139\n 62: aload 11\n 64: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 12\n 71: iload 10\n 73: iinc 10, 1\n 76: istore 13\n 78: iload 13\n 80: ifge 86\n 83: invokestatic #106 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 86: iload 13\n 88: aload 12\n 90: astore 14\n 92: istore 15\n 94: iconst_0\n 95: istore 16\n 97: iload 15\n 99: aload 14\n 101: checkcast #8 // class java/util/List\n 104: pop\n 105: istore 18\n 107: iconst_0\n 108: istore 19\n 110: iload 18\n 112: iload_1\n 113: if_icmpeq 120\n 116: iconst_1\n 117: goto 121\n 120: iconst_0\n 121: ifeq 134\n 124: aload 6\n 126: aload 14\n 128: invokeinterface #124, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 133: pop\n 134: nop\n 135: nop\n 136: goto 52\n 139: nop\n 140: aload 6\n 142: checkcast #8 // class java/util/List\n 145: nop\n 146: checkcast #78 // class java/lang/Iterable\n 149: astore_3\n 150: nop\n 151: iconst_0\n 152: istore 4\n 154: aload_3\n 155: astore 5\n 157: new #80 // class java/util/ArrayList\n 160: dup\n 161: aload_3\n 162: bipush 10\n 164: invokestatic #84 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 167: invokespecial #87 // Method java/util/ArrayList.\"<init>\":(I)V\n 170: checkcast #89 // class java/util/Collection\n 173: astore 6\n 175: iconst_0\n 176: istore 7\n 178: aload 5\n 180: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 185: astore 8\n 187: aload 8\n 189: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 194: ifeq 378\n 197: aload 8\n 199: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 204: astore 9\n 206: aload 6\n 208: aload 9\n 210: checkcast #8 // class java/util/List\n 213: astore 10\n 215: astore 28\n 217: iconst_0\n 218: istore 11\n 220: aload 10\n 222: checkcast #78 // class java/lang/Iterable\n 225: astore 12\n 227: iconst_0\n 228: istore 13\n 230: aload 12\n 232: astore 14\n 234: new #80 // class java/util/ArrayList\n 237: dup\n 238: invokespecial #182 // Method java/util/ArrayList.\"<init>\":()V\n 241: checkcast #89 // class java/util/Collection\n 244: astore 15\n 246: iconst_0\n 247: istore 16\n 249: aload 14\n 251: astore 17\n 253: iconst_0\n 254: istore 18\n 256: iconst_0\n 257: istore 19\n 259: aload 17\n 261: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 266: astore 20\n 268: aload 20\n 270: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 275: ifeq 358\n 278: aload 20\n 280: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 285: astore 21\n 287: iload 19\n 289: iinc 19, 1\n 292: istore 22\n 294: iload 22\n 296: ifge 302\n 299: invokestatic #106 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 302: iload 22\n 304: aload 21\n 306: astore 23\n 308: istore 24\n 310: iconst_0\n 311: istore 25\n 313: iload 24\n 315: aload 23\n 317: checkcast #160 // class java/lang/Number\n 320: invokevirtual #163 // Method java/lang/Number.intValue:()I\n 323: pop\n 324: istore 26\n 326: iconst_0\n 327: istore 27\n 329: iload 26\n 331: iload_2\n 332: if_icmpeq 339\n 335: iconst_1\n 336: goto 340\n 339: iconst_0\n 340: ifeq 353\n 343: aload 15\n 345: aload 23\n 347: invokeinterface #124, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 352: pop\n 353: nop\n 354: nop\n 355: goto 268\n 358: nop\n 359: aload 15\n 361: checkcast #8 // class java/util/List\n 364: nop\n 365: nop\n 366: aload 28\n 368: swap\n 369: invokeinterface #124, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 374: pop\n 375: goto 187\n 378: aload 6\n 380: checkcast #8 // class java/util/List\n 383: nop\n 384: areturn\n\n public static final int determinant(java.util.List<? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: ldc #63 // String matrix\n 3: invokestatic #69 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokeinterface #158, 1 // InterfaceMethod java/util/List.size:()I\n 12: iconst_2\n 13: if_icmpne 108\n 16: aload_0\n 17: iconst_0\n 18: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 23: checkcast #8 // class java/util/List\n 26: iconst_0\n 27: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 32: checkcast #160 // class java/lang/Number\n 35: invokevirtual #163 // Method java/lang/Number.intValue:()I\n 38: aload_0\n 39: iconst_1\n 40: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 45: checkcast #8 // class java/util/List\n 48: iconst_1\n 49: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 54: checkcast #160 // class java/lang/Number\n 57: invokevirtual #163 // Method java/lang/Number.intValue:()I\n 60: imul\n 61: aload_0\n 62: iconst_0\n 63: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 68: checkcast #8 // class java/util/List\n 71: iconst_1\n 72: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 77: checkcast #160 // class java/lang/Number\n 80: invokevirtual #163 // Method java/lang/Number.intValue:()I\n 83: aload_0\n 84: iconst_1\n 85: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 90: checkcast #8 // class java/util/List\n 93: iconst_0\n 94: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 99: checkcast #160 // class java/lang/Number\n 102: invokevirtual #163 // Method java/lang/Number.intValue:()I\n 105: imul\n 106: isub\n 107: ireturn\n 108: aload_0\n 109: checkcast #89 // class java/util/Collection\n 112: invokestatic #110 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 115: checkcast #78 // class java/lang/Iterable\n 118: astore_1\n 119: iconst_0\n 120: istore_2\n 121: aload_1\n 122: invokeinterface #93, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 127: astore_3\n 128: aload_3\n 129: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 134: ifeq 222\n 137: aload_3\n 138: checkcast #112 // class kotlin/collections/IntIterator\n 141: invokevirtual #116 // Method kotlin/collections/IntIterator.nextInt:()I\n 144: istore 4\n 146: iload_2\n 147: iload 4\n 149: istore 5\n 151: istore 9\n 153: iconst_0\n 154: istore 6\n 156: iload 5\n 158: iconst_2\n 159: irem\n 160: ifne 167\n 163: iconst_1\n 164: goto 168\n 167: iconst_m1\n 168: istore 7\n 170: aload_0\n 171: iconst_0\n 172: iload 5\n 174: invokestatic #174 // Method getSubMatrix:(Ljava/util/List;II)Ljava/util/List;\n 177: astore 8\n 179: iload 7\n 181: aload_0\n 182: iconst_0\n 183: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 188: checkcast #8 // class java/util/List\n 191: iload 5\n 193: invokeinterface #151, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 198: checkcast #160 // class java/lang/Number\n 201: invokevirtual #163 // Method java/lang/Number.intValue:()I\n 204: imul\n 205: aload 8\n 207: invokestatic #178 // Method determinant:(Ljava/util/List;)I\n 210: imul\n 211: istore 10\n 213: iload 9\n 215: iload 10\n 217: iadd\n 218: istore_2\n 219: goto 128\n 222: iload_2\n 223: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #202 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Utils.kt
import java.io.File import java.math.BigInteger import java.security.MessageDigest import kotlin.math.abs typealias Matrix = Array<IntArray> typealias BooleanMatrix = Array<BooleanArray> typealias Int3DMatrix = Array<Array<IntArray>> typealias Boolean3DMatrix = Array<Array<BooleanArray>> /** * Reads lines from the given input txt file. */ fun readInput(name: String) = File("src", "$name.txt") .readLines() /** * Converts string to md5 hash. */ fun String.md5() = BigInteger(1, MessageDigest.getInstance("MD5").digest(toByteArray())) .toString(16) .padStart(32, '0') operator fun IntRange.contains(other: IntRange): Boolean = first <= other.first && other.last <= last val IntRange.size get() = abs(this.last - this.first) + 1 data class XY(val x: Int, val y: Int) data class MutableXY(var x: Int, var y: Int) { fun toXY() = XY(x = x, y = y) } data class IJ(val i: Int, val j: Int) data class MutableIJ(var i: Int, var j: Int) { fun toIJ() = IJ(i = i, j = j) } fun BooleanMatrix.deepCopyOf(): BooleanMatrix = Array(this.size) { i -> this[i].copyOf() } data class Item(val steps: Int, val ij: IJ) : Comparable<Item> { override fun compareTo(other: Item): Int { return this.steps - other.steps } } /** * Create all possible combinations from the list's elements */ fun <T> List<T>.allCombinations(): List<List<T>> { val results = mutableListOf<List<T>>() repeat(this.size + 1) { count -> combine(data = ArrayList(count), results, start = 0, index = 0, count = count) } return results } /** * Create all possible combinations with size "count " from the list's elements * @param count - count of the elements in each combination */ fun <T> List<T>.combinations(count: Int): List<List<T>> { val results = mutableListOf<List<T>>() combine(data = ArrayList(count), results, start = 0, index = 0, count = count) return results } private fun <T> List<T>.combine( data: ArrayList<T>, results: MutableList<List<T>>, start: Int, index: Int, count: Int, ) { // Current combination is ready to be added to the result if (index == count) { results.add(ArrayList(data)) return } // replace index with all possible elements. The condition // "this.lastIndex - i + 1 >= (count - 1) - index" makes sure that including one element // at index will make a combination with remaining elements // at remaining positions var i = start while (i <= this.lastIndex && (this.lastIndex - i + 1 >= (count - 1) - index)) { if (data.lastIndex < index) { data.add(this[i]) } else { data[index] = this[i] } combine(data, results, start = i + 1, index = index + 1, count = count) i++ } }
[ { "class_path": "Kvest__AOC2022__6409e65/UtilsKt.class", "javap": "Compiled from \"Utils.kt\"\npublic final class UtilsKt {\n public static final java.util.List<java.lang.String> readInput(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #10 // String name\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #18 // class java/io/File\n 9: dup\n 10: ldc #20 // String src\n 12: new #22 // class java/lang/StringBuilder\n 15: dup\n 16: invokespecial #26 // Method java/lang/StringBuilder.\"<init>\":()V\n 19: aload_0\n 20: invokevirtual #30 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 23: ldc #32 // String .txt\n 25: invokevirtual #30 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 28: invokevirtual #36 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 31: invokespecial #39 // Method java/io/File.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 34: aconst_null\n 35: iconst_1\n 36: aconst_null\n 37: invokestatic #45 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 40: areturn\n\n public static final java.lang.String md5(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #50 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #52 // class java/math/BigInteger\n 9: dup\n 10: iconst_1\n 11: ldc #54 // String MD5\n 13: invokestatic #60 // Method java/security/MessageDigest.getInstance:(Ljava/lang/String;)Ljava/security/MessageDigest;\n 16: aload_0\n 17: astore_1\n 18: getstatic #66 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 21: aload_1\n 22: swap\n 23: invokevirtual #72 // Method java/lang/String.getBytes:(Ljava/nio/charset/Charset;)[B\n 26: dup\n 27: ldc #74 // String getBytes(...)\n 29: invokestatic #77 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 32: invokevirtual #81 // Method java/security/MessageDigest.digest:([B)[B\n 35: invokespecial #84 // Method java/math/BigInteger.\"<init>\":(I[B)V\n 38: bipush 16\n 40: invokevirtual #87 // Method java/math/BigInteger.toString:(I)Ljava/lang/String;\n 43: dup\n 44: ldc #89 // String toString(...)\n 46: invokestatic #77 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 49: bipush 32\n 51: bipush 48\n 53: invokestatic #95 // Method kotlin/text/StringsKt.padStart:(Ljava/lang/String;IC)Ljava/lang/String;\n 56: areturn\n\n public static final boolean contains(kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_0\n 1: ldc #50 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #100 // String other\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokevirtual #106 // Method kotlin/ranges/IntRange.getFirst:()I\n 16: aload_1\n 17: invokevirtual #106 // Method kotlin/ranges/IntRange.getFirst:()I\n 20: if_icmpgt 38\n 23: aload_1\n 24: invokevirtual #109 // Method kotlin/ranges/IntRange.getLast:()I\n 27: aload_0\n 28: invokevirtual #109 // Method kotlin/ranges/IntRange.getLast:()I\n 31: if_icmpgt 38\n 34: iconst_1\n 35: goto 39\n 38: iconst_0\n 39: ireturn\n\n public static final int getSize(kotlin.ranges.IntRange);\n Code:\n 0: aload_0\n 1: ldc #50 // 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: invokevirtual #109 // Method kotlin/ranges/IntRange.getLast:()I\n 10: aload_0\n 11: invokevirtual #106 // Method kotlin/ranges/IntRange.getFirst:()I\n 14: isub\n 15: invokestatic #119 // Method java/lang/Math.abs:(I)I\n 18: iconst_1\n 19: iadd\n 20: ireturn\n\n public static final boolean[][] deepCopyOf(boolean[][]);\n Code:\n 0: aload_0\n 1: ldc #50 // String <this>\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 #124 // class \"[Ljava/lang/Object;\"\n 12: arraylength\n 13: istore_2\n 14: iload_2\n 15: anewarray #126 // class \"[Z\"\n 18: astore_3\n 19: iload_1\n 20: iload_2\n 21: if_icmpge 52\n 24: iload_1\n 25: istore 4\n 27: aload_3\n 28: iload 4\n 30: aload_0\n 31: iload 4\n 33: aaload\n 34: dup\n 35: arraylength\n 36: invokestatic #132 // Method java/util/Arrays.copyOf:([ZI)[Z\n 39: dup\n 40: ldc #134 // String copyOf(...)\n 42: invokestatic #77 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 45: aastore\n 46: iinc 1, 1\n 49: goto 19\n 52: aload_3\n 53: areturn\n\n public static final <T> java.util.List<java.util.List<T>> allCombinations(java.util.List<? extends T>);\n Code:\n 0: aload_0\n 1: ldc #50 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #142 // class java/util/ArrayList\n 9: dup\n 10: invokespecial #143 // Method java/util/ArrayList.\"<init>\":()V\n 13: checkcast #145 // class java/util/List\n 16: astore_1\n 17: aload_0\n 18: invokeinterface #148, 1 // InterfaceMethod java/util/List.size:()I\n 23: iconst_1\n 24: iadd\n 25: istore_2\n 26: iconst_0\n 27: istore_3\n 28: iload_3\n 29: iload_2\n 30: if_icmpge 64\n 33: iload_3\n 34: istore 4\n 36: iconst_0\n 37: istore 5\n 39: aload_0\n 40: new #142 // class java/util/ArrayList\n 43: dup\n 44: iload 4\n 46: invokespecial #151 // Method java/util/ArrayList.\"<init>\":(I)V\n 49: aload_1\n 50: iconst_0\n 51: iconst_0\n 52: iload 4\n 54: invokestatic #155 // Method combine:(Ljava/util/List;Ljava/util/ArrayList;Ljava/util/List;III)V\n 57: nop\n 58: iinc 3, 1\n 61: goto 28\n 64: aload_1\n 65: areturn\n\n public static final <T> java.util.List<java.util.List<T>> combinations(java.util.List<? extends T>, int);\n Code:\n 0: aload_0\n 1: ldc #50 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #142 // class java/util/ArrayList\n 9: dup\n 10: invokespecial #143 // Method java/util/ArrayList.\"<init>\":()V\n 13: checkcast #145 // class java/util/List\n 16: astore_2\n 17: aload_0\n 18: new #142 // class java/util/ArrayList\n 21: dup\n 22: iload_1\n 23: invokespecial #151 // Method java/util/ArrayList.\"<init>\":(I)V\n 26: aload_2\n 27: iconst_0\n 28: iconst_0\n 29: iload_1\n 30: invokestatic #155 // Method combine:(Ljava/util/List;Ljava/util/ArrayList;Ljava/util/List;III)V\n 33: aload_2\n 34: areturn\n\n private static final <T> void combine(java.util.List<? extends T>, java.util.ArrayList<T>, java.util.List<java.util.List<T>>, int, int, int);\n Code:\n 0: iload 4\n 2: iload 5\n 4: if_icmpne 26\n 7: aload_2\n 8: new #142 // class java/util/ArrayList\n 11: dup\n 12: aload_1\n 13: checkcast #168 // class java/util/Collection\n 16: invokespecial #171 // Method java/util/ArrayList.\"<init>\":(Ljava/util/Collection;)V\n 19: invokeinterface #175, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 24: pop\n 25: return\n 26: iload_3\n 27: istore 6\n 29: iload 6\n 31: aload_0\n 32: invokestatic #181 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 35: if_icmpgt 122\n 38: aload_0\n 39: invokestatic #181 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 42: iload 6\n 44: isub\n 45: iconst_1\n 46: iadd\n 47: iload 5\n 49: iconst_1\n 50: isub\n 51: iload 4\n 53: isub\n 54: if_icmplt 122\n 57: aload_1\n 58: checkcast #145 // class java/util/List\n 61: invokestatic #181 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 64: iload 4\n 66: if_icmpge 85\n 69: aload_1\n 70: aload_0\n 71: iload 6\n 73: invokeinterface #185, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 78: invokevirtual #186 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 81: pop\n 82: goto 100\n 85: aload_1\n 86: iload 4\n 88: aload_0\n 89: iload 6\n 91: invokeinterface #185, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 96: invokevirtual #190 // Method java/util/ArrayList.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 99: pop\n 100: aload_0\n 101: aload_1\n 102: aload_2\n 103: iload 6\n 105: iconst_1\n 106: iadd\n 107: iload 4\n 109: iconst_1\n 110: iadd\n 111: iload 5\n 113: invokestatic #155 // Method combine:(Ljava/util/List;Ljava/util/ArrayList;Ljava/util/List;III)V\n 116: iinc 6, 1\n 119: goto 29\n 122: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day14.kt
import kotlin.math.max import kotlin.math.min fun main() { val testInput = readInput("Day14_test") check(part1(testInput) == 24) check(part2(testInput) == 93) val input = readInput("Day14") println(part1(input)) println(part2(input)) } private val SAND_START_POINT = XY(500, 0) private fun part1(input: List<String>): Int { val points = mutableSetOf<XY>() parseInput(input, points) val bottom = points.maxOf { it.y } val rocksCount = points.size solve(bottom, points, SAND_START_POINT, exitOnBottom = true) return points.size - rocksCount } private fun part2(input: List<String>): Int { val points = mutableSetOf<XY>() parseInput(input, points) val bottom = points.maxOf { it.y } + 2 val rocksCount = points.size solve(bottom, points, SAND_START_POINT, exitOnBottom = false) return points.size - rocksCount } private fun parseInput(input: List<String>, points: MutableSet<XY>) { input .map { it.split(" -> ") } .forEach { row -> row.windowed(2, 1) { (from, to) -> val xFrom = from.substringBefore(",").toInt() val yFrom = from.substringAfter(",").toInt() val xTo = to.substringBefore(",").toInt() val yTo = to.substringAfter(",").toInt() for (x in min(xFrom, xTo)..max(xFrom, xTo)) { for (y in min(yFrom, yTo)..max(yFrom, yTo)) { points.add(XY(x = x, y = y)) } } } } } private fun solve(bottom: Int, points: MutableSet<XY>, point: XY, exitOnBottom: Boolean): Boolean { if (points.contains(point)) { return false } if (point.y == bottom) { return exitOnBottom } if (solve(bottom, points, XY(x = point.x, y = point.y + 1), exitOnBottom)) return true if (solve(bottom, points, XY(x = point.x - 1, y = point.y + 1), exitOnBottom)) return true if (solve(bottom, points, XY(x = point.x + 1, y = point.y + 1), exitOnBottom)) return true points.add(point) return false }
[ { "class_path": "Kvest__AOC2022__6409e65/Day14Kt.class", "javap": "Compiled from \"Day14.kt\"\npublic final class Day14Kt {\n private static final XY SAND_START_POINT;\n\n public static final void main();\n Code:\n 0: ldc #8 // String 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: bipush 24\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 33\n 23: new #20 // class java/lang/IllegalStateException\n 26: dup\n 27: ldc #22 // String Check failed.\n 29: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 32: athrow\n 33: aload_0\n 34: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 37: bipush 93\n 39: if_icmpne 46\n 42: iconst_1\n 43: goto 47\n 46: iconst_0\n 47: ifne 60\n 50: new #20 // class java/lang/IllegalStateException\n 53: dup\n 54: ldc #22 // String Check failed.\n 56: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 59: athrow\n 60: ldc #31 // String Day14\n 62: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 65: astore_1\n 66: aload_1\n 67: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 70: istore_2\n 71: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 74: iload_2\n 75: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 78: aload_1\n 79: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 82: istore_2\n 83: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 86: iload_2\n 87: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 90: return\n\n private static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: new #51 // class java/util/LinkedHashSet\n 3: dup\n 4: invokespecial #53 // Method java/util/LinkedHashSet.\"<init>\":()V\n 7: checkcast #55 // class java/util/Set\n 10: astore_1\n 11: aload_0\n 12: aload_1\n 13: invokestatic #59 // Method parseInput:(Ljava/util/List;Ljava/util/Set;)V\n 16: aload_1\n 17: checkcast #61 // class java/lang/Iterable\n 20: invokeinterface #65, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 25: astore 4\n 27: aload 4\n 29: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 34: ifne 45\n 37: new #73 // class java/util/NoSuchElementException\n 40: dup\n 41: invokespecial #74 // Method java/util/NoSuchElementException.\"<init>\":()V\n 44: athrow\n 45: aload 4\n 47: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 52: checkcast #80 // class XY\n 55: astore 5\n 57: iconst_0\n 58: istore 6\n 60: aload 5\n 62: invokevirtual #84 // Method XY.getY:()I\n 65: istore 5\n 67: aload 4\n 69: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 74: ifeq 113\n 77: aload 4\n 79: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 84: checkcast #80 // class XY\n 87: astore 6\n 89: iconst_0\n 90: istore 7\n 92: aload 6\n 94: invokevirtual #84 // Method XY.getY:()I\n 97: istore 6\n 99: iload 5\n 101: iload 6\n 103: if_icmpge 67\n 106: iload 6\n 108: istore 5\n 110: goto 67\n 113: iload 5\n 115: istore_2\n 116: aload_1\n 117: invokeinterface #87, 1 // InterfaceMethod java/util/Set.size:()I\n 122: istore_3\n 123: iload_2\n 124: aload_1\n 125: getstatic #91 // Field SAND_START_POINT:LXY;\n 128: iconst_1\n 129: invokestatic #95 // Method solve:(ILjava/util/Set;LXY;Z)Z\n 132: pop\n 133: aload_1\n 134: invokeinterface #87, 1 // InterfaceMethod java/util/Set.size:()I\n 139: iload_3\n 140: isub\n 141: ireturn\n\n private static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: new #51 // class java/util/LinkedHashSet\n 3: dup\n 4: invokespecial #53 // Method java/util/LinkedHashSet.\"<init>\":()V\n 7: checkcast #55 // class java/util/Set\n 10: astore_1\n 11: aload_0\n 12: aload_1\n 13: invokestatic #59 // Method parseInput:(Ljava/util/List;Ljava/util/Set;)V\n 16: aload_1\n 17: checkcast #61 // class java/lang/Iterable\n 20: invokeinterface #65, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 25: astore 4\n 27: aload 4\n 29: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 34: ifne 45\n 37: new #73 // class java/util/NoSuchElementException\n 40: dup\n 41: invokespecial #74 // Method java/util/NoSuchElementException.\"<init>\":()V\n 44: athrow\n 45: aload 4\n 47: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 52: checkcast #80 // class XY\n 55: astore 5\n 57: iconst_0\n 58: istore 6\n 60: aload 5\n 62: invokevirtual #84 // Method XY.getY:()I\n 65: istore 5\n 67: aload 4\n 69: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 74: ifeq 113\n 77: aload 4\n 79: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 84: checkcast #80 // class XY\n 87: astore 6\n 89: iconst_0\n 90: istore 7\n 92: aload 6\n 94: invokevirtual #84 // Method XY.getY:()I\n 97: istore 6\n 99: iload 5\n 101: iload 6\n 103: if_icmpge 67\n 106: iload 6\n 108: istore 5\n 110: goto 67\n 113: iload 5\n 115: iconst_2\n 116: iadd\n 117: istore_2\n 118: aload_1\n 119: invokeinterface #87, 1 // InterfaceMethod java/util/Set.size:()I\n 124: istore_3\n 125: iload_2\n 126: aload_1\n 127: getstatic #91 // Field SAND_START_POINT:LXY;\n 130: iconst_0\n 131: invokestatic #95 // Method solve:(ILjava/util/Set;LXY;Z)Z\n 134: pop\n 135: aload_1\n 136: invokeinterface #87, 1 // InterfaceMethod java/util/Set.size:()I\n 141: iload_3\n 142: isub\n 143: ireturn\n\n private static final void parseInput(java.util.List<java.lang.String>, java.util.Set<XY>);\n Code:\n 0: aload_0\n 1: checkcast #61 // class java/lang/Iterable\n 4: astore_2\n 5: nop\n 6: iconst_0\n 7: istore_3\n 8: aload_2\n 9: astore 4\n 11: new #106 // class java/util/ArrayList\n 14: dup\n 15: aload_2\n 16: bipush 10\n 18: invokestatic #112 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 21: invokespecial #114 // Method java/util/ArrayList.\"<init>\":(I)V\n 24: checkcast #116 // class java/util/Collection\n 27: astore 5\n 29: iconst_0\n 30: istore 6\n 32: aload 4\n 34: invokeinterface #65, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 7\n 41: aload 7\n 43: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 113\n 51: aload 7\n 53: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 8\n 60: aload 5\n 62: aload 8\n 64: checkcast #118 // class java/lang/String\n 67: astore 9\n 69: astore 12\n 71: iconst_0\n 72: istore 10\n 74: aload 9\n 76: checkcast #120 // class java/lang/CharSequence\n 79: iconst_1\n 80: anewarray #118 // class java/lang/String\n 83: astore 11\n 85: aload 11\n 87: iconst_0\n 88: ldc #122 // String ->\n 90: aastore\n 91: aload 11\n 93: iconst_0\n 94: iconst_0\n 95: bipush 6\n 97: aconst_null\n 98: invokestatic #128 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 101: aload 12\n 103: swap\n 104: invokeinterface #132, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 109: pop\n 110: goto 41\n 113: aload 5\n 115: checkcast #48 // class java/util/List\n 118: nop\n 119: checkcast #61 // class java/lang/Iterable\n 122: astore_2\n 123: nop\n 124: iconst_0\n 125: istore_3\n 126: aload_2\n 127: invokeinterface #65, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 132: astore 4\n 134: aload 4\n 136: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 141: ifeq 188\n 144: aload 4\n 146: invokeinterface #78, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 151: astore 5\n 153: aload 5\n 155: checkcast #48 // class java/util/List\n 158: astore 6\n 160: iconst_0\n 161: istore 7\n 163: aload 6\n 165: checkcast #61 // class java/lang/Iterable\n 168: iconst_2\n 169: iconst_1\n 170: iconst_0\n 171: aload_1\n 172: invokedynamic #152, 0 // InvokeDynamic #0:invoke:(Ljava/util/Set;)Lkotlin/jvm/functions/Function1;\n 177: iconst_4\n 178: aconst_null\n 179: invokestatic #156 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/util/List;\n 182: pop\n 183: nop\n 184: nop\n 185: goto 134\n 188: nop\n 189: return\n\n private static final boolean solve(int, java.util.Set<XY>, XY, boolean);\n Code:\n 0: aload_1\n 1: aload_2\n 2: invokeinterface #176, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 7: ifeq 12\n 10: iconst_0\n 11: ireturn\n 12: aload_2\n 13: invokevirtual #84 // Method XY.getY:()I\n 16: iload_0\n 17: if_icmpne 22\n 20: iload_3\n 21: ireturn\n 22: iload_0\n 23: aload_1\n 24: new #80 // class XY\n 27: dup\n 28: aload_2\n 29: invokevirtual #179 // Method XY.getX:()I\n 32: aload_2\n 33: invokevirtual #84 // Method XY.getY:()I\n 36: iconst_1\n 37: iadd\n 38: invokespecial #182 // Method XY.\"<init>\":(II)V\n 41: iload_3\n 42: invokestatic #95 // Method solve:(ILjava/util/Set;LXY;Z)Z\n 45: ifeq 50\n 48: iconst_1\n 49: ireturn\n 50: iload_0\n 51: aload_1\n 52: new #80 // class XY\n 55: dup\n 56: aload_2\n 57: invokevirtual #179 // Method XY.getX:()I\n 60: iconst_1\n 61: isub\n 62: aload_2\n 63: invokevirtual #84 // Method XY.getY:()I\n 66: iconst_1\n 67: iadd\n 68: invokespecial #182 // Method XY.\"<init>\":(II)V\n 71: iload_3\n 72: invokestatic #95 // Method solve:(ILjava/util/Set;LXY;Z)Z\n 75: ifeq 80\n 78: iconst_1\n 79: ireturn\n 80: iload_0\n 81: aload_1\n 82: new #80 // class XY\n 85: dup\n 86: aload_2\n 87: invokevirtual #179 // Method XY.getX:()I\n 90: iconst_1\n 91: iadd\n 92: aload_2\n 93: invokevirtual #84 // Method XY.getY:()I\n 96: iconst_1\n 97: iadd\n 98: invokespecial #182 // Method XY.\"<init>\":(II)V\n 101: iload_3\n 102: invokestatic #95 // Method solve:(ILjava/util/Set;LXY;Z)Z\n 105: ifeq 110\n 108: iconst_1\n 109: ireturn\n 110: aload_1\n 111: aload_2\n 112: invokeinterface #183, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 117: pop\n 118: iconst_0\n 119: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #189 // Method main:()V\n 3: return\n\n private static final kotlin.Unit parseInput$lambda$4$lambda$3(java.util.Set, java.util.List);\n Code:\n 0: aload_1\n 1: ldc #193 // String <destruct>\n 3: invokestatic #199 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: iconst_0\n 8: invokeinterface #203, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 13: checkcast #118 // class java/lang/String\n 16: astore_2\n 17: aload_1\n 18: iconst_1\n 19: invokeinterface #203, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 24: checkcast #118 // class java/lang/String\n 27: astore_3\n 28: aload_2\n 29: ldc #205 // String ,\n 31: aconst_null\n 32: iconst_2\n 33: aconst_null\n 34: invokestatic #209 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 37: invokestatic #215 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 40: istore 4\n 42: aload_2\n 43: ldc #205 // String ,\n 45: aconst_null\n 46: iconst_2\n 47: aconst_null\n 48: invokestatic #218 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 51: invokestatic #215 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 54: istore 5\n 56: aload_3\n 57: ldc #205 // String ,\n 59: aconst_null\n 60: iconst_2\n 61: aconst_null\n 62: invokestatic #209 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 65: invokestatic #215 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 68: istore 6\n 70: aload_3\n 71: ldc #205 // String ,\n 73: aconst_null\n 74: iconst_2\n 75: aconst_null\n 76: invokestatic #218 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 79: invokestatic #215 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 82: istore 7\n 84: iload 4\n 86: iload 6\n 88: invokestatic #224 // Method java/lang/Math.min:(II)I\n 91: istore 8\n 93: iload 4\n 95: iload 6\n 97: invokestatic #227 // Method java/lang/Math.max:(II)I\n 100: istore 9\n 102: iload 8\n 104: iload 9\n 106: if_icmpgt 178\n 109: iload 5\n 111: iload 7\n 113: invokestatic #224 // Method java/lang/Math.min:(II)I\n 116: istore 10\n 118: iload 5\n 120: iload 7\n 122: invokestatic #227 // Method java/lang/Math.max:(II)I\n 125: istore 11\n 127: iload 10\n 129: iload 11\n 131: if_icmpgt 165\n 134: aload_0\n 135: new #80 // class XY\n 138: dup\n 139: iload 8\n 141: iload 10\n 143: invokespecial #182 // Method XY.\"<init>\":(II)V\n 146: invokeinterface #183, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 151: pop\n 152: iload 10\n 154: iload 11\n 156: if_icmpeq 165\n 159: iinc 10, 1\n 162: goto 134\n 165: iload 8\n 167: iload 9\n 169: if_icmpeq 178\n 172: iinc 8, 1\n 175: goto 109\n 178: getstatic #233 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 181: areturn\n\n static {};\n Code:\n 0: new #80 // class XY\n 3: dup\n 4: sipush 500\n 7: iconst_0\n 8: invokespecial #182 // Method XY.\"<init>\":(II)V\n 11: putstatic #91 // Field SAND_START_POINT:LXY;\n 14: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day04.kt
fun main() { val testInput = readInput("Day04_test") check(part1(testInput) == 2) check(part2(testInput) == 4) val input = readInput("Day04") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { return input .map(String::parseSectionRanges) .count { it.first in it.second || it.second in it.first } } private fun part2(input: List<String>): Int { return input .map(String::parseSectionRanges) .count { it.first.first in it.second || it.second.first in it.first } } private val ROW_FORMAT = Regex("(\\d+)-(\\d+),(\\d+)-(\\d+)") private fun String.parseSectionRanges(): Pair<IntRange, IntRange> { val match = ROW_FORMAT.find(this) val (a, b, c, d) = requireNotNull(match).destructured return IntRange(a.toInt(), b.toInt()) to IntRange(c.toInt(), d.toInt()) }
[ { "class_path": "Kvest__AOC2022__6409e65/Day04Kt.class", "javap": "Compiled from \"Day04.kt\"\npublic final class Day04Kt {\n private static final kotlin.text.Regex ROW_FORMAT;\n\n public static final void main();\n Code:\n 0: ldc #8 // String Day04_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: iconst_2\n 11: if_icmpne 18\n 14: iconst_1\n 15: goto 19\n 18: iconst_0\n 19: ifne 32\n 22: new #20 // class java/lang/IllegalStateException\n 25: dup\n 26: ldc #22 // String Check failed.\n 28: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 31: athrow\n 32: aload_0\n 33: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 36: iconst_4\n 37: if_icmpne 44\n 40: iconst_1\n 41: goto 45\n 44: iconst_0\n 45: ifne 58\n 48: new #20 // class java/lang/IllegalStateException\n 51: dup\n 52: ldc #22 // String Check failed.\n 54: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 57: athrow\n 58: ldc #31 // String Day04\n 60: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 63: astore_1\n 64: aload_1\n 65: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 68: istore_2\n 69: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 72: iload_2\n 73: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 76: aload_1\n 77: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 80: istore_2\n 81: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 84: iload_2\n 85: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 88: return\n\n private static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #51 // class java/lang/Iterable\n 4: astore_1\n 5: nop\n 6: iconst_0\n 7: istore_2\n 8: aload_1\n 9: astore_3\n 10: new #53 // class java/util/ArrayList\n 13: dup\n 14: aload_1\n 15: bipush 10\n 17: invokestatic #59 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #61 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #63 // class java/util/Collection\n 26: astore 4\n 28: iconst_0\n 29: istore 5\n 31: aload_3\n 32: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore 6\n 39: aload 6\n 41: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 89\n 49: aload 6\n 51: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 56: astore 7\n 58: aload 4\n 60: aload 7\n 62: checkcast #79 // class java/lang/String\n 65: astore 8\n 67: astore 10\n 69: iconst_0\n 70: istore 9\n 72: aload 8\n 74: invokestatic #83 // Method parseSectionRanges:(Ljava/lang/String;)Lkotlin/Pair;\n 77: aload 10\n 79: swap\n 80: invokeinterface #87, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 85: pop\n 86: goto 39\n 89: aload 4\n 91: checkcast #48 // class java/util/List\n 94: nop\n 95: checkcast #51 // class java/lang/Iterable\n 98: astore_1\n 99: nop\n 100: iconst_0\n 101: istore_2\n 102: aload_1\n 103: instanceof #63 // class java/util/Collection\n 106: ifeq 125\n 109: aload_1\n 110: checkcast #63 // class java/util/Collection\n 113: invokeinterface #90, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 118: ifeq 125\n 121: iconst_0\n 122: goto 230\n 125: iconst_0\n 126: istore_3\n 127: aload_1\n 128: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 133: astore 4\n 135: aload 4\n 137: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 142: ifeq 229\n 145: aload 4\n 147: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 152: astore 5\n 154: aload 5\n 156: checkcast #92 // class kotlin/Pair\n 159: astore 6\n 161: iconst_0\n 162: istore 7\n 164: aload 6\n 166: invokevirtual #95 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 169: checkcast #97 // class kotlin/ranges/IntRange\n 172: aload 6\n 174: invokevirtual #100 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 177: checkcast #97 // class kotlin/ranges/IntRange\n 180: invokestatic #104 // Method UtilsKt.contains:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z\n 183: ifne 208\n 186: aload 6\n 188: invokevirtual #100 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 191: checkcast #97 // class kotlin/ranges/IntRange\n 194: aload 6\n 196: invokevirtual #95 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 199: checkcast #97 // class kotlin/ranges/IntRange\n 202: invokestatic #104 // Method UtilsKt.contains:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Z\n 205: ifeq 212\n 208: iconst_1\n 209: goto 213\n 212: iconst_0\n 213: ifeq 135\n 216: iinc 3, 1\n 219: iload_3\n 220: ifge 135\n 223: invokestatic #107 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 226: goto 135\n 229: iload_3\n 230: ireturn\n\n private static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #51 // class java/lang/Iterable\n 4: astore_1\n 5: nop\n 6: iconst_0\n 7: istore_2\n 8: aload_1\n 9: astore_3\n 10: new #53 // class java/util/ArrayList\n 13: dup\n 14: aload_1\n 15: bipush 10\n 17: invokestatic #59 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #61 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #63 // class java/util/Collection\n 26: astore 4\n 28: iconst_0\n 29: istore 5\n 31: aload_3\n 32: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore 6\n 39: aload 6\n 41: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 89\n 49: aload 6\n 51: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 56: astore 7\n 58: aload 4\n 60: aload 7\n 62: checkcast #79 // class java/lang/String\n 65: astore 8\n 67: astore 12\n 69: iconst_0\n 70: istore 9\n 72: aload 8\n 74: invokestatic #83 // Method parseSectionRanges:(Ljava/lang/String;)Lkotlin/Pair;\n 77: aload 12\n 79: swap\n 80: invokeinterface #87, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 85: pop\n 86: goto 39\n 89: aload 4\n 91: checkcast #48 // class java/util/List\n 94: nop\n 95: checkcast #51 // class java/lang/Iterable\n 98: astore_1\n 99: nop\n 100: iconst_0\n 101: istore_2\n 102: aload_1\n 103: instanceof #63 // class java/util/Collection\n 106: ifeq 125\n 109: aload_1\n 110: checkcast #63 // class java/util/Collection\n 113: invokeinterface #90, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 118: ifeq 125\n 121: iconst_0\n 122: goto 312\n 125: iconst_0\n 126: istore_3\n 127: aload_1\n 128: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 133: astore 4\n 135: aload 4\n 137: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 142: ifeq 311\n 145: aload 4\n 147: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 152: astore 5\n 154: aload 5\n 156: checkcast #92 // class kotlin/Pair\n 159: astore 6\n 161: iconst_0\n 162: istore 7\n 164: aload 6\n 166: invokevirtual #95 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 169: checkcast #97 // class kotlin/ranges/IntRange\n 172: astore 8\n 174: aload 8\n 176: invokevirtual #130 // Method kotlin/ranges/IntRange.getFirst:()I\n 179: istore 9\n 181: aload 8\n 183: invokevirtual #133 // Method kotlin/ranges/IntRange.getLast:()I\n 186: istore 10\n 188: aload 6\n 190: invokevirtual #100 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 193: checkcast #97 // class kotlin/ranges/IntRange\n 196: invokevirtual #130 // Method kotlin/ranges/IntRange.getFirst:()I\n 199: istore 11\n 201: iload 9\n 203: iload 11\n 205: if_icmpgt 223\n 208: iload 11\n 210: iload 10\n 212: if_icmpgt 219\n 215: iconst_1\n 216: goto 224\n 219: iconst_0\n 220: goto 224\n 223: iconst_0\n 224: ifne 290\n 227: aload 6\n 229: invokevirtual #100 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 232: checkcast #97 // class kotlin/ranges/IntRange\n 235: astore 8\n 237: aload 8\n 239: invokevirtual #130 // Method kotlin/ranges/IntRange.getFirst:()I\n 242: istore 9\n 244: aload 8\n 246: invokevirtual #133 // Method kotlin/ranges/IntRange.getLast:()I\n 249: istore 10\n 251: aload 6\n 253: invokevirtual #95 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 256: checkcast #97 // class kotlin/ranges/IntRange\n 259: invokevirtual #130 // Method kotlin/ranges/IntRange.getFirst:()I\n 262: istore 11\n 264: iload 9\n 266: iload 11\n 268: if_icmpgt 286\n 271: iload 11\n 273: iload 10\n 275: if_icmpgt 282\n 278: iconst_1\n 279: goto 287\n 282: iconst_0\n 283: goto 287\n 286: iconst_0\n 287: ifeq 294\n 290: iconst_1\n 291: goto 295\n 294: iconst_0\n 295: ifeq 135\n 298: iinc 3, 1\n 301: iload_3\n 302: ifge 135\n 305: invokestatic #107 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 308: goto 135\n 311: iload_3\n 312: ireturn\n\n private static final kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange> parseSectionRanges(java.lang.String);\n Code:\n 0: getstatic #140 // Field ROW_FORMAT:Lkotlin/text/Regex;\n 3: aload_0\n 4: checkcast #142 // class java/lang/CharSequence\n 7: iconst_0\n 8: iconst_2\n 9: aconst_null\n 10: invokestatic #148 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 13: astore_1\n 14: aload_1\n 15: dup\n 16: ifnonnull 35\n 19: pop\n 20: ldc #150 // String Required value was null.\n 22: astore_3\n 23: new #152 // class java/lang/IllegalArgumentException\n 26: dup\n 27: aload_3\n 28: invokevirtual #156 // Method java/lang/Object.toString:()Ljava/lang/String;\n 31: invokespecial #157 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 34: athrow\n 35: invokeinterface #163, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 40: astore_2\n 41: aload_2\n 42: invokevirtual #169 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 45: invokeinterface #173, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 50: iconst_1\n 51: invokeinterface #177, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 56: checkcast #79 // class java/lang/String\n 59: astore_3\n 60: aload_2\n 61: invokevirtual #169 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 64: invokeinterface #173, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 69: iconst_2\n 70: invokeinterface #177, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 75: checkcast #79 // class java/lang/String\n 78: astore 4\n 80: aload_2\n 81: invokevirtual #169 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 84: invokeinterface #173, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 89: iconst_3\n 90: invokeinterface #177, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 95: checkcast #79 // class java/lang/String\n 98: astore 5\n 100: aload_2\n 101: invokevirtual #169 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 104: invokeinterface #173, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 109: iconst_4\n 110: invokeinterface #177, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 115: checkcast #79 // class java/lang/String\n 118: astore 6\n 120: new #97 // class kotlin/ranges/IntRange\n 123: dup\n 124: aload_3\n 125: invokestatic #183 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 128: aload 4\n 130: invokestatic #183 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 133: invokespecial #186 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 136: new #97 // class kotlin/ranges/IntRange\n 139: dup\n 140: aload 5\n 142: invokestatic #183 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 145: aload 6\n 147: invokestatic #183 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 150: invokespecial #186 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 153: invokestatic #192 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 156: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #202 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: new #144 // class kotlin/text/Regex\n 3: dup\n 4: ldc #207 // String (\\\\d+)-(\\\\d+),(\\\\d+)-(\\\\d+)\n 6: invokespecial #208 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: putstatic #140 // Field ROW_FORMAT:Lkotlin/text/Regex;\n 12: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day15.kt
import java.util.* import kotlin.math.abs import kotlin.math.max import kotlin.time.ExperimentalTime @ExperimentalTime fun main() { val testInput = readInput("Day15_test") val (testSensors, testBeacons) = parseInput(testInput) check(part1(testSensors, testBeacons, targetLine = 10) == 26) check(part2(testSensors, bound = 20) == 56000011L) val input = readInput("Day15") val (sensors, beacons) = parseInput(input) println(part1(sensors, beacons, targetLine = 2_000_000)) println(part2(sensors, bound = 4_000_000)) } private fun part1(sensors: List<Sensor>, beacons: Set<XY>, targetLine: Int): Int { val intervals = calculateLineCoverage(sensors, targetLine) val beaconsOnLine = beacons.filter { beacon -> beacon.y == targetLine }.count() return intervals.sumOf { it.size } - beaconsOnLine } private fun part2(sensors: List<Sensor>, bound: Int): Long { for (y in 0..bound) { val intervals = calculateLineCoverage(sensors, y) if (intervals[0].first > 0) { return y.toLong() } for (i in 1..intervals.lastIndex) { if (intervals[i].first - intervals[i - 1].last > 1) { return (intervals[i - 1].last + 1) * 4_000_000L + y } } if (intervals.last().last < bound) { return (intervals.last().last + 1) * 4_000_000L + y } } error("Not found") } private val ROW_FORMAT = Regex("Sensor at x=(-?\\d+), y=(-?\\d+): closest beacon is at x=(-?\\d+), y=(-?\\d+)") private fun parseInput(input: List<String>): Pair<List<Sensor>, Set<XY>> { val sensors = mutableListOf<Sensor>() val beacons = mutableSetOf<XY>() input.forEach { val match = ROW_FORMAT.find(it) val (x, y, beaconX, beaconY) = requireNotNull(match).destructured val radius = abs(x.toInt() - beaconX.toInt()) + abs(y.toInt() - beaconY.toInt()) sensors.add(Sensor(x = x.toInt(), y = y.toInt(), radius = radius)) beacons.add(XY(x = beaconX.toInt(), y = beaconY.toInt())) } return Pair(sensors, beacons) } private fun calculateLineCoverage(sensors: List<Sensor>, line: Int): List<IntRange> { val intervals = sensors .mapNotNull { sensor -> val count = sensor.radius - abs(sensor.y - line) if (count > 0) { ((sensor.x - count)..(sensor.x + count)) } else { null } } .sortedBy { it.first } val result = LinkedList<IntRange>() //collapse intervals if possible result.addLast(intervals.first()) for (i in 1..intervals.lastIndex) { if (result.last.last >= intervals[i].first) { val tmp = result.pollLast() result.addLast(tmp.first..max(tmp.last, intervals[i].last)) } else { result.addLast(intervals[i]) } } return result } private data class Sensor( val x: Int, val y: Int, val radius: Int, )
[ { "class_path": "Kvest__AOC2022__6409e65/Day15Kt$calculateLineCoverage$$inlined$sortedBy$1.class", "javap": "Compiled from \"Comparisons.kt\"\npublic final class Day15Kt$calculateLineCoverage$$inlined$sortedBy$1<T> implements java.util.Comparator {\n public Day15Kt$calculateLineCoverage$$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": "" }, { "class_path": "Kvest__AOC2022__6409e65/Day15Kt.class", "javap": "Compiled from \"Day15.kt\"\npublic final class Day15Kt {\n private static final kotlin.text.Regex ROW_FORMAT;\n\n public static final void main();\n Code:\n 0: ldc #9 // String Day15_test\n 2: invokestatic #15 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: invokestatic #19 // Method parseInput:(Ljava/util/List;)Lkotlin/Pair;\n 10: astore_1\n 11: aload_1\n 12: invokevirtual #25 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 15: checkcast #27 // class java/util/List\n 18: astore_2\n 19: aload_1\n 20: invokevirtual #30 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 23: checkcast #32 // class java/util/Set\n 26: astore_3\n 27: aload_2\n 28: aload_3\n 29: bipush 10\n 31: invokestatic #36 // Method part1:(Ljava/util/List;Ljava/util/Set;I)I\n 34: bipush 26\n 36: if_icmpne 43\n 39: iconst_1\n 40: goto 44\n 43: iconst_0\n 44: ifne 57\n 47: new #38 // class java/lang/IllegalStateException\n 50: dup\n 51: ldc #40 // String Check failed.\n 53: invokespecial #44 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 56: athrow\n 57: aload_2\n 58: bipush 20\n 60: invokestatic #48 // Method part2:(Ljava/util/List;I)J\n 63: ldc2_w #49 // long 56000011l\n 66: lcmp\n 67: ifne 74\n 70: iconst_1\n 71: goto 75\n 74: iconst_0\n 75: ifne 88\n 78: new #38 // class java/lang/IllegalStateException\n 81: dup\n 82: ldc #40 // String Check failed.\n 84: invokespecial #44 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 87: athrow\n 88: ldc #52 // String Day15\n 90: invokestatic #15 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 93: astore 4\n 95: aload 4\n 97: invokestatic #19 // Method parseInput:(Ljava/util/List;)Lkotlin/Pair;\n 100: astore 5\n 102: aload 5\n 104: invokevirtual #25 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 107: checkcast #27 // class java/util/List\n 110: astore 6\n 112: aload 5\n 114: invokevirtual #30 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 117: checkcast #32 // class java/util/Set\n 120: astore 7\n 122: aload 6\n 124: aload 7\n 126: ldc #53 // int 2000000\n 128: invokestatic #36 // Method part1:(Ljava/util/List;Ljava/util/Set;I)I\n 131: istore 8\n 133: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 136: iload 8\n 138: invokevirtual #65 // Method java/io/PrintStream.println:(I)V\n 141: aload 6\n 143: ldc #66 // int 4000000\n 145: invokestatic #48 // Method part2:(Ljava/util/List;I)J\n 148: lstore 8\n 150: getstatic #59 // Field java/lang/System.out:Ljava/io/PrintStream;\n 153: lload 8\n 155: invokevirtual #69 // Method java/io/PrintStream.println:(J)V\n 158: return\n\n private static final int part1(java.util.List<Sensor>, java.util.Set<XY>, int);\n Code:\n 0: aload_0\n 1: iload_2\n 2: invokestatic #82 // Method calculateLineCoverage:(Ljava/util/List;I)Ljava/util/List;\n 5: astore_3\n 6: aload_1\n 7: checkcast #84 // class java/lang/Iterable\n 10: astore 5\n 12: iconst_0\n 13: istore 6\n 15: aload 5\n 17: astore 7\n 19: new #86 // class java/util/ArrayList\n 22: dup\n 23: invokespecial #88 // Method java/util/ArrayList.\"<init>\":()V\n 26: checkcast #90 // class java/util/Collection\n 29: astore 8\n 31: iconst_0\n 32: istore 9\n 34: aload 7\n 36: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 41: astore 10\n 43: aload 10\n 45: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 50: ifeq 102\n 53: aload 10\n 55: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 60: astore 11\n 62: aload 11\n 64: checkcast #105 // class XY\n 67: astore 12\n 69: iconst_0\n 70: istore 13\n 72: aload 12\n 74: invokevirtual #109 // Method XY.getY:()I\n 77: iload_2\n 78: if_icmpne 85\n 81: iconst_1\n 82: goto 86\n 85: iconst_0\n 86: ifeq 43\n 89: aload 8\n 91: aload 11\n 93: invokeinterface #113, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 98: pop\n 99: goto 43\n 102: aload 8\n 104: checkcast #27 // class java/util/List\n 107: nop\n 108: checkcast #90 // class java/util/Collection\n 111: invokeinterface #116, 1 // InterfaceMethod java/util/Collection.size:()I\n 116: istore 4\n 118: aload_3\n 119: checkcast #84 // class java/lang/Iterable\n 122: astore 5\n 124: iconst_0\n 125: istore 6\n 127: aload 5\n 129: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 134: astore 7\n 136: aload 7\n 138: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 143: ifeq 186\n 146: aload 7\n 148: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 153: astore 8\n 155: iload 6\n 157: aload 8\n 159: checkcast #118 // class kotlin/ranges/IntRange\n 162: astore 9\n 164: istore 14\n 166: iconst_0\n 167: istore 10\n 169: aload 9\n 171: invokestatic #122 // Method UtilsKt.getSize:(Lkotlin/ranges/IntRange;)I\n 174: istore 15\n 176: iload 14\n 178: iload 15\n 180: iadd\n 181: istore 6\n 183: goto 136\n 186: iload 6\n 188: iload 4\n 190: isub\n 191: ireturn\n\n private static final long part2(java.util.List<Sensor>, int);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: iload_2\n 3: iload_1\n 4: if_icmpgt 169\n 7: aload_0\n 8: iload_2\n 9: invokestatic #82 // Method calculateLineCoverage:(Ljava/util/List;I)Ljava/util/List;\n 12: astore_3\n 13: aload_3\n 14: iconst_0\n 15: invokeinterface #146, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 20: checkcast #118 // class kotlin/ranges/IntRange\n 23: invokevirtual #149 // Method kotlin/ranges/IntRange.getFirst:()I\n 26: ifle 32\n 29: iload_2\n 30: i2l\n 31: lreturn\n 32: iconst_1\n 33: istore 4\n 35: aload_3\n 36: invokestatic #155 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 39: istore 5\n 41: iload 4\n 43: iload 5\n 45: if_icmpgt 123\n 48: aload_3\n 49: iload 4\n 51: invokeinterface #146, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 56: checkcast #118 // class kotlin/ranges/IntRange\n 59: invokevirtual #149 // Method kotlin/ranges/IntRange.getFirst:()I\n 62: aload_3\n 63: iload 4\n 65: iconst_1\n 66: isub\n 67: invokeinterface #146, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 72: checkcast #118 // class kotlin/ranges/IntRange\n 75: invokevirtual #158 // Method kotlin/ranges/IntRange.getLast:()I\n 78: isub\n 79: iconst_1\n 80: if_icmple 110\n 83: aload_3\n 84: iload 4\n 86: iconst_1\n 87: isub\n 88: invokeinterface #146, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 93: checkcast #118 // class kotlin/ranges/IntRange\n 96: invokevirtual #158 // Method kotlin/ranges/IntRange.getLast:()I\n 99: iconst_1\n 100: iadd\n 101: i2l\n 102: ldc2_w #159 // long 4000000l\n 105: lmul\n 106: iload_2\n 107: i2l\n 108: ladd\n 109: lreturn\n 110: iload 4\n 112: iload 5\n 114: if_icmpeq 123\n 117: iinc 4, 1\n 120: goto 48\n 123: aload_3\n 124: invokestatic #164 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 127: checkcast #118 // class kotlin/ranges/IntRange\n 130: invokevirtual #158 // Method kotlin/ranges/IntRange.getLast:()I\n 133: iload_1\n 134: if_icmpge 158\n 137: aload_3\n 138: invokestatic #164 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 141: checkcast #118 // class kotlin/ranges/IntRange\n 144: invokevirtual #158 // Method kotlin/ranges/IntRange.getLast:()I\n 147: iconst_1\n 148: iadd\n 149: i2l\n 150: ldc2_w #159 // long 4000000l\n 153: lmul\n 154: iload_2\n 155: i2l\n 156: ladd\n 157: lreturn\n 158: iload_2\n 159: iload_1\n 160: if_icmpeq 169\n 163: iinc 2, 1\n 166: goto 7\n 169: new #38 // class java/lang/IllegalStateException\n 172: dup\n 173: ldc #166 // String Not found\n 175: invokevirtual #170 // Method java/lang/Object.toString:()Ljava/lang/String;\n 178: invokespecial #44 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 181: athrow\n\n private static final kotlin.Pair<java.util.List<Sensor>, java.util.Set<XY>> parseInput(java.util.List<java.lang.String>);\n Code:\n 0: new #86 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #88 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #27 // class java/util/List\n 10: astore_1\n 11: new #176 // class java/util/LinkedHashSet\n 14: dup\n 15: invokespecial #177 // Method java/util/LinkedHashSet.\"<init>\":()V\n 18: checkcast #32 // class java/util/Set\n 21: astore_2\n 22: aload_0\n 23: checkcast #84 // class java/lang/Iterable\n 26: astore_3\n 27: iconst_0\n 28: istore 4\n 30: aload_3\n 31: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 5\n 38: aload 5\n 40: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 284\n 48: aload 5\n 50: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 6\n 57: aload 6\n 59: checkcast #179 // class java/lang/String\n 62: astore 7\n 64: iconst_0\n 65: istore 8\n 67: getstatic #183 // Field ROW_FORMAT:Lkotlin/text/Regex;\n 70: aload 7\n 72: checkcast #185 // class java/lang/CharSequence\n 75: iconst_0\n 76: iconst_2\n 77: aconst_null\n 78: invokestatic #191 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 81: astore 9\n 83: aload 9\n 85: dup\n 86: ifnonnull 107\n 89: pop\n 90: ldc #193 // String Required value was null.\n 92: astore 10\n 94: new #195 // class java/lang/IllegalArgumentException\n 97: dup\n 98: aload 10\n 100: invokevirtual #170 // Method java/lang/Object.toString:()Ljava/lang/String;\n 103: invokespecial #196 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 106: athrow\n 107: invokeinterface #202, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 112: astore 11\n 114: aload 11\n 116: invokevirtual #208 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 119: invokeinterface #212, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 124: iconst_1\n 125: invokeinterface #146, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 130: checkcast #179 // class java/lang/String\n 133: astore 10\n 135: aload 11\n 137: invokevirtual #208 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 140: invokeinterface #212, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 145: iconst_2\n 146: invokeinterface #146, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 151: checkcast #179 // class java/lang/String\n 154: astore 12\n 156: aload 11\n 158: invokevirtual #208 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 161: invokeinterface #212, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 166: iconst_3\n 167: invokeinterface #146, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 172: checkcast #179 // class java/lang/String\n 175: astore 13\n 177: aload 11\n 179: invokevirtual #208 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 182: invokeinterface #212, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 187: iconst_4\n 188: invokeinterface #146, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 193: checkcast #179 // class java/lang/String\n 196: astore 14\n 198: aload 10\n 200: invokestatic #218 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 203: aload 13\n 205: invokestatic #218 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 208: isub\n 209: invokestatic #224 // Method java/lang/Math.abs:(I)I\n 212: aload 12\n 214: invokestatic #218 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 217: aload 14\n 219: invokestatic #218 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 222: isub\n 223: invokestatic #224 // Method java/lang/Math.abs:(I)I\n 226: iadd\n 227: istore 15\n 229: aload_1\n 230: new #226 // class Sensor\n 233: dup\n 234: aload 10\n 236: invokestatic #218 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 239: aload 12\n 241: invokestatic #218 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 244: iload 15\n 246: invokespecial #229 // Method Sensor.\"<init>\":(III)V\n 249: invokeinterface #230, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 254: pop\n 255: aload_2\n 256: new #105 // class XY\n 259: dup\n 260: aload 13\n 262: invokestatic #218 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 265: aload 14\n 267: invokestatic #218 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 270: invokespecial #233 // Method XY.\"<init>\":(II)V\n 273: invokeinterface #234, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 278: pop\n 279: nop\n 280: nop\n 281: goto 38\n 284: nop\n 285: new #21 // class kotlin/Pair\n 288: dup\n 289: aload_1\n 290: aload_2\n 291: invokespecial #237 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 294: areturn\n\n private static final java.util.List<kotlin.ranges.IntRange> calculateLineCoverage(java.util.List<Sensor>, int);\n Code:\n 0: aload_0\n 1: checkcast #84 // class java/lang/Iterable\n 4: astore_3\n 5: nop\n 6: iconst_0\n 7: istore 4\n 9: aload_3\n 10: astore 5\n 12: new #86 // class java/util/ArrayList\n 15: dup\n 16: invokespecial #88 // Method java/util/ArrayList.\"<init>\":()V\n 19: checkcast #90 // class java/util/Collection\n 22: astore 6\n 24: iconst_0\n 25: istore 7\n 27: aload 5\n 29: astore 8\n 31: iconst_0\n 32: istore 9\n 34: aload 8\n 36: invokeinterface #94, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 41: astore 10\n 43: aload 10\n 45: invokeinterface #100, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 50: ifeq 157\n 53: aload 10\n 55: invokeinterface #103, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 60: astore 11\n 62: aload 11\n 64: astore 12\n 66: iconst_0\n 67: istore 13\n 69: aload 12\n 71: checkcast #226 // class Sensor\n 74: astore 14\n 76: iconst_0\n 77: istore 15\n 79: aload 14\n 81: invokevirtual #252 // Method Sensor.getRadius:()I\n 84: aload 14\n 86: invokevirtual #253 // Method Sensor.getY:()I\n 89: iload_1\n 90: isub\n 91: invokestatic #224 // Method java/lang/Math.abs:(I)I\n 94: isub\n 95: istore 16\n 97: iload 16\n 99: ifle 128\n 102: new #118 // class kotlin/ranges/IntRange\n 105: dup\n 106: aload 14\n 108: invokevirtual #256 // Method Sensor.getX:()I\n 111: iload 16\n 113: isub\n 114: aload 14\n 116: invokevirtual #256 // Method Sensor.getX:()I\n 119: iload 16\n 121: iadd\n 122: invokespecial #257 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 125: goto 129\n 128: aconst_null\n 129: nop\n 130: dup\n 131: ifnull 152\n 134: astore 17\n 136: iconst_0\n 137: istore 18\n 139: aload 6\n 141: aload 17\n 143: invokeinterface #113, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 148: pop\n 149: goto 153\n 152: pop\n 153: nop\n 154: goto 43\n 157: nop\n 158: aload 6\n 160: checkcast #27 // class java/util/List\n 163: nop\n 164: checkcast #84 // class java/lang/Iterable\n 167: astore_3\n 168: nop\n 169: iconst_0\n 170: istore 4\n 172: aload_3\n 173: new #259 // class Day15Kt$calculateLineCoverage$$inlined$sortedBy$1\n 176: dup\n 177: invokespecial #260 // Method Day15Kt$calculateLineCoverage$$inlined$sortedBy$1.\"<init>\":()V\n 180: checkcast #262 // class java/util/Comparator\n 183: invokestatic #266 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 186: astore_2\n 187: new #268 // class java/util/LinkedList\n 190: dup\n 191: invokespecial #269 // Method java/util/LinkedList.\"<init>\":()V\n 194: astore_3\n 195: aload_3\n 196: aload_2\n 197: invokestatic #272 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 200: invokevirtual #276 // Method java/util/LinkedList.addLast:(Ljava/lang/Object;)V\n 203: iconst_1\n 204: istore 4\n 206: aload_2\n 207: invokestatic #155 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 210: istore 5\n 212: iload 4\n 214: iload 5\n 216: if_icmpgt 321\n 219: aload_3\n 220: invokevirtual #278 // Method java/util/LinkedList.getLast:()Ljava/lang/Object;\n 223: checkcast #118 // class kotlin/ranges/IntRange\n 226: invokevirtual #158 // Method kotlin/ranges/IntRange.getLast:()I\n 229: aload_2\n 230: iload 4\n 232: invokeinterface #146, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 237: checkcast #118 // class kotlin/ranges/IntRange\n 240: invokevirtual #149 // Method kotlin/ranges/IntRange.getFirst:()I\n 243: if_icmplt 296\n 246: aload_3\n 247: invokevirtual #281 // Method java/util/LinkedList.pollLast:()Ljava/lang/Object;\n 250: checkcast #118 // class kotlin/ranges/IntRange\n 253: astore 6\n 255: aload_3\n 256: new #118 // class kotlin/ranges/IntRange\n 259: dup\n 260: aload 6\n 262: invokevirtual #149 // Method kotlin/ranges/IntRange.getFirst:()I\n 265: aload 6\n 267: invokevirtual #158 // Method kotlin/ranges/IntRange.getLast:()I\n 270: aload_2\n 271: iload 4\n 273: invokeinterface #146, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 278: checkcast #118 // class kotlin/ranges/IntRange\n 281: invokevirtual #158 // Method kotlin/ranges/IntRange.getLast:()I\n 284: invokestatic #285 // Method java/lang/Math.max:(II)I\n 287: invokespecial #257 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 290: invokevirtual #276 // Method java/util/LinkedList.addLast:(Ljava/lang/Object;)V\n 293: goto 308\n 296: aload_3\n 297: aload_2\n 298: iload 4\n 300: invokeinterface #146, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 305: invokevirtual #276 // Method java/util/LinkedList.addLast:(Ljava/lang/Object;)V\n 308: iload 4\n 310: iload 5\n 312: if_icmpeq 321\n 315: iinc 4, 1\n 318: goto 219\n 321: aload_3\n 322: checkcast #27 // class java/util/List\n 325: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #307 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: new #187 // class kotlin/text/Regex\n 3: dup\n 4: ldc_w #312 // String Sensor at x=(-?\\\\d+), y=(-?\\\\d+): closest beacon is at x=(-?\\\\d+), y=(-?\\\\d+)\n 7: invokespecial #313 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 10: putstatic #183 // Field ROW_FORMAT:Lkotlin/text/Regex;\n 13: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day22.kt
fun main() { val testInput = readInput("Day22_test") val testMap = testInput.subList(0, testInput.size - 2).toMap() val testPath = testInput.last().parsePath() check(part1(testMap, testPath) == 6032) check(part2(testMap, testMap.buildTestCubeAdjacentMap(), testPath) == 5031) val input = readInput("Day22") val map = input.subList(0, input.size - 2).toMap() val path = input.last().parsePath() println(part1(map, path)) println(part2(map, map.buildCubeAdjacentMap(), path)) } private const val VOID = 0 private const val OPEN = 1 private const val WALL = 2 private const val RIGHT = 0 private const val DOWN = 1 private const val LEFT = 2 private const val UP = 3 private fun part1(map: Matrix, path: List<PathItem>): Int { val adjacentMap = map.buildAdjacentMap() return solve(map, adjacentMap, path) } private fun part2(map: Matrix, adjacentMap: Int3DMatrix, path: List<PathItem>): Int = solve(map, adjacentMap, path) private fun solve(map: Matrix, adjacentMap: Int3DMatrix, path: List<PathItem>): Int { // "You begin the path in the leftmost open tile of the top row of tiles." val position = MutableIJ( i = 0, j = map[0].indexOfFirst { it == OPEN } ) var rotation = RIGHT path.forEach { pathItem -> when (pathItem) { is PathItem.Move -> { for (k in 1..pathItem.stepsCount) { val i = adjacentMap[position.i][position.j][rotation * 3] val j = adjacentMap[position.i][position.j][rotation * 3 + 1] if (map[i][j] == WALL) { break } rotation = adjacentMap[position.i][position.j][rotation * 3 + 2] position.i = i position.j = j } } PathItem.RotationLeft -> rotation = if (rotation == RIGHT) UP else rotation - 1 PathItem.RotationRight -> rotation = if (rotation == UP) RIGHT else rotation + 1 } } return 1_000 * (position.i + 1) + 4 * (position.j + 1) + rotation } private fun List<String>.toMap(): Matrix { val iSize = this.size val jSize = this.maxOf { it.length } val result = Array(iSize) { i -> IntArray(jSize) { j -> when (this[i].getOrNull(j)) { '.' -> OPEN '#' -> WALL else -> VOID } } } return result } private fun Matrix.buildAdjacentMap(): Int3DMatrix { return Array(this.size) { i -> Array(this[i].size) { j -> if (this[i][j] != VOID) { var jRight = (j + 1) % this[i].size while (this[i][jRight] == VOID) { jRight = (jRight + 1) % this[i].size } var iDown = (i + 1) % this.size while (this[iDown][j] == VOID) { iDown = (iDown + 1) % this.size } var jLeft = if (j > 0) (j - 1) else this[i].lastIndex while (this[i][jLeft] == VOID) { jLeft = if (jLeft > 0) (jLeft - 1) else this[i].lastIndex } var iUp = if (i > 0) (i - 1) else this.lastIndex while (this[iUp][j] == VOID) { iUp = if (iUp > 0) (iUp - 1) else this.lastIndex } intArrayOf( i, jRight, RIGHT, iDown, j, DOWN, i, jLeft, LEFT, iUp, j, UP ) } else { intArrayOf() } } } } private fun Matrix.buildCubeAdjacentMap(): Int3DMatrix { val result = Array(this.size) { i -> Array(this[i].size) { j -> if (this[i][j] != VOID) { intArrayOf( i, j + 1, RIGHT, i + 1, j, DOWN, i, j - 1, LEFT, i - 1, j, UP ) } else { intArrayOf() } } } val cubeSize = this.size / 4 //Link cube edges /* 22221111 22221111 22221111 22221111 3333 3333 3333 3333 55554444 55554444 55554444 55554444 6666 6666 6666 6666 */ //Link 1 <-> 3 edges repeat(cubeSize) { delta -> result[cubeSize - 1][2 * cubeSize + delta][3 * DOWN] = cubeSize + delta result[cubeSize - 1][2 * cubeSize + delta][3 * DOWN + 1] = 2 * cubeSize - 1 result[cubeSize - 1][2 * cubeSize + delta][3 * DOWN + 2] = LEFT result[cubeSize + delta][2 * cubeSize - 1][3 * RIGHT] = cubeSize - 1 result[cubeSize + delta][2 * cubeSize - 1][3 * RIGHT + 1] = 2 * cubeSize + delta result[cubeSize + delta][2 * cubeSize - 1][3 * RIGHT + 2] = UP } //Link 1 <-> 4 edges repeat(cubeSize) { delta -> result[cubeSize - delta - 1][3 * cubeSize - 1][3 * RIGHT] = 2 * cubeSize + delta result[cubeSize - delta - 1][3 * cubeSize - 1][3 * RIGHT + 1] = 2 * cubeSize - 1 result[cubeSize - delta - 1][3 * cubeSize - 1][3 * RIGHT + 2] = LEFT result[2 * cubeSize + delta][2 * cubeSize - 1][3 * RIGHT] = cubeSize - delta - 1 result[2 * cubeSize + delta][2 * cubeSize - 1][3 * RIGHT + 1] = 3 * cubeSize - 1 result[2 * cubeSize + delta][2 * cubeSize - 1][3 * RIGHT + 2] = LEFT } //Link 1 <-> 6 edges repeat(cubeSize) { delta -> result[0][2 * cubeSize + delta][3 * UP] = 4 * cubeSize - 1 result[0][2 * cubeSize + delta][3 * UP + 1] = delta result[0][2 * cubeSize + delta][3 * UP + 2] = UP result[4 * cubeSize - 1][delta][3 * DOWN] = 0 result[4 * cubeSize - 1][delta][3 * DOWN + 1] = 2 * cubeSize + delta result[4 * cubeSize - 1][delta][3 * DOWN + 2] = DOWN } //Link 2 <-> 5 edges repeat(cubeSize) { delta -> result[cubeSize - delta - 1][cubeSize][3 * LEFT] = 2 * cubeSize + delta result[cubeSize - delta - 1][cubeSize][3 * LEFT + 1] = 0 result[cubeSize - delta - 1][cubeSize][3 * LEFT + 2] = RIGHT result[2 * cubeSize + delta][0][3 * LEFT] = cubeSize - delta - 1 result[2 * cubeSize + delta][0][3 * LEFT + 1] = cubeSize result[2 * cubeSize + delta][0][3 * LEFT + 2] = RIGHT } //Link 2 <-> 6 edges repeat(cubeSize) { delta -> result[0][cubeSize + delta][3 * UP] = 3 * cubeSize + delta result[0][cubeSize + delta][3 * UP + 1] = 0 result[0][cubeSize + delta][3 * UP + 2] = RIGHT result[3 * cubeSize + delta][0][3 * LEFT] = 0 result[3 * cubeSize + delta][0][3 * LEFT + 1] = cubeSize + delta result[3 * cubeSize + delta][0][3 * LEFT + 2] = DOWN } //Link 3 <-> 5 edges repeat(cubeSize) { delta -> result[2 * cubeSize - delta - 1][cubeSize][3 * LEFT] = 2 * cubeSize result[2 * cubeSize - delta - 1][cubeSize][3 * LEFT + 1] = cubeSize - delta - 1 result[2 * cubeSize - delta - 1][cubeSize][3 * LEFT + 2] = DOWN result[2 * cubeSize][cubeSize - delta - 1][3 * UP] = 2 * cubeSize - delta - 1 result[2 * cubeSize][cubeSize - delta - 1][3 * UP + 1] = cubeSize result[2 * cubeSize][cubeSize - delta - 1][3 * UP + 2] = RIGHT } //Link 4 <-> 6 edges repeat(cubeSize) { delta -> result[3 * cubeSize - 1][cubeSize + delta][3 * DOWN] = 3 * cubeSize + delta result[3 * cubeSize - 1][cubeSize + delta][3 * DOWN + 1] = cubeSize - 1 result[3 * cubeSize - 1][cubeSize + delta][3 * DOWN + 2] = LEFT result[3 * cubeSize + delta][cubeSize - 1][3 * RIGHT] = 3 * cubeSize - 1 result[3 * cubeSize + delta][cubeSize - 1][3 * RIGHT + 1] = cubeSize + delta result[3 * cubeSize + delta][cubeSize - 1][3 * RIGHT + 2] = UP } return result } private fun Matrix.buildTestCubeAdjacentMap(): Int3DMatrix { val result = Array(this.size) { i -> Array(this[i].size) { j -> if (this[i][j] != VOID) { intArrayOf( i, j + 1, RIGHT, i + 1, j, DOWN, i, j - 1, LEFT, i - 1, j, UP ) } else { intArrayOf() } } } val cubeSize = this.size / 3 val leftTop = cubeSize * 2 //Link cube edges /* 1111 1111 1111 1111 222233334444 222233334444 222233334444 222233334444 55556666 55556666 55556666 55556666 */ //Link 1 <-> 2 repeat(cubeSize) { delta -> result[0][leftTop + delta][3 * UP] = cubeSize result[0][leftTop + delta][3 * UP + 1] = cubeSize - delta - 1 result[0][leftTop + delta][3 * UP + 2] = DOWN result[cubeSize][cubeSize - delta - 1][3 * UP] = 0 result[cubeSize][cubeSize - delta - 1][3 * UP + 1] = leftTop + delta result[cubeSize][cubeSize - delta - 1][3 * UP + 2] = DOWN } //Link 1 <-> 3 repeat(cubeSize) { delta -> result[delta][leftTop][3 * LEFT] = cubeSize result[delta][leftTop][3 * LEFT + 1] = cubeSize + delta result[delta][leftTop][3 * LEFT + 2] = DOWN result[cubeSize][cubeSize + delta][3 * UP] = delta result[cubeSize][cubeSize + delta][3 * UP + 1] = leftTop result[cubeSize][cubeSize + delta][3 * UP + 2] = RIGHT } //Link 1 <-> 6 repeat(cubeSize) { delta -> result[delta][3 * cubeSize - 1][3 * RIGHT] = 3 * cubeSize - delta - 1 result[delta][3 * cubeSize - 1][3 * RIGHT + 1] = 4 * cubeSize - 1 result[delta][3 * cubeSize - 1][3 * RIGHT + 2] = LEFT result[3 * cubeSize - delta - 1][4 * cubeSize - 1][3 * RIGHT] = delta result[3 * cubeSize - delta - 1][4 * cubeSize - 1][3 * RIGHT + 1] = 3 * cubeSize - 1 result[3 * cubeSize - delta - 1][4 * cubeSize - 1][3 * RIGHT + 2] = LEFT } //Link 2 <-> 5 repeat(cubeSize) { delta -> result[2 * cubeSize - 1][delta][3 * DOWN] = 3 * cubeSize - 1 result[2 * cubeSize - 1][delta][3 * DOWN + 1] = 3 * cubeSize - delta - 1 result[2 * cubeSize - 1][delta][3 * DOWN + 2] = UP result[3 * cubeSize - 1][3 * cubeSize - delta - 1][3 * DOWN] = 2 * cubeSize - 1 result[3 * cubeSize - 1][3 * cubeSize - delta - 1][3 * DOWN + 1] = delta result[3 * cubeSize - 1][3 * cubeSize - delta - 1][3 * DOWN + 2] = UP } //Link 2 <-> 6 repeat(cubeSize) { delta -> result[cubeSize + delta][0][3 * LEFT] = 3 * cubeSize - 1 result[cubeSize + delta][0][3 * LEFT + 1] = 4 * cubeSize - delta - 1 result[cubeSize + delta][0][3 * LEFT + 2] = UP result[3 * cubeSize - 1][4 * cubeSize - delta - 1][3 * DOWN] = cubeSize + delta result[3 * cubeSize - 1][4 * cubeSize - delta - 1][3 * DOWN + 1] = 0 result[3 * cubeSize - 1][4 * cubeSize - delta - 1][3 * DOWN + 2] = RIGHT } //Link 3 <-> 5 repeat(cubeSize) { delta -> result[2 * cubeSize - 1][2 * cubeSize - delta - 1][3 * DOWN] = 2 * cubeSize + delta result[2 * cubeSize - 1][2 * cubeSize - delta - 1][3 * DOWN + 1] = 2 * cubeSize result[2 * cubeSize - 1][2 * cubeSize - delta - 1][3 * DOWN + 2] = RIGHT result[2 * cubeSize + delta][2 * cubeSize][3 * LEFT] = 2 * cubeSize - 1 result[2 * cubeSize + delta][2 * cubeSize][3 * LEFT + 1] = 2 * cubeSize - delta - 1 result[2 * cubeSize + delta][2 * cubeSize][3 * LEFT + 2] = UP } //Link 4 <-> 6 repeat(cubeSize) { delta -> result[2 * cubeSize - delta - 1][3 * cubeSize - 1][3 * RIGHT] = 2 * cubeSize result[2 * cubeSize - delta - 1][3 * cubeSize - 1][3 * RIGHT + 1] = 3 * cubeSize + delta result[2 * cubeSize - delta - 1][3 * cubeSize - 1][3 * RIGHT + 2] = DOWN result[2 * cubeSize][3 * cubeSize + delta][3 * UP] = 2 * cubeSize - delta - 1 result[2 * cubeSize][3 * cubeSize + delta][3 * UP + 1] = 3 * cubeSize - 1 result[2 * cubeSize][3 * cubeSize + delta][3 * UP + 2] = LEFT } return result } private val PATH_FORMAT = Regex("(R|L|\\d+)") private fun String.parsePath(): List<PathItem> { return PATH_FORMAT.findAll(this) .map { when (it.value) { "R" -> PathItem.RotationRight "L" -> PathItem.RotationLeft else -> PathItem.Move(it.value.toInt()) } } .toList() } private sealed interface PathItem { class Move(val stepsCount: Int) : PathItem object RotationRight : PathItem object RotationLeft : PathItem }
[ { "class_path": "Kvest__AOC2022__6409e65/Day22Kt.class", "javap": "Compiled from \"Day22.kt\"\npublic final class Day22Kt {\n private static final int VOID;\n\n private static final int OPEN;\n\n private static final int WALL;\n\n private static final int RIGHT;\n\n private static final int DOWN;\n\n private static final int LEFT;\n\n private static final int UP;\n\n private static final kotlin.text.Regex PATH_FORMAT;\n\n public static final void main();\n Code:\n 0: ldc #8 // String Day22_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: iconst_0\n 8: aload_0\n 9: invokeinterface #20, 1 // InterfaceMethod java/util/List.size:()I\n 14: iconst_2\n 15: isub\n 16: invokeinterface #24, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 21: invokestatic #28 // Method toMap:(Ljava/util/List;)[[I\n 24: astore_1\n 25: aload_0\n 26: invokestatic #34 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 29: checkcast #36 // class java/lang/String\n 32: invokestatic #39 // Method parsePath:(Ljava/lang/String;)Ljava/util/List;\n 35: astore_2\n 36: aload_1\n 37: aload_2\n 38: invokestatic #43 // Method part1:([[ILjava/util/List;)I\n 41: sipush 6032\n 44: if_icmpne 51\n 47: iconst_1\n 48: goto 52\n 51: iconst_0\n 52: ifne 65\n 55: new #45 // class java/lang/IllegalStateException\n 58: dup\n 59: ldc #47 // String Check failed.\n 61: invokespecial #51 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 64: athrow\n 65: aload_1\n 66: aload_1\n 67: invokestatic #55 // Method buildTestCubeAdjacentMap:([[I)[[[I\n 70: aload_2\n 71: invokestatic #59 // Method part2:([[I[[[ILjava/util/List;)I\n 74: sipush 5031\n 77: if_icmpne 84\n 80: iconst_1\n 81: goto 85\n 84: iconst_0\n 85: ifne 98\n 88: new #45 // class java/lang/IllegalStateException\n 91: dup\n 92: ldc #47 // String Check failed.\n 94: invokespecial #51 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 97: athrow\n 98: ldc #61 // String Day22\n 100: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 103: astore_3\n 104: aload_3\n 105: iconst_0\n 106: aload_3\n 107: invokeinterface #20, 1 // InterfaceMethod java/util/List.size:()I\n 112: iconst_2\n 113: isub\n 114: invokeinterface #24, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 119: invokestatic #28 // Method toMap:(Ljava/util/List;)[[I\n 122: astore 4\n 124: aload_3\n 125: invokestatic #34 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 128: checkcast #36 // class java/lang/String\n 131: invokestatic #39 // Method parsePath:(Ljava/lang/String;)Ljava/util/List;\n 134: astore 5\n 136: aload 4\n 138: aload 5\n 140: invokestatic #43 // Method part1:([[ILjava/util/List;)I\n 143: istore 6\n 145: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 148: iload 6\n 150: invokevirtual #73 // Method java/io/PrintStream.println:(I)V\n 153: aload 4\n 155: aload 4\n 157: invokestatic #76 // Method buildCubeAdjacentMap:([[I)[[[I\n 160: aload 5\n 162: invokestatic #59 // Method part2:([[I[[[ILjava/util/List;)I\n 165: istore 6\n 167: getstatic #67 // Field java/lang/System.out:Ljava/io/PrintStream;\n 170: iload 6\n 172: invokevirtual #73 // Method java/io/PrintStream.println:(I)V\n 175: return\n\n private static final int part1(int[][], java.util.List<? extends PathItem>);\n Code:\n 0: aload_0\n 1: invokestatic #89 // Method buildAdjacentMap:([[I)[[[I\n 4: astore_2\n 5: aload_0\n 6: aload_2\n 7: aload_1\n 8: invokestatic #92 // Method solve:([[I[[[ILjava/util/List;)I\n 11: ireturn\n\n private static final int part2(int[][], int[][][], java.util.List<? extends PathItem>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: aload_2\n 3: invokestatic #92 // Method solve:([[I[[[ILjava/util/List;)I\n 6: ireturn\n\n private static final int solve(int[][], int[][][], java.util.List<? extends PathItem>);\n Code:\n 0: iconst_0\n 1: aload_0\n 2: iconst_0\n 3: aaload\n 4: astore 4\n 6: istore 16\n 8: iconst_0\n 9: istore 5\n 11: iconst_0\n 12: istore 6\n 14: aload 4\n 16: arraylength\n 17: istore 7\n 19: iload 6\n 21: iload 7\n 23: if_icmpge 61\n 26: aload 4\n 28: iload 6\n 30: iaload\n 31: istore 8\n 33: iconst_0\n 34: istore 9\n 36: iload 8\n 38: iconst_1\n 39: if_icmpne 46\n 42: iconst_1\n 43: goto 47\n 46: iconst_0\n 47: ifeq 55\n 50: iload 6\n 52: goto 62\n 55: iinc 6, 1\n 58: goto 19\n 61: iconst_m1\n 62: istore 17\n 64: iload 16\n 66: iload 17\n 68: istore 18\n 70: istore 19\n 72: new #97 // class MutableIJ\n 75: dup\n 76: iload 19\n 78: iload 18\n 80: invokespecial #100 // Method MutableIJ.\"<init>\":(II)V\n 83: astore_3\n 84: iconst_0\n 85: istore 4\n 87: aload_2\n 88: checkcast #102 // class java/lang/Iterable\n 91: astore 5\n 93: iconst_0\n 94: istore 6\n 96: aload 5\n 98: invokeinterface #106, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 103: astore 7\n 105: aload 7\n 107: invokeinterface #112, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 112: ifeq 335\n 115: aload 7\n 117: invokeinterface #116, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 122: astore 8\n 124: aload 8\n 126: checkcast #118 // class PathItem\n 129: astore 9\n 131: iconst_0\n 132: istore 10\n 134: aload 9\n 136: astore 11\n 138: aload 11\n 140: instanceof #120 // class PathItem$Move\n 143: ifeq 263\n 146: iconst_1\n 147: istore 12\n 149: aload 9\n 151: checkcast #120 // class PathItem$Move\n 154: invokevirtual #123 // Method PathItem$Move.getStepsCount:()I\n 157: istore 13\n 159: iload 12\n 161: iload 13\n 163: if_icmpgt 330\n 166: aload_1\n 167: aload_3\n 168: invokevirtual #126 // Method MutableIJ.getI:()I\n 171: aaload\n 172: aload_3\n 173: invokevirtual #129 // Method MutableIJ.getJ:()I\n 176: aaload\n 177: iload 4\n 179: iconst_3\n 180: imul\n 181: iaload\n 182: istore 14\n 184: aload_1\n 185: aload_3\n 186: invokevirtual #126 // Method MutableIJ.getI:()I\n 189: aaload\n 190: aload_3\n 191: invokevirtual #129 // Method MutableIJ.getJ:()I\n 194: aaload\n 195: iload 4\n 197: iconst_3\n 198: imul\n 199: iconst_1\n 200: iadd\n 201: iaload\n 202: istore 15\n 204: aload_0\n 205: iload 14\n 207: aaload\n 208: iload 15\n 210: iaload\n 211: iconst_2\n 212: if_icmpne 218\n 215: goto 330\n 218: aload_1\n 219: aload_3\n 220: invokevirtual #126 // Method MutableIJ.getI:()I\n 223: aaload\n 224: aload_3\n 225: invokevirtual #129 // Method MutableIJ.getJ:()I\n 228: aaload\n 229: iload 4\n 231: iconst_3\n 232: imul\n 233: iconst_2\n 234: iadd\n 235: iaload\n 236: istore 4\n 238: aload_3\n 239: iload 14\n 241: invokevirtual #132 // Method MutableIJ.setI:(I)V\n 244: aload_3\n 245: iload 15\n 247: invokevirtual #135 // Method MutableIJ.setJ:(I)V\n 250: iload 12\n 252: iload 13\n 254: if_icmpeq 330\n 257: iinc 12, 1\n 260: goto 166\n 263: aload 11\n 265: getstatic #141 // Field PathItem$RotationLeft.INSTANCE:LPathItem$RotationLeft;\n 268: invokestatic #147 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 271: ifeq 292\n 274: iload 4\n 276: ifne 283\n 279: iconst_3\n 280: goto 287\n 283: iload 4\n 285: iconst_1\n 286: isub\n 287: istore 4\n 289: goto 330\n 292: aload 11\n 294: getstatic #152 // Field PathItem$RotationRight.INSTANCE:LPathItem$RotationRight;\n 297: invokestatic #147 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 300: ifeq 322\n 303: iload 4\n 305: iconst_3\n 306: if_icmpne 313\n 309: iconst_0\n 310: goto 317\n 313: iload 4\n 315: iconst_1\n 316: iadd\n 317: istore 4\n 319: goto 330\n 322: new #154 // class kotlin/NoWhenBranchMatchedException\n 325: dup\n 326: invokespecial #156 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 329: athrow\n 330: nop\n 331: nop\n 332: goto 105\n 335: nop\n 336: sipush 1000\n 339: aload_3\n 340: invokevirtual #126 // Method MutableIJ.getI:()I\n 343: iconst_1\n 344: iadd\n 345: imul\n 346: iconst_4\n 347: aload_3\n 348: invokevirtual #129 // Method MutableIJ.getJ:()I\n 351: iconst_1\n 352: iadd\n 353: imul\n 354: iadd\n 355: iload 4\n 357: iadd\n 358: ireturn\n\n private static final int[][] toMap(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokeinterface #20, 1 // InterfaceMethod java/util/List.size:()I\n 6: istore_1\n 7: aload_0\n 8: checkcast #102 // class java/lang/Iterable\n 11: invokeinterface #106, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 16: astore 4\n 18: aload 4\n 20: invokeinterface #112, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 25: ifne 36\n 28: new #182 // class java/util/NoSuchElementException\n 31: dup\n 32: invokespecial #183 // Method java/util/NoSuchElementException.\"<init>\":()V\n 35: athrow\n 36: aload 4\n 38: invokeinterface #116, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 43: checkcast #36 // class java/lang/String\n 46: astore 5\n 48: iconst_0\n 49: istore 6\n 51: aload 5\n 53: invokevirtual #186 // Method java/lang/String.length:()I\n 56: istore 5\n 58: aload 4\n 60: invokeinterface #112, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 65: ifeq 104\n 68: aload 4\n 70: invokeinterface #116, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 75: checkcast #36 // class java/lang/String\n 78: astore 6\n 80: iconst_0\n 81: istore 7\n 83: aload 6\n 85: invokevirtual #186 // Method java/lang/String.length:()I\n 88: istore 6\n 90: iload 5\n 92: iload 6\n 94: if_icmpge 58\n 97: iload 6\n 99: istore 5\n 101: goto 58\n 104: iload 5\n 106: istore_2\n 107: iconst_0\n 108: istore 4\n 110: iload_1\n 111: anewarray #179 // class \"[I\"\n 114: astore 5\n 116: iload 4\n 118: iload_1\n 119: if_icmpge 247\n 122: iload 4\n 124: istore 6\n 126: aload 5\n 128: iload 6\n 130: iconst_0\n 131: istore 7\n 133: iload_2\n 134: newarray int\n 136: astore 8\n 138: istore 13\n 140: astore 12\n 142: iload 7\n 144: iload_2\n 145: if_icmpge 234\n 148: iload 7\n 150: istore 9\n 152: aload 8\n 154: iload 9\n 156: aload_0\n 157: iload 6\n 159: invokeinterface #190, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 164: checkcast #192 // class java/lang/CharSequence\n 167: iload 9\n 169: invokestatic #198 // Method kotlin/text/StringsKt.getOrNull:(Ljava/lang/CharSequence;I)Ljava/lang/Character;\n 172: astore 10\n 174: aload 10\n 176: bipush 46\n 178: istore 11\n 180: dup\n 181: ifnonnull 188\n 184: pop\n 185: goto 200\n 188: invokevirtual #204 // Method java/lang/Character.charValue:()C\n 191: iload 11\n 193: if_icmpne 200\n 196: iconst_1\n 197: goto 227\n 200: aload 10\n 202: bipush 35\n 204: istore 11\n 206: dup\n 207: ifnonnull 214\n 210: pop\n 211: goto 226\n 214: invokevirtual #204 // Method java/lang/Character.charValue:()C\n 217: iload 11\n 219: if_icmpne 226\n 222: iconst_2\n 223: goto 227\n 226: iconst_0\n 227: iastore\n 228: iinc 7, 1\n 231: goto 142\n 234: aload 12\n 236: iload 13\n 238: aload 8\n 240: aastore\n 241: iinc 4, 1\n 244: goto 116\n 247: aload 5\n 249: astore_3\n 250: aload_3\n 251: areturn\n\n private static final int[][][] buildAdjacentMap(int[][]);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: aload_0\n 3: checkcast #212 // class \"[Ljava/lang/Object;\"\n 6: arraylength\n 7: istore_2\n 8: iload_2\n 9: anewarray #85 // class \"[[I\"\n 12: astore_3\n 13: iload_1\n 14: iload_2\n 15: if_icmpge 394\n 18: iload_1\n 19: istore 4\n 21: aload_3\n 22: iload 4\n 24: iconst_0\n 25: istore 5\n 27: aload_0\n 28: iload 4\n 30: aaload\n 31: arraylength\n 32: istore 6\n 34: iload 6\n 36: anewarray #179 // class \"[I\"\n 39: astore 7\n 41: istore 15\n 43: astore 14\n 45: iload 5\n 47: iload 6\n 49: if_icmpge 381\n 52: iload 5\n 54: istore 8\n 56: aload 7\n 58: iload 8\n 60: aload_0\n 61: iload 4\n 63: aaload\n 64: iload 8\n 66: iaload\n 67: ifeq 371\n 70: iload 8\n 72: iconst_1\n 73: iadd\n 74: aload_0\n 75: iload 4\n 77: aaload\n 78: arraylength\n 79: irem\n 80: istore 9\n 82: istore 17\n 84: astore 16\n 86: aload_0\n 87: iload 4\n 89: aaload\n 90: iload 9\n 92: iaload\n 93: ifne 111\n 96: iload 9\n 98: iconst_1\n 99: iadd\n 100: aload_0\n 101: iload 4\n 103: aaload\n 104: arraylength\n 105: irem\n 106: istore 9\n 108: goto 86\n 111: aload 16\n 113: iload 17\n 115: iload 4\n 117: iconst_1\n 118: iadd\n 119: aload_0\n 120: checkcast #212 // class \"[Ljava/lang/Object;\"\n 123: arraylength\n 124: irem\n 125: istore 10\n 127: istore 17\n 129: astore 16\n 131: aload_0\n 132: iload 10\n 134: aaload\n 135: iload 8\n 137: iaload\n 138: ifne 156\n 141: iload 10\n 143: iconst_1\n 144: iadd\n 145: aload_0\n 146: checkcast #212 // class \"[Ljava/lang/Object;\"\n 149: arraylength\n 150: irem\n 151: istore 10\n 153: goto 131\n 156: aload 16\n 158: iload 17\n 160: iload 8\n 162: ifle 172\n 165: iload 8\n 167: iconst_1\n 168: isub\n 169: goto 179\n 172: aload_0\n 173: iload 4\n 175: aaload\n 176: invokestatic #218 // Method kotlin/collections/ArraysKt.getLastIndex:([I)I\n 179: istore 11\n 181: istore 17\n 183: astore 16\n 185: aload_0\n 186: iload 4\n 188: aaload\n 189: iload 11\n 191: iaload\n 192: ifne 219\n 195: iload 11\n 197: ifle 207\n 200: iload 11\n 202: iconst_1\n 203: isub\n 204: goto 214\n 207: aload_0\n 208: iload 4\n 210: aaload\n 211: invokestatic #218 // Method kotlin/collections/ArraysKt.getLastIndex:([I)I\n 214: istore 11\n 216: goto 185\n 219: aload 16\n 221: iload 17\n 223: iload 4\n 225: ifle 235\n 228: iload 4\n 230: iconst_1\n 231: isub\n 232: goto 242\n 235: aload_0\n 236: checkcast #212 // class \"[Ljava/lang/Object;\"\n 239: invokestatic #221 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 242: istore 12\n 244: istore 17\n 246: astore 16\n 248: aload_0\n 249: iload 12\n 251: aaload\n 252: iload 8\n 254: iaload\n 255: ifne 282\n 258: iload 12\n 260: ifle 270\n 263: iload 12\n 265: iconst_1\n 266: isub\n 267: goto 277\n 270: aload_0\n 271: checkcast #212 // class \"[Ljava/lang/Object;\"\n 274: invokestatic #221 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 277: istore 12\n 279: goto 248\n 282: aload 16\n 284: iload 17\n 286: bipush 12\n 288: newarray int\n 290: astore 13\n 292: aload 13\n 294: iconst_0\n 295: iload 4\n 297: iastore\n 298: aload 13\n 300: iconst_1\n 301: iload 9\n 303: iastore\n 304: aload 13\n 306: iconst_2\n 307: iconst_0\n 308: iastore\n 309: aload 13\n 311: iconst_3\n 312: iload 10\n 314: iastore\n 315: aload 13\n 317: iconst_4\n 318: iload 8\n 320: iastore\n 321: aload 13\n 323: iconst_5\n 324: iconst_1\n 325: iastore\n 326: aload 13\n 328: bipush 6\n 330: iload 4\n 332: iastore\n 333: aload 13\n 335: bipush 7\n 337: iload 11\n 339: iastore\n 340: aload 13\n 342: bipush 8\n 344: iconst_2\n 345: iastore\n 346: aload 13\n 348: bipush 9\n 350: iload 12\n 352: iastore\n 353: aload 13\n 355: bipush 10\n 357: iload 8\n 359: iastore\n 360: aload 13\n 362: bipush 11\n 364: iconst_3\n 365: iastore\n 366: aload 13\n 368: goto 374\n 371: iconst_0\n 372: newarray int\n 374: aastore\n 375: iinc 5, 1\n 378: goto 45\n 381: aload 14\n 383: iload 15\n 385: aload 7\n 387: aastore\n 388: iinc 1, 1\n 391: goto 13\n 394: aload_3\n 395: areturn\n\n private static final int[][][] buildCubeAdjacentMap(int[][]);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: aload_0\n 3: checkcast #212 // class \"[Ljava/lang/Object;\"\n 6: arraylength\n 7: istore_3\n 8: iload_3\n 9: anewarray #85 // class \"[[I\"\n 12: astore 4\n 14: iload_2\n 15: iload_3\n 16: if_icmpge 188\n 19: iload_2\n 20: istore 5\n 22: aload 4\n 24: iload 5\n 26: iconst_0\n 27: istore 6\n 29: aload_0\n 30: iload 5\n 32: aaload\n 33: arraylength\n 34: istore 7\n 36: iload 7\n 38: anewarray #179 // class \"[I\"\n 41: astore 8\n 43: istore 12\n 45: astore 11\n 47: iload 6\n 49: iload 7\n 51: if_icmpge 175\n 54: iload 6\n 56: istore 9\n 58: aload 8\n 60: iload 9\n 62: aload_0\n 63: iload 5\n 65: aaload\n 66: iload 9\n 68: iaload\n 69: ifeq 165\n 72: bipush 12\n 74: newarray int\n 76: astore 10\n 78: aload 10\n 80: iconst_0\n 81: iload 5\n 83: iastore\n 84: aload 10\n 86: iconst_1\n 87: iload 9\n 89: iconst_1\n 90: iadd\n 91: iastore\n 92: aload 10\n 94: iconst_2\n 95: iconst_0\n 96: iastore\n 97: aload 10\n 99: iconst_3\n 100: iload 5\n 102: iconst_1\n 103: iadd\n 104: iastore\n 105: aload 10\n 107: iconst_4\n 108: iload 9\n 110: iastore\n 111: aload 10\n 113: iconst_5\n 114: iconst_1\n 115: iastore\n 116: aload 10\n 118: bipush 6\n 120: iload 5\n 122: iastore\n 123: aload 10\n 125: bipush 7\n 127: iload 9\n 129: iconst_1\n 130: isub\n 131: iastore\n 132: aload 10\n 134: bipush 8\n 136: iconst_2\n 137: iastore\n 138: aload 10\n 140: bipush 9\n 142: iload 5\n 144: iconst_1\n 145: isub\n 146: iastore\n 147: aload 10\n 149: bipush 10\n 151: iload 9\n 153: iastore\n 154: aload 10\n 156: bipush 11\n 158: iconst_3\n 159: iastore\n 160: aload 10\n 162: goto 168\n 165: iconst_0\n 166: newarray int\n 168: aastore\n 169: iinc 6, 1\n 172: goto 47\n 175: aload 11\n 177: iload 12\n 179: aload 8\n 181: aastore\n 182: iinc 2, 1\n 185: goto 14\n 188: aload 4\n 190: astore_1\n 191: aload_0\n 192: checkcast #212 // class \"[Ljava/lang/Object;\"\n 195: arraylength\n 196: iconst_4\n 197: idiv\n 198: istore_2\n 199: iconst_0\n 200: istore_3\n 201: iload_3\n 202: iload_2\n 203: if_icmpge 323\n 206: iload_3\n 207: istore 4\n 209: iconst_0\n 210: istore 5\n 212: aload_1\n 213: iload_2\n 214: iconst_1\n 215: isub\n 216: aaload\n 217: iconst_2\n 218: iload_2\n 219: imul\n 220: iload 4\n 222: iadd\n 223: aaload\n 224: iconst_3\n 225: iload_2\n 226: iload 4\n 228: iadd\n 229: iastore\n 230: aload_1\n 231: iload_2\n 232: iconst_1\n 233: isub\n 234: aaload\n 235: iconst_2\n 236: iload_2\n 237: imul\n 238: iload 4\n 240: iadd\n 241: aaload\n 242: iconst_4\n 243: iconst_2\n 244: iload_2\n 245: imul\n 246: iconst_1\n 247: isub\n 248: iastore\n 249: aload_1\n 250: iload_2\n 251: iconst_1\n 252: isub\n 253: aaload\n 254: iconst_2\n 255: iload_2\n 256: imul\n 257: iload 4\n 259: iadd\n 260: aaload\n 261: iconst_5\n 262: iconst_2\n 263: iastore\n 264: aload_1\n 265: iload_2\n 266: iload 4\n 268: iadd\n 269: aaload\n 270: iconst_2\n 271: iload_2\n 272: imul\n 273: iconst_1\n 274: isub\n 275: aaload\n 276: iconst_0\n 277: iload_2\n 278: iconst_1\n 279: isub\n 280: iastore\n 281: aload_1\n 282: iload_2\n 283: iload 4\n 285: iadd\n 286: aaload\n 287: iconst_2\n 288: iload_2\n 289: imul\n 290: iconst_1\n 291: isub\n 292: aaload\n 293: iconst_1\n 294: iconst_2\n 295: iload_2\n 296: imul\n 297: iload 4\n 299: iadd\n 300: iastore\n 301: aload_1\n 302: iload_2\n 303: iload 4\n 305: iadd\n 306: aaload\n 307: iconst_2\n 308: iload_2\n 309: imul\n 310: iconst_1\n 311: isub\n 312: aaload\n 313: iconst_2\n 314: iconst_3\n 315: iastore\n 316: nop\n 317: iinc 3, 1\n 320: goto 201\n 323: iconst_0\n 324: istore_3\n 325: iload_3\n 326: iload_2\n 327: if_icmpge 463\n 330: iload_3\n 331: istore 4\n 333: iconst_0\n 334: istore 5\n 336: aload_1\n 337: iload_2\n 338: iload 4\n 340: isub\n 341: iconst_1\n 342: isub\n 343: aaload\n 344: iconst_3\n 345: iload_2\n 346: imul\n 347: iconst_1\n 348: isub\n 349: aaload\n 350: iconst_0\n 351: iconst_2\n 352: iload_2\n 353: imul\n 354: iload 4\n 356: iadd\n 357: iastore\n 358: aload_1\n 359: iload_2\n 360: iload 4\n 362: isub\n 363: iconst_1\n 364: isub\n 365: aaload\n 366: iconst_3\n 367: iload_2\n 368: imul\n 369: iconst_1\n 370: isub\n 371: aaload\n 372: iconst_1\n 373: iconst_2\n 374: iload_2\n 375: imul\n 376: iconst_1\n 377: isub\n 378: iastore\n 379: aload_1\n 380: iload_2\n 381: iload 4\n 383: isub\n 384: iconst_1\n 385: isub\n 386: aaload\n 387: iconst_3\n 388: iload_2\n 389: imul\n 390: iconst_1\n 391: isub\n 392: aaload\n 393: iconst_2\n 394: iconst_2\n 395: iastore\n 396: aload_1\n 397: iconst_2\n 398: iload_2\n 399: imul\n 400: iload 4\n 402: iadd\n 403: aaload\n 404: iconst_2\n 405: iload_2\n 406: imul\n 407: iconst_1\n 408: isub\n 409: aaload\n 410: iconst_0\n 411: iload_2\n 412: iload 4\n 414: isub\n 415: iconst_1\n 416: isub\n 417: iastore\n 418: aload_1\n 419: iconst_2\n 420: iload_2\n 421: imul\n 422: iload 4\n 424: iadd\n 425: aaload\n 426: iconst_2\n 427: iload_2\n 428: imul\n 429: iconst_1\n 430: isub\n 431: aaload\n 432: iconst_1\n 433: iconst_3\n 434: iload_2\n 435: imul\n 436: iconst_1\n 437: isub\n 438: iastore\n 439: aload_1\n 440: iconst_2\n 441: iload_2\n 442: imul\n 443: iload 4\n 445: iadd\n 446: aaload\n 447: iconst_2\n 448: iload_2\n 449: imul\n 450: iconst_1\n 451: isub\n 452: aaload\n 453: iconst_2\n 454: iconst_2\n 455: iastore\n 456: nop\n 457: iinc 3, 1\n 460: goto 325\n 463: iconst_0\n 464: istore_3\n 465: iload_3\n 466: iload_2\n 467: if_icmpge 574\n 470: iload_3\n 471: istore 4\n 473: iconst_0\n 474: istore 5\n 476: aload_1\n 477: iconst_0\n 478: aaload\n 479: iconst_2\n 480: iload_2\n 481: imul\n 482: iload 4\n 484: iadd\n 485: aaload\n 486: bipush 9\n 488: iconst_4\n 489: iload_2\n 490: imul\n 491: iconst_1\n 492: isub\n 493: iastore\n 494: aload_1\n 495: iconst_0\n 496: aaload\n 497: iconst_2\n 498: iload_2\n 499: imul\n 500: iload 4\n 502: iadd\n 503: aaload\n 504: bipush 10\n 506: iload 4\n 508: iastore\n 509: aload_1\n 510: iconst_0\n 511: aaload\n 512: iconst_2\n 513: iload_2\n 514: imul\n 515: iload 4\n 517: iadd\n 518: aaload\n 519: bipush 11\n 521: iconst_3\n 522: iastore\n 523: aload_1\n 524: iconst_4\n 525: iload_2\n 526: imul\n 527: iconst_1\n 528: isub\n 529: aaload\n 530: iload 4\n 532: aaload\n 533: iconst_3\n 534: iconst_0\n 535: iastore\n 536: aload_1\n 537: iconst_4\n 538: iload_2\n 539: imul\n 540: iconst_1\n 541: isub\n 542: aaload\n 543: iload 4\n 545: aaload\n 546: iconst_4\n 547: iconst_2\n 548: iload_2\n 549: imul\n 550: iload 4\n 552: iadd\n 553: iastore\n 554: aload_1\n 555: iconst_4\n 556: iload_2\n 557: imul\n 558: iconst_1\n 559: isub\n 560: aaload\n 561: iload 4\n 563: aaload\n 564: iconst_5\n 565: iconst_1\n 566: iastore\n 567: nop\n 568: iinc 3, 1\n 571: goto 465\n 574: iconst_0\n 575: istore_3\n 576: iload_3\n 577: iload_2\n 578: if_icmpge 688\n 581: iload_3\n 582: istore 4\n 584: iconst_0\n 585: istore 5\n 587: aload_1\n 588: iload_2\n 589: iload 4\n 591: isub\n 592: iconst_1\n 593: isub\n 594: aaload\n 595: iload_2\n 596: aaload\n 597: bipush 6\n 599: iconst_2\n 600: iload_2\n 601: imul\n 602: iload 4\n 604: iadd\n 605: iastore\n 606: aload_1\n 607: iload_2\n 608: iload 4\n 610: isub\n 611: iconst_1\n 612: isub\n 613: aaload\n 614: iload_2\n 615: aaload\n 616: bipush 7\n 618: iconst_0\n 619: iastore\n 620: aload_1\n 621: iload_2\n 622: iload 4\n 624: isub\n 625: iconst_1\n 626: isub\n 627: aaload\n 628: iload_2\n 629: aaload\n 630: bipush 8\n 632: iconst_0\n 633: iastore\n 634: aload_1\n 635: iconst_2\n 636: iload_2\n 637: imul\n 638: iload 4\n 640: iadd\n 641: aaload\n 642: iconst_0\n 643: aaload\n 644: bipush 6\n 646: iload_2\n 647: iload 4\n 649: isub\n 650: iconst_1\n 651: isub\n 652: iastore\n 653: aload_1\n 654: iconst_2\n 655: iload_2\n 656: imul\n 657: iload 4\n 659: iadd\n 660: aaload\n 661: iconst_0\n 662: aaload\n 663: bipush 7\n 665: iload_2\n 666: iastore\n 667: aload_1\n 668: iconst_2\n 669: iload_2\n 670: imul\n 671: iload 4\n 673: iadd\n 674: aaload\n 675: iconst_0\n 676: aaload\n 677: bipush 8\n 679: iconst_0\n 680: iastore\n 681: nop\n 682: iinc 3, 1\n 685: goto 576\n 688: iconst_0\n 689: istore_3\n 690: iload_3\n 691: iload_2\n 692: if_icmpge 794\n 695: iload_3\n 696: istore 4\n 698: iconst_0\n 699: istore 5\n 701: aload_1\n 702: iconst_0\n 703: aaload\n 704: iload_2\n 705: iload 4\n 707: iadd\n 708: aaload\n 709: bipush 9\n 711: iconst_3\n 712: iload_2\n 713: imul\n 714: iload 4\n 716: iadd\n 717: iastore\n 718: aload_1\n 719: iconst_0\n 720: aaload\n 721: iload_2\n 722: iload 4\n 724: iadd\n 725: aaload\n 726: bipush 10\n 728: iconst_0\n 729: iastore\n 730: aload_1\n 731: iconst_0\n 732: aaload\n 733: iload_2\n 734: iload 4\n 736: iadd\n 737: aaload\n 738: bipush 11\n 740: iconst_0\n 741: iastore\n 742: aload_1\n 743: iconst_3\n 744: iload_2\n 745: imul\n 746: iload 4\n 748: iadd\n 749: aaload\n 750: iconst_0\n 751: aaload\n 752: bipush 6\n 754: iconst_0\n 755: iastore\n 756: aload_1\n 757: iconst_3\n 758: iload_2\n 759: imul\n 760: iload 4\n 762: iadd\n 763: aaload\n 764: iconst_0\n 765: aaload\n 766: bipush 7\n 768: iload_2\n 769: iload 4\n 771: iadd\n 772: iastore\n 773: aload_1\n 774: iconst_3\n 775: iload_2\n 776: imul\n 777: iload 4\n 779: iadd\n 780: aaload\n 781: iconst_0\n 782: aaload\n 783: bipush 8\n 785: iconst_1\n 786: iastore\n 787: nop\n 788: iinc 3, 1\n 791: goto 690\n 794: iconst_0\n 795: istore_3\n 796: iload_3\n 797: iload_2\n 798: if_icmpge 924\n 801: iload_3\n 802: istore 4\n 804: iconst_0\n 805: istore 5\n 807: aload_1\n 808: iconst_2\n 809: iload_2\n 810: imul\n 811: iload 4\n 813: isub\n 814: iconst_1\n 815: isub\n 816: aaload\n 817: iload_2\n 818: aaload\n 819: bipush 6\n 821: iconst_2\n 822: iload_2\n 823: imul\n 824: iastore\n 825: aload_1\n 826: iconst_2\n 827: iload_2\n 828: imul\n 829: iload 4\n 831: isub\n 832: iconst_1\n 833: isub\n 834: aaload\n 835: iload_2\n 836: aaload\n 837: bipush 7\n 839: iload_2\n 840: iload 4\n 842: isub\n 843: iconst_1\n 844: isub\n 845: iastore\n 846: aload_1\n 847: iconst_2\n 848: iload_2\n 849: imul\n 850: iload 4\n 852: isub\n 853: iconst_1\n 854: isub\n 855: aaload\n 856: iload_2\n 857: aaload\n 858: bipush 8\n 860: iconst_1\n 861: iastore\n 862: aload_1\n 863: iconst_2\n 864: iload_2\n 865: imul\n 866: aaload\n 867: iload_2\n 868: iload 4\n 870: isub\n 871: iconst_1\n 872: isub\n 873: aaload\n 874: bipush 9\n 876: iconst_2\n 877: iload_2\n 878: imul\n 879: iload 4\n 881: isub\n 882: iconst_1\n 883: isub\n 884: iastore\n 885: aload_1\n 886: iconst_2\n 887: iload_2\n 888: imul\n 889: aaload\n 890: iload_2\n 891: iload 4\n 893: isub\n 894: iconst_1\n 895: isub\n 896: aaload\n 897: bipush 10\n 899: iload_2\n 900: iastore\n 901: aload_1\n 902: iconst_2\n 903: iload_2\n 904: imul\n 905: aaload\n 906: iload_2\n 907: iload 4\n 909: isub\n 910: iconst_1\n 911: isub\n 912: aaload\n 913: bipush 11\n 915: iconst_0\n 916: iastore\n 917: nop\n 918: iinc 3, 1\n 921: goto 796\n 924: iconst_0\n 925: istore_3\n 926: iload_3\n 927: iload_2\n 928: if_icmpge 1048\n 931: iload_3\n 932: istore 4\n 934: iconst_0\n 935: istore 5\n 937: aload_1\n 938: iconst_3\n 939: iload_2\n 940: imul\n 941: iconst_1\n 942: isub\n 943: aaload\n 944: iload_2\n 945: iload 4\n 947: iadd\n 948: aaload\n 949: iconst_3\n 950: iconst_3\n 951: iload_2\n 952: imul\n 953: iload 4\n 955: iadd\n 956: iastore\n 957: aload_1\n 958: iconst_3\n 959: iload_2\n 960: imul\n 961: iconst_1\n 962: isub\n 963: aaload\n 964: iload_2\n 965: iload 4\n 967: iadd\n 968: aaload\n 969: iconst_4\n 970: iload_2\n 971: iconst_1\n 972: isub\n 973: iastore\n 974: aload_1\n 975: iconst_3\n 976: iload_2\n 977: imul\n 978: iconst_1\n 979: isub\n 980: aaload\n 981: iload_2\n 982: iload 4\n 984: iadd\n 985: aaload\n 986: iconst_5\n 987: iconst_2\n 988: iastore\n 989: aload_1\n 990: iconst_3\n 991: iload_2\n 992: imul\n 993: iload 4\n 995: iadd\n 996: aaload\n 997: iload_2\n 998: iconst_1\n 999: isub\n 1000: aaload\n 1001: iconst_0\n 1002: iconst_3\n 1003: iload_2\n 1004: imul\n 1005: iconst_1\n 1006: isub\n 1007: iastore\n 1008: aload_1\n 1009: iconst_3\n 1010: iload_2\n 1011: imul\n 1012: iload 4\n 1014: iadd\n 1015: aaload\n 1016: iload_2\n 1017: iconst_1\n 1018: isub\n 1019: aaload\n 1020: iconst_1\n 1021: iload_2\n 1022: iload 4\n 1024: iadd\n 1025: iastore\n 1026: aload_1\n 1027: iconst_3\n 1028: iload_2\n 1029: imul\n 1030: iload 4\n 1032: iadd\n 1033: aaload\n 1034: iload_2\n 1035: iconst_1\n 1036: isub\n 1037: aaload\n 1038: iconst_2\n 1039: iconst_3\n 1040: iastore\n 1041: nop\n 1042: iinc 3, 1\n 1045: goto 926\n 1048: aload_1\n 1049: areturn\n\n private static final int[][][] buildTestCubeAdjacentMap(int[][]);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: aload_0\n 3: checkcast #212 // class \"[Ljava/lang/Object;\"\n 6: arraylength\n 7: istore_3\n 8: iload_3\n 9: anewarray #85 // class \"[[I\"\n 12: astore 4\n 14: iload_2\n 15: iload_3\n 16: if_icmpge 188\n 19: iload_2\n 20: istore 5\n 22: aload 4\n 24: iload 5\n 26: iconst_0\n 27: istore 6\n 29: aload_0\n 30: iload 5\n 32: aaload\n 33: arraylength\n 34: istore 7\n 36: iload 7\n 38: anewarray #179 // class \"[I\"\n 41: astore 8\n 43: istore 12\n 45: astore 11\n 47: iload 6\n 49: iload 7\n 51: if_icmpge 175\n 54: iload 6\n 56: istore 9\n 58: aload 8\n 60: iload 9\n 62: aload_0\n 63: iload 5\n 65: aaload\n 66: iload 9\n 68: iaload\n 69: ifeq 165\n 72: bipush 12\n 74: newarray int\n 76: astore 10\n 78: aload 10\n 80: iconst_0\n 81: iload 5\n 83: iastore\n 84: aload 10\n 86: iconst_1\n 87: iload 9\n 89: iconst_1\n 90: iadd\n 91: iastore\n 92: aload 10\n 94: iconst_2\n 95: iconst_0\n 96: iastore\n 97: aload 10\n 99: iconst_3\n 100: iload 5\n 102: iconst_1\n 103: iadd\n 104: iastore\n 105: aload 10\n 107: iconst_4\n 108: iload 9\n 110: iastore\n 111: aload 10\n 113: iconst_5\n 114: iconst_1\n 115: iastore\n 116: aload 10\n 118: bipush 6\n 120: iload 5\n 122: iastore\n 123: aload 10\n 125: bipush 7\n 127: iload 9\n 129: iconst_1\n 130: isub\n 131: iastore\n 132: aload 10\n 134: bipush 8\n 136: iconst_2\n 137: iastore\n 138: aload 10\n 140: bipush 9\n 142: iload 5\n 144: iconst_1\n 145: isub\n 146: iastore\n 147: aload 10\n 149: bipush 10\n 151: iload 9\n 153: iastore\n 154: aload 10\n 156: bipush 11\n 158: iconst_3\n 159: iastore\n 160: aload 10\n 162: goto 168\n 165: iconst_0\n 166: newarray int\n 168: aastore\n 169: iinc 6, 1\n 172: goto 47\n 175: aload 11\n 177: iload 12\n 179: aload 8\n 181: aastore\n 182: iinc 2, 1\n 185: goto 14\n 188: aload 4\n 190: astore_1\n 191: aload_0\n 192: checkcast #212 // class \"[Ljava/lang/Object;\"\n 195: arraylength\n 196: iconst_3\n 197: idiv\n 198: istore_2\n 199: iload_2\n 200: iconst_2\n 201: imul\n 202: istore_3\n 203: iconst_0\n 204: istore 4\n 206: iload 4\n 208: iload_2\n 209: if_icmpge 312\n 212: iload 4\n 214: istore 5\n 216: iconst_0\n 217: istore 6\n 219: aload_1\n 220: iconst_0\n 221: aaload\n 222: iload_3\n 223: iload 5\n 225: iadd\n 226: aaload\n 227: bipush 9\n 229: iload_2\n 230: iastore\n 231: aload_1\n 232: iconst_0\n 233: aaload\n 234: iload_3\n 235: iload 5\n 237: iadd\n 238: aaload\n 239: bipush 10\n 241: iload_2\n 242: iload 5\n 244: isub\n 245: iconst_1\n 246: isub\n 247: iastore\n 248: aload_1\n 249: iconst_0\n 250: aaload\n 251: iload_3\n 252: iload 5\n 254: iadd\n 255: aaload\n 256: bipush 11\n 258: iconst_1\n 259: iastore\n 260: aload_1\n 261: iload_2\n 262: aaload\n 263: iload_2\n 264: iload 5\n 266: isub\n 267: iconst_1\n 268: isub\n 269: aaload\n 270: bipush 9\n 272: iconst_0\n 273: iastore\n 274: aload_1\n 275: iload_2\n 276: aaload\n 277: iload_2\n 278: iload 5\n 280: isub\n 281: iconst_1\n 282: isub\n 283: aaload\n 284: bipush 10\n 286: iload_3\n 287: iload 5\n 289: iadd\n 290: iastore\n 291: aload_1\n 292: iload_2\n 293: aaload\n 294: iload_2\n 295: iload 5\n 297: isub\n 298: iconst_1\n 299: isub\n 300: aaload\n 301: bipush 11\n 303: iconst_1\n 304: iastore\n 305: nop\n 306: iinc 4, 1\n 309: goto 206\n 312: iconst_0\n 313: istore 4\n 315: iload 4\n 317: iload_2\n 318: if_icmpge 405\n 321: iload 4\n 323: istore 5\n 325: iconst_0\n 326: istore 6\n 328: aload_1\n 329: iload 5\n 331: aaload\n 332: iload_3\n 333: aaload\n 334: bipush 6\n 336: iload_2\n 337: iastore\n 338: aload_1\n 339: iload 5\n 341: aaload\n 342: iload_3\n 343: aaload\n 344: bipush 7\n 346: iload_2\n 347: iload 5\n 349: iadd\n 350: iastore\n 351: aload_1\n 352: iload 5\n 354: aaload\n 355: iload_3\n 356: aaload\n 357: bipush 8\n 359: iconst_1\n 360: iastore\n 361: aload_1\n 362: iload_2\n 363: aaload\n 364: iload_2\n 365: iload 5\n 367: iadd\n 368: aaload\n 369: bipush 9\n 371: iload 5\n 373: iastore\n 374: aload_1\n 375: iload_2\n 376: aaload\n 377: iload_2\n 378: iload 5\n 380: iadd\n 381: aaload\n 382: bipush 10\n 384: iload_3\n 385: iastore\n 386: aload_1\n 387: iload_2\n 388: aaload\n 389: iload_2\n 390: iload 5\n 392: iadd\n 393: aaload\n 394: bipush 11\n 396: iconst_0\n 397: iastore\n 398: nop\n 399: iinc 4, 1\n 402: goto 315\n 405: iconst_0\n 406: istore 4\n 408: iload 4\n 410: iload_2\n 411: if_icmpge 540\n 414: iload 4\n 416: istore 5\n 418: iconst_0\n 419: istore 6\n 421: aload_1\n 422: iload 5\n 424: aaload\n 425: iconst_3\n 426: iload_2\n 427: imul\n 428: iconst_1\n 429: isub\n 430: aaload\n 431: iconst_0\n 432: iconst_3\n 433: iload_2\n 434: imul\n 435: iload 5\n 437: isub\n 438: iconst_1\n 439: isub\n 440: iastore\n 441: aload_1\n 442: iload 5\n 444: aaload\n 445: iconst_3\n 446: iload_2\n 447: imul\n 448: iconst_1\n 449: isub\n 450: aaload\n 451: iconst_1\n 452: iconst_4\n 453: iload_2\n 454: imul\n 455: iconst_1\n 456: isub\n 457: iastore\n 458: aload_1\n 459: iload 5\n 461: aaload\n 462: iconst_3\n 463: iload_2\n 464: imul\n 465: iconst_1\n 466: isub\n 467: aaload\n 468: iconst_2\n 469: iconst_2\n 470: iastore\n 471: aload_1\n 472: iconst_3\n 473: iload_2\n 474: imul\n 475: iload 5\n 477: isub\n 478: iconst_1\n 479: isub\n 480: aaload\n 481: iconst_4\n 482: iload_2\n 483: imul\n 484: iconst_1\n 485: isub\n 486: aaload\n 487: iconst_0\n 488: iload 5\n 490: iastore\n 491: aload_1\n 492: iconst_3\n 493: iload_2\n 494: imul\n 495: iload 5\n 497: isub\n 498: iconst_1\n 499: isub\n 500: aaload\n 501: iconst_4\n 502: iload_2\n 503: imul\n 504: iconst_1\n 505: isub\n 506: aaload\n 507: iconst_1\n 508: iconst_3\n 509: iload_2\n 510: imul\n 511: iconst_1\n 512: isub\n 513: iastore\n 514: aload_1\n 515: iconst_3\n 516: iload_2\n 517: imul\n 518: iload 5\n 520: isub\n 521: iconst_1\n 522: isub\n 523: aaload\n 524: iconst_4\n 525: iload_2\n 526: imul\n 527: iconst_1\n 528: isub\n 529: aaload\n 530: iconst_2\n 531: iconst_2\n 532: iastore\n 533: nop\n 534: iinc 4, 1\n 537: goto 408\n 540: iconst_0\n 541: istore 4\n 543: iload 4\n 545: iload_2\n 546: if_icmpge 675\n 549: iload 4\n 551: istore 5\n 553: iconst_0\n 554: istore 6\n 556: aload_1\n 557: iconst_2\n 558: iload_2\n 559: imul\n 560: iconst_1\n 561: isub\n 562: aaload\n 563: iload 5\n 565: aaload\n 566: iconst_3\n 567: iconst_3\n 568: iload_2\n 569: imul\n 570: iconst_1\n 571: isub\n 572: iastore\n 573: aload_1\n 574: iconst_2\n 575: iload_2\n 576: imul\n 577: iconst_1\n 578: isub\n 579: aaload\n 580: iload 5\n 582: aaload\n 583: iconst_4\n 584: iconst_3\n 585: iload_2\n 586: imul\n 587: iload 5\n 589: isub\n 590: iconst_1\n 591: isub\n 592: iastore\n 593: aload_1\n 594: iconst_2\n 595: iload_2\n 596: imul\n 597: iconst_1\n 598: isub\n 599: aaload\n 600: iload 5\n 602: aaload\n 603: iconst_5\n 604: iconst_3\n 605: iastore\n 606: aload_1\n 607: iconst_3\n 608: iload_2\n 609: imul\n 610: iconst_1\n 611: isub\n 612: aaload\n 613: iconst_3\n 614: iload_2\n 615: imul\n 616: iload 5\n 618: isub\n 619: iconst_1\n 620: isub\n 621: aaload\n 622: iconst_3\n 623: iconst_2\n 624: iload_2\n 625: imul\n 626: iconst_1\n 627: isub\n 628: iastore\n 629: aload_1\n 630: iconst_3\n 631: iload_2\n 632: imul\n 633: iconst_1\n 634: isub\n 635: aaload\n 636: iconst_3\n 637: iload_2\n 638: imul\n 639: iload 5\n 641: isub\n 642: iconst_1\n 643: isub\n 644: aaload\n 645: iconst_4\n 646: iload 5\n 648: iastore\n 649: aload_1\n 650: iconst_3\n 651: iload_2\n 652: imul\n 653: iconst_1\n 654: isub\n 655: aaload\n 656: iconst_3\n 657: iload_2\n 658: imul\n 659: iload 5\n 661: isub\n 662: iconst_1\n 663: isub\n 664: aaload\n 665: iconst_5\n 666: iconst_3\n 667: iastore\n 668: nop\n 669: iinc 4, 1\n 672: goto 543\n 675: iconst_0\n 676: istore 4\n 678: iload 4\n 680: iload_2\n 681: if_icmpge 805\n 684: iload 4\n 686: istore 5\n 688: iconst_0\n 689: istore 6\n 691: aload_1\n 692: iload_2\n 693: iload 5\n 695: iadd\n 696: aaload\n 697: iconst_0\n 698: aaload\n 699: bipush 6\n 701: iconst_3\n 702: iload_2\n 703: imul\n 704: iconst_1\n 705: isub\n 706: iastore\n 707: aload_1\n 708: iload_2\n 709: iload 5\n 711: iadd\n 712: aaload\n 713: iconst_0\n 714: aaload\n 715: bipush 7\n 717: iconst_4\n 718: iload_2\n 719: imul\n 720: iload 5\n 722: isub\n 723: iconst_1\n 724: isub\n 725: iastore\n 726: aload_1\n 727: iload_2\n 728: iload 5\n 730: iadd\n 731: aaload\n 732: iconst_0\n 733: aaload\n 734: bipush 8\n 736: iconst_3\n 737: iastore\n 738: aload_1\n 739: iconst_3\n 740: iload_2\n 741: imul\n 742: iconst_1\n 743: isub\n 744: aaload\n 745: iconst_4\n 746: iload_2\n 747: imul\n 748: iload 5\n 750: isub\n 751: iconst_1\n 752: isub\n 753: aaload\n 754: iconst_3\n 755: iload_2\n 756: iload 5\n 758: iadd\n 759: iastore\n 760: aload_1\n 761: iconst_3\n 762: iload_2\n 763: imul\n 764: iconst_1\n 765: isub\n 766: aaload\n 767: iconst_4\n 768: iload_2\n 769: imul\n 770: iload 5\n 772: isub\n 773: iconst_1\n 774: isub\n 775: aaload\n 776: iconst_4\n 777: iconst_0\n 778: iastore\n 779: aload_1\n 780: iconst_3\n 781: iload_2\n 782: imul\n 783: iconst_1\n 784: isub\n 785: aaload\n 786: iconst_4\n 787: iload_2\n 788: imul\n 789: iload 5\n 791: isub\n 792: iconst_1\n 793: isub\n 794: aaload\n 795: iconst_5\n 796: iconst_0\n 797: iastore\n 798: nop\n 799: iinc 4, 1\n 802: goto 678\n 805: iconst_0\n 806: istore 4\n 808: iload 4\n 810: iload_2\n 811: if_icmpge 951\n 814: iload 4\n 816: istore 5\n 818: iconst_0\n 819: istore 6\n 821: aload_1\n 822: iconst_2\n 823: iload_2\n 824: imul\n 825: iconst_1\n 826: isub\n 827: aaload\n 828: iconst_2\n 829: iload_2\n 830: imul\n 831: iload 5\n 833: isub\n 834: iconst_1\n 835: isub\n 836: aaload\n 837: iconst_3\n 838: iconst_2\n 839: iload_2\n 840: imul\n 841: iload 5\n 843: iadd\n 844: iastore\n 845: aload_1\n 846: iconst_2\n 847: iload_2\n 848: imul\n 849: iconst_1\n 850: isub\n 851: aaload\n 852: iconst_2\n 853: iload_2\n 854: imul\n 855: iload 5\n 857: isub\n 858: iconst_1\n 859: isub\n 860: aaload\n 861: iconst_4\n 862: iconst_2\n 863: iload_2\n 864: imul\n 865: iastore\n 866: aload_1\n 867: iconst_2\n 868: iload_2\n 869: imul\n 870: iconst_1\n 871: isub\n 872: aaload\n 873: iconst_2\n 874: iload_2\n 875: imul\n 876: iload 5\n 878: isub\n 879: iconst_1\n 880: isub\n 881: aaload\n 882: iconst_5\n 883: iconst_0\n 884: iastore\n 885: aload_1\n 886: iconst_2\n 887: iload_2\n 888: imul\n 889: iload 5\n 891: iadd\n 892: aaload\n 893: iconst_2\n 894: iload_2\n 895: imul\n 896: aaload\n 897: bipush 6\n 899: iconst_2\n 900: iload_2\n 901: imul\n 902: iconst_1\n 903: isub\n 904: iastore\n 905: aload_1\n 906: iconst_2\n 907: iload_2\n 908: imul\n 909: iload 5\n 911: iadd\n 912: aaload\n 913: iconst_2\n 914: iload_2\n 915: imul\n 916: aaload\n 917: bipush 7\n 919: iconst_2\n 920: iload_2\n 921: imul\n 922: iload 5\n 924: isub\n 925: iconst_1\n 926: isub\n 927: iastore\n 928: aload_1\n 929: iconst_2\n 930: iload_2\n 931: imul\n 932: iload 5\n 934: iadd\n 935: aaload\n 936: iconst_2\n 937: iload_2\n 938: imul\n 939: aaload\n 940: bipush 8\n 942: iconst_3\n 943: iastore\n 944: nop\n 945: iinc 4, 1\n 948: goto 808\n 951: iconst_0\n 952: istore 4\n 954: iload 4\n 956: iload_2\n 957: if_icmpge 1097\n 960: iload 4\n 962: istore 5\n 964: iconst_0\n 965: istore 6\n 967: aload_1\n 968: iconst_2\n 969: iload_2\n 970: imul\n 971: iload 5\n 973: isub\n 974: iconst_1\n 975: isub\n 976: aaload\n 977: iconst_3\n 978: iload_2\n 979: imul\n 980: iconst_1\n 981: isub\n 982: aaload\n 983: iconst_0\n 984: iconst_2\n 985: iload_2\n 986: imul\n 987: iastore\n 988: aload_1\n 989: iconst_2\n 990: iload_2\n 991: imul\n 992: iload 5\n 994: isub\n 995: iconst_1\n 996: isub\n 997: aaload\n 998: iconst_3\n 999: iload_2\n 1000: imul\n 1001: iconst_1\n 1002: isub\n 1003: aaload\n 1004: iconst_1\n 1005: iconst_3\n 1006: iload_2\n 1007: imul\n 1008: iload 5\n 1010: iadd\n 1011: iastore\n 1012: aload_1\n 1013: iconst_2\n 1014: iload_2\n 1015: imul\n 1016: iload 5\n 1018: isub\n 1019: iconst_1\n 1020: isub\n 1021: aaload\n 1022: iconst_3\n 1023: iload_2\n 1024: imul\n 1025: iconst_1\n 1026: isub\n 1027: aaload\n 1028: iconst_2\n 1029: iconst_1\n 1030: iastore\n 1031: aload_1\n 1032: iconst_2\n 1033: iload_2\n 1034: imul\n 1035: aaload\n 1036: iconst_3\n 1037: iload_2\n 1038: imul\n 1039: iload 5\n 1041: iadd\n 1042: aaload\n 1043: bipush 9\n 1045: iconst_2\n 1046: iload_2\n 1047: imul\n 1048: iload 5\n 1050: isub\n 1051: iconst_1\n 1052: isub\n 1053: iastore\n 1054: aload_1\n 1055: iconst_2\n 1056: iload_2\n 1057: imul\n 1058: aaload\n 1059: iconst_3\n 1060: iload_2\n 1061: imul\n 1062: iload 5\n 1064: iadd\n 1065: aaload\n 1066: bipush 10\n 1068: iconst_3\n 1069: iload_2\n 1070: imul\n 1071: iconst_1\n 1072: isub\n 1073: iastore\n 1074: aload_1\n 1075: iconst_2\n 1076: iload_2\n 1077: imul\n 1078: aaload\n 1079: iconst_3\n 1080: iload_2\n 1081: imul\n 1082: iload 5\n 1084: iadd\n 1085: aaload\n 1086: bipush 11\n 1088: iconst_2\n 1089: iastore\n 1090: nop\n 1091: iinc 4, 1\n 1094: goto 954\n 1097: aload_1\n 1098: areturn\n\n private static final java.util.List<PathItem> parsePath(java.lang.String);\n Code:\n 0: getstatic #250 // Field PATH_FORMAT:Lkotlin/text/Regex;\n 3: aload_0\n 4: checkcast #192 // class java/lang/CharSequence\n 7: iconst_0\n 8: iconst_2\n 9: aconst_null\n 10: invokestatic #256 // Method kotlin/text/Regex.findAll$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/sequences/Sequence;\n 13: invokedynamic #275, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 18: invokestatic #280 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 21: invokestatic #284 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 24: 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 PathItem parsePath$lambda$17(kotlin.text.MatchResult);\n Code:\n 0: aload_0\n 1: ldc_w #291 // String it\n 4: invokestatic #295 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokeinterface #301, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 13: astore_1\n 14: aload_1\n 15: ldc_w #303 // String R\n 18: invokestatic #147 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 21: ifeq 33\n 24: getstatic #152 // Field PathItem$RotationRight.INSTANCE:LPathItem$RotationRight;\n 27: checkcast #118 // class PathItem\n 30: goto 71\n 33: aload_1\n 34: ldc_w #305 // String L\n 37: invokestatic #147 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 40: ifeq 52\n 43: getstatic #141 // Field PathItem$RotationLeft.INSTANCE:LPathItem$RotationLeft;\n 46: checkcast #118 // class PathItem\n 49: goto 71\n 52: new #120 // class PathItem$Move\n 55: dup\n 56: aload_0\n 57: invokeinterface #301, 1 // InterfaceMethod kotlin/text/MatchResult.getValue:()Ljava/lang/String;\n 62: invokestatic #311 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 65: invokespecial #313 // Method PathItem$Move.\"<init>\":(I)V\n 68: checkcast #118 // class PathItem\n 71: areturn\n\n static {};\n Code:\n 0: new #252 // class kotlin/text/Regex\n 3: dup\n 4: ldc_w #317 // String (R|L|\\\\d+)\n 7: invokespecial #318 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 10: putstatic #250 // Field PATH_FORMAT:Lkotlin/text/Regex;\n 13: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day23.kt
import kotlin.math.max import kotlin.math.min fun main() { val testInput = readInput("Day23_test") check(part1(testInput) == 110) check(part2(testInput) == 20) val input = readInput("Day23") println(part1(input)) println(part2(input)) } private val DIRECTIONS = listOf( //N, NE, NW listOf( intArrayOf(-1, 0), intArrayOf(-1, 1), intArrayOf(-1, -1) ), //S, SE, SW listOf( intArrayOf(1, 0), intArrayOf(1, 1), intArrayOf(1, -1) ), //W, NW, SW listOf( intArrayOf(0, -1), intArrayOf(-1, -1), intArrayOf(1, -1) ), //E, NE, SE listOf( intArrayOf(0, 1), intArrayOf(-1, 1), intArrayOf(1, 1) ), ) private val ALL_ADJACENT = listOf( intArrayOf(-1, -1), intArrayOf(-1, 0), intArrayOf(-1, 1), intArrayOf(0, 1), intArrayOf(1, 1), intArrayOf(1, 0), intArrayOf(1, -1), intArrayOf(0, -1), ) private fun part1(input: List<String>): Int { var elves = input.toElves() val moveMap = mutableMapOf<IJ, IJ>() val counts = mutableMapOf<IJ, Int>() repeat(10) { iterationNumber -> moveMap.clear() counts.clear() elves.calculateMoves(iterationNumber, moveMap, counts) elves = elves.applyMoves(moveMap, counts) } var iFrom = elves.first().i var jFrom = elves.first().j var iTo = iFrom var jTo = jFrom elves.forEach { iFrom = min(iFrom, it.i) jFrom = min(jFrom, it.j) iTo = max(iTo, it.i) jTo = max(jTo, it.j) } var count = 0 for (i in iFrom..iTo) { for (j in jFrom..jTo) { if (IJ(i, j) !in elves) { ++count } } } return count } private fun part2(input: List<String>): Int { var elves = input.toElves() var iterationNumber = 0 val moveMap = mutableMapOf<IJ, IJ>() val counts = mutableMapOf<IJ, Int>() while (true) { moveMap.clear() counts.clear() elves.calculateMoves(iterationNumber, moveMap, counts) if (moveMap.isEmpty()) { break } elves = elves.applyMoves(moveMap, counts) ++iterationNumber } return iterationNumber + 1 } private fun List<String>.toElves(): Set<IJ> { return this.flatMapIndexed { i, row -> row.mapIndexedNotNull { j, ch -> if (ch == '#') { IJ(i, j) } else { null } } }.toSet() } private fun Set<IJ>.calculateMoves( iterationNumber: Int, moveMap: MutableMap<IJ, IJ>, counts: MutableMap<IJ, Int> ) { this.forEach { elf -> val shouldMove = ALL_ADJACENT.any { delta -> IJ(elf.i + delta[0], elf.j + delta[1]) in this } if (shouldMove) { val moveDirection = DIRECTIONS.indices.firstNotNullOfOrNull { i -> DIRECTIONS[(i + iterationNumber) % DIRECTIONS.size].takeIf { dir -> dir.all { delta -> IJ(elf.i + delta[0], elf.j + delta[1]) !in this } } } if (moveDirection != null) { val newLocation = IJ(elf.i + moveDirection[0][0], elf.j + moveDirection[0][1]) moveMap[elf] = newLocation counts[newLocation] = counts.getOrDefault(newLocation, 0) + 1 } } } } private fun Set<IJ>.applyMoves( moveMap: MutableMap<IJ, IJ>, counts: MutableMap<IJ, Int> ): Set<IJ> { return this.map { elf -> moveMap[elf]?.takeIf { counts[it] == 1 } ?: elf }.toSet() }
[ { "class_path": "Kvest__AOC2022__6409e65/Day23Kt.class", "javap": "Compiled from \"Day23.kt\"\npublic final class Day23Kt {\n private static final java.util.List<java.util.List<int[]>> DIRECTIONS;\n\n private static final java.util.List<int[]> ALL_ADJACENT;\n\n public static final void main();\n Code:\n 0: ldc #8 // String Day23_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: bipush 110\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 33\n 23: new #20 // class java/lang/IllegalStateException\n 26: dup\n 27: ldc #22 // String Check failed.\n 29: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 32: athrow\n 33: aload_0\n 34: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 37: bipush 20\n 39: if_icmpne 46\n 42: iconst_1\n 43: goto 47\n 46: iconst_0\n 47: ifne 60\n 50: new #20 // class java/lang/IllegalStateException\n 53: dup\n 54: ldc #22 // String Check failed.\n 56: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 59: athrow\n 60: ldc #31 // String Day23\n 62: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 65: astore_1\n 66: aload_1\n 67: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 70: istore_2\n 71: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 74: iload_2\n 75: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 78: aload_1\n 79: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 82: istore_2\n 83: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 86: iload_2\n 87: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 90: return\n\n private static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aconst_null\n 1: astore_1\n 2: aload_0\n 3: invokestatic #53 // Method toElves:(Ljava/util/List;)Ljava/util/Set;\n 6: astore_1\n 7: new #55 // class java/util/LinkedHashMap\n 10: dup\n 11: invokespecial #57 // Method java/util/LinkedHashMap.\"<init>\":()V\n 14: checkcast #59 // class java/util/Map\n 17: astore_2\n 18: new #55 // class java/util/LinkedHashMap\n 21: dup\n 22: invokespecial #57 // Method java/util/LinkedHashMap.\"<init>\":()V\n 25: checkcast #59 // class java/util/Map\n 28: astore_3\n 29: bipush 10\n 31: istore 4\n 33: iconst_0\n 34: istore 5\n 36: iload 5\n 38: iload 4\n 40: if_icmpge 84\n 43: iload 5\n 45: istore 6\n 47: iconst_0\n 48: istore 7\n 50: aload_2\n 51: invokeinterface #62, 1 // InterfaceMethod java/util/Map.clear:()V\n 56: aload_3\n 57: invokeinterface #62, 1 // InterfaceMethod java/util/Map.clear:()V\n 62: aload_1\n 63: iload 6\n 65: aload_2\n 66: aload_3\n 67: invokestatic #66 // Method calculateMoves:(Ljava/util/Set;ILjava/util/Map;Ljava/util/Map;)V\n 70: aload_1\n 71: aload_2\n 72: aload_3\n 73: invokestatic #70 // Method applyMoves:(Ljava/util/Set;Ljava/util/Map;Ljava/util/Map;)Ljava/util/Set;\n 76: astore_1\n 77: nop\n 78: iinc 5, 1\n 81: goto 36\n 84: iconst_0\n 85: istore 4\n 87: aload_1\n 88: checkcast #72 // class java/lang/Iterable\n 91: invokestatic #78 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 94: checkcast #80 // class IJ\n 97: invokevirtual #84 // Method IJ.getI:()I\n 100: istore 4\n 102: iconst_0\n 103: istore 5\n 105: aload_1\n 106: checkcast #72 // class java/lang/Iterable\n 109: invokestatic #78 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 112: checkcast #80 // class IJ\n 115: invokevirtual #87 // Method IJ.getJ:()I\n 118: istore 5\n 120: iconst_0\n 121: istore 6\n 123: iload 4\n 125: istore 6\n 127: iconst_0\n 128: istore 7\n 130: iload 5\n 132: istore 7\n 134: aload_1\n 135: checkcast #72 // class java/lang/Iterable\n 138: astore 8\n 140: iconst_0\n 141: istore 9\n 143: aload 8\n 145: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 150: astore 10\n 152: aload 10\n 154: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 159: ifeq 234\n 162: aload 10\n 164: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 169: astore 11\n 171: aload 11\n 173: checkcast #80 // class IJ\n 176: astore 12\n 178: iconst_0\n 179: istore 13\n 181: iload 4\n 183: aload 12\n 185: invokevirtual #84 // Method IJ.getI:()I\n 188: invokestatic #107 // Method java/lang/Math.min:(II)I\n 191: istore 4\n 193: iload 5\n 195: aload 12\n 197: invokevirtual #87 // Method IJ.getJ:()I\n 200: invokestatic #107 // Method java/lang/Math.min:(II)I\n 203: istore 5\n 205: iload 6\n 207: aload 12\n 209: invokevirtual #84 // Method IJ.getI:()I\n 212: invokestatic #110 // Method java/lang/Math.max:(II)I\n 215: istore 6\n 217: iload 7\n 219: aload 12\n 221: invokevirtual #87 // Method IJ.getJ:()I\n 224: invokestatic #110 // Method java/lang/Math.max:(II)I\n 227: istore 7\n 229: nop\n 230: nop\n 231: goto 152\n 234: nop\n 235: iconst_0\n 236: istore 8\n 238: iload 4\n 240: istore 9\n 242: iload 6\n 244: istore 10\n 246: iload 9\n 248: iload 10\n 250: if_icmpgt 317\n 253: iload 5\n 255: istore 11\n 257: iload 7\n 259: istore 12\n 261: iload 11\n 263: iload 12\n 265: if_icmpgt 304\n 268: aload_1\n 269: new #80 // class IJ\n 272: dup\n 273: iload 9\n 275: iload 11\n 277: invokespecial #113 // Method IJ.\"<init>\":(II)V\n 280: invokeinterface #119, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 285: ifne 291\n 288: iinc 8, 1\n 291: iload 11\n 293: iload 12\n 295: if_icmpeq 304\n 298: iinc 11, 1\n 301: goto 268\n 304: iload 9\n 306: iload 10\n 308: if_icmpeq 317\n 311: iinc 9, 1\n 314: goto 253\n 317: iload 8\n 319: ireturn\n\n private static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #53 // Method toElves:(Ljava/util/List;)Ljava/util/Set;\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: new #55 // class java/util/LinkedHashMap\n 10: dup\n 11: invokespecial #57 // Method java/util/LinkedHashMap.\"<init>\":()V\n 14: checkcast #59 // class java/util/Map\n 17: astore_3\n 18: new #55 // class java/util/LinkedHashMap\n 21: dup\n 22: invokespecial #57 // Method java/util/LinkedHashMap.\"<init>\":()V\n 25: checkcast #59 // class java/util/Map\n 28: astore 4\n 30: nop\n 31: aload_3\n 32: invokeinterface #62, 1 // InterfaceMethod java/util/Map.clear:()V\n 37: aload 4\n 39: invokeinterface #62, 1 // InterfaceMethod java/util/Map.clear:()V\n 44: aload_1\n 45: iload_2\n 46: aload_3\n 47: aload 4\n 49: invokestatic #66 // Method calculateMoves:(Ljava/util/Set;ILjava/util/Map;Ljava/util/Map;)V\n 52: aload_3\n 53: invokeinterface #144, 1 // InterfaceMethod java/util/Map.isEmpty:()Z\n 58: ifeq 64\n 61: goto 78\n 64: aload_1\n 65: aload_3\n 66: aload 4\n 68: invokestatic #70 // Method applyMoves:(Ljava/util/Set;Ljava/util/Map;Ljava/util/Map;)Ljava/util/Set;\n 71: astore_1\n 72: iinc 2, 1\n 75: goto 30\n 78: iload_2\n 79: iconst_1\n 80: iadd\n 81: ireturn\n\n private static final java.util.Set<IJ> toElves(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #72 // class java/lang/Iterable\n 4: astore_1\n 5: new #148 // class java/util/ArrayList\n 8: dup\n 9: invokespecial #149 // Method java/util/ArrayList.\"<init>\":()V\n 12: checkcast #151 // class java/util/Collection\n 15: astore_2\n 16: iconst_0\n 17: istore_3\n 18: aload_1\n 19: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 24: astore 4\n 26: aload 4\n 28: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 33: ifeq 236\n 36: aload 4\n 38: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 43: astore 5\n 45: iload_3\n 46: iinc 3, 1\n 49: istore 6\n 51: iload 6\n 53: ifge 59\n 56: invokestatic #154 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 59: iload 6\n 61: aload 5\n 63: checkcast #156 // class java/lang/String\n 66: astore 7\n 68: istore 8\n 70: iconst_0\n 71: istore 9\n 73: aload 7\n 75: checkcast #158 // class java/lang/CharSequence\n 78: astore 10\n 80: iconst_0\n 81: istore 11\n 83: aload 10\n 85: astore 12\n 87: new #148 // class java/util/ArrayList\n 90: dup\n 91: invokespecial #149 // Method java/util/ArrayList.\"<init>\":()V\n 94: checkcast #151 // class java/util/Collection\n 97: astore 13\n 99: iconst_0\n 100: istore 14\n 102: aload 12\n 104: astore 15\n 106: iconst_0\n 107: istore 16\n 109: iconst_0\n 110: istore 17\n 112: iconst_0\n 113: istore 18\n 115: iload 18\n 117: aload 15\n 119: invokeinterface #161, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 124: if_icmpge 216\n 127: aload 15\n 129: iload 18\n 131: invokeinterface #165, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 136: istore 19\n 138: iload 17\n 140: iinc 17, 1\n 143: iload 19\n 145: istore 20\n 147: istore 21\n 149: iconst_0\n 150: istore 22\n 152: iload 21\n 154: iload 20\n 156: istore 23\n 158: istore 24\n 160: iconst_0\n 161: istore 25\n 163: iload 23\n 165: bipush 35\n 167: if_icmpne 184\n 170: new #80 // class IJ\n 173: dup\n 174: iload 8\n 176: iload 24\n 178: invokespecial #113 // Method IJ.\"<init>\":(II)V\n 181: goto 185\n 184: aconst_null\n 185: nop\n 186: dup\n 187: ifnull 208\n 190: astore 26\n 192: iconst_0\n 193: istore 27\n 195: aload 13\n 197: aload 26\n 199: invokeinterface #168, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 204: pop\n 205: goto 209\n 208: pop\n 209: nop\n 210: iinc 18, 1\n 213: goto 115\n 216: nop\n 217: aload 13\n 219: checkcast #48 // class java/util/List\n 222: nop\n 223: checkcast #72 // class java/lang/Iterable\n 226: nop\n 227: aload_2\n 228: swap\n 229: invokestatic #172 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 232: pop\n 233: goto 26\n 236: aload_2\n 237: checkcast #48 // class java/util/List\n 240: checkcast #72 // class java/lang/Iterable\n 243: invokestatic #176 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 246: areturn\n\n private static final void calculateMoves(java.util.Set<IJ>, int, java.util.Map<IJ, IJ>, java.util.Map<IJ, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: checkcast #72 // class java/lang/Iterable\n 4: astore 4\n 6: iconst_0\n 7: istore 5\n 9: aload 4\n 11: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 16: astore 6\n 18: aload 6\n 20: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 25: ifeq 495\n 28: aload 6\n 30: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 35: astore 7\n 37: aload 7\n 39: checkcast #80 // class IJ\n 42: astore 8\n 44: iconst_0\n 45: istore 9\n 47: getstatic #203 // Field ALL_ADJACENT:Ljava/util/List;\n 50: checkcast #72 // class java/lang/Iterable\n 53: astore 10\n 55: iconst_0\n 56: istore 11\n 58: aload 10\n 60: instanceof #151 // class java/util/Collection\n 63: ifeq 83\n 66: aload 10\n 68: checkcast #151 // class java/util/Collection\n 71: invokeinterface #204, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 76: ifeq 83\n 79: iconst_0\n 80: goto 162\n 83: aload 10\n 85: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 90: astore 12\n 92: aload 12\n 94: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 99: ifeq 161\n 102: aload 12\n 104: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 109: astore 13\n 111: aload 13\n 113: checkcast #206 // class \"[I\"\n 116: astore 14\n 118: iconst_0\n 119: istore 15\n 121: aload_0\n 122: new #80 // class IJ\n 125: dup\n 126: aload 8\n 128: invokevirtual #84 // Method IJ.getI:()I\n 131: aload 14\n 133: iconst_0\n 134: iaload\n 135: iadd\n 136: aload 8\n 138: invokevirtual #87 // Method IJ.getJ:()I\n 141: aload 14\n 143: iconst_1\n 144: iaload\n 145: iadd\n 146: invokespecial #113 // Method IJ.\"<init>\":(II)V\n 149: invokeinterface #119, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 154: ifeq 92\n 157: iconst_1\n 158: goto 162\n 161: iconst_0\n 162: istore 16\n 164: iload 16\n 166: ifeq 490\n 169: getstatic #209 // Field DIRECTIONS:Ljava/util/List;\n 172: checkcast #151 // class java/util/Collection\n 175: invokestatic #213 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 178: checkcast #72 // class java/lang/Iterable\n 181: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 186: astore 12\n 188: aload 12\n 190: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 195: ifeq 392\n 198: aload 12\n 200: checkcast #215 // class kotlin/collections/IntIterator\n 203: invokevirtual #218 // Method kotlin/collections/IntIterator.nextInt:()I\n 206: istore 13\n 208: iconst_0\n 209: istore 14\n 211: getstatic #209 // Field DIRECTIONS:Ljava/util/List;\n 214: iload 13\n 216: iload_1\n 217: iadd\n 218: getstatic #209 // Field DIRECTIONS:Ljava/util/List;\n 221: invokeinterface #221, 1 // InterfaceMethod java/util/List.size:()I\n 226: irem\n 227: invokeinterface #225, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 232: astore 15\n 234: aload 15\n 236: checkcast #48 // class java/util/List\n 239: astore 17\n 241: iconst_0\n 242: istore 18\n 244: aload 17\n 246: checkcast #72 // class java/lang/Iterable\n 249: astore 19\n 251: iconst_0\n 252: istore 20\n 254: aload 19\n 256: instanceof #151 // class java/util/Collection\n 259: ifeq 279\n 262: aload 19\n 264: checkcast #151 // class java/util/Collection\n 267: invokeinterface #204, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 272: ifeq 279\n 275: iconst_1\n 276: goto 366\n 279: aload 19\n 281: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 286: astore 21\n 288: aload 21\n 290: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 295: ifeq 365\n 298: aload 21\n 300: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 305: astore 22\n 307: aload 22\n 309: checkcast #206 // class \"[I\"\n 312: astore 23\n 314: iconst_0\n 315: istore 24\n 317: aload_0\n 318: new #80 // class IJ\n 321: dup\n 322: aload 8\n 324: invokevirtual #84 // Method IJ.getI:()I\n 327: aload 23\n 329: iconst_0\n 330: iaload\n 331: iadd\n 332: aload 8\n 334: invokevirtual #87 // Method IJ.getJ:()I\n 337: aload 23\n 339: iconst_1\n 340: iaload\n 341: iadd\n 342: invokespecial #113 // Method IJ.\"<init>\":(II)V\n 345: invokeinterface #119, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 350: ifne 357\n 353: iconst_1\n 354: goto 358\n 357: iconst_0\n 358: ifne 288\n 361: iconst_0\n 362: goto 366\n 365: iconst_1\n 366: nop\n 367: ifeq 375\n 370: aload 15\n 372: goto 376\n 375: aconst_null\n 376: checkcast #48 // class java/util/List\n 379: nop\n 380: astore 13\n 382: aload 13\n 384: ifnull 188\n 387: aload 13\n 389: goto 393\n 392: aconst_null\n 393: astore 10\n 395: aload 10\n 397: ifnull 490\n 400: new #80 // class IJ\n 403: dup\n 404: aload 8\n 406: invokevirtual #84 // Method IJ.getI:()I\n 409: aload 10\n 411: iconst_0\n 412: invokeinterface #225, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 417: checkcast #206 // class \"[I\"\n 420: iconst_0\n 421: iaload\n 422: iadd\n 423: aload 8\n 425: invokevirtual #87 // Method IJ.getJ:()I\n 428: aload 10\n 430: iconst_0\n 431: invokeinterface #225, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 436: checkcast #206 // class \"[I\"\n 439: iconst_1\n 440: iaload\n 441: iadd\n 442: invokespecial #113 // Method IJ.\"<init>\":(II)V\n 445: astore 11\n 447: aload_2\n 448: aload 8\n 450: aload 11\n 452: invokeinterface #229, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 457: pop\n 458: aload_3\n 459: aload 11\n 461: aload_3\n 462: aload 11\n 464: iconst_0\n 465: invokestatic #235 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 468: invokeinterface #238, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 473: checkcast #240 // class java/lang/Number\n 476: invokevirtual #243 // Method java/lang/Number.intValue:()I\n 479: iconst_1\n 480: iadd\n 481: invokestatic #235 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 484: invokeinterface #229, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 489: pop\n 490: nop\n 491: nop\n 492: goto 18\n 495: nop\n 496: return\n\n private static final java.util.Set<IJ> applyMoves(java.util.Set<IJ>, java.util.Map<IJ, IJ>, java.util.Map<IJ, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: checkcast #72 // 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 #148 // class java/util/ArrayList\n 14: dup\n 15: aload_3\n 16: bipush 10\n 18: invokestatic #265 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 21: invokespecial #267 // Method java/util/ArrayList.\"<init>\":(I)V\n 24: checkcast #151 // class java/util/Collection\n 27: astore 6\n 29: iconst_0\n 30: istore 7\n 32: aload 5\n 34: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 8\n 41: aload 8\n 43: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 161\n 51: aload 8\n 53: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 9\n 60: aload 6\n 62: aload 9\n 64: checkcast #80 // class IJ\n 67: astore 10\n 69: astore 16\n 71: iconst_0\n 72: istore 11\n 74: aload_1\n 75: aload 10\n 77: invokeinterface #270, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 82: checkcast #80 // class IJ\n 85: dup\n 86: ifnull 146\n 89: astore 12\n 91: aload 12\n 93: astore 13\n 95: iconst_0\n 96: istore 14\n 98: aload_2\n 99: aload 13\n 101: invokeinterface #270, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 106: checkcast #231 // class java/lang/Integer\n 109: iconst_1\n 110: istore 15\n 112: dup\n 113: ifnonnull 120\n 116: pop\n 117: goto 132\n 120: invokevirtual #271 // Method java/lang/Integer.intValue:()I\n 123: iload 15\n 125: if_icmpne 132\n 128: iconst_1\n 129: goto 133\n 132: iconst_0\n 133: ifeq 141\n 136: aload 12\n 138: goto 142\n 141: aconst_null\n 142: dup\n 143: ifnonnull 149\n 146: pop\n 147: aload 10\n 149: aload 16\n 151: swap\n 152: invokeinterface #168, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 157: pop\n 158: goto 41\n 161: aload 6\n 163: checkcast #48 // class java/util/List\n 166: nop\n 167: checkcast #72 // class java/lang/Iterable\n 170: invokestatic #176 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 173: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #282 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: iconst_4\n 1: anewarray #48 // class java/util/List\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: iconst_3\n 8: anewarray #206 // class \"[I\"\n 11: astore_1\n 12: aload_1\n 13: iconst_0\n 14: iconst_2\n 15: newarray int\n 17: astore_2\n 18: aload_2\n 19: iconst_0\n 20: iconst_m1\n 21: iastore\n 22: aload_2\n 23: iconst_1\n 24: iconst_0\n 25: iastore\n 26: aload_2\n 27: aastore\n 28: aload_1\n 29: iconst_1\n 30: iconst_2\n 31: newarray int\n 33: astore_2\n 34: aload_2\n 35: iconst_0\n 36: iconst_m1\n 37: iastore\n 38: aload_2\n 39: iconst_1\n 40: iconst_1\n 41: iastore\n 42: aload_2\n 43: aastore\n 44: aload_1\n 45: iconst_2\n 46: iconst_2\n 47: newarray int\n 49: astore_2\n 50: aload_2\n 51: iconst_0\n 52: iconst_m1\n 53: iastore\n 54: aload_2\n 55: iconst_1\n 56: iconst_m1\n 57: iastore\n 58: aload_2\n 59: aastore\n 60: aload_1\n 61: checkcast #287 // class \"[Ljava/lang/Object;\"\n 64: invokestatic #291 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 67: aastore\n 68: aload_0\n 69: iconst_1\n 70: iconst_3\n 71: anewarray #206 // class \"[I\"\n 74: astore_1\n 75: aload_1\n 76: iconst_0\n 77: iconst_2\n 78: newarray int\n 80: astore_2\n 81: aload_2\n 82: iconst_0\n 83: iconst_1\n 84: iastore\n 85: aload_2\n 86: iconst_1\n 87: iconst_0\n 88: iastore\n 89: aload_2\n 90: aastore\n 91: aload_1\n 92: iconst_1\n 93: iconst_2\n 94: newarray int\n 96: astore_2\n 97: aload_2\n 98: iconst_0\n 99: iconst_1\n 100: iastore\n 101: aload_2\n 102: iconst_1\n 103: iconst_1\n 104: iastore\n 105: aload_2\n 106: aastore\n 107: aload_1\n 108: iconst_2\n 109: iconst_2\n 110: newarray int\n 112: astore_2\n 113: aload_2\n 114: iconst_0\n 115: iconst_1\n 116: iastore\n 117: aload_2\n 118: iconst_1\n 119: iconst_m1\n 120: iastore\n 121: aload_2\n 122: aastore\n 123: aload_1\n 124: checkcast #287 // class \"[Ljava/lang/Object;\"\n 127: invokestatic #291 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 130: aastore\n 131: aload_0\n 132: iconst_2\n 133: iconst_3\n 134: anewarray #206 // class \"[I\"\n 137: astore_1\n 138: aload_1\n 139: iconst_0\n 140: iconst_2\n 141: newarray int\n 143: astore_2\n 144: aload_2\n 145: iconst_0\n 146: iconst_0\n 147: iastore\n 148: aload_2\n 149: iconst_1\n 150: iconst_m1\n 151: iastore\n 152: aload_2\n 153: aastore\n 154: aload_1\n 155: iconst_1\n 156: iconst_2\n 157: newarray int\n 159: astore_2\n 160: aload_2\n 161: iconst_0\n 162: iconst_m1\n 163: iastore\n 164: aload_2\n 165: iconst_1\n 166: iconst_m1\n 167: iastore\n 168: aload_2\n 169: aastore\n 170: aload_1\n 171: iconst_2\n 172: iconst_2\n 173: newarray int\n 175: astore_2\n 176: aload_2\n 177: iconst_0\n 178: iconst_1\n 179: iastore\n 180: aload_2\n 181: iconst_1\n 182: iconst_m1\n 183: iastore\n 184: aload_2\n 185: aastore\n 186: aload_1\n 187: checkcast #287 // class \"[Ljava/lang/Object;\"\n 190: invokestatic #291 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 193: aastore\n 194: aload_0\n 195: iconst_3\n 196: iconst_3\n 197: anewarray #206 // class \"[I\"\n 200: astore_1\n 201: aload_1\n 202: iconst_0\n 203: iconst_2\n 204: newarray int\n 206: astore_2\n 207: aload_2\n 208: iconst_0\n 209: iconst_0\n 210: iastore\n 211: aload_2\n 212: iconst_1\n 213: iconst_1\n 214: iastore\n 215: aload_2\n 216: aastore\n 217: aload_1\n 218: iconst_1\n 219: iconst_2\n 220: newarray int\n 222: astore_2\n 223: aload_2\n 224: iconst_0\n 225: iconst_m1\n 226: iastore\n 227: aload_2\n 228: iconst_1\n 229: iconst_1\n 230: iastore\n 231: aload_2\n 232: aastore\n 233: aload_1\n 234: iconst_2\n 235: iconst_2\n 236: newarray int\n 238: astore_2\n 239: aload_2\n 240: iconst_0\n 241: iconst_1\n 242: iastore\n 243: aload_2\n 244: iconst_1\n 245: iconst_1\n 246: iastore\n 247: aload_2\n 248: aastore\n 249: aload_1\n 250: checkcast #287 // class \"[Ljava/lang/Object;\"\n 253: invokestatic #291 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 256: aastore\n 257: aload_0\n 258: invokestatic #291 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 261: putstatic #209 // Field DIRECTIONS:Ljava/util/List;\n 264: bipush 8\n 266: anewarray #206 // class \"[I\"\n 269: astore_0\n 270: aload_0\n 271: iconst_0\n 272: iconst_2\n 273: newarray int\n 275: astore_1\n 276: aload_1\n 277: iconst_0\n 278: iconst_m1\n 279: iastore\n 280: aload_1\n 281: iconst_1\n 282: iconst_m1\n 283: iastore\n 284: aload_1\n 285: aastore\n 286: aload_0\n 287: iconst_1\n 288: iconst_2\n 289: newarray int\n 291: astore_1\n 292: aload_1\n 293: iconst_0\n 294: iconst_m1\n 295: iastore\n 296: aload_1\n 297: iconst_1\n 298: iconst_0\n 299: iastore\n 300: aload_1\n 301: aastore\n 302: aload_0\n 303: iconst_2\n 304: iconst_2\n 305: newarray int\n 307: astore_1\n 308: aload_1\n 309: iconst_0\n 310: iconst_m1\n 311: iastore\n 312: aload_1\n 313: iconst_1\n 314: iconst_1\n 315: iastore\n 316: aload_1\n 317: aastore\n 318: aload_0\n 319: iconst_3\n 320: iconst_2\n 321: newarray int\n 323: astore_1\n 324: aload_1\n 325: iconst_0\n 326: iconst_0\n 327: iastore\n 328: aload_1\n 329: iconst_1\n 330: iconst_1\n 331: iastore\n 332: aload_1\n 333: aastore\n 334: aload_0\n 335: iconst_4\n 336: iconst_2\n 337: newarray int\n 339: astore_1\n 340: aload_1\n 341: iconst_0\n 342: iconst_1\n 343: iastore\n 344: aload_1\n 345: iconst_1\n 346: iconst_1\n 347: iastore\n 348: aload_1\n 349: aastore\n 350: aload_0\n 351: iconst_5\n 352: iconst_2\n 353: newarray int\n 355: astore_1\n 356: aload_1\n 357: iconst_0\n 358: iconst_1\n 359: iastore\n 360: aload_1\n 361: iconst_1\n 362: iconst_0\n 363: iastore\n 364: aload_1\n 365: aastore\n 366: aload_0\n 367: bipush 6\n 369: iconst_2\n 370: newarray int\n 372: astore_1\n 373: aload_1\n 374: iconst_0\n 375: iconst_1\n 376: iastore\n 377: aload_1\n 378: iconst_1\n 379: iconst_m1\n 380: iastore\n 381: aload_1\n 382: aastore\n 383: aload_0\n 384: bipush 7\n 386: iconst_2\n 387: newarray int\n 389: astore_1\n 390: aload_1\n 391: iconst_0\n 392: iconst_0\n 393: iastore\n 394: aload_1\n 395: iconst_1\n 396: iconst_m1\n 397: iastore\n 398: aload_1\n 399: aastore\n 400: aload_0\n 401: checkcast #287 // class \"[Ljava/lang/Object;\"\n 404: invokestatic #291 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 407: putstatic #203 // Field ALL_ADJACENT:Ljava/util/List;\n 410: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day05.kt
import java.util.* fun main() { val testInput = readInput("Day05_test") check(part1(testInput) == "CMZ") check(part2(testInput) == "MCD") val input = readInput("Day05") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): String = solve(input) { stacks, cmd -> repeat(cmd.count) { stacks[cmd.to].push(stacks[cmd.from].pop()) } } private fun part2(input: List<String>): String { val stack = LinkedList<Char>() return solve(input) { stacks, cmd -> repeat(cmd.count) { stack.push(stacks[cmd.from].pop()) } while (stack.isNotEmpty()) { stacks[cmd.to].push(stack.pop()) } } } private fun solve(input: List<String>, reorderStrategy: (List<LinkedList<Char>>, Command) -> Unit): String { val dividerIndex = input.indexOfFirst { it.isEmpty() } val stacks = input .subList(0, dividerIndex) .toInitialStacks() input .subList(dividerIndex + 1, input.lastIndex + 1) .map(String::toCommand) .forEach { cmd -> reorderStrategy(stacks, cmd) } return stacks.joinToString(separator = "") { it.pop().toString() } } private fun List<String>.toInitialStacks(): List<LinkedList<Char>> { val count = this.last() .trim() .drop( this.last() .lastIndexOf(' ') ) .toInt() val list = List(count) { LinkedList<Char>() } this.subList(0, this.lastIndex) .asReversed() .forEach { row -> var i = 1 while (i <= row.lastIndex) { if (row[i].isLetter()) { list[i / 4].push(row[i]) } i += 4 } } return list } private val COMMAND_FORMAT = Regex("move (\\d+) from (\\d+) to (\\d+)") private fun String.toCommand(): Command { val match = COMMAND_FORMAT.find(this) val (move, from, to) = requireNotNull(match).destructured return Command(from = from.toInt() - 1, to = to.toInt() - 1, count = move.toInt()) } private class Command(val from: Int, val to: Int, val count: Int)
[ { "class_path": "Kvest__AOC2022__6409e65/Day05Kt.class", "javap": "Compiled from \"Day05.kt\"\npublic final class Day05Kt {\n private static final kotlin.text.Regex COMMAND_FORMAT;\n\n public static final void main();\n Code:\n 0: ldc #8 // String Day05_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;)Ljava/lang/String;\n 10: ldc #20 // String CMZ\n 12: invokestatic #26 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 15: ifne 28\n 18: new #28 // class java/lang/IllegalStateException\n 21: dup\n 22: ldc #30 // String Check failed.\n 24: invokespecial #34 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 27: athrow\n 28: aload_0\n 29: invokestatic #37 // Method part2:(Ljava/util/List;)Ljava/lang/String;\n 32: ldc #39 // String MCD\n 34: invokestatic #26 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 37: ifne 50\n 40: new #28 // class java/lang/IllegalStateException\n 43: dup\n 44: ldc #30 // String Check failed.\n 46: invokespecial #34 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 49: athrow\n 50: ldc #41 // String Day05\n 52: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 55: astore_1\n 56: aload_1\n 57: invokestatic #18 // Method part1:(Ljava/util/List;)Ljava/lang/String;\n 60: getstatic #47 // Field java/lang/System.out:Ljava/io/PrintStream;\n 63: swap\n 64: invokevirtual #53 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 67: aload_1\n 68: invokestatic #37 // Method part2:(Ljava/util/List;)Ljava/lang/String;\n 71: getstatic #47 // Field java/lang/System.out:Ljava/io/PrintStream;\n 74: swap\n 75: invokevirtual #53 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 78: return\n\n private static final java.lang.String part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokedynamic #78, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;\n 6: invokestatic #82 // Method solve:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)Ljava/lang/String;\n 9: areturn\n\n private static final java.lang.String part2(java.util.List<java.lang.String>);\n Code:\n 0: new #84 // class java/util/LinkedList\n 3: dup\n 4: invokespecial #86 // Method java/util/LinkedList.\"<init>\":()V\n 7: astore_1\n 8: aload_0\n 9: aload_1\n 10: invokedynamic #94, 0 // InvokeDynamic #1:invoke:(Ljava/util/LinkedList;)Lkotlin/jvm/functions/Function2;\n 15: invokestatic #82 // Method solve:(Ljava/util/List;Lkotlin/jvm/functions/Function2;)Ljava/lang/String;\n 18: areturn\n\n private static final java.lang.String solve(java.util.List<java.lang.String>, kotlin.jvm.functions.Function2<? super java.util.List<? extends java.util.LinkedList<java.lang.Character>>, ? super Command, kotlin.Unit>);\n Code:\n 0: aload_0\n 1: astore_3\n 2: iconst_0\n 3: istore 4\n 5: iconst_0\n 6: istore 5\n 8: aload_3\n 9: invokeinterface #101, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 14: astore 6\n 16: aload 6\n 18: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 23: ifeq 78\n 26: aload 6\n 28: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 33: astore 7\n 35: aload 7\n 37: checkcast #113 // class java/lang/String\n 40: astore 8\n 42: iconst_0\n 43: istore 9\n 45: aload 8\n 47: checkcast #115 // class java/lang/CharSequence\n 50: invokeinterface #119, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 55: ifne 62\n 58: iconst_1\n 59: goto 63\n 62: iconst_0\n 63: nop\n 64: ifeq 72\n 67: iload 5\n 69: goto 79\n 72: iinc 5, 1\n 75: goto 16\n 78: iconst_m1\n 79: istore_2\n 80: aload_0\n 81: iconst_0\n 82: iload_2\n 83: invokeinterface #123, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 88: invokestatic #127 // Method toInitialStacks:(Ljava/util/List;)Ljava/util/List;\n 91: astore_3\n 92: aload_0\n 93: iload_2\n 94: iconst_1\n 95: iadd\n 96: aload_0\n 97: invokestatic #133 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 100: iconst_1\n 101: iadd\n 102: invokeinterface #123, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 107: checkcast #135 // class java/lang/Iterable\n 110: astore 4\n 112: nop\n 113: iconst_0\n 114: istore 5\n 116: aload 4\n 118: astore 6\n 120: new #137 // class java/util/ArrayList\n 123: dup\n 124: aload 4\n 126: bipush 10\n 128: invokestatic #141 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 131: invokespecial #144 // Method java/util/ArrayList.\"<init>\":(I)V\n 134: checkcast #146 // class java/util/Collection\n 137: astore 7\n 139: iconst_0\n 140: istore 8\n 142: aload 6\n 144: invokeinterface #147, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 149: astore 9\n 151: aload 9\n 153: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 158: ifeq 201\n 161: aload 9\n 163: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 168: astore 10\n 170: aload 7\n 172: aload 10\n 174: checkcast #113 // class java/lang/String\n 177: astore 11\n 179: astore 13\n 181: iconst_0\n 182: istore 12\n 184: aload 11\n 186: invokestatic #151 // Method toCommand:(Ljava/lang/String;)LCommand;\n 189: aload 13\n 191: swap\n 192: invokeinterface #155, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 197: pop\n 198: goto 151\n 201: aload 7\n 203: checkcast #58 // class java/util/List\n 206: nop\n 207: checkcast #135 // class java/lang/Iterable\n 210: astore 4\n 212: nop\n 213: iconst_0\n 214: istore 5\n 216: aload 4\n 218: invokeinterface #147, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 223: astore 6\n 225: aload 6\n 227: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 232: ifeq 269\n 235: aload 6\n 237: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 242: astore 7\n 244: aload 7\n 246: checkcast #157 // class Command\n 249: astore 8\n 251: iconst_0\n 252: istore 9\n 254: aload_1\n 255: aload_3\n 256: aload 8\n 258: invokeinterface #161, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 263: pop\n 264: nop\n 265: nop\n 266: goto 225\n 269: nop\n 270: aload_3\n 271: checkcast #135 // class java/lang/Iterable\n 274: ldc #163 // String\n 276: checkcast #115 // class java/lang/CharSequence\n 279: aconst_null\n 280: aconst_null\n 281: iconst_0\n 282: aconst_null\n 283: invokedynamic #174, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;\n 288: bipush 30\n 290: aconst_null\n 291: invokestatic #178 // 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 294: areturn\n\n private static final java.util.List<java.util.LinkedList<java.lang.Character>> toInitialStacks(java.util.List<java.lang.String>);\n Code:\n 0: nop\n 1: nop\n 2: aload_0\n 3: invokestatic #212 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 6: checkcast #113 // class java/lang/String\n 9: checkcast #115 // class java/lang/CharSequence\n 12: invokestatic #218 // Method kotlin/text/StringsKt.trim:(Ljava/lang/CharSequence;)Ljava/lang/CharSequence;\n 15: invokevirtual #222 // Method java/lang/Object.toString:()Ljava/lang/String;\n 18: aload_0\n 19: invokestatic #212 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 22: checkcast #115 // class java/lang/CharSequence\n 25: bipush 32\n 27: iconst_0\n 28: iconst_0\n 29: bipush 6\n 31: aconst_null\n 32: invokestatic #226 // Method kotlin/text/StringsKt.lastIndexOf$default:(Ljava/lang/CharSequence;CIZILjava/lang/Object;)I\n 35: invokestatic #230 // Method kotlin/text/StringsKt.drop:(Ljava/lang/String;I)Ljava/lang/String;\n 38: invokestatic #236 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 41: istore_1\n 42: new #137 // class java/util/ArrayList\n 45: dup\n 46: iload_1\n 47: invokespecial #144 // Method java/util/ArrayList.\"<init>\":(I)V\n 50: astore_3\n 51: iconst_0\n 52: istore 4\n 54: iload 4\n 56: iload_1\n 57: if_icmpge 94\n 60: iload 4\n 62: istore 5\n 64: aload_3\n 65: iload 5\n 67: istore 6\n 69: astore 10\n 71: iconst_0\n 72: istore 7\n 74: new #84 // class java/util/LinkedList\n 77: dup\n 78: invokespecial #86 // Method java/util/LinkedList.\"<init>\":()V\n 81: aload 10\n 83: swap\n 84: invokevirtual #237 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 87: pop\n 88: iinc 4, 1\n 91: goto 54\n 94: aload_3\n 95: checkcast #58 // class java/util/List\n 98: astore_2\n 99: aload_0\n 100: iconst_0\n 101: aload_0\n 102: invokestatic #133 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 105: invokeinterface #123, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 110: invokestatic #240 // Method kotlin/collections/CollectionsKt.asReversed:(Ljava/util/List;)Ljava/util/List;\n 113: checkcast #135 // class java/lang/Iterable\n 116: astore_3\n 117: nop\n 118: iconst_0\n 119: istore 4\n 121: aload_3\n 122: invokeinterface #147, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 127: astore 5\n 129: aload 5\n 131: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 136: ifeq 224\n 139: aload 5\n 141: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 146: astore 6\n 148: aload 6\n 150: checkcast #113 // class java/lang/String\n 153: astore 7\n 155: iconst_0\n 156: istore 8\n 158: iconst_1\n 159: istore 9\n 161: iload 9\n 163: aload 7\n 165: checkcast #115 // class java/lang/CharSequence\n 168: invokestatic #243 // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I\n 171: if_icmpgt 219\n 174: aload 7\n 176: iload 9\n 178: invokevirtual #247 // Method java/lang/String.charAt:(I)C\n 181: invokestatic #253 // Method java/lang/Character.isLetter:(C)Z\n 184: ifeq 213\n 187: aload_2\n 188: iload 9\n 190: iconst_4\n 191: idiv\n 192: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 197: checkcast #84 // class java/util/LinkedList\n 200: aload 7\n 202: iload 9\n 204: invokevirtual #247 // Method java/lang/String.charAt:(I)C\n 207: invokestatic #261 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 210: invokevirtual #264 // Method java/util/LinkedList.push:(Ljava/lang/Object;)V\n 213: iinc 9, 4\n 216: goto 161\n 219: nop\n 220: nop\n 221: goto 129\n 224: nop\n 225: aload_2\n 226: areturn\n\n private static final Command toCommand(java.lang.String);\n Code:\n 0: getstatic #275 // Field COMMAND_FORMAT:Lkotlin/text/Regex;\n 3: aload_0\n 4: checkcast #115 // class java/lang/CharSequence\n 7: iconst_0\n 8: iconst_2\n 9: aconst_null\n 10: invokestatic #281 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 13: astore_1\n 14: aload_1\n 15: dup\n 16: ifnonnull 36\n 19: pop\n 20: ldc_w #283 // String Required value was null.\n 23: astore_3\n 24: new #285 // class java/lang/IllegalArgumentException\n 27: dup\n 28: aload_3\n 29: invokevirtual #222 // Method java/lang/Object.toString:()Ljava/lang/String;\n 32: invokespecial #286 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 35: athrow\n 36: invokeinterface #292, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 41: astore_2\n 42: aload_2\n 43: invokevirtual #298 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 46: invokeinterface #302, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 51: iconst_1\n 52: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 57: checkcast #113 // class java/lang/String\n 60: astore_3\n 61: aload_2\n 62: invokevirtual #298 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 65: invokeinterface #302, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 70: iconst_2\n 71: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 76: checkcast #113 // class java/lang/String\n 79: astore 4\n 81: aload_2\n 82: invokevirtual #298 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 85: invokeinterface #302, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 90: iconst_3\n 91: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 96: checkcast #113 // class java/lang/String\n 99: astore 5\n 101: new #157 // class Command\n 104: dup\n 105: aload 4\n 107: invokestatic #236 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 110: iconst_1\n 111: isub\n 112: aload 5\n 114: invokestatic #236 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 117: iconst_1\n 118: isub\n 119: aload_3\n 120: invokestatic #236 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 123: invokespecial #305 // Method Command.\"<init>\":(III)V\n 126: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #314 // Method main:()V\n 3: return\n\n private static final kotlin.Unit part1$lambda$1(java.util.List, Command);\n Code:\n 0: aload_0\n 1: ldc_w #317 // String stacks\n 4: invokestatic #321 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: ldc_w #322 // String cmd\n 11: invokestatic #321 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: aload_1\n 15: invokevirtual #325 // Method Command.getCount:()I\n 18: istore_2\n 19: iconst_0\n 20: istore_3\n 21: iload_3\n 22: iload_2\n 23: if_icmpge 71\n 26: iload_3\n 27: istore 4\n 29: iconst_0\n 30: istore 5\n 32: aload_0\n 33: aload_1\n 34: invokevirtual #328 // Method Command.getTo:()I\n 37: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 42: checkcast #84 // class java/util/LinkedList\n 45: aload_0\n 46: aload_1\n 47: invokevirtual #331 // Method Command.getFrom:()I\n 50: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 55: checkcast #84 // class java/util/LinkedList\n 58: invokevirtual #334 // Method java/util/LinkedList.pop:()Ljava/lang/Object;\n 61: invokevirtual #264 // Method java/util/LinkedList.push:(Ljava/lang/Object;)V\n 64: nop\n 65: iinc 3, 1\n 68: goto 21\n 71: getstatic #340 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 74: areturn\n\n private static final kotlin.Unit part2$lambda$3(java.util.LinkedList, java.util.List, Command);\n Code:\n 0: aload_1\n 1: ldc_w #317 // String stacks\n 4: invokestatic #321 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_2\n 8: ldc_w #322 // String cmd\n 11: invokestatic #321 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: aload_2\n 15: invokevirtual #325 // Method Command.getCount:()I\n 18: istore_3\n 19: iconst_0\n 20: istore 4\n 22: iload 4\n 24: iload_3\n 25: if_icmpge 62\n 28: iload 4\n 30: istore 5\n 32: iconst_0\n 33: istore 6\n 35: aload_0\n 36: aload_1\n 37: aload_2\n 38: invokevirtual #331 // Method Command.getFrom:()I\n 41: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 46: checkcast #84 // class java/util/LinkedList\n 49: invokevirtual #334 // Method java/util/LinkedList.pop:()Ljava/lang/Object;\n 52: invokevirtual #264 // Method java/util/LinkedList.push:(Ljava/lang/Object;)V\n 55: nop\n 56: iinc 4, 1\n 59: goto 22\n 62: aload_0\n 63: checkcast #146 // class java/util/Collection\n 66: invokeinterface #344, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 71: ifne 78\n 74: iconst_1\n 75: goto 79\n 78: iconst_0\n 79: ifeq 105\n 82: aload_1\n 83: aload_2\n 84: invokevirtual #328 // Method Command.getTo:()I\n 87: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 92: checkcast #84 // class java/util/LinkedList\n 95: aload_0\n 96: invokevirtual #334 // Method java/util/LinkedList.pop:()Ljava/lang/Object;\n 99: invokevirtual #264 // Method java/util/LinkedList.push:(Ljava/lang/Object;)V\n 102: goto 62\n 105: getstatic #340 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 108: areturn\n\n private static final java.lang.CharSequence solve$lambda$6(java.util.LinkedList);\n Code:\n 0: aload_0\n 1: ldc_w #347 // String it\n 4: invokestatic #321 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokevirtual #334 // Method java/util/LinkedList.pop:()Ljava/lang/Object;\n 11: checkcast #249 // class java/lang/Character\n 14: invokevirtual #348 // Method java/lang/Character.toString:()Ljava/lang/String;\n 17: checkcast #115 // class java/lang/CharSequence\n 20: areturn\n\n static {};\n Code:\n 0: new #277 // class kotlin/text/Regex\n 3: dup\n 4: ldc_w #351 // String move (\\\\d+) from (\\\\d+) to (\\\\d+)\n 7: invokespecial #352 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 10: putstatic #275 // Field COMMAND_FORMAT:Lkotlin/text/Regex;\n 13: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day21.kt
fun main() { val testInput = readInput("Day21_test") val testOperations = testInput.toOperations() check(part1(testOperations) == 152L) check(part2(testOperations) == 301L) val input = readInput("Day21") val operations = input.toOperations() println(part1(operations)) println(part2(operations)) } private fun part1(operations: Map<String, MathOperation>): Long = getValue("root", operations) private const val TARGET_OPERATION = "humn" private fun part2(operations: Map<String, MathOperation>): Long { val rootOp = operations.getValue("root") val operand1Depends = dependsOn(rootOp.operand1, TARGET_OPERATION, operations) val targetValue = getValue( name = if (operand1Depends) rootOp.operand2 else rootOp.operand1, operations = operations ) return correctToValue( name = if (operand1Depends) rootOp.operand1 else rootOp.operand2, targetValue = targetValue, targetOperationName = TARGET_OPERATION, operations = operations ) } private fun correctToValue( name: String, targetValue: Long, targetOperationName: String, operations: Map<String, MathOperation> ): Long { if (name == targetOperationName) { return targetValue } val op = operations.getValue(name) val operand1Depends = dependsOn(op.operand1, TARGET_OPERATION, operations) val anotherOperandValue = getValue( name = if (operand1Depends) op.operand2 else op.operand1, operations = operations ) val nextName = if (operand1Depends) op.operand1 else op.operand2 val nextTargetValue = when (op) { is MathOperation.Divide -> if (operand1Depends) { targetValue * anotherOperandValue } else { anotherOperandValue / targetValue } is MathOperation.Minus -> if (operand1Depends) { targetValue + anotherOperandValue } else { anotherOperandValue - targetValue } is MathOperation.Multiply -> targetValue / anotherOperandValue is MathOperation.Plus -> targetValue - anotherOperandValue is MathOperation.Value -> error("Should not be here") } return correctToValue(nextName, nextTargetValue, targetOperationName, operations) } private fun dependsOn( operationName: String, targetDependency: String, operations: Map<String, MathOperation> ): Boolean { if (operationName == targetDependency) { return true } return when (val op = operations.getValue(operationName)) { is MathOperation.Value -> false else -> dependsOn(op.operand1, targetDependency, operations) || dependsOn(op.operand2, targetDependency, operations) } } private fun getValue(name: String, operations: Map<String, MathOperation>): Long { return when (val op = operations.getValue(name)) { is MathOperation.Divide -> getValue(op.operand1, operations) / getValue(op.operand2, operations) is MathOperation.Minus -> getValue(op.operand1, operations) - getValue(op.operand2, operations) is MathOperation.Multiply -> getValue(op.operand1, operations) * getValue(op.operand2, operations) is MathOperation.Plus -> getValue(op.operand1, operations) + getValue(op.operand2, operations) is MathOperation.Value -> op.value } } private fun List<String>.toOperations(): Map<String, MathOperation> = this.associate { row -> val name = row.substringBefore(":") val operationStr = row.substringAfter(": ") val operation = when { operationStr.contains('+') -> MathOperation.Plus( operand1 = operationStr.substringBefore(" + "), operand2 = operationStr.substringAfter(" + ") ) operationStr.contains('-') -> MathOperation.Minus( operand1 = operationStr.substringBefore(" - "), operand2 = operationStr.substringAfter(" - ") ) operationStr.contains('/') -> MathOperation.Divide( operand1 = operationStr.substringBefore(" / "), operand2 = operationStr.substringAfter(" / ") ) operationStr.contains('*') -> MathOperation.Multiply( operand1 = operationStr.substringBefore(" * "), operand2 = operationStr.substringAfter(" * ") ) else -> MathOperation.Value(operationStr.toLong()) } name to operation } private sealed interface MathOperation { class Value(val value: Long) : MathOperation class Plus(val operand1: String, val operand2: String) : MathOperation class Minus(val operand1: String, val operand2: String) : MathOperation class Multiply(val operand1: String, val operand2: String) : MathOperation class Divide(val operand1: String, val operand2: String) : MathOperation } private val MathOperation.operand1: String get() = when (this) { is MathOperation.Divide -> this.operand1 is MathOperation.Minus -> this.operand1 is MathOperation.Multiply -> this.operand1 is MathOperation.Plus -> this.operand1 is MathOperation.Value -> error("MathOperation.Value doesn't have operands") } private val MathOperation.operand2: String get() = when (this) { is MathOperation.Divide -> this.operand2 is MathOperation.Minus -> this.operand2 is MathOperation.Multiply -> this.operand2 is MathOperation.Plus -> this.operand2 is MathOperation.Value -> error("MathOperation.Value doesn't have operands") }
[ { "class_path": "Kvest__AOC2022__6409e65/Day21Kt.class", "javap": "Compiled from \"Day21.kt\"\npublic final class Day21Kt {\n private static final java.lang.String TARGET_OPERATION;\n\n public static final void main();\n Code:\n 0: ldc #8 // String Day21_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 toOperations:(Ljava/util/List;)Ljava/util/Map;\n 10: astore_1\n 11: aload_1\n 12: invokestatic #22 // Method part1:(Ljava/util/Map;)J\n 15: ldc2_w #23 // long 152l\n 18: lcmp\n 19: ifne 26\n 22: iconst_1\n 23: goto 27\n 26: iconst_0\n 27: ifne 40\n 30: new #26 // class java/lang/IllegalStateException\n 33: dup\n 34: ldc #28 // String Check failed.\n 36: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 39: athrow\n 40: aload_1\n 41: invokestatic #35 // Method part2:(Ljava/util/Map;)J\n 44: ldc2_w #36 // long 301l\n 47: lcmp\n 48: ifne 55\n 51: iconst_1\n 52: goto 56\n 55: iconst_0\n 56: ifne 69\n 59: new #26 // class java/lang/IllegalStateException\n 62: dup\n 63: ldc #28 // String Check failed.\n 65: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 68: athrow\n 69: ldc #39 // String Day21\n 71: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 74: astore_2\n 75: aload_2\n 76: invokestatic #18 // Method toOperations:(Ljava/util/List;)Ljava/util/Map;\n 79: astore_3\n 80: aload_3\n 81: invokestatic #22 // Method part1:(Ljava/util/Map;)J\n 84: lstore 4\n 86: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 89: lload 4\n 91: invokevirtual #51 // Method java/io/PrintStream.println:(J)V\n 94: aload_3\n 95: invokestatic #35 // Method part2:(Ljava/util/Map;)J\n 98: lstore 4\n 100: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 103: lload 4\n 105: invokevirtual #51 // Method java/io/PrintStream.println:(J)V\n 108: return\n\n private static final long part1(java.util.Map<java.lang.String, ? extends MathOperation>);\n Code:\n 0: ldc #64 // String root\n 2: aload_0\n 3: invokestatic #68 // Method getValue:(Ljava/lang/String;Ljava/util/Map;)J\n 6: lreturn\n\n private static final long part2(java.util.Map<java.lang.String, ? extends MathOperation>);\n Code:\n 0: aload_0\n 1: ldc #64 // String root\n 3: invokestatic #73 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 6: checkcast #75 // class MathOperation\n 9: astore_1\n 10: aload_1\n 11: invokestatic #79 // Method getOperand1:(LMathOperation;)Ljava/lang/String;\n 14: ldc #81 // String humn\n 16: aload_0\n 17: invokestatic #85 // Method dependsOn:(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)Z\n 20: istore_2\n 21: iload_2\n 22: ifeq 32\n 25: aload_1\n 26: invokestatic #88 // Method getOperand2:(LMathOperation;)Ljava/lang/String;\n 29: goto 36\n 32: aload_1\n 33: invokestatic #79 // Method getOperand1:(LMathOperation;)Ljava/lang/String;\n 36: aload_0\n 37: invokestatic #68 // Method getValue:(Ljava/lang/String;Ljava/util/Map;)J\n 40: lstore_3\n 41: iload_2\n 42: ifeq 52\n 45: aload_1\n 46: invokestatic #79 // Method getOperand1:(LMathOperation;)Ljava/lang/String;\n 49: goto 56\n 52: aload_1\n 53: invokestatic #88 // Method getOperand2:(LMathOperation;)Ljava/lang/String;\n 56: lload_3\n 57: ldc #81 // String humn\n 59: aload_0\n 60: invokestatic #92 // Method correctToValue:(Ljava/lang/String;JLjava/lang/String;Ljava/util/Map;)J\n 63: lreturn\n\n private static final long correctToValue(java.lang.String, long, java.lang.String, java.util.Map<java.lang.String, ? extends MathOperation>);\n Code:\n 0: aload_0\n 1: aload_3\n 2: invokestatic #107 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 5: ifeq 10\n 8: lload_1\n 9: lreturn\n 10: aload 4\n 12: aload_0\n 13: invokestatic #73 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 16: checkcast #75 // class MathOperation\n 19: astore 5\n 21: aload 5\n 23: invokestatic #79 // Method getOperand1:(LMathOperation;)Ljava/lang/String;\n 26: ldc #81 // String humn\n 28: aload 4\n 30: invokestatic #85 // Method dependsOn:(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)Z\n 33: istore 6\n 35: iload 6\n 37: ifeq 48\n 40: aload 5\n 42: invokestatic #88 // Method getOperand2:(LMathOperation;)Ljava/lang/String;\n 45: goto 53\n 48: aload 5\n 50: invokestatic #79 // Method getOperand1:(LMathOperation;)Ljava/lang/String;\n 53: aload 4\n 55: invokestatic #68 // Method getValue:(Ljava/lang/String;Ljava/util/Map;)J\n 58: lstore 7\n 60: iload 6\n 62: ifeq 73\n 65: aload 5\n 67: invokestatic #79 // Method getOperand1:(LMathOperation;)Ljava/lang/String;\n 70: goto 78\n 73: aload 5\n 75: invokestatic #88 // Method getOperand2:(LMathOperation;)Ljava/lang/String;\n 78: astore 9\n 80: aload 5\n 82: astore 12\n 84: aload 12\n 86: instanceof #109 // class MathOperation$Divide\n 89: ifeq 111\n 92: iload 6\n 94: ifeq 104\n 97: lload_1\n 98: lload 7\n 100: lmul\n 101: goto 197\n 104: lload 7\n 106: lload_1\n 107: ldiv\n 108: goto 197\n 111: aload 12\n 113: instanceof #111 // class MathOperation$Minus\n 116: ifeq 138\n 119: iload 6\n 121: ifeq 131\n 124: lload_1\n 125: lload 7\n 127: ladd\n 128: goto 197\n 131: lload 7\n 133: lload_1\n 134: lsub\n 135: goto 197\n 138: aload 12\n 140: instanceof #113 // class MathOperation$Multiply\n 143: ifeq 153\n 146: lload_1\n 147: lload 7\n 149: ldiv\n 150: goto 197\n 153: aload 12\n 155: instanceof #115 // class MathOperation$Plus\n 158: ifeq 168\n 161: lload_1\n 162: lload 7\n 164: lsub\n 165: goto 197\n 168: aload 12\n 170: instanceof #117 // class MathOperation$Value\n 173: ifeq 189\n 176: new #26 // class java/lang/IllegalStateException\n 179: dup\n 180: ldc #119 // String Should not be here\n 182: invokevirtual #123 // Method java/lang/Object.toString:()Ljava/lang/String;\n 185: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 188: athrow\n 189: new #125 // class kotlin/NoWhenBranchMatchedException\n 192: dup\n 193: invokespecial #127 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 196: athrow\n 197: lstore 10\n 199: aload 9\n 201: lload 10\n 203: aload_3\n 204: aload 4\n 206: invokestatic #92 // Method correctToValue:(Ljava/lang/String;JLjava/lang/String;Ljava/util/Map;)J\n 209: lreturn\n\n private static final boolean dependsOn(java.lang.String, java.lang.String, java.util.Map<java.lang.String, ? extends MathOperation>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #107 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 5: ifeq 10\n 8: iconst_1\n 9: ireturn\n 10: aload_2\n 11: aload_0\n 12: invokestatic #73 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 15: checkcast #75 // class MathOperation\n 18: astore_3\n 19: aload_3\n 20: instanceof #117 // class MathOperation$Value\n 23: ifeq 30\n 26: iconst_0\n 27: goto 59\n 30: aload_3\n 31: invokestatic #79 // Method getOperand1:(LMathOperation;)Ljava/lang/String;\n 34: aload_1\n 35: aload_2\n 36: invokestatic #85 // Method dependsOn:(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)Z\n 39: ifne 54\n 42: aload_3\n 43: invokestatic #88 // Method getOperand2:(LMathOperation;)Ljava/lang/String;\n 46: aload_1\n 47: aload_2\n 48: invokestatic #85 // Method dependsOn:(Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)Z\n 51: ifeq 58\n 54: iconst_1\n 55: goto 59\n 58: iconst_0\n 59: ireturn\n\n private static final long getValue(java.lang.String, java.util.Map<java.lang.String, ? extends MathOperation>);\n Code:\n 0: aload_1\n 1: aload_0\n 2: invokestatic #73 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 5: checkcast #75 // class MathOperation\n 8: astore_2\n 9: aload_2\n 10: instanceof #109 // class MathOperation$Divide\n 13: ifeq 42\n 16: aload_2\n 17: checkcast #109 // class MathOperation$Divide\n 20: invokevirtual #140 // Method MathOperation$Divide.getOperand1:()Ljava/lang/String;\n 23: aload_1\n 24: invokestatic #68 // Method getValue:(Ljava/lang/String;Ljava/util/Map;)J\n 27: aload_2\n 28: checkcast #109 // class MathOperation$Divide\n 31: invokevirtual #142 // Method MathOperation$Divide.getOperand2:()Ljava/lang/String;\n 34: aload_1\n 35: invokestatic #68 // Method getValue:(Ljava/lang/String;Ljava/util/Map;)J\n 38: ldiv\n 39: goto 166\n 42: aload_2\n 43: instanceof #111 // class MathOperation$Minus\n 46: ifeq 75\n 49: aload_2\n 50: checkcast #111 // class MathOperation$Minus\n 53: invokevirtual #143 // Method MathOperation$Minus.getOperand1:()Ljava/lang/String;\n 56: aload_1\n 57: invokestatic #68 // Method getValue:(Ljava/lang/String;Ljava/util/Map;)J\n 60: aload_2\n 61: checkcast #111 // class MathOperation$Minus\n 64: invokevirtual #144 // Method MathOperation$Minus.getOperand2:()Ljava/lang/String;\n 67: aload_1\n 68: invokestatic #68 // Method getValue:(Ljava/lang/String;Ljava/util/Map;)J\n 71: lsub\n 72: goto 166\n 75: aload_2\n 76: instanceof #113 // class MathOperation$Multiply\n 79: ifeq 108\n 82: aload_2\n 83: checkcast #113 // class MathOperation$Multiply\n 86: invokevirtual #145 // Method MathOperation$Multiply.getOperand1:()Ljava/lang/String;\n 89: aload_1\n 90: invokestatic #68 // Method getValue:(Ljava/lang/String;Ljava/util/Map;)J\n 93: aload_2\n 94: checkcast #113 // class MathOperation$Multiply\n 97: invokevirtual #146 // Method MathOperation$Multiply.getOperand2:()Ljava/lang/String;\n 100: aload_1\n 101: invokestatic #68 // Method getValue:(Ljava/lang/String;Ljava/util/Map;)J\n 104: lmul\n 105: goto 166\n 108: aload_2\n 109: instanceof #115 // class MathOperation$Plus\n 112: ifeq 141\n 115: aload_2\n 116: checkcast #115 // class MathOperation$Plus\n 119: invokevirtual #147 // Method MathOperation$Plus.getOperand1:()Ljava/lang/String;\n 122: aload_1\n 123: invokestatic #68 // Method getValue:(Ljava/lang/String;Ljava/util/Map;)J\n 126: aload_2\n 127: checkcast #115 // class MathOperation$Plus\n 130: invokevirtual #148 // Method MathOperation$Plus.getOperand2:()Ljava/lang/String;\n 133: aload_1\n 134: invokestatic #68 // Method getValue:(Ljava/lang/String;Ljava/util/Map;)J\n 137: ladd\n 138: goto 166\n 141: aload_2\n 142: instanceof #117 // class MathOperation$Value\n 145: ifeq 158\n 148: aload_2\n 149: checkcast #117 // class MathOperation$Value\n 152: invokevirtual #151 // Method MathOperation$Value.getValue:()J\n 155: goto 166\n 158: new #125 // class kotlin/NoWhenBranchMatchedException\n 161: dup\n 162: invokespecial #127 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 165: athrow\n 166: lreturn\n\n private static final java.util.Map<java.lang.String, MathOperation> toOperations(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #154 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: bipush 10\n 10: invokestatic #160 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 13: invokestatic #164 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 16: bipush 16\n 18: invokestatic #170 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 21: istore_3\n 22: aload_1\n 23: astore 4\n 25: new #172 // class java/util/LinkedHashMap\n 28: dup\n 29: iload_3\n 30: invokespecial #175 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 33: checkcast #61 // class java/util/Map\n 36: astore 5\n 38: iconst_0\n 39: istore 6\n 41: aload 4\n 43: invokeinterface #179, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 48: astore 7\n 50: aload 7\n 52: invokeinterface #185, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 57: ifeq 351\n 60: aload 7\n 62: invokeinterface #189, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 67: astore 8\n 69: aload 5\n 71: astore 9\n 73: aload 8\n 75: checkcast #100 // class java/lang/String\n 78: astore 10\n 80: iconst_0\n 81: istore 11\n 83: aload 10\n 85: ldc #191 // String :\n 87: aconst_null\n 88: iconst_2\n 89: aconst_null\n 90: invokestatic #197 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 93: astore 12\n 95: aload 10\n 97: ldc #199 // String :\n 99: aconst_null\n 100: iconst_2\n 101: aconst_null\n 102: invokestatic #202 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 105: astore 13\n 107: nop\n 108: aload 13\n 110: checkcast #204 // class java/lang/CharSequence\n 113: bipush 43\n 115: iconst_0\n 116: iconst_2\n 117: aconst_null\n 118: invokestatic #208 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;CZILjava/lang/Object;)Z\n 121: ifeq 157\n 124: new #115 // class MathOperation$Plus\n 127: dup\n 128: aload 13\n 130: ldc #210 // String +\n 132: aconst_null\n 133: iconst_2\n 134: aconst_null\n 135: invokestatic #197 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 138: aload 13\n 140: ldc #210 // String +\n 142: aconst_null\n 143: iconst_2\n 144: aconst_null\n 145: invokestatic #202 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 148: invokespecial #213 // Method MathOperation$Plus.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 151: checkcast #75 // class MathOperation\n 154: goto 319\n 157: aload 13\n 159: checkcast #204 // class java/lang/CharSequence\n 162: bipush 45\n 164: iconst_0\n 165: iconst_2\n 166: aconst_null\n 167: invokestatic #208 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;CZILjava/lang/Object;)Z\n 170: ifeq 206\n 173: new #111 // class MathOperation$Minus\n 176: dup\n 177: aload 13\n 179: ldc #215 // String -\n 181: aconst_null\n 182: iconst_2\n 183: aconst_null\n 184: invokestatic #197 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 187: aload 13\n 189: ldc #215 // String -\n 191: aconst_null\n 192: iconst_2\n 193: aconst_null\n 194: invokestatic #202 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 197: invokespecial #216 // Method MathOperation$Minus.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 200: checkcast #75 // class MathOperation\n 203: goto 319\n 206: aload 13\n 208: checkcast #204 // class java/lang/CharSequence\n 211: bipush 47\n 213: iconst_0\n 214: iconst_2\n 215: aconst_null\n 216: invokestatic #208 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;CZILjava/lang/Object;)Z\n 219: ifeq 255\n 222: new #109 // class MathOperation$Divide\n 225: dup\n 226: aload 13\n 228: ldc #218 // String /\n 230: aconst_null\n 231: iconst_2\n 232: aconst_null\n 233: invokestatic #197 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 236: aload 13\n 238: ldc #218 // String /\n 240: aconst_null\n 241: iconst_2\n 242: aconst_null\n 243: invokestatic #202 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 246: invokespecial #219 // Method MathOperation$Divide.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 249: checkcast #75 // class MathOperation\n 252: goto 319\n 255: aload 13\n 257: checkcast #204 // class java/lang/CharSequence\n 260: bipush 42\n 262: iconst_0\n 263: iconst_2\n 264: aconst_null\n 265: invokestatic #208 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;CZILjava/lang/Object;)Z\n 268: ifeq 304\n 271: new #113 // class MathOperation$Multiply\n 274: dup\n 275: aload 13\n 277: ldc #221 // String *\n 279: aconst_null\n 280: iconst_2\n 281: aconst_null\n 282: invokestatic #197 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 285: aload 13\n 287: ldc #221 // String *\n 289: aconst_null\n 290: iconst_2\n 291: aconst_null\n 292: invokestatic #202 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 295: invokespecial #222 // Method MathOperation$Multiply.\"<init>\":(Ljava/lang/String;Ljava/lang/String;)V\n 298: checkcast #75 // class MathOperation\n 301: goto 319\n 304: new #117 // class MathOperation$Value\n 307: dup\n 308: aload 13\n 310: invokestatic #228 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 313: invokespecial #230 // Method MathOperation$Value.\"<init>\":(J)V\n 316: checkcast #75 // class MathOperation\n 319: astore 14\n 321: aload 12\n 323: aload 14\n 325: invokestatic #236 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 328: astore 10\n 330: aload 9\n 332: aload 10\n 334: invokevirtual #241 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 337: aload 10\n 339: invokevirtual #244 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 342: invokeinterface #248, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 347: pop\n 348: goto 50\n 351: aload 5\n 353: nop\n 354: areturn\n\n private static final java.lang.String getOperand1(MathOperation);\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: instanceof #109 // class MathOperation$Divide\n 6: ifeq 19\n 9: aload_0\n 10: checkcast #109 // class MathOperation$Divide\n 13: invokevirtual #140 // Method MathOperation$Divide.getOperand1:()Ljava/lang/String;\n 16: goto 99\n 19: aload_1\n 20: instanceof #111 // class MathOperation$Minus\n 23: ifeq 36\n 26: aload_0\n 27: checkcast #111 // class MathOperation$Minus\n 30: invokevirtual #143 // Method MathOperation$Minus.getOperand1:()Ljava/lang/String;\n 33: goto 99\n 36: aload_1\n 37: instanceof #113 // class MathOperation$Multiply\n 40: ifeq 53\n 43: aload_0\n 44: checkcast #113 // class MathOperation$Multiply\n 47: invokevirtual #145 // Method MathOperation$Multiply.getOperand1:()Ljava/lang/String;\n 50: goto 99\n 53: aload_1\n 54: instanceof #115 // class MathOperation$Plus\n 57: ifeq 70\n 60: aload_0\n 61: checkcast #115 // class MathOperation$Plus\n 64: invokevirtual #147 // Method MathOperation$Plus.getOperand1:()Ljava/lang/String;\n 67: goto 99\n 70: aload_1\n 71: instanceof #117 // class MathOperation$Value\n 74: ifeq 91\n 77: new #26 // class java/lang/IllegalStateException\n 80: dup\n 81: ldc_w #265 // String MathOperation.Value doesn\\'t have operands\n 84: invokevirtual #123 // Method java/lang/Object.toString:()Ljava/lang/String;\n 87: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 90: athrow\n 91: new #125 // class kotlin/NoWhenBranchMatchedException\n 94: dup\n 95: invokespecial #127 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 98: athrow\n 99: areturn\n\n private static final java.lang.String getOperand2(MathOperation);\n Code:\n 0: aload_0\n 1: astore_1\n 2: aload_1\n 3: instanceof #109 // class MathOperation$Divide\n 6: ifeq 19\n 9: aload_0\n 10: checkcast #109 // class MathOperation$Divide\n 13: invokevirtual #142 // Method MathOperation$Divide.getOperand2:()Ljava/lang/String;\n 16: goto 99\n 19: aload_1\n 20: instanceof #111 // class MathOperation$Minus\n 23: ifeq 36\n 26: aload_0\n 27: checkcast #111 // class MathOperation$Minus\n 30: invokevirtual #144 // Method MathOperation$Minus.getOperand2:()Ljava/lang/String;\n 33: goto 99\n 36: aload_1\n 37: instanceof #113 // class MathOperation$Multiply\n 40: ifeq 53\n 43: aload_0\n 44: checkcast #113 // class MathOperation$Multiply\n 47: invokevirtual #146 // Method MathOperation$Multiply.getOperand2:()Ljava/lang/String;\n 50: goto 99\n 53: aload_1\n 54: instanceof #115 // class MathOperation$Plus\n 57: ifeq 70\n 60: aload_0\n 61: checkcast #115 // class MathOperation$Plus\n 64: invokevirtual #148 // Method MathOperation$Plus.getOperand2:()Ljava/lang/String;\n 67: goto 99\n 70: aload_1\n 71: instanceof #117 // class MathOperation$Value\n 74: ifeq 91\n 77: new #26 // class java/lang/IllegalStateException\n 80: dup\n 81: ldc_w #265 // String MathOperation.Value doesn\\'t have operands\n 84: invokevirtual #123 // Method java/lang/Object.toString:()Ljava/lang/String;\n 87: invokespecial #32 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 90: athrow\n 91: new #125 // class kotlin/NoWhenBranchMatchedException\n 94: dup\n 95: invokespecial #127 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 98: athrow\n 99: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #270 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day17.kt
import java.util.* fun main() { val testInput = readInput("Day17_test")[0] check(part1(testInput) == 3068) check(part2(testInput) == 1514285714288L) val input = readInput("Day17")[0] println(part1(input)) println(part2(input)) } private const val PART1_ROCKS_COUNT = 2022 private const val PART2_ROCKS_COUNT = 1_000_000_000_000L private fun part1(input: String): Int { val shifter = Shifter(input) val cave = LinkedList<Int>() val generator = RockGenerator() repeat(PART1_ROCKS_COUNT) { val rock = generator.nextRock() cave.fall(rock, shifter) } return cave.size } private const val PATTERN_SIZE = 20 private fun part2(input: String): Long { val shifter = Shifter(input) val cave = LinkedList<Int>() val generator = RockGenerator() var pattern: List<Int>? = null var patternFoundIteration = 0L var patternFoundCaveSize = 0 var skippedCaveSize = 0L var count = PART2_ROCKS_COUNT while (count > 0) { val rock = generator.nextRock() cave.fall(rock, shifter) --count //State of the cave repeats iteratively. Find this repetition and use it to skip the huge amount of calculations if (pattern == null) { //Try to find pattern val index = cave.findPattern(PATTERN_SIZE) if (index >= 0) { pattern = cave.takeLast(PATTERN_SIZE) patternFoundIteration = count patternFoundCaveSize = cave.size } } else { //Wait for the next repetition of the pattern if (cave.subList(cave.size - PATTERN_SIZE, cave.size) == pattern) { val rocksPerIteration = patternFoundIteration - count val caveIncreasePerIteration = cave.size - patternFoundCaveSize val skippedIterations = count / rocksPerIteration skippedCaveSize = skippedIterations * caveIncreasePerIteration count %= rocksPerIteration } } } return skippedCaveSize + cave.size } private fun List<Int>.findPattern(patternSize: Int): Int { if (this.size < 2 * patternSize) { return -1 } val tail = this.subList(this.size - patternSize, this.size) for (i in (this.size - patternSize) downTo patternSize) { if (tail == this.subList(i - patternSize, i)) { return i } } return -1 } private fun LinkedList<Int>.fall(rock: IntArray, shifter: Shifter) { val caveRows = IntArray(rock.size) //First 4 shifts happen before rock will rich the most top row of the cave repeat(4) { shifter.next().invoke(rock, caveRows) } var bottom = this.lastIndex while (true) { if (bottom == -1) { break } for (i in caveRows.lastIndex downTo 1) { caveRows[i] = caveRows[i - 1] } caveRows[0] = this[bottom] val canFall = rock.foldIndexed(true) { i, acc, value -> acc && (value and caveRows[i] == 0) } if (canFall) { --bottom } else { break } shifter.next().invoke(rock, caveRows) } rock.forEachIndexed { i, value -> if ((bottom + i + 1) in this.indices) { this[bottom + i + 1] = this[bottom + i + 1] or value } else { this.addLast(value) } } } private const val LEFT_BORDER = 0b1000000 private const val RIGHT_BORDER = 0b0000001 class Shifter(private val pattern: String) { private var current: Int = 0 private val left: (IntArray, IntArray) -> Unit = { rock, caveRows -> val canShift = rock.foldIndexed(true) { i, acc, value -> acc && ((value and LEFT_BORDER) == 0) && ((value shl 1) and caveRows[i] == 0) } if (canShift) { rock.forEachIndexed { i, value -> rock[i] = value shl 1 } } } private val right: (IntArray, IntArray) -> Unit = { rock, caveRows -> val canShift = rock.foldIndexed(true) { i, acc, value -> acc && (value and RIGHT_BORDER == 0) && ((value shr 1) and caveRows[i] == 0) } if (canShift) { rock.forEachIndexed { i, value -> rock[i] = value shr 1 } } } fun next(): (IntArray, IntArray) -> Unit { return (if (pattern[current] == '<') left else right).also { current = (current + 1) % pattern.length } } } private class RockGenerator { private var i = 0 val rocks = listOf( intArrayOf( 0b0011110, ), intArrayOf( 0b0001000, 0b0011100, 0b0001000, ), intArrayOf( 0b0011100, 0b0000100, 0b0000100, ), intArrayOf( 0b0010000, 0b0010000, 0b0010000, 0b0010000, ), intArrayOf( 0b0011000, 0b0011000, ), ) fun nextRock(): IntArray { return rocks[i].copyOf().also { i = (i + 1) % rocks.size } } }
[ { "class_path": "Kvest__AOC2022__6409e65/Day17Kt.class", "javap": "Compiled from \"Day17.kt\"\npublic final class Day17Kt {\n private static final int PART1_ROCKS_COUNT;\n\n private static final long PART2_ROCKS_COUNT;\n\n private static final int PATTERN_SIZE;\n\n private static final int LEFT_BORDER;\n\n private static final int RIGHT_BORDER;\n\n public static final void main();\n Code:\n 0: ldc #8 // String Day17_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: iconst_0\n 6: invokeinterface #20, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 11: checkcast #22 // class java/lang/String\n 14: astore_0\n 15: aload_0\n 16: invokestatic #26 // Method part1:(Ljava/lang/String;)I\n 19: sipush 3068\n 22: if_icmpne 29\n 25: iconst_1\n 26: goto 30\n 29: iconst_0\n 30: ifne 43\n 33: new #28 // class java/lang/IllegalStateException\n 36: dup\n 37: ldc #30 // String Check failed.\n 39: invokespecial #34 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 42: athrow\n 43: aload_0\n 44: invokestatic #38 // Method part2:(Ljava/lang/String;)J\n 47: ldc2_w #39 // long 1514285714288l\n 50: lcmp\n 51: ifne 58\n 54: iconst_1\n 55: goto 59\n 58: iconst_0\n 59: ifne 72\n 62: new #28 // class java/lang/IllegalStateException\n 65: dup\n 66: ldc #30 // String Check failed.\n 68: invokespecial #34 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 71: athrow\n 72: ldc #42 // String Day17\n 74: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 77: iconst_0\n 78: invokeinterface #20, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 83: checkcast #22 // class java/lang/String\n 86: astore_1\n 87: aload_1\n 88: invokestatic #26 // Method part1:(Ljava/lang/String;)I\n 91: istore_2\n 92: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 95: iload_2\n 96: invokevirtual #54 // Method java/io/PrintStream.println:(I)V\n 99: aload_1\n 100: invokestatic #38 // Method part2:(Ljava/lang/String;)J\n 103: lstore_2\n 104: getstatic #48 // Field java/lang/System.out:Ljava/io/PrintStream;\n 107: lload_2\n 108: invokevirtual #57 // Method java/io/PrintStream.println:(J)V\n 111: return\n\n private static final int part1(java.lang.String);\n Code:\n 0: new #62 // class Shifter\n 3: dup\n 4: aload_0\n 5: invokespecial #63 // Method Shifter.\"<init>\":(Ljava/lang/String;)V\n 8: astore_1\n 9: new #65 // class java/util/LinkedList\n 12: dup\n 13: invokespecial #67 // Method java/util/LinkedList.\"<init>\":()V\n 16: astore_2\n 17: new #69 // class RockGenerator\n 20: dup\n 21: invokespecial #70 // Method RockGenerator.\"<init>\":()V\n 24: astore_3\n 25: sipush 2022\n 28: istore 4\n 30: iconst_0\n 31: istore 5\n 33: iload 5\n 35: iload 4\n 37: if_icmpge 67\n 40: iload 5\n 42: istore 6\n 44: iconst_0\n 45: istore 7\n 47: aload_3\n 48: invokevirtual #74 // Method RockGenerator.nextRock:()[I\n 51: astore 8\n 53: aload_2\n 54: aload 8\n 56: aload_1\n 57: invokestatic #78 // Method fall:(Ljava/util/LinkedList;[ILShifter;)V\n 60: nop\n 61: iinc 5, 1\n 64: goto 33\n 67: aload_2\n 68: invokevirtual #82 // Method java/util/LinkedList.size:()I\n 71: ireturn\n\n private static final long part2(java.lang.String);\n Code:\n 0: new #62 // class Shifter\n 3: dup\n 4: aload_0\n 5: invokespecial #63 // Method Shifter.\"<init>\":(Ljava/lang/String;)V\n 8: astore_1\n 9: new #65 // class java/util/LinkedList\n 12: dup\n 13: invokespecial #67 // Method java/util/LinkedList.\"<init>\":()V\n 16: astore_2\n 17: new #69 // class RockGenerator\n 20: dup\n 21: invokespecial #70 // Method RockGenerator.\"<init>\":()V\n 24: astore_3\n 25: aconst_null\n 26: astore 4\n 28: lconst_0\n 29: lstore 5\n 31: iconst_0\n 32: istore 7\n 34: lconst_0\n 35: lstore 8\n 37: ldc2_w #94 // long 1000000000000l\n 40: lstore 10\n 42: lload 10\n 44: lconst_0\n 45: lcmp\n 46: ifle 179\n 49: aload_3\n 50: invokevirtual #74 // Method RockGenerator.nextRock:()[I\n 53: astore 12\n 55: aload_2\n 56: aload 12\n 58: aload_1\n 59: invokestatic #78 // Method fall:(Ljava/util/LinkedList;[ILShifter;)V\n 62: lload 10\n 64: ldc2_w #96 // long -1l\n 67: ladd\n 68: lstore 10\n 70: aload 4\n 72: ifnonnull 115\n 75: aload_2\n 76: checkcast #16 // class java/util/List\n 79: bipush 20\n 81: invokestatic #101 // Method findPattern:(Ljava/util/List;I)I\n 84: istore 13\n 86: iload 13\n 88: iflt 42\n 91: aload_2\n 92: checkcast #16 // class java/util/List\n 95: bipush 20\n 97: invokestatic #107 // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;\n 100: astore 4\n 102: lload 10\n 104: lstore 5\n 106: aload_2\n 107: invokevirtual #82 // Method java/util/LinkedList.size:()I\n 110: istore 7\n 112: goto 42\n 115: aload_2\n 116: aload_2\n 117: invokevirtual #82 // Method java/util/LinkedList.size:()I\n 120: bipush 20\n 122: isub\n 123: aload_2\n 124: invokevirtual #82 // Method java/util/LinkedList.size:()I\n 127: invokevirtual #111 // Method java/util/LinkedList.subList:(II)Ljava/util/List;\n 130: aload 4\n 132: invokestatic #117 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 135: ifeq 42\n 138: lload 5\n 140: lload 10\n 142: lsub\n 143: lstore 13\n 145: aload_2\n 146: invokevirtual #82 // Method java/util/LinkedList.size:()I\n 149: iload 7\n 151: isub\n 152: istore 15\n 154: lload 10\n 156: lload 13\n 158: ldiv\n 159: lstore 16\n 161: lload 16\n 163: iload 15\n 165: i2l\n 166: lmul\n 167: lstore 8\n 169: lload 10\n 171: lload 13\n 173: lrem\n 174: lstore 10\n 176: goto 42\n 179: lload 8\n 181: aload_2\n 182: invokevirtual #82 // Method java/util/LinkedList.size:()I\n 185: i2l\n 186: ladd\n 187: lreturn\n\n private static final int findPattern(java.util.List<java.lang.Integer>, int);\n Code:\n 0: aload_0\n 1: invokeinterface #131, 1 // InterfaceMethod java/util/List.size:()I\n 6: iconst_2\n 7: iload_1\n 8: imul\n 9: if_icmpge 14\n 12: iconst_m1\n 13: ireturn\n 14: aload_0\n 15: aload_0\n 16: invokeinterface #131, 1 // InterfaceMethod java/util/List.size:()I\n 21: iload_1\n 22: isub\n 23: aload_0\n 24: invokeinterface #131, 1 // InterfaceMethod java/util/List.size:()I\n 29: invokeinterface #132, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 34: astore_2\n 35: aload_0\n 36: invokeinterface #131, 1 // InterfaceMethod java/util/List.size:()I\n 41: iload_1\n 42: isub\n 43: istore_3\n 44: iload_1\n 45: iload_3\n 46: if_icmpgt 79\n 49: aload_2\n 50: aload_0\n 51: iload_3\n 52: iload_1\n 53: isub\n 54: iload_3\n 55: invokeinterface #132, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 60: invokestatic #117 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 63: ifeq 68\n 66: iload_3\n 67: ireturn\n 68: iload_3\n 69: iload_1\n 70: if_icmpeq 79\n 73: iinc 3, -1\n 76: goto 49\n 79: iconst_m1\n 80: ireturn\n\n private static final void fall(java.util.LinkedList<java.lang.Integer>, int[], Shifter);\n Code:\n 0: aload_1\n 1: arraylength\n 2: newarray int\n 4: astore_3\n 5: iconst_4\n 6: istore 4\n 8: iconst_0\n 9: istore 5\n 11: iload 5\n 13: iload 4\n 15: if_icmpge 44\n 18: iload 5\n 20: istore 6\n 22: iconst_0\n 23: istore 7\n 25: aload_2\n 26: invokevirtual #141 // Method Shifter.next:()Lkotlin/jvm/functions/Function2;\n 29: aload_1\n 30: aload_3\n 31: invokeinterface #147, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 36: pop\n 37: nop\n 38: iinc 5, 1\n 41: goto 11\n 44: iconst_0\n 45: istore 4\n 47: aload_0\n 48: checkcast #16 // class java/util/List\n 51: invokestatic #151 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 54: istore 4\n 56: nop\n 57: iload 4\n 59: iconst_m1\n 60: if_icmpne 66\n 63: goto 235\n 66: aload_3\n 67: invokestatic #156 // Method kotlin/collections/ArraysKt.getLastIndex:([I)I\n 70: istore 5\n 72: iconst_0\n 73: iload 5\n 75: if_icmpge 94\n 78: aload_3\n 79: iload 5\n 81: aload_3\n 82: iload 5\n 84: iconst_1\n 85: isub\n 86: iaload\n 87: iastore\n 88: iinc 5, -1\n 91: goto 72\n 94: aload_3\n 95: iconst_0\n 96: aload_0\n 97: iload 4\n 99: invokevirtual #157 // Method java/util/LinkedList.get:(I)Ljava/lang/Object;\n 102: dup\n 103: ldc #159 // String get(...)\n 105: invokestatic #163 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 108: checkcast #165 // class java/lang/Number\n 111: invokevirtual #168 // Method java/lang/Number.intValue:()I\n 114: iastore\n 115: aload_1\n 116: astore 6\n 118: iconst_1\n 119: istore 7\n 121: iconst_0\n 122: istore 8\n 124: iconst_0\n 125: istore 9\n 127: iload 7\n 129: istore 10\n 131: iconst_0\n 132: istore 11\n 134: aload 6\n 136: arraylength\n 137: istore 12\n 139: iload 11\n 141: iload 12\n 143: if_icmpge 199\n 146: aload 6\n 148: iload 11\n 150: iaload\n 151: istore 13\n 153: iload 9\n 155: iinc 9, 1\n 158: iload 10\n 160: iload 13\n 162: istore 14\n 164: istore 15\n 166: istore 16\n 168: iconst_0\n 169: istore 17\n 171: iload 15\n 173: ifeq 190\n 176: iload 14\n 178: aload_3\n 179: iload 16\n 181: iaload\n 182: iand\n 183: ifne 190\n 186: iconst_1\n 187: goto 191\n 190: iconst_0\n 191: istore 10\n 193: iinc 11, 1\n 196: goto 139\n 199: iload 10\n 201: istore 5\n 203: iload 5\n 205: ifeq 217\n 208: iload 4\n 210: iconst_m1\n 211: iadd\n 212: istore 4\n 214: goto 220\n 217: goto 235\n 220: aload_2\n 221: invokevirtual #141 // Method Shifter.next:()Lkotlin/jvm/functions/Function2;\n 224: aload_1\n 225: aload_3\n 226: invokeinterface #147, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 231: pop\n 232: goto 56\n 235: aload_1\n 236: astore 5\n 238: iconst_0\n 239: istore 6\n 241: iconst_0\n 242: istore 7\n 244: iconst_0\n 245: istore 8\n 247: aload 5\n 249: arraylength\n 250: istore 9\n 252: iload 8\n 254: iload 9\n 256: if_icmpge 380\n 259: aload 5\n 261: iload 8\n 263: iaload\n 264: istore 10\n 266: iload 7\n 268: iinc 7, 1\n 271: iload 10\n 273: istore 11\n 275: istore 12\n 277: iconst_0\n 278: istore 13\n 280: aload_0\n 281: checkcast #170 // class java/util/Collection\n 284: invokeinterface #171, 1 // InterfaceMethod java/util/Collection.size:()I\n 289: istore 14\n 291: iload 4\n 293: iload 12\n 295: iadd\n 296: iconst_1\n 297: iadd\n 298: istore 15\n 300: iconst_0\n 301: iload 15\n 303: if_icmpgt 321\n 306: iload 15\n 308: iload 14\n 310: if_icmpge 317\n 313: iconst_1\n 314: goto 322\n 317: iconst_0\n 318: goto 322\n 321: iconst_0\n 322: ifeq 363\n 325: aload_0\n 326: iload 4\n 328: iload 12\n 330: iadd\n 331: iconst_1\n 332: iadd\n 333: aload_0\n 334: iload 4\n 336: iload 12\n 338: iadd\n 339: iconst_1\n 340: iadd\n 341: invokevirtual #157 // Method java/util/LinkedList.get:(I)Ljava/lang/Object;\n 344: checkcast #165 // class java/lang/Number\n 347: invokevirtual #168 // Method java/lang/Number.intValue:()I\n 350: iload 11\n 352: ior\n 353: invokestatic #177 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 356: invokevirtual #181 // Method java/util/LinkedList.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 359: pop\n 360: goto 372\n 363: aload_0\n 364: iload 11\n 366: invokestatic #177 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 369: invokevirtual #185 // Method java/util/LinkedList.addLast:(Ljava/lang/Object;)V\n 372: nop\n 373: nop\n 374: iinc 8, 1\n 377: goto 252\n 380: nop\n 381: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #207 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day07.kt
import java.util.* fun main() { val testInput = readInput("Day07_test") val testRoot = buildFileSystem(testInput) val testSizeCache = mutableMapOf<Node, Long>() check(part1(testRoot, testSizeCache) == 95437L) check(part2(testRoot, testSizeCache) == 24933642L) val input = readInput("Day07") val root = buildFileSystem(input) val sizeCache = mutableMapOf<Node, Long>() println(part1(root, sizeCache)) println(part2(root, sizeCache)) } private const val MAX = 100000L private fun part1(root: Node, sizeCache: MutableMap<Node, Long>): Long { var result = 0L root.visit { node -> if (node.isDir) { val size = sizeCache.getOrPut(node, node::size) if (size < MAX) { result += size } } } return result } private const val TOTAL_SPACE = 70000000L private const val TARGET_FREE_SPACE = 30000000L private fun part2(root: Node, sizeCache: MutableMap<Node, Long>): Long { val rootSize = sizeCache.getOrPut(root, root::size) val spaceToFreeUp = TARGET_FREE_SPACE - (TOTAL_SPACE - rootSize) var result = Long.MAX_VALUE root.visit { node -> if (node.isDir) { val size = sizeCache.getOrPut(node, node::size) if (size >= spaceToFreeUp && size < result) { result = size } } } return result } private fun buildFileSystem(commands: List<String>): Node { val root = Node.Dir() val navigationStack = LinkedList<Node>() var i = 0 while (i <= commands.lastIndex) { val cmd = commands[i++] when { cmd.startsWith("$ cd /") -> { navigationStack.clear() navigationStack.push(root) } cmd.startsWith("$ cd ..") -> navigationStack.pop() cmd.startsWith("$ cd ") -> { val destinationName = cmd.substringAfter("$ cd ") val destination = navigationStack.peek().getChild(destinationName) navigationStack.push(destination) } cmd.startsWith("$ ls") -> { val targetNode = navigationStack.peek() while (i <= commands.lastIndex && !commands[i].startsWith("$")) { val item = commands[i++] if (item.startsWith("dir")) { targetNode.addChild( name = item.substringAfter("dir "), child = Node.Dir() ) } else { targetNode.addChild( name = item.substringAfter(" "), child = Node.File( size = item.substringBefore(" ").toLong() ) ) } } } } } return root } sealed interface Node { val isDir: Boolean fun getChild(name: String): Node fun addChild(name: String, child: Node) fun size(): Long fun visit(action: (Node) -> Unit) class Dir : Node { private val children = mutableMapOf<String, Node>() override val isDir: Boolean get() = true override fun getChild(name: String): Node = children[name] ?: error("Child $name not found") override fun addChild(name: String, child: Node) { children[name] = child } override fun size(): Long { return children.values.fold(0) { acc, node -> acc + node.size() } } override fun visit(action: (Node) -> Unit) { children.forEach { it.value.visit(action) } action(this) } } class File(val size: Long) : Node { override val isDir: Boolean get() = false override fun getChild(name: String): Node = error("getChild is not applicable for File") override fun addChild(name: String, child: Node) = error("addChild is not applicable for File") override fun size(): Long = size override fun visit(action: (Node) -> Unit) { action(this) } } }
[ { "class_path": "Kvest__AOC2022__6409e65/Day07Kt.class", "javap": "Compiled from \"Day07.kt\"\npublic final class Day07Kt {\n private static final long MAX;\n\n private static final long TOTAL_SPACE;\n\n private static final long TARGET_FREE_SPACE;\n\n public static final void main();\n Code:\n 0: ldc #8 // String Day07_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 buildFileSystem:(Ljava/util/List;)LNode;\n 10: astore_1\n 11: new #20 // class java/util/LinkedHashMap\n 14: dup\n 15: invokespecial #23 // Method java/util/LinkedHashMap.\"<init>\":()V\n 18: checkcast #25 // class java/util/Map\n 21: astore_2\n 22: aload_1\n 23: aload_2\n 24: invokestatic #29 // Method part1:(LNode;Ljava/util/Map;)J\n 27: ldc2_w #30 // long 95437l\n 30: lcmp\n 31: ifne 38\n 34: iconst_1\n 35: goto 39\n 38: iconst_0\n 39: ifne 52\n 42: new #33 // class java/lang/IllegalStateException\n 45: dup\n 46: ldc #35 // String Check failed.\n 48: invokespecial #38 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 51: athrow\n 52: aload_1\n 53: aload_2\n 54: invokestatic #41 // Method part2:(LNode;Ljava/util/Map;)J\n 57: ldc2_w #42 // long 24933642l\n 60: lcmp\n 61: ifne 68\n 64: iconst_1\n 65: goto 69\n 68: iconst_0\n 69: ifne 82\n 72: new #33 // class java/lang/IllegalStateException\n 75: dup\n 76: ldc #35 // String Check failed.\n 78: invokespecial #38 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 81: athrow\n 82: ldc #45 // String Day07\n 84: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 87: astore_3\n 88: aload_3\n 89: invokestatic #18 // Method buildFileSystem:(Ljava/util/List;)LNode;\n 92: astore 4\n 94: new #20 // class java/util/LinkedHashMap\n 97: dup\n 98: invokespecial #23 // Method java/util/LinkedHashMap.\"<init>\":()V\n 101: checkcast #25 // class java/util/Map\n 104: astore 5\n 106: aload 4\n 108: aload 5\n 110: invokestatic #29 // Method part1:(LNode;Ljava/util/Map;)J\n 113: lstore 6\n 115: getstatic #51 // Field java/lang/System.out:Ljava/io/PrintStream;\n 118: lload 6\n 120: invokevirtual #57 // Method java/io/PrintStream.println:(J)V\n 123: aload 4\n 125: aload 5\n 127: invokestatic #41 // Method part2:(LNode;Ljava/util/Map;)J\n 130: lstore 6\n 132: getstatic #51 // Field java/lang/System.out:Ljava/io/PrintStream;\n 135: lload 6\n 137: invokevirtual #57 // Method java/io/PrintStream.println:(J)V\n 140: return\n\n private static final long part1(Node, java.util.Map<Node, java.lang.Long>);\n Code:\n 0: new #73 // class kotlin/jvm/internal/Ref$LongRef\n 3: dup\n 4: invokespecial #74 // Method kotlin/jvm/internal/Ref$LongRef.\"<init>\":()V\n 7: astore_2\n 8: aload_0\n 9: aload_1\n 10: aload_2\n 11: invokedynamic #94, 0 // InvokeDynamic #0:invoke:(Ljava/util/Map;Lkotlin/jvm/internal/Ref$LongRef;)Lkotlin/jvm/functions/Function1;\n 16: invokeinterface #98, 2 // InterfaceMethod Node.visit:(Lkotlin/jvm/functions/Function1;)V\n 21: aload_2\n 22: getfield #102 // Field kotlin/jvm/internal/Ref$LongRef.element:J\n 25: lreturn\n\n private static final long part2(Node, java.util.Map<Node, java.lang.Long>);\n Code:\n 0: aload_1\n 1: astore 4\n 3: iconst_0\n 4: istore 5\n 6: aload 4\n 8: aload_0\n 9: invokeinterface #107, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 14: astore 6\n 16: aload 6\n 18: ifnonnull 51\n 21: iconst_0\n 22: istore 7\n 24: aload_0\n 25: invokeinterface #111, 1 // InterfaceMethod Node.size:()J\n 30: invokestatic #117 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 33: astore 7\n 35: aload 4\n 37: aload_0\n 38: aload 7\n 40: invokeinterface #121, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 45: pop\n 46: aload 7\n 48: goto 53\n 51: aload 6\n 53: nop\n 54: checkcast #123 // class java/lang/Number\n 57: invokevirtual #126 // Method java/lang/Number.longValue:()J\n 60: lstore_2\n 61: ldc2_w #127 // long 30000000l\n 64: ldc2_w #129 // long 70000000l\n 67: lload_2\n 68: lsub\n 69: lsub\n 70: lstore 4\n 72: new #73 // class kotlin/jvm/internal/Ref$LongRef\n 75: dup\n 76: invokespecial #74 // Method kotlin/jvm/internal/Ref$LongRef.\"<init>\":()V\n 79: astore 6\n 81: aload 6\n 83: ldc2_w #131 // long 9223372036854775807l\n 86: putfield #102 // Field kotlin/jvm/internal/Ref$LongRef.element:J\n 89: aload_0\n 90: aload_1\n 91: lload 4\n 93: aload 6\n 95: invokedynamic #140, 0 // InvokeDynamic #1:invoke:(Ljava/util/Map;JLkotlin/jvm/internal/Ref$LongRef;)Lkotlin/jvm/functions/Function1;\n 100: invokeinterface #98, 2 // InterfaceMethod Node.visit:(Lkotlin/jvm/functions/Function1;)V\n 105: aload 6\n 107: getfield #102 // Field kotlin/jvm/internal/Ref$LongRef.element:J\n 110: lreturn\n\n private static final Node buildFileSystem(java.util.List<java.lang.String>);\n Code:\n 0: new #152 // class Node$Dir\n 3: dup\n 4: invokespecial #153 // Method Node$Dir.\"<init>\":()V\n 7: astore_1\n 8: new #155 // class java/util/LinkedList\n 11: dup\n 12: invokespecial #156 // Method java/util/LinkedList.\"<init>\":()V\n 15: astore_2\n 16: iconst_0\n 17: istore_3\n 18: iload_3\n 19: aload_0\n 20: invokestatic #162 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 23: if_icmpgt 290\n 26: aload_0\n 27: iload_3\n 28: iinc 3, 1\n 31: invokeinterface #165, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 36: checkcast #167 // class java/lang/String\n 39: astore 4\n 41: nop\n 42: aload 4\n 44: ldc #169 // String $ cd /\n 46: iconst_0\n 47: iconst_2\n 48: aconst_null\n 49: invokestatic #175 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 52: ifeq 67\n 55: aload_2\n 56: invokevirtual #178 // Method java/util/LinkedList.clear:()V\n 59: aload_2\n 60: aload_1\n 61: invokevirtual #182 // Method java/util/LinkedList.push:(Ljava/lang/Object;)V\n 64: goto 18\n 67: aload 4\n 69: ldc #184 // String $ cd ..\n 71: iconst_0\n 72: iconst_2\n 73: aconst_null\n 74: invokestatic #175 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 77: ifeq 88\n 80: aload_2\n 81: invokevirtual #188 // Method java/util/LinkedList.pop:()Ljava/lang/Object;\n 84: pop\n 85: goto 18\n 88: aload 4\n 90: ldc #190 // String $ cd\n 92: iconst_0\n 93: iconst_2\n 94: aconst_null\n 95: invokestatic #175 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 98: ifeq 138\n 101: aload 4\n 103: ldc #190 // String $ cd\n 105: aconst_null\n 106: iconst_2\n 107: aconst_null\n 108: invokestatic #194 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 111: astore 5\n 113: aload_2\n 114: invokevirtual #197 // Method java/util/LinkedList.peek:()Ljava/lang/Object;\n 117: checkcast #70 // class Node\n 120: aload 5\n 122: invokeinterface #201, 2 // InterfaceMethod Node.getChild:(Ljava/lang/String;)LNode;\n 127: astore 6\n 129: aload_2\n 130: aload 6\n 132: invokevirtual #182 // Method java/util/LinkedList.push:(Ljava/lang/Object;)V\n 135: goto 18\n 138: aload 4\n 140: ldc #203 // String $ ls\n 142: iconst_0\n 143: iconst_2\n 144: aconst_null\n 145: invokestatic #175 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 148: ifeq 18\n 151: aload_2\n 152: invokevirtual #197 // Method java/util/LinkedList.peek:()Ljava/lang/Object;\n 155: checkcast #70 // class Node\n 158: astore 5\n 160: iload_3\n 161: aload_0\n 162: invokestatic #162 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 165: if_icmpgt 18\n 168: aload_0\n 169: iload_3\n 170: invokeinterface #165, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 175: checkcast #167 // class java/lang/String\n 178: ldc #205 // String $\n 180: iconst_0\n 181: iconst_2\n 182: aconst_null\n 183: invokestatic #175 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 186: ifne 18\n 189: aload_0\n 190: iload_3\n 191: iinc 3, 1\n 194: invokeinterface #165, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 199: checkcast #167 // class java/lang/String\n 202: astore 6\n 204: aload 6\n 206: ldc #207 // String dir\n 208: iconst_0\n 209: iconst_2\n 210: aconst_null\n 211: invokestatic #175 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 214: ifeq 247\n 217: aload 5\n 219: aload 6\n 221: ldc #209 // String dir\n 223: aconst_null\n 224: iconst_2\n 225: aconst_null\n 226: invokestatic #194 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 229: new #152 // class Node$Dir\n 232: dup\n 233: invokespecial #153 // Method Node$Dir.\"<init>\":()V\n 236: checkcast #70 // class Node\n 239: invokeinterface #213, 3 // InterfaceMethod Node.addChild:(Ljava/lang/String;LNode;)V\n 244: goto 160\n 247: aload 5\n 249: aload 6\n 251: ldc #215 // String\n 253: aconst_null\n 254: iconst_2\n 255: aconst_null\n 256: invokestatic #194 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 259: new #217 // class Node$File\n 262: dup\n 263: aload 6\n 265: ldc #215 // String\n 267: aconst_null\n 268: iconst_2\n 269: aconst_null\n 270: invokestatic #220 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 273: invokestatic #224 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 276: invokespecial #226 // Method Node$File.\"<init>\":(J)V\n 279: checkcast #70 // class Node\n 282: invokeinterface #213, 3 // InterfaceMethod Node.addChild:(Ljava/lang/String;LNode;)V\n 287: goto 160\n 290: aload_1\n 291: checkcast #70 // class Node\n 294: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #240 // Method main:()V\n 3: return\n\n private static final kotlin.Unit part1$lambda$0(java.util.Map, kotlin.jvm.internal.Ref$LongRef, Node);\n Code:\n 0: aload_2\n 1: ldc #244 // String node\n 3: invokestatic #250 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: invokeinterface #254, 1 // InterfaceMethod Node.isDir:()Z\n 12: ifeq 94\n 15: aload_0\n 16: astore 5\n 18: iconst_0\n 19: istore 6\n 21: aload 5\n 23: aload_2\n 24: invokeinterface #107, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 29: astore 7\n 31: aload 7\n 33: ifnonnull 66\n 36: iconst_0\n 37: istore 8\n 39: aload_2\n 40: invokeinterface #111, 1 // InterfaceMethod Node.size:()J\n 45: invokestatic #117 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 48: astore 8\n 50: aload 5\n 52: aload_2\n 53: aload 8\n 55: invokeinterface #121, 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 #123 // class java/lang/Number\n 72: invokevirtual #126 // Method java/lang/Number.longValue:()J\n 75: lstore_3\n 76: lload_3\n 77: ldc2_w #255 // long 100000l\n 80: lcmp\n 81: ifge 94\n 84: aload_1\n 85: aload_1\n 86: getfield #102 // Field kotlin/jvm/internal/Ref$LongRef.element:J\n 89: lload_3\n 90: ladd\n 91: putfield #102 // Field kotlin/jvm/internal/Ref$LongRef.element:J\n 94: getstatic #262 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 97: areturn\n\n private static final kotlin.Unit part2$lambda$3(java.util.Map, long, kotlin.jvm.internal.Ref$LongRef, Node);\n Code:\n 0: aload 4\n 2: ldc #244 // String node\n 4: invokestatic #250 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload 4\n 9: invokeinterface #254, 1 // InterfaceMethod Node.isDir:()Z\n 14: ifeq 105\n 17: aload_0\n 18: astore 7\n 20: iconst_0\n 21: istore 8\n 23: aload 7\n 25: aload 4\n 27: invokeinterface #107, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 32: astore 9\n 34: aload 9\n 36: ifnonnull 71\n 39: iconst_0\n 40: istore 10\n 42: aload 4\n 44: invokeinterface #111, 1 // InterfaceMethod Node.size:()J\n 49: invokestatic #117 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 52: astore 10\n 54: aload 7\n 56: aload 4\n 58: aload 10\n 60: invokeinterface #121, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 65: pop\n 66: aload 10\n 68: goto 73\n 71: aload 9\n 73: nop\n 74: checkcast #123 // class java/lang/Number\n 77: invokevirtual #126 // Method java/lang/Number.longValue:()J\n 80: lstore 5\n 82: lload 5\n 84: lload_1\n 85: lcmp\n 86: iflt 105\n 89: lload 5\n 91: aload_3\n 92: getfield #102 // Field kotlin/jvm/internal/Ref$LongRef.element:J\n 95: lcmp\n 96: ifge 105\n 99: aload_3\n 100: lload 5\n 102: putfield #102 // Field kotlin/jvm/internal/Ref$LongRef.element:J\n 105: getstatic #262 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 108: areturn\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day06.kt
fun main() { val testInput = readInput("Day06_test") check(part1(testInput[0]) == 5) check(part1(testInput[1]) == 6) check(part1(testInput[2]) == 10) check(part1(testInput[3]) == 11) check(part2(testInput[0]) == 23) check(part2(testInput[1]) == 23) check(part2(testInput[2]) == 29) check(part2(testInput[3]) == 26) val input = readInput("Day06") println(part1(input[0])) println(part2(input[0])) } private fun part1(input: String): Int = findUniqueSequence(input, 4) private fun part2(input: String): Int = findUniqueSequence(input, 14) private fun findUniqueSequence(input: String, targetCount: Int): Int { val counts = mutableMapOf<Char, Int>() repeat(targetCount - 1) { i -> counts[input[i]] = counts.getOrDefault(input[i], 0) + 1 } for (i in (targetCount - 1)..input.lastIndex) { counts[input[i]] = counts.getOrDefault(input[i], 0) + 1 if (counts.size == targetCount) { return i + 1 } if (counts[input[i - targetCount + 1]] == 1) { counts.remove(input[i - targetCount + 1]) } else { counts[input[i - targetCount + 1]] = counts.getValue(input[i - targetCount + 1]) - 1 } } error("Not found") }
[ { "class_path": "Kvest__AOC2022__6409e65/Day06Kt.class", "javap": "Compiled from \"Day06.kt\"\npublic final class Day06Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day06_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: aload_0\n 7: iconst_0\n 8: invokeinterface #20, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 13: checkcast #22 // class java/lang/String\n 16: invokestatic #26 // Method part1:(Ljava/lang/String;)I\n 19: iconst_5\n 20: if_icmpne 27\n 23: iconst_1\n 24: goto 28\n 27: iconst_0\n 28: ifne 41\n 31: new #28 // class java/lang/IllegalStateException\n 34: dup\n 35: ldc #30 // String Check failed.\n 37: invokespecial #34 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 40: athrow\n 41: aload_0\n 42: iconst_1\n 43: invokeinterface #20, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 48: checkcast #22 // class java/lang/String\n 51: invokestatic #26 // Method part1:(Ljava/lang/String;)I\n 54: bipush 6\n 56: if_icmpne 63\n 59: iconst_1\n 60: goto 64\n 63: iconst_0\n 64: ifne 77\n 67: new #28 // class java/lang/IllegalStateException\n 70: dup\n 71: ldc #30 // String Check failed.\n 73: invokespecial #34 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 76: athrow\n 77: aload_0\n 78: iconst_2\n 79: invokeinterface #20, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 84: checkcast #22 // class java/lang/String\n 87: invokestatic #26 // Method part1:(Ljava/lang/String;)I\n 90: bipush 10\n 92: if_icmpne 99\n 95: iconst_1\n 96: goto 100\n 99: iconst_0\n 100: ifne 113\n 103: new #28 // class java/lang/IllegalStateException\n 106: dup\n 107: ldc #30 // String Check failed.\n 109: invokespecial #34 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 112: athrow\n 113: aload_0\n 114: iconst_3\n 115: invokeinterface #20, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 120: checkcast #22 // class java/lang/String\n 123: invokestatic #26 // Method part1:(Ljava/lang/String;)I\n 126: bipush 11\n 128: if_icmpne 135\n 131: iconst_1\n 132: goto 136\n 135: iconst_0\n 136: ifne 149\n 139: new #28 // class java/lang/IllegalStateException\n 142: dup\n 143: ldc #30 // String Check failed.\n 145: invokespecial #34 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 148: athrow\n 149: aload_0\n 150: iconst_0\n 151: invokeinterface #20, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 156: checkcast #22 // class java/lang/String\n 159: invokestatic #37 // Method part2:(Ljava/lang/String;)I\n 162: bipush 23\n 164: if_icmpne 171\n 167: iconst_1\n 168: goto 172\n 171: iconst_0\n 172: ifne 185\n 175: new #28 // class java/lang/IllegalStateException\n 178: dup\n 179: ldc #30 // String Check failed.\n 181: invokespecial #34 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 184: athrow\n 185: aload_0\n 186: iconst_1\n 187: invokeinterface #20, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 192: checkcast #22 // class java/lang/String\n 195: invokestatic #37 // Method part2:(Ljava/lang/String;)I\n 198: bipush 23\n 200: if_icmpne 207\n 203: iconst_1\n 204: goto 208\n 207: iconst_0\n 208: ifne 221\n 211: new #28 // class java/lang/IllegalStateException\n 214: dup\n 215: ldc #30 // String Check failed.\n 217: invokespecial #34 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 220: athrow\n 221: aload_0\n 222: iconst_2\n 223: invokeinterface #20, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 228: checkcast #22 // class java/lang/String\n 231: invokestatic #37 // Method part2:(Ljava/lang/String;)I\n 234: bipush 29\n 236: if_icmpne 243\n 239: iconst_1\n 240: goto 244\n 243: iconst_0\n 244: ifne 257\n 247: new #28 // class java/lang/IllegalStateException\n 250: dup\n 251: ldc #30 // String Check failed.\n 253: invokespecial #34 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 256: athrow\n 257: aload_0\n 258: iconst_3\n 259: invokeinterface #20, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 264: checkcast #22 // class java/lang/String\n 267: invokestatic #37 // Method part2:(Ljava/lang/String;)I\n 270: bipush 26\n 272: if_icmpne 279\n 275: iconst_1\n 276: goto 280\n 279: iconst_0\n 280: ifne 293\n 283: new #28 // class java/lang/IllegalStateException\n 286: dup\n 287: ldc #30 // String Check failed.\n 289: invokespecial #34 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 292: athrow\n 293: ldc #39 // String Day06\n 295: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 298: astore_1\n 299: aload_1\n 300: iconst_0\n 301: invokeinterface #20, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 306: checkcast #22 // class java/lang/String\n 309: invokestatic #26 // Method part1:(Ljava/lang/String;)I\n 312: istore_2\n 313: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 316: iload_2\n 317: invokevirtual #51 // Method java/io/PrintStream.println:(I)V\n 320: aload_1\n 321: iconst_0\n 322: invokeinterface #20, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 327: checkcast #22 // class java/lang/String\n 330: invokestatic #37 // Method part2:(Ljava/lang/String;)I\n 333: istore_2\n 334: getstatic #45 // Field java/lang/System.out:Ljava/io/PrintStream;\n 337: iload_2\n 338: invokevirtual #51 // Method java/io/PrintStream.println:(I)V\n 341: return\n\n private static final int part1(java.lang.String);\n Code:\n 0: aload_0\n 1: iconst_4\n 2: invokestatic #58 // Method findUniqueSequence:(Ljava/lang/String;I)I\n 5: ireturn\n\n private static final int part2(java.lang.String);\n Code:\n 0: aload_0\n 1: bipush 14\n 3: invokestatic #58 // Method findUniqueSequence:(Ljava/lang/String;I)I\n 6: ireturn\n\n private static final int findUniqueSequence(java.lang.String, int);\n Code:\n 0: new #61 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #63 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #65 // class java/util/Map\n 10: astore_2\n 11: iload_1\n 12: iconst_1\n 13: isub\n 14: istore_3\n 15: iconst_0\n 16: istore 4\n 18: iload 4\n 20: iload_3\n 21: if_icmpge 84\n 24: iload 4\n 26: istore 5\n 28: iconst_0\n 29: istore 6\n 31: aload_2\n 32: aload_0\n 33: iload 5\n 35: invokevirtual #69 // Method java/lang/String.charAt:(I)C\n 38: invokestatic #75 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 41: aload_2\n 42: aload_0\n 43: iload 5\n 45: invokevirtual #69 // Method java/lang/String.charAt:(I)C\n 48: invokestatic #75 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 51: iconst_0\n 52: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 55: invokeinterface #84, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 60: checkcast #86 // class java/lang/Number\n 63: invokevirtual #90 // Method java/lang/Number.intValue:()I\n 66: iconst_1\n 67: iadd\n 68: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 71: invokeinterface #93, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 76: pop\n 77: nop\n 78: iinc 4, 1\n 81: goto 18\n 84: iload_1\n 85: iconst_1\n 86: isub\n 87: istore_3\n 88: aload_0\n 89: checkcast #95 // class java/lang/CharSequence\n 92: invokestatic #101 // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I\n 95: istore 4\n 97: iload_3\n 98: iload 4\n 100: if_icmpgt 281\n 103: aload_2\n 104: aload_0\n 105: iload_3\n 106: invokevirtual #69 // Method java/lang/String.charAt:(I)C\n 109: invokestatic #75 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 112: aload_2\n 113: aload_0\n 114: iload_3\n 115: invokevirtual #69 // Method java/lang/String.charAt:(I)C\n 118: invokestatic #75 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 121: iconst_0\n 122: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 125: invokeinterface #84, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 130: checkcast #86 // class java/lang/Number\n 133: invokevirtual #90 // Method java/lang/Number.intValue:()I\n 136: iconst_1\n 137: iadd\n 138: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 141: invokeinterface #93, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 146: pop\n 147: aload_2\n 148: invokeinterface #104, 1 // InterfaceMethod java/util/Map.size:()I\n 153: iload_1\n 154: if_icmpne 161\n 157: iload_3\n 158: iconst_1\n 159: iadd\n 160: ireturn\n 161: aload_2\n 162: aload_0\n 163: iload_3\n 164: iload_1\n 165: isub\n 166: iconst_1\n 167: iadd\n 168: invokevirtual #69 // Method java/lang/String.charAt:(I)C\n 171: invokestatic #75 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 174: invokeinterface #107, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 179: checkcast #77 // class java/lang/Integer\n 182: iconst_1\n 183: istore 5\n 185: dup\n 186: ifnonnull 193\n 189: pop\n 190: goto 223\n 193: invokevirtual #108 // Method java/lang/Integer.intValue:()I\n 196: iload 5\n 198: if_icmpne 223\n 201: aload_2\n 202: aload_0\n 203: iload_3\n 204: iload_1\n 205: isub\n 206: iconst_1\n 207: iadd\n 208: invokevirtual #69 // Method java/lang/String.charAt:(I)C\n 211: invokestatic #75 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 214: invokeinterface #111, 2 // InterfaceMethod java/util/Map.remove:(Ljava/lang/Object;)Ljava/lang/Object;\n 219: pop\n 220: goto 269\n 223: aload_2\n 224: aload_0\n 225: iload_3\n 226: iload_1\n 227: isub\n 228: iconst_1\n 229: iadd\n 230: invokevirtual #69 // Method java/lang/String.charAt:(I)C\n 233: invokestatic #75 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 236: aload_2\n 237: aload_0\n 238: iload_3\n 239: iload_1\n 240: isub\n 241: iconst_1\n 242: iadd\n 243: invokevirtual #69 // Method java/lang/String.charAt:(I)C\n 246: invokestatic #75 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 249: invokestatic #117 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 252: checkcast #86 // class java/lang/Number\n 255: invokevirtual #90 // Method java/lang/Number.intValue:()I\n 258: iconst_1\n 259: isub\n 260: invokestatic #80 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 263: invokeinterface #93, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 268: pop\n 269: iload_3\n 270: iload 4\n 272: if_icmpeq 281\n 275: iinc 3, 1\n 278: goto 103\n 281: new #28 // class java/lang/IllegalStateException\n 284: dup\n 285: ldc #119 // String Not found\n 287: invokevirtual #123 // Method java/lang/Object.toString:()Ljava/lang/String;\n 290: invokespecial #34 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 293: athrow\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #132 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day16.kt
import java.util.* import kotlin.math.max fun main() { val testInput = readInput("Day16_test") check(part1(testInput) == 1651) check(part2(testInput) == 1707) val input = readInput("Day16") println(part1(input)) println(part2(input)) } private const val PART1_MINUTES = 30 private const val PART2_MINUTES = 26 private const val START_VALVE = "AA" private fun part1(input: List<String>): Int { val valves = input.parseInputAndOptimize() val bitsMapper = valves.calcBitsMapper() return solve( minutesLeft = PART1_MINUTES, name = START_VALVE, openedBitmask = 0, valves = valves, bitsMapper = bitsMapper ) } private fun part2(input: List<String>): Int { val valves = input.parseInputAndOptimize() val bitsMapper = valves.calcBitsMapper() val valvesToOpen = bitsMapper.keys.toList() - START_VALVE val allBits = valvesToOpen.fold(0L) { acc, valve -> acc or bitsMapper.getValue(valve) } val memo = mutableMapOf<Long, Int>() //Brut-force all possible variants where some valves will be opened by me and the rest - by elephant return valvesToOpen.allCombinations() .map { valves -> valves.fold(0L) { acc, valve -> acc or bitsMapper.getValue(valve) } } .maxOf { valveBits -> val otherBits = allBits and valveBits.inv() val first = memo.getOrPut(valveBits) { solve( minutesLeft = PART2_MINUTES, name = START_VALVE, openedBitmask = valveBits, valves = valves, bitsMapper = bitsMapper ) } val second = memo.getOrPut(otherBits) { solve( minutesLeft = PART2_MINUTES, name = START_VALVE, openedBitmask = otherBits, valves = valves, bitsMapper = bitsMapper ) } first + second } } private fun solve( minutesLeft: Int, name: String, openedBitmask: Long, valves: Map<String, Valve>, bitsMapper: Map<String, Long>, memo: MutableMap<String, Int> = mutableMapOf() ): Int { val key = "${minutesLeft}_${name}_$openedBitmask" if (key in memo) { return memo.getValue(key) } val valve = valves.getValue(name) val resultInc = valve.rate * minutesLeft var result = resultInc valve.destinations.forEach { (nextName, timeToReachAndOpen) -> val nextBit = bitsMapper.getValue(nextName) if (minutesLeft > timeToReachAndOpen && (openedBitmask and nextBit) == 0L) { result = max( result, resultInc + solve( minutesLeft = minutesLeft - timeToReachAndOpen, name = nextName, openedBitmask = (openedBitmask or nextBit), valves = valves, bitsMapper = bitsMapper, memo = memo ) ) } } memo[key] = result return result } private val ROW_FORMAT = Regex("Valve ([A-Z]+) has flow rate=(\\d+); tunnel[s]? lead[s]? to valve[s]? ([A-Z, ]+)") private fun List<String>.parseInputAndOptimize(): Map<String, Valve> { val rates = mutableMapOf<String, Int>() val tunnelsFromValve = mutableMapOf<String, List<String>>() this.forEach { val match = ROW_FORMAT.find(it) val (valve, rate, tunnels) = requireNotNull(match).destructured rates[valve] = rate.toInt() tunnelsFromValve[valve] = tunnels.split(", ") } // Consider only valves with rate > 0 // Don't forget to add START valve return rates.filter { it.value > 0 || it.key == START_VALVE } .mapValues { (name, rate) -> Valve( rate = rate, destinations = buildTunnelsChains(name, tunnelsFromValve, rates) ) } } private fun buildTunnelsChains( start: String, tunnels: Map<String, List<String>>, rates: Map<String, Int> ): List<Destination> { return buildList { val queue = PriorityQueue<Pair<String, Int>> { a, b -> a.second - b.second } queue.offer(start to 0) val visited = mutableSetOf<String>() while (queue.isNotEmpty()) { val (name, time) = queue.poll() if (name in visited) { continue } visited.add(name) if (rates.getValue(name) > 0 && name != start) { add(Destination(name, time + 1)) //add 1 minute for opening } tunnels[name]?.forEach { next -> queue.offer(next to time + 1) } } } } private fun Map<String, Valve>.calcBitsMapper(): Map<String, Long> { var i = 1L return this.mapValues { val res = i i = i shl 1 res } } private data class Valve( val rate: Int, val destinations: List<Destination> ) private data class Destination( val name: String, val timeToReachAndOpen: Int )
[ { "class_path": "Kvest__AOC2022__6409e65/Day16Kt.class", "javap": "Compiled from \"Day16.kt\"\npublic final class Day16Kt {\n private static final int PART1_MINUTES;\n\n private static final int PART2_MINUTES;\n\n private static final java.lang.String START_VALVE;\n\n private static final kotlin.text.Regex ROW_FORMAT;\n\n public static final void main();\n Code:\n 0: ldc #8 // String Day16_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: sipush 1651\n 13: if_icmpne 20\n 16: iconst_1\n 17: goto 21\n 20: iconst_0\n 21: ifne 34\n 24: new #20 // class java/lang/IllegalStateException\n 27: dup\n 28: ldc #22 // String Check failed.\n 30: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 33: athrow\n 34: aload_0\n 35: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 38: sipush 1707\n 41: if_icmpne 48\n 44: iconst_1\n 45: goto 49\n 48: iconst_0\n 49: ifne 62\n 52: new #20 // class java/lang/IllegalStateException\n 55: dup\n 56: ldc #22 // String Check failed.\n 58: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 61: athrow\n 62: ldc #31 // String Day16\n 64: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 67: astore_1\n 68: aload_1\n 69: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 72: istore_2\n 73: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 76: iload_2\n 77: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 80: aload_1\n 81: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 84: istore_2\n 85: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 88: iload_2\n 89: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 92: return\n\n private static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #53 // Method parseInputAndOptimize:(Ljava/util/List;)Ljava/util/Map;\n 4: astore_1\n 5: aload_1\n 6: invokestatic #57 // Method calcBitsMapper:(Ljava/util/Map;)Ljava/util/Map;\n 9: astore_2\n 10: bipush 30\n 12: ldc #59 // String AA\n 14: lconst_0\n 15: aload_1\n 16: aload_2\n 17: aconst_null\n 18: bipush 32\n 20: aconst_null\n 21: invokestatic #63 // Method solve$default:(ILjava/lang/String;JLjava/util/Map;Ljava/util/Map;Ljava/util/Map;ILjava/lang/Object;)I\n 24: ireturn\n\n private static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #53 // Method parseInputAndOptimize:(Ljava/util/List;)Ljava/util/Map;\n 4: astore_1\n 5: aload_1\n 6: invokestatic #57 // Method calcBitsMapper:(Ljava/util/Map;)Ljava/util/Map;\n 9: astore_2\n 10: aload_2\n 11: invokeinterface #72, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 16: checkcast #74 // class java/lang/Iterable\n 19: invokestatic #80 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 22: checkcast #74 // class java/lang/Iterable\n 25: ldc #59 // String AA\n 27: invokestatic #84 // Method kotlin/collections/CollectionsKt.minus:(Ljava/lang/Iterable;Ljava/lang/Object;)Ljava/util/List;\n 30: astore_3\n 31: aload_3\n 32: checkcast #74 // class java/lang/Iterable\n 35: astore 6\n 37: lconst_0\n 38: lstore 7\n 40: iconst_0\n 41: istore 9\n 43: lload 7\n 45: lstore 10\n 47: aload 6\n 49: invokeinterface #88, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 54: astore 12\n 56: aload 12\n 58: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 63: ifeq 109\n 66: aload 12\n 68: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 73: astore 13\n 75: lload 10\n 77: aload 13\n 79: checkcast #100 // class java/lang/String\n 82: astore 14\n 84: lstore 15\n 86: iconst_0\n 87: istore 17\n 89: lload 15\n 91: aload_2\n 92: aload 14\n 94: invokestatic #106 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 97: checkcast #108 // class java/lang/Number\n 100: invokevirtual #112 // Method java/lang/Number.longValue:()J\n 103: lor\n 104: lstore 10\n 106: goto 56\n 109: lload 10\n 111: lstore 4\n 113: new #114 // class java/util/LinkedHashMap\n 116: dup\n 117: invokespecial #116 // Method java/util/LinkedHashMap.\"<init>\":()V\n 120: checkcast #68 // class java/util/Map\n 123: astore 6\n 125: aload_3\n 126: invokestatic #120 // Method UtilsKt.allCombinations:(Ljava/util/List;)Ljava/util/List;\n 129: checkcast #74 // class java/lang/Iterable\n 132: astore 7\n 134: nop\n 135: iconst_0\n 136: istore 9\n 138: aload 7\n 140: astore 10\n 142: new #122 // class java/util/ArrayList\n 145: dup\n 146: aload 7\n 148: bipush 10\n 150: invokestatic #126 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 153: invokespecial #128 // Method java/util/ArrayList.\"<init>\":(I)V\n 156: checkcast #130 // class java/util/Collection\n 159: astore 12\n 161: iconst_0\n 162: istore 13\n 164: aload 10\n 166: invokeinterface #88, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 171: astore 14\n 173: aload 14\n 175: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 180: ifeq 303\n 183: aload 14\n 185: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 190: astore 15\n 192: aload 12\n 194: aload 15\n 196: checkcast #48 // class java/util/List\n 199: astore 16\n 201: astore 34\n 203: iconst_0\n 204: istore 17\n 206: aload 16\n 208: checkcast #74 // class java/lang/Iterable\n 211: astore 18\n 213: lconst_0\n 214: lstore 19\n 216: iconst_0\n 217: istore 21\n 219: lload 19\n 221: lstore 22\n 223: aload 18\n 225: invokeinterface #88, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 230: astore 24\n 232: aload 24\n 234: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 239: ifeq 285\n 242: aload 24\n 244: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 249: astore 25\n 251: lload 22\n 253: aload 25\n 255: checkcast #100 // class java/lang/String\n 258: astore 26\n 260: lstore 27\n 262: iconst_0\n 263: istore 29\n 265: lload 27\n 267: aload_2\n 268: aload 26\n 270: invokestatic #106 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 273: checkcast #108 // class java/lang/Number\n 276: invokevirtual #112 // Method java/lang/Number.longValue:()J\n 279: lor\n 280: lstore 22\n 282: goto 232\n 285: lload 22\n 287: nop\n 288: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 291: aload 34\n 293: swap\n 294: invokeinterface #140, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 299: pop\n 300: goto 173\n 303: aload 12\n 305: checkcast #48 // class java/util/List\n 308: nop\n 309: checkcast #74 // class java/lang/Iterable\n 312: invokeinterface #88, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 317: astore 9\n 319: aload 9\n 321: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 326: ifne 337\n 329: new #142 // class java/util/NoSuchElementException\n 332: dup\n 333: invokespecial #143 // Method java/util/NoSuchElementException.\"<init>\":()V\n 336: athrow\n 337: aload 9\n 339: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 344: checkcast #108 // class java/lang/Number\n 347: invokevirtual #112 // Method java/lang/Number.longValue:()J\n 350: lstore 10\n 352: iconst_0\n 353: istore 13\n 355: lload 4\n 357: lload 10\n 359: ldc2_w #144 // long -1l\n 362: lxor\n 363: land\n 364: lstore 14\n 366: aload 6\n 368: astore 16\n 370: lload 10\n 372: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 375: astore 17\n 377: iconst_0\n 378: istore 18\n 380: aload 16\n 382: aload 17\n 384: invokeinterface #149, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 389: astore 19\n 391: aload 19\n 393: ifnonnull 437\n 396: iconst_0\n 397: istore 21\n 399: bipush 26\n 401: ldc #59 // String AA\n 403: lload 10\n 405: aload_1\n 406: aload_2\n 407: aconst_null\n 408: bipush 32\n 410: aconst_null\n 411: invokestatic #63 // Method solve$default:(ILjava/lang/String;JLjava/util/Map;Ljava/util/Map;Ljava/util/Map;ILjava/lang/Object;)I\n 414: nop\n 415: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 418: astore 22\n 420: aload 16\n 422: aload 17\n 424: aload 22\n 426: invokeinterface #158, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 431: pop\n 432: aload 22\n 434: goto 439\n 437: aload 19\n 439: nop\n 440: checkcast #108 // class java/lang/Number\n 443: invokevirtual #162 // Method java/lang/Number.intValue:()I\n 446: istore 24\n 448: aload 6\n 450: astore 17\n 452: lload 14\n 454: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 457: astore 18\n 459: iconst_0\n 460: istore 19\n 462: aload 17\n 464: aload 18\n 466: invokeinterface #149, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 471: astore 21\n 473: aload 21\n 475: ifnonnull 519\n 478: iconst_0\n 479: istore 22\n 481: bipush 26\n 483: ldc #59 // String AA\n 485: lload 14\n 487: aload_1\n 488: aload_2\n 489: aconst_null\n 490: bipush 32\n 492: aconst_null\n 493: invokestatic #63 // Method solve$default:(ILjava/lang/String;JLjava/util/Map;Ljava/util/Map;Ljava/util/Map;ILjava/lang/Object;)I\n 496: nop\n 497: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 500: astore 25\n 502: aload 17\n 504: aload 18\n 506: aload 25\n 508: invokeinterface #158, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 513: pop\n 514: aload 25\n 516: goto 521\n 519: aload 21\n 521: nop\n 522: checkcast #108 // class java/lang/Number\n 525: invokevirtual #162 // Method java/lang/Number.intValue:()I\n 528: istore 16\n 530: iload 24\n 532: iload 16\n 534: iadd\n 535: istore 26\n 537: aload 9\n 539: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 544: ifeq 761\n 547: aload 9\n 549: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 554: checkcast #108 // class java/lang/Number\n 557: invokevirtual #112 // Method java/lang/Number.longValue:()J\n 560: lstore 27\n 562: iconst_0\n 563: istore 29\n 565: lload 4\n 567: lload 27\n 569: ldc2_w #144 // long -1l\n 572: lxor\n 573: land\n 574: lstore 30\n 576: aload 6\n 578: astore 17\n 580: lload 27\n 582: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 585: astore 18\n 587: iconst_0\n 588: istore 19\n 590: aload 17\n 592: aload 18\n 594: invokeinterface #149, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 599: astore 21\n 601: aload 21\n 603: ifnonnull 647\n 606: iconst_0\n 607: istore 22\n 609: bipush 26\n 611: ldc #59 // String AA\n 613: lload 27\n 615: aload_1\n 616: aload_2\n 617: aconst_null\n 618: bipush 32\n 620: aconst_null\n 621: invokestatic #63 // Method solve$default:(ILjava/lang/String;JLjava/util/Map;Ljava/util/Map;Ljava/util/Map;ILjava/lang/Object;)I\n 624: nop\n 625: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 628: astore 24\n 630: aload 17\n 632: aload 18\n 634: aload 24\n 636: invokeinterface #158, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 641: pop\n 642: aload 24\n 644: goto 649\n 647: aload 21\n 649: nop\n 650: checkcast #108 // class java/lang/Number\n 653: invokevirtual #162 // Method java/lang/Number.intValue:()I\n 656: istore 25\n 658: aload 6\n 660: astore 18\n 662: lload 30\n 664: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 667: astore 19\n 669: iconst_0\n 670: istore 21\n 672: aload 18\n 674: aload 19\n 676: invokeinterface #149, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 681: astore 22\n 683: aload 22\n 685: ifnonnull 729\n 688: iconst_0\n 689: istore 24\n 691: bipush 26\n 693: ldc #59 // String AA\n 695: lload 30\n 697: aload_1\n 698: aload_2\n 699: aconst_null\n 700: bipush 32\n 702: aconst_null\n 703: invokestatic #63 // Method solve$default:(ILjava/lang/String;JLjava/util/Map;Ljava/util/Map;Ljava/util/Map;ILjava/lang/Object;)I\n 706: nop\n 707: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 710: astore 32\n 712: aload 18\n 714: aload 19\n 716: aload 32\n 718: invokeinterface #158, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 723: pop\n 724: aload 32\n 726: goto 731\n 729: aload 22\n 731: nop\n 732: checkcast #108 // class java/lang/Number\n 735: invokevirtual #162 // Method java/lang/Number.intValue:()I\n 738: istore 17\n 740: iload 25\n 742: iload 17\n 744: iadd\n 745: istore 33\n 747: iload 26\n 749: iload 33\n 751: if_icmpge 537\n 754: iload 33\n 756: istore 26\n 758: goto 537\n 761: iload 26\n 763: ireturn\n\n private static final int solve(int, java.lang.String, long, java.util.Map<java.lang.String, Valve>, java.util.Map<java.lang.String, java.lang.Long>, java.util.Map<java.lang.String, java.lang.Integer>);\n Code:\n 0: new #204 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #205 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: iload_0\n 8: invokevirtual #209 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 11: bipush 95\n 13: invokevirtual #212 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 16: aload_1\n 17: invokevirtual #215 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 20: bipush 95\n 22: invokevirtual #212 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 25: lload_2\n 26: invokevirtual #218 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 29: invokevirtual #222 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 32: astore 7\n 34: aload 6\n 36: aload 7\n 38: invokeinterface #225, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 43: ifeq 60\n 46: aload 6\n 48: aload 7\n 50: invokestatic #106 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 53: checkcast #108 // class java/lang/Number\n 56: invokevirtual #162 // Method java/lang/Number.intValue:()I\n 59: ireturn\n 60: aload 4\n 62: aload_1\n 63: invokestatic #106 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 66: checkcast #227 // class Valve\n 69: astore 8\n 71: aload 8\n 73: invokevirtual #230 // Method Valve.getRate:()I\n 76: iload_0\n 77: imul\n 78: istore 9\n 80: iconst_0\n 81: istore 10\n 83: iload 9\n 85: istore 10\n 87: aload 8\n 89: invokevirtual #234 // Method Valve.getDestinations:()Ljava/util/List;\n 92: checkcast #74 // class java/lang/Iterable\n 95: astore 11\n 97: iconst_0\n 98: istore 12\n 100: aload 11\n 102: invokeinterface #88, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 107: astore 13\n 109: aload 13\n 111: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 116: ifeq 218\n 119: aload 13\n 121: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 126: astore 14\n 128: aload 14\n 130: checkcast #236 // class Destination\n 133: astore 15\n 135: iconst_0\n 136: istore 16\n 138: aload 15\n 140: invokevirtual #239 // Method Destination.component1:()Ljava/lang/String;\n 143: astore 17\n 145: aload 15\n 147: invokevirtual #242 // Method Destination.component2:()I\n 150: istore 18\n 152: aload 5\n 154: aload 17\n 156: invokestatic #106 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 159: checkcast #108 // class java/lang/Number\n 162: invokevirtual #112 // Method java/lang/Number.longValue:()J\n 165: lstore 19\n 167: iload_0\n 168: iload 18\n 170: if_icmple 213\n 173: lload_2\n 174: lload 19\n 176: land\n 177: lconst_0\n 178: lcmp\n 179: ifne 213\n 182: nop\n 183: nop\n 184: iload 10\n 186: iload 9\n 188: iload_0\n 189: iload 18\n 191: isub\n 192: aload 17\n 194: lload_2\n 195: lload 19\n 197: lor\n 198: aload 4\n 200: aload 5\n 202: aload 6\n 204: invokestatic #244 // Method solve:(ILjava/lang/String;JLjava/util/Map;Ljava/util/Map;Ljava/util/Map;)I\n 207: iadd\n 208: invokestatic #250 // Method java/lang/Math.max:(II)I\n 211: istore 10\n 213: nop\n 214: nop\n 215: goto 109\n 218: nop\n 219: aload 6\n 221: aload 7\n 223: iload 10\n 225: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 228: invokeinterface #158, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 233: pop\n 234: iload 10\n 236: ireturn\n\n static int solve$default(int, java.lang.String, long, java.util.Map, java.util.Map, java.util.Map, int, java.lang.Object);\n Code:\n 0: iload 7\n 2: bipush 32\n 4: iand\n 5: ifeq 20\n 8: new #114 // class java/util/LinkedHashMap\n 11: dup\n 12: invokespecial #116 // Method java/util/LinkedHashMap.\"<init>\":()V\n 15: checkcast #68 // class java/util/Map\n 18: astore 6\n 20: iload_0\n 21: aload_1\n 22: lload_2\n 23: aload 4\n 25: aload 5\n 27: aload 6\n 29: invokestatic #244 // Method solve:(ILjava/lang/String;JLjava/util/Map;Ljava/util/Map;Ljava/util/Map;)I\n 32: ireturn\n\n private static final java.util.Map<java.lang.String, Valve> parseInputAndOptimize(java.util.List<java.lang.String>);\n Code:\n 0: new #114 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #116 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #68 // class java/util/Map\n 10: astore_1\n 11: new #114 // class java/util/LinkedHashMap\n 14: dup\n 15: invokespecial #116 // Method java/util/LinkedHashMap.\"<init>\":()V\n 18: checkcast #68 // class java/util/Map\n 21: astore_2\n 22: aload_0\n 23: checkcast #74 // class java/lang/Iterable\n 26: astore_3\n 27: iconst_0\n 28: istore 4\n 30: aload_3\n 31: invokeinterface #88, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 36: astore 5\n 38: aload 5\n 40: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 45: ifeq 246\n 48: aload 5\n 50: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 55: astore 6\n 57: aload 6\n 59: checkcast #100 // class java/lang/String\n 62: astore 7\n 64: iconst_0\n 65: istore 8\n 67: getstatic #268 // Field ROW_FORMAT:Lkotlin/text/Regex;\n 70: aload 7\n 72: checkcast #270 // class java/lang/CharSequence\n 75: iconst_0\n 76: iconst_2\n 77: aconst_null\n 78: invokestatic #276 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 81: astore 9\n 83: aload 9\n 85: dup\n 86: ifnonnull 108\n 89: pop\n 90: ldc_w #278 // String Required value was null.\n 93: astore 10\n 95: new #280 // class java/lang/IllegalArgumentException\n 98: dup\n 99: aload 10\n 101: invokevirtual #281 // Method java/lang/Object.toString:()Ljava/lang/String;\n 104: invokespecial #282 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 107: athrow\n 108: invokeinterface #288, 1 // InterfaceMethod kotlin/text/MatchResult.getDestructured:()Lkotlin/text/MatchResult$Destructured;\n 113: astore 11\n 115: aload 11\n 117: invokevirtual #294 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 120: invokeinterface #297, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 125: iconst_1\n 126: invokeinterface #300, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 131: checkcast #100 // class java/lang/String\n 134: astore 10\n 136: aload 11\n 138: invokevirtual #294 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 141: invokeinterface #297, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 146: iconst_2\n 147: invokeinterface #300, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 152: checkcast #100 // class java/lang/String\n 155: astore 12\n 157: aload 11\n 159: invokevirtual #294 // Method kotlin/text/MatchResult$Destructured.getMatch:()Lkotlin/text/MatchResult;\n 162: invokeinterface #297, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 167: iconst_3\n 168: invokeinterface #300, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 173: checkcast #100 // class java/lang/String\n 176: astore 13\n 178: nop\n 179: aload_1\n 180: aload 10\n 182: aload 12\n 184: invokestatic #304 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 187: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 190: invokeinterface #158, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 195: pop\n 196: aload_2\n 197: astore 14\n 199: aload 13\n 201: checkcast #270 // class java/lang/CharSequence\n 204: iconst_1\n 205: anewarray #100 // class java/lang/String\n 208: astore 15\n 210: aload 15\n 212: iconst_0\n 213: ldc_w #306 // String ,\n 216: aastore\n 217: aload 15\n 219: iconst_0\n 220: iconst_0\n 221: bipush 6\n 223: aconst_null\n 224: invokestatic #312 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 227: astore 15\n 229: aload 14\n 231: aload 10\n 233: aload 15\n 235: invokeinterface #158, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 240: pop\n 241: nop\n 242: nop\n 243: goto 38\n 246: nop\n 247: aload_1\n 248: astore_3\n 249: iconst_0\n 250: istore 4\n 252: aload_3\n 253: astore 5\n 255: new #114 // class java/util/LinkedHashMap\n 258: dup\n 259: invokespecial #116 // Method java/util/LinkedHashMap.\"<init>\":()V\n 262: checkcast #68 // class java/util/Map\n 265: astore 6\n 267: iconst_0\n 268: istore 7\n 270: aload 5\n 272: invokeinterface #315, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 277: invokeinterface #318, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 282: astore 8\n 284: aload 8\n 286: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 291: ifeq 377\n 294: aload 8\n 296: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 301: checkcast #320 // class java/util/Map$Entry\n 304: astore 9\n 306: aload 9\n 308: astore 10\n 310: iconst_0\n 311: istore 11\n 313: aload 10\n 315: invokeinterface #322, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 320: checkcast #108 // class java/lang/Number\n 323: invokevirtual #162 // Method java/lang/Number.intValue:()I\n 326: ifgt 344\n 329: aload 10\n 331: invokeinterface #325, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 336: ldc #59 // String AA\n 338: invokestatic #331 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 341: ifeq 348\n 344: iconst_1\n 345: goto 349\n 348: iconst_0\n 349: ifeq 284\n 352: aload 6\n 354: aload 9\n 356: invokeinterface #325, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 361: aload 9\n 363: invokeinterface #322, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 368: invokeinterface #158, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 373: pop\n 374: goto 284\n 377: aload 6\n 379: nop\n 380: astore_3\n 381: nop\n 382: iconst_0\n 383: istore 4\n 385: aload_3\n 386: astore 5\n 388: new #114 // class java/util/LinkedHashMap\n 391: dup\n 392: aload_3\n 393: invokeinterface #334, 1 // InterfaceMethod java/util/Map.size:()I\n 398: invokestatic #338 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 401: invokespecial #339 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 404: checkcast #68 // class java/util/Map\n 407: astore 6\n 409: iconst_0\n 410: istore 7\n 412: aload 5\n 414: invokeinterface #315, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 419: checkcast #74 // class java/lang/Iterable\n 422: astore 8\n 424: iconst_0\n 425: istore 9\n 427: aload 8\n 429: invokeinterface #88, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 434: astore 10\n 436: aload 10\n 438: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 443: ifeq 554\n 446: aload 10\n 448: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 453: astore 11\n 455: aload 6\n 457: aload 11\n 459: checkcast #320 // class java/util/Map$Entry\n 462: astore 12\n 464: astore 13\n 466: iconst_0\n 467: istore 14\n 469: aload 12\n 471: invokeinterface #325, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 476: aload 13\n 478: swap\n 479: aload 11\n 481: checkcast #320 // class java/util/Map$Entry\n 484: astore 15\n 486: astore 20\n 488: astore 19\n 490: iconst_0\n 491: istore 16\n 493: aload 15\n 495: invokeinterface #325, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 500: checkcast #100 // class java/lang/String\n 503: astore 17\n 505: aload 15\n 507: invokeinterface #322, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 512: checkcast #108 // class java/lang/Number\n 515: invokevirtual #162 // Method java/lang/Number.intValue:()I\n 518: istore 18\n 520: new #227 // class Valve\n 523: dup\n 524: iload 18\n 526: aload 17\n 528: aload_2\n 529: aload_1\n 530: invokestatic #343 // Method buildTunnelsChains:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Map;)Ljava/util/List;\n 533: invokespecial #346 // Method Valve.\"<init>\":(ILjava/util/List;)V\n 536: nop\n 537: astore 21\n 539: aload 19\n 541: aload 20\n 543: aload 21\n 545: invokeinterface #158, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 550: pop\n 551: goto 436\n 554: aload 6\n 556: nop\n 557: nop\n 558: areturn\n\n private static final java.util.List<Destination> buildTunnelsChains(java.lang.String, java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>, java.util.Map<java.lang.String, java.lang.Integer>);\n Code:\n 0: invokestatic #376 // Method kotlin/collections/CollectionsKt.createListBuilder:()Ljava/util/List;\n 3: astore_3\n 4: aload_3\n 5: astore 4\n 7: iconst_0\n 8: istore 5\n 10: new #378 // class java/util/PriorityQueue\n 13: dup\n 14: invokedynamic #397, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;\n 19: invokedynamic #408, 0 // InvokeDynamic #1:compare:(Lkotlin/jvm/functions/Function2;)Ljava/util/Comparator;\n 24: invokespecial #411 // Method java/util/PriorityQueue.\"<init>\":(Ljava/util/Comparator;)V\n 27: astore 6\n 29: aload 6\n 31: aload_0\n 32: iconst_0\n 33: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 36: invokestatic #417 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 39: invokevirtual #420 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z\n 42: pop\n 43: new #422 // class java/util/LinkedHashSet\n 46: dup\n 47: invokespecial #423 // Method java/util/LinkedHashSet.\"<init>\":()V\n 50: checkcast #317 // class java/util/Set\n 53: astore 7\n 55: aload 6\n 57: checkcast #130 // class java/util/Collection\n 60: invokeinterface #426, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 65: ifne 72\n 68: iconst_1\n 69: goto 73\n 72: iconst_0\n 73: ifeq 272\n 76: aload 6\n 78: invokevirtual #429 // Method java/util/PriorityQueue.poll:()Ljava/lang/Object;\n 81: checkcast #431 // class kotlin/Pair\n 84: astore 8\n 86: aload 8\n 88: invokevirtual #433 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 91: checkcast #100 // class java/lang/String\n 94: astore 9\n 96: aload 8\n 98: invokevirtual #435 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 101: checkcast #108 // class java/lang/Number\n 104: invokevirtual #162 // Method java/lang/Number.intValue:()I\n 107: istore 10\n 109: aload 7\n 111: aload 9\n 113: invokeinterface #438, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 118: ifeq 124\n 121: goto 55\n 124: aload 7\n 126: aload 9\n 128: invokeinterface #439, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 133: pop\n 134: aload_2\n 135: aload 9\n 137: invokestatic #106 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 140: checkcast #108 // class java/lang/Number\n 143: invokevirtual #162 // Method java/lang/Number.intValue:()I\n 146: ifle 179\n 149: aload 9\n 151: aload_0\n 152: invokestatic #331 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 155: ifne 179\n 158: aload 4\n 160: new #236 // class Destination\n 163: dup\n 164: aload 9\n 166: iload 10\n 168: iconst_1\n 169: iadd\n 170: invokespecial #442 // Method Destination.\"<init>\":(Ljava/lang/String;I)V\n 173: invokeinterface #443, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 178: pop\n 179: aload_1\n 180: aload 9\n 182: invokeinterface #149, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 187: checkcast #48 // class java/util/List\n 190: dup\n 191: ifnull 267\n 194: checkcast #74 // class java/lang/Iterable\n 197: astore 11\n 199: iconst_0\n 200: istore 12\n 202: aload 11\n 204: invokeinterface #88, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 209: astore 13\n 211: aload 13\n 213: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 218: ifeq 263\n 221: aload 13\n 223: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 228: astore 14\n 230: aload 14\n 232: checkcast #100 // class java/lang/String\n 235: astore 15\n 237: iconst_0\n 238: istore 16\n 240: aload 6\n 242: aload 15\n 244: iload 10\n 246: iconst_1\n 247: iadd\n 248: invokestatic #154 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 251: invokestatic #417 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 254: invokevirtual #420 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z\n 257: pop\n 258: nop\n 259: nop\n 260: goto 211\n 263: nop\n 264: goto 55\n 267: pop\n 268: nop\n 269: goto 55\n 272: nop\n 273: aload_3\n 274: invokestatic #446 // Method kotlin/collections/CollectionsKt.build:(Ljava/util/List;)Ljava/util/List;\n 277: areturn\n\n private static final java.util.Map<java.lang.String, java.lang.Long> calcBitsMapper(java.util.Map<java.lang.String, Valve>);\n Code:\n 0: lconst_0\n 1: lstore 20\n 3: lconst_1\n 4: lstore 20\n 6: aload_0\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: astore_3\n 12: new #114 // class java/util/LinkedHashMap\n 15: dup\n 16: aload_1\n 17: invokeinterface #334, 1 // InterfaceMethod java/util/Map.size:()I\n 22: invokestatic #338 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 25: invokespecial #339 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 28: checkcast #68 // class java/util/Map\n 31: astore 4\n 33: iconst_0\n 34: istore 5\n 36: aload_3\n 37: invokeinterface #315, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 42: checkcast #74 // class java/lang/Iterable\n 45: astore 6\n 47: iconst_0\n 48: istore 7\n 50: aload 6\n 52: invokeinterface #88, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 57: astore 8\n 59: aload 8\n 61: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 66: ifeq 148\n 69: aload 8\n 71: invokeinterface #98, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 76: astore 9\n 78: aload 4\n 80: aload 9\n 82: checkcast #320 // class java/util/Map$Entry\n 85: astore 10\n 87: astore 11\n 89: iconst_0\n 90: istore 12\n 92: aload 10\n 94: invokeinterface #325, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 99: aload 11\n 101: swap\n 102: aload 9\n 104: checkcast #320 // class java/util/Map$Entry\n 107: astore 13\n 109: astore 18\n 111: astore 17\n 113: iconst_0\n 114: istore 14\n 116: lload 20\n 118: lstore 15\n 120: lload 20\n 122: iconst_1\n 123: lshl\n 124: lstore 20\n 126: lload 15\n 128: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 131: astore 19\n 133: aload 17\n 135: aload 18\n 137: aload 19\n 139: invokeinterface #158, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 144: pop\n 145: goto 59\n 148: aload 4\n 150: nop\n 151: nop\n 152: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #463 // Method main:()V\n 3: return\n\n private static final int buildTunnelsChains$lambda$13$lambda$10(kotlin.Pair, kotlin.Pair);\n Code:\n 0: aload_0\n 1: invokevirtual #468 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 4: checkcast #108 // class java/lang/Number\n 7: invokevirtual #162 // Method java/lang/Number.intValue:()I\n 10: aload_1\n 11: invokevirtual #468 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 14: checkcast #108 // class java/lang/Number\n 17: invokevirtual #162 // Method java/lang/Number.intValue:()I\n 20: isub\n 21: ireturn\n\n private static final int buildTunnelsChains$lambda$13$lambda$11(kotlin.jvm.functions.Function2, java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: aload_2\n 3: invokeinterface #475, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 8: checkcast #108 // class java/lang/Number\n 11: invokevirtual #162 // Method java/lang/Number.intValue:()I\n 14: ireturn\n\n static {};\n Code:\n 0: new #272 // class kotlin/text/Regex\n 3: dup\n 4: ldc_w #482 // String Valve ([A-Z]+) has flow rate=(\\\\d+); tunnel[s]? lead[s]? to valve[s]? ([A-Z, ]+)\n 7: invokespecial #483 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 10: putstatic #268 // Field ROW_FORMAT:Lkotlin/text/Regex;\n 13: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day20.kt
fun main() { val testInput = readInput("Day20_test") check(part1(testInput) == 3L) check(part2(testInput) == 1623178306L) val input = readInput("Day20") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Long = solve(input, String::toLong, mixesCount = 1) private fun part2(input: List<String>): Long = solve(input, String::part2Converter, mixesCount = 10) private fun String.part2Converter(): Long = this.toLong() * 811589153L private fun solve(input: List<String>, converter: String.() -> Long, mixesCount: Int): Long { val nodes = input.map { LinkedNode(it.converter()) } var zeroIndex = -1 for (i in nodes.indices) { nodes[i].next = if (i < nodes.lastIndex) nodes[i + 1] else nodes.first() nodes[i].prev = if (i > 0) nodes[i - 1] else nodes.last() if (nodes[i].value == 0L) { zeroIndex = i } } repeat(mixesCount) { nodes.forEach { node -> val count = correctMovesCount(node.value, nodes.size) if (count > 0) { var target = node repeat(count) { target = target.next } //delete node from chain node.prev.next = node.next node.next.prev = node.prev //insert node to the new position node.next = target.next target.next.prev = node target.next = node node.prev = target } } } var node = nodes[zeroIndex] var result = 0L repeat(3_001) { if (it == 1_000 || it == 2_000 || it == 3_000) { result += node.value } node = node.next } return result } private fun correctMovesCount(count: Long, size: Int): Int { return if (count > 0) { //reduce the full cycles (count % (size - 1)).toInt() } else { //(size + (count % (size - 1)) - 1) - this converts negative steps to positive steps // % (size - 1) - this reduce the full cycles when the steps count is more than the items in the chain ((size + (count % (size - 1)) - 1) % (size - 1)).toInt() } } private class LinkedNode(val value: Long) { lateinit var next: LinkedNode lateinit var prev: LinkedNode }
[ { "class_path": "Kvest__AOC2022__6409e65/Day20Kt.class", "javap": "Compiled from \"Day20.kt\"\npublic final class Day20Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String 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: ldc2_w #19 // long 3l\n 13: lcmp\n 14: ifne 21\n 17: iconst_1\n 18: goto 22\n 21: iconst_0\n 22: ifne 35\n 25: new #22 // class java/lang/IllegalStateException\n 28: dup\n 29: ldc #24 // String Check failed.\n 31: invokespecial #28 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 34: athrow\n 35: aload_0\n 36: invokestatic #31 // Method part2:(Ljava/util/List;)J\n 39: ldc2_w #32 // long 1623178306l\n 42: lcmp\n 43: ifne 50\n 46: iconst_1\n 47: goto 51\n 50: iconst_0\n 51: ifne 64\n 54: new #22 // class java/lang/IllegalStateException\n 57: dup\n 58: ldc #24 // String Check failed.\n 60: invokespecial #28 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 63: athrow\n 64: ldc #35 // String Day20\n 66: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 69: astore_1\n 70: aload_1\n 71: invokestatic #18 // Method part1:(Ljava/util/List;)J\n 74: lstore_2\n 75: getstatic #41 // Field java/lang/System.out:Ljava/io/PrintStream;\n 78: lload_2\n 79: invokevirtual #47 // Method java/io/PrintStream.println:(J)V\n 82: aload_1\n 83: invokestatic #31 // Method part2:(Ljava/util/List;)J\n 86: lstore_2\n 87: getstatic #41 // Field java/lang/System.out:Ljava/io/PrintStream;\n 90: lload_2\n 91: invokevirtual #47 // Method java/io/PrintStream.println:(J)V\n 94: return\n\n private static final long part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: getstatic #59 // Field Day20Kt$part1$1.INSTANCE:LDay20Kt$part1$1;\n 4: checkcast #61 // class kotlin/jvm/functions/Function1\n 7: iconst_1\n 8: invokestatic #65 // Method solve:(Ljava/util/List;Lkotlin/jvm/functions/Function1;I)J\n 11: lreturn\n\n private static final long part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: getstatic #70 // Field Day20Kt$part2$1.INSTANCE:LDay20Kt$part2$1;\n 4: checkcast #61 // class kotlin/jvm/functions/Function1\n 7: bipush 10\n 9: invokestatic #65 // Method solve:(Ljava/util/List;Lkotlin/jvm/functions/Function1;I)J\n 12: lreturn\n\n private static final long part2Converter(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #77 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 4: ldc2_w #78 // long 811589153l\n 7: lmul\n 8: lreturn\n\n private static final long solve(java.util.List<java.lang.String>, kotlin.jvm.functions.Function1<? super java.lang.String, java.lang.Long>, int);\n Code:\n 0: aload_0\n 1: checkcast #84 // class java/lang/Iterable\n 4: astore 4\n 6: iconst_0\n 7: istore 5\n 9: aload 4\n 11: astore 6\n 13: new #86 // class java/util/ArrayList\n 16: dup\n 17: aload 4\n 19: bipush 10\n 21: invokestatic #92 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 24: invokespecial #95 // Method java/util/ArrayList.\"<init>\":(I)V\n 27: checkcast #97 // class java/util/Collection\n 30: astore 7\n 32: iconst_0\n 33: istore 8\n 35: aload 6\n 37: invokeinterface #101, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 42: astore 9\n 44: aload 9\n 46: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 51: ifeq 110\n 54: aload 9\n 56: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: astore 10\n 63: aload 7\n 65: aload 10\n 67: checkcast #113 // class java/lang/String\n 70: astore 11\n 72: astore 19\n 74: iconst_0\n 75: istore 12\n 77: new #115 // class LinkedNode\n 80: dup\n 81: aload_1\n 82: aload 11\n 84: invokeinterface #119, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 89: checkcast #121 // class java/lang/Number\n 92: invokevirtual #125 // Method java/lang/Number.longValue:()J\n 95: invokespecial #127 // Method LinkedNode.\"<init>\":(J)V\n 98: aload 19\n 100: swap\n 101: invokeinterface #131, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 106: pop\n 107: goto 44\n 110: aload 7\n 112: checkcast #52 // class java/util/List\n 115: nop\n 116: astore_3\n 117: iconst_m1\n 118: istore 4\n 120: iconst_0\n 121: istore 5\n 123: aload_3\n 124: checkcast #97 // class java/util/Collection\n 127: invokeinterface #135, 1 // InterfaceMethod java/util/Collection.size:()I\n 132: istore 6\n 134: iload 5\n 136: iload 6\n 138: if_icmpge 258\n 141: aload_3\n 142: iload 5\n 144: invokeinterface #139, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 149: checkcast #115 // class LinkedNode\n 152: iload 5\n 154: aload_3\n 155: invokestatic #143 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 158: if_icmpge 177\n 161: aload_3\n 162: iload 5\n 164: iconst_1\n 165: iadd\n 166: invokeinterface #139, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 171: checkcast #115 // class LinkedNode\n 174: goto 184\n 177: aload_3\n 178: invokestatic #147 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 181: checkcast #115 // class LinkedNode\n 184: invokevirtual #151 // Method LinkedNode.setNext:(LLinkedNode;)V\n 187: aload_3\n 188: iload 5\n 190: invokeinterface #139, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 195: checkcast #115 // class LinkedNode\n 198: iload 5\n 200: ifle 219\n 203: aload_3\n 204: iload 5\n 206: iconst_1\n 207: isub\n 208: invokeinterface #139, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 213: checkcast #115 // class LinkedNode\n 216: goto 226\n 219: aload_3\n 220: invokestatic #154 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 223: checkcast #115 // class LinkedNode\n 226: invokevirtual #157 // Method LinkedNode.setPrev:(LLinkedNode;)V\n 229: aload_3\n 230: iload 5\n 232: invokeinterface #139, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 237: checkcast #115 // class LinkedNode\n 240: invokevirtual #160 // Method LinkedNode.getValue:()J\n 243: lconst_0\n 244: lcmp\n 245: ifne 252\n 248: iload 5\n 250: istore 4\n 252: iinc 5, 1\n 255: goto 134\n 258: iconst_0\n 259: istore 5\n 261: iload 5\n 263: iload_2\n 264: if_icmpge 453\n 267: iload 5\n 269: istore 6\n 271: iconst_0\n 272: istore 7\n 274: aload_3\n 275: checkcast #84 // class java/lang/Iterable\n 278: astore 8\n 280: iconst_0\n 281: istore 9\n 283: aload 8\n 285: invokeinterface #101, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 290: astore 10\n 292: aload 10\n 294: invokeinterface #107, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 299: ifeq 445\n 302: aload 10\n 304: invokeinterface #111, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 309: astore 11\n 311: aload 11\n 313: checkcast #115 // class LinkedNode\n 316: astore 12\n 318: iconst_0\n 319: istore 13\n 321: aload 12\n 323: invokevirtual #160 // Method LinkedNode.getValue:()J\n 326: aload_3\n 327: invokeinterface #161, 1 // InterfaceMethod java/util/List.size:()I\n 332: invokestatic #165 // Method correctMovesCount:(JI)I\n 335: istore 14\n 337: iload 14\n 339: ifle 440\n 342: aconst_null\n 343: astore 15\n 345: aload 12\n 347: astore 15\n 349: iconst_0\n 350: istore 16\n 352: iload 16\n 354: iload 14\n 356: if_icmpge 380\n 359: iload 16\n 361: istore 17\n 363: iconst_0\n 364: istore 18\n 366: aload 15\n 368: invokevirtual #169 // Method LinkedNode.getNext:()LLinkedNode;\n 371: astore 15\n 373: nop\n 374: iinc 16, 1\n 377: goto 352\n 380: aload 12\n 382: invokevirtual #172 // Method LinkedNode.getPrev:()LLinkedNode;\n 385: aload 12\n 387: invokevirtual #169 // Method LinkedNode.getNext:()LLinkedNode;\n 390: invokevirtual #151 // Method LinkedNode.setNext:(LLinkedNode;)V\n 393: aload 12\n 395: invokevirtual #169 // Method LinkedNode.getNext:()LLinkedNode;\n 398: aload 12\n 400: invokevirtual #172 // Method LinkedNode.getPrev:()LLinkedNode;\n 403: invokevirtual #157 // Method LinkedNode.setPrev:(LLinkedNode;)V\n 406: aload 12\n 408: aload 15\n 410: invokevirtual #169 // Method LinkedNode.getNext:()LLinkedNode;\n 413: invokevirtual #151 // Method LinkedNode.setNext:(LLinkedNode;)V\n 416: aload 15\n 418: invokevirtual #169 // Method LinkedNode.getNext:()LLinkedNode;\n 421: aload 12\n 423: invokevirtual #157 // Method LinkedNode.setPrev:(LLinkedNode;)V\n 426: aload 15\n 428: aload 12\n 430: invokevirtual #151 // Method LinkedNode.setNext:(LLinkedNode;)V\n 433: aload 12\n 435: aload 15\n 437: invokevirtual #157 // Method LinkedNode.setPrev:(LLinkedNode;)V\n 440: nop\n 441: nop\n 442: goto 292\n 445: nop\n 446: nop\n 447: iinc 5, 1\n 450: goto 261\n 453: aconst_null\n 454: astore 5\n 456: aload_3\n 457: iload 4\n 459: invokeinterface #139, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 464: astore 5\n 466: lconst_0\n 467: lstore 20\n 469: sipush 3001\n 472: istore 7\n 474: iconst_0\n 475: istore 8\n 477: iload 8\n 479: iload 7\n 481: if_icmpge 558\n 484: iload 8\n 486: istore 9\n 488: iconst_0\n 489: istore 10\n 491: iload 9\n 493: lookupswitch { // 3\n 1000: 528\n 2000: 528\n 3000: 528\n default: 541\n }\n 528: lload 20\n 530: aload 5\n 532: checkcast #115 // class LinkedNode\n 535: invokevirtual #160 // Method LinkedNode.getValue:()J\n 538: ladd\n 539: lstore 20\n 541: aload 5\n 543: checkcast #115 // class LinkedNode\n 546: invokevirtual #169 // Method LinkedNode.getNext:()LLinkedNode;\n 549: astore 5\n 551: nop\n 552: iinc 8, 1\n 555: goto 477\n 558: lload 20\n 560: lreturn\n\n private static final int correctMovesCount(long, int);\n Code:\n 0: lload_0\n 1: lconst_0\n 2: lcmp\n 3: ifle 16\n 6: lload_0\n 7: iload_2\n 8: iconst_1\n 9: isub\n 10: i2l\n 11: lrem\n 12: l2i\n 13: goto 33\n 16: iload_2\n 17: i2l\n 18: lload_0\n 19: iload_2\n 20: iconst_1\n 21: isub\n 22: i2l\n 23: lrem\n 24: ladd\n 25: lconst_1\n 26: lsub\n 27: iload_2\n 28: iconst_1\n 29: isub\n 30: i2l\n 31: lrem\n 32: l2i\n 33: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #206 // Method main:()V\n 3: return\n\n public static final long access$part2Converter(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #211 // Method part2Converter:(Ljava/lang/String;)J\n 4: lreturn\n}\n", "javap_err": "" }, { "class_path": "Kvest__AOC2022__6409e65/Day20Kt$part1$1.class", "javap": "Compiled from \"Day20.kt\"\nfinal class Day20Kt$part1$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, java.lang.Long> {\n public static final Day20Kt$part1$1 INSTANCE;\n\n Day20Kt$part1$1();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class kotlin/text/StringsKt\n 4: ldc #13 // String toLong\n 6: ldc #15 // String toLong(Ljava/lang/String;)J\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.Long invoke(java.lang.String);\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_1\n 7: invokestatic #36 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 10: invokestatic #40 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 13: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #44 // class java/lang/String\n 5: invokevirtual #46 // Method invoke:(Ljava/lang/String;)Ljava/lang/Long;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class Day20Kt$part1$1\n 3: dup\n 4: invokespecial #51 // Method \"<init>\":()V\n 7: putstatic #54 // Field INSTANCE:LDay20Kt$part1$1;\n 10: return\n}\n", "javap_err": "" }, { "class_path": "Kvest__AOC2022__6409e65/Day20Kt$part2$1.class", "javap": "Compiled from \"Day20.kt\"\nfinal class Day20Kt$part2$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.lang.String, java.lang.Long> {\n public static final Day20Kt$part2$1 INSTANCE;\n\n Day20Kt$part2$1();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class Day20Kt\n 4: ldc #13 // String part2Converter\n 6: ldc #15 // String part2Converter(Ljava/lang/String;)J\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.Long invoke(java.lang.String);\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_1\n 7: invokestatic #34 // Method Day20Kt.access$part2Converter:(Ljava/lang/String;)J\n 10: invokestatic #40 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 13: areturn\n\n public java.lang.Object invoke(java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: checkcast #44 // class java/lang/String\n 5: invokevirtual #46 // Method invoke:(Ljava/lang/String;)Ljava/lang/Long;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class Day20Kt$part2$1\n 3: dup\n 4: invokespecial #51 // Method \"<init>\":()V\n 7: putstatic #54 // Field INSTANCE:LDay20Kt$part2$1;\n 10: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day25.kt
fun main() { val testInput = readInput("Day25_test") check(part1(testInput) == "2=-1=0") val input = readInput("Day25") println(part1(input)) } private fun part1(input: List<String>): String { val sum = input.sumOf(String::SNAFUToInt) return sum.toSNAFU() } private fun String.SNAFUToInt(): Long { var result = 0L var pow = 1L for (i in this.lastIndex downTo 0) { result += when (this[i]) { '-' -> -pow '=' -> -2L * pow else -> this[i].digitToInt() * pow } pow *= 5L } return result } private fun Long.toSNAFU(): String { var tmp = this var result = "" while (tmp != 0L) { val rem = tmp % 5L tmp /= 5L if (rem <= 2) { result = rem.toString() + result } else { ++tmp result = when (rem) { 3L -> "=" 4L -> "-" else -> error(Unit) } + result } } return result }
[ { "class_path": "Kvest__AOC2022__6409e65/Day25Kt.class", "javap": "Compiled from \"Day25.kt\"\npublic final class Day25Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day25_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;)Ljava/lang/String;\n 10: ldc #20 // String 2=-1=0\n 12: invokestatic #26 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 15: ifne 28\n 18: new #28 // class java/lang/IllegalStateException\n 21: dup\n 22: ldc #30 // String Check failed.\n 24: invokespecial #34 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 27: athrow\n 28: ldc #36 // String Day25\n 30: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 33: astore_1\n 34: aload_1\n 35: invokestatic #18 // Method part1:(Ljava/util/List;)Ljava/lang/String;\n 38: getstatic #42 // Field java/lang/System.out:Ljava/io/PrintStream;\n 41: swap\n 42: invokevirtual #48 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 45: return\n\n private static final java.lang.String part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #56 // class java/lang/Iterable\n 4: astore_3\n 5: lconst_0\n 6: lstore 4\n 8: aload_3\n 9: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 14: astore 6\n 16: aload 6\n 18: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 23: ifeq 66\n 26: aload 6\n 28: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 33: astore 7\n 35: lload 4\n 37: aload 7\n 39: checkcast #72 // class java/lang/String\n 42: astore 8\n 44: lstore 10\n 46: iconst_0\n 47: istore 9\n 49: aload 8\n 51: invokestatic #76 // Method SNAFUToInt:(Ljava/lang/String;)J\n 54: lstore 12\n 56: lload 10\n 58: lload 12\n 60: ladd\n 61: lstore 4\n 63: goto 16\n 66: lload 4\n 68: lstore_1\n 69: lload_1\n 70: invokestatic #80 // Method toSNAFU:(J)Ljava/lang/String;\n 73: areturn\n\n private static final long SNAFUToInt(java.lang.String);\n Code:\n 0: lconst_0\n 1: lstore_1\n 2: lconst_1\n 3: lstore_3\n 4: aload_0\n 5: checkcast #88 // class java/lang/CharSequence\n 8: invokestatic #94 // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I\n 11: istore 5\n 13: iconst_m1\n 14: iload 5\n 16: if_icmpge 91\n 19: lload_1\n 20: aload_0\n 21: iload 5\n 23: invokevirtual #98 // Method java/lang/String.charAt:(I)C\n 26: lookupswitch { // 2\n 45: 52\n 61: 57\n default: 65\n }\n 52: lload_3\n 53: lneg\n 54: goto 77\n 57: ldc2_w #99 // long -2l\n 60: lload_3\n 61: lmul\n 62: goto 77\n 65: aload_0\n 66: iload 5\n 68: invokevirtual #98 // Method java/lang/String.charAt:(I)C\n 71: invokestatic #106 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 74: i2l\n 75: lload_3\n 76: lmul\n 77: ladd\n 78: lstore_1\n 79: lload_3\n 80: ldc2_w #107 // long 5l\n 83: lmul\n 84: lstore_3\n 85: iinc 5, -1\n 88: goto 13\n 91: lload_1\n 92: lreturn\n\n private static final java.lang.String toSNAFU(long);\n Code:\n 0: lload_0\n 1: lstore_2\n 2: ldc #114 // String\n 4: astore 4\n 6: lload_2\n 7: lconst_0\n 8: lcmp\n 9: ifeq 132\n 12: lload_2\n 13: ldc2_w #107 // long 5l\n 16: lrem\n 17: lstore 5\n 19: lload_2\n 20: ldc2_w #107 // long 5l\n 23: ldiv\n 24: lstore_2\n 25: lload 5\n 27: ldc2_w #115 // long 2l\n 30: lcmp\n 31: ifgt 59\n 34: new #118 // class java/lang/StringBuilder\n 37: dup\n 38: invokespecial #120 // Method java/lang/StringBuilder.\"<init>\":()V\n 41: lload 5\n 43: invokevirtual #124 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 46: aload 4\n 48: invokevirtual #127 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: invokevirtual #131 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 54: astore 4\n 56: goto 6\n 59: lload_2\n 60: lconst_1\n 61: ladd\n 62: lstore_2\n 63: new #118 // class java/lang/StringBuilder\n 66: dup\n 67: invokespecial #120 // Method java/lang/StringBuilder.\"<init>\":()V\n 70: lload 5\n 72: lstore 7\n 74: lload 7\n 76: ldc2_w #132 // long 3l\n 79: lcmp\n 80: ifne 88\n 83: ldc #135 // String =\n 85: goto 116\n 88: lload 7\n 90: ldc2_w #136 // long 4l\n 93: lcmp\n 94: ifne 102\n 97: ldc #139 // String -\n 99: goto 116\n 102: new #28 // class java/lang/IllegalStateException\n 105: dup\n 106: getstatic #145 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 109: invokevirtual #146 // Method java/lang/Object.toString:()Ljava/lang/String;\n 112: invokespecial #34 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 115: athrow\n 116: invokevirtual #127 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 119: aload 4\n 121: invokevirtual #127 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 124: invokevirtual #131 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 127: astore 4\n 129: goto 6\n 132: aload 4\n 134: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #152 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day13.kt
fun main() { val testInput = readInput("Day13_test") check(part1(testInput) == 13) check(part2(testInput) == 140) val input = readInput("Day13") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { return input.windowed(size = 2, step = 3) .map { list -> list.map { it.parseList() } } .mapIndexed { index, (first, second) -> if (checkOrder(first.values, second.values) == Order.RIGHT) index + 1 else 0 } .sum() } private fun part2(input: List<String>): Int { val dividerPackets = listOf( "[[2]]".parseList(), "[[6]]".parseList(), ) val originalPackets = input .filter { it.isNotEmpty() } .map(String::parseList) return (originalPackets + dividerPackets) .sortedWith(ListValueComparator) .mapIndexed { index, listValue -> if (listValue in dividerPackets) index + 1 else 1 } .reduce { acc, value -> acc * value } } private object ListValueComparator : Comparator<ListValue> { override fun compare(left: ListValue, right: ListValue): Int = checkOrder(left.values, right.values).value } private fun String.parseList( fromIndex: Int = 0, finishedIndex: IntArray = intArrayOf(fromIndex) ): ListValue { check(this[fromIndex] == '[') { "This is not start of the list" } var current = fromIndex + 1 val result = mutableListOf<Value>() while (current <= this.lastIndex) { when (this[current]) { ',' -> ++current ']' -> break '[' -> { val nested = this.parseList(current, finishedIndex) result.add(nested) current = finishedIndex[0] + 1 } else -> { val to = this.indexOfAny(chars = charArrayOf(',', ']'), startIndex = current) val intValue = this.substring(current, to).toInt() result.add(IntValue(intValue)) current = if (this[to] == ',') { to + 1 } else { to } } } } finishedIndex[0] = current return ListValue(result) } private fun checkOrder(left: List<Value>, right: List<Value>): Order { for (i in left.indices) { if (i > right.lastIndex) { return Order.WRONG } val leftItem = left[i] val rightItem = right[i] if (leftItem is IntValue && rightItem is IntValue) { if (leftItem.value < rightItem.value) return Order.RIGHT if (leftItem.value > rightItem.value) return Order.WRONG } else { val result = checkOrder( left = if (leftItem is ListValue) leftItem.values else listOf(leftItem), right = if (rightItem is ListValue) rightItem.values else listOf(rightItem) ) if (result != Order.UNKNOWN) return result } } return if (left.size < right.size) Order.RIGHT else Order.UNKNOWN } private sealed interface Value private class IntValue(val value: Int) : Value private class ListValue(val values: List<Value>) : Value private enum class Order(val value: Int) { UNKNOWN(0), RIGHT(-1), WRONG(1) }
[ { "class_path": "Kvest__AOC2022__6409e65/Day13Kt.class", "javap": "Compiled from \"Day13.kt\"\npublic final class Day13Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day13_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: bipush 13\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 33\n 23: new #20 // class java/lang/IllegalStateException\n 26: dup\n 27: ldc #22 // String Check failed.\n 29: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 32: athrow\n 33: aload_0\n 34: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 37: sipush 140\n 40: if_icmpne 47\n 43: iconst_1\n 44: goto 48\n 47: iconst_0\n 48: ifne 61\n 51: new #20 // class java/lang/IllegalStateException\n 54: dup\n 55: ldc #22 // String Check failed.\n 57: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 60: athrow\n 61: ldc #31 // String Day13\n 63: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 66: astore_1\n 67: aload_1\n 68: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 71: istore_2\n 72: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 75: iload_2\n 76: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 79: aload_1\n 80: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 83: istore_2\n 84: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 87: iload_2\n 88: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 91: return\n\n private static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #51 // class java/lang/Iterable\n 4: iconst_2\n 5: iconst_3\n 6: iconst_0\n 7: iconst_4\n 8: aconst_null\n 9: invokestatic #57 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;\n 12: checkcast #51 // 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 #59 // class java/util/ArrayList\n 24: dup\n 25: aload_1\n 26: bipush 10\n 28: invokestatic #63 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 31: invokespecial #65 // Method java/util/ArrayList.\"<init>\":(I)V\n 34: checkcast #67 // class java/util/Collection\n 37: astore 4\n 39: iconst_0\n 40: istore 5\n 42: aload_3\n 43: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 48: astore 6\n 50: aload 6\n 52: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 57: ifeq 201\n 60: aload 6\n 62: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 67: astore 7\n 69: aload 4\n 71: aload 7\n 73: checkcast #48 // class java/util/List\n 76: astore 8\n 78: astore 20\n 80: iconst_0\n 81: istore 9\n 83: aload 8\n 85: checkcast #51 // class java/lang/Iterable\n 88: astore 10\n 90: iconst_0\n 91: istore 11\n 93: aload 10\n 95: astore 12\n 97: new #59 // class java/util/ArrayList\n 100: dup\n 101: aload 10\n 103: bipush 10\n 105: invokestatic #63 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 108: invokespecial #65 // Method java/util/ArrayList.\"<init>\":(I)V\n 111: checkcast #67 // class java/util/Collection\n 114: astore 13\n 116: iconst_0\n 117: istore 14\n 119: aload 12\n 121: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 126: astore 15\n 128: aload 15\n 130: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 135: ifeq 182\n 138: aload 15\n 140: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 145: astore 16\n 147: aload 13\n 149: aload 16\n 151: checkcast #83 // class java/lang/String\n 154: astore 17\n 156: astore 18\n 158: iconst_0\n 159: istore 19\n 161: aload 17\n 163: iconst_0\n 164: aconst_null\n 165: iconst_3\n 166: aconst_null\n 167: invokestatic #87 // Method parseList$default:(Ljava/lang/String;I[IILjava/lang/Object;)LListValue;\n 170: aload 18\n 172: swap\n 173: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 178: pop\n 179: goto 128\n 182: aload 13\n 184: checkcast #48 // class java/util/List\n 187: nop\n 188: nop\n 189: aload 20\n 191: swap\n 192: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 197: pop\n 198: goto 50\n 201: aload 4\n 203: checkcast #48 // class java/util/List\n 206: nop\n 207: checkcast #51 // class java/lang/Iterable\n 210: astore_1\n 211: nop\n 212: iconst_0\n 213: istore_2\n 214: aload_1\n 215: astore_3\n 216: new #59 // class java/util/ArrayList\n 219: dup\n 220: aload_1\n 221: bipush 10\n 223: invokestatic #63 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 226: invokespecial #65 // Method java/util/ArrayList.\"<init>\":(I)V\n 229: checkcast #67 // class java/util/Collection\n 232: astore 4\n 234: iconst_0\n 235: istore 5\n 237: iconst_0\n 238: istore 6\n 240: aload_3\n 241: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 246: astore 7\n 248: aload 7\n 250: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 255: ifeq 368\n 258: aload 7\n 260: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 265: astore 8\n 267: aload 4\n 269: iload 6\n 271: iinc 6, 1\n 274: istore 9\n 276: iload 9\n 278: ifge 284\n 281: invokestatic #94 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 284: iload 9\n 286: aload 8\n 288: checkcast #48 // class java/util/List\n 291: astore 10\n 293: istore 11\n 295: astore 20\n 297: iconst_0\n 298: istore 12\n 300: aload 10\n 302: iconst_0\n 303: invokeinterface #98, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 308: checkcast #100 // class ListValue\n 311: astore 13\n 313: aload 10\n 315: iconst_1\n 316: invokeinterface #98, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 321: checkcast #100 // class ListValue\n 324: astore 14\n 326: aload 13\n 328: invokevirtual #104 // Method ListValue.getValues:()Ljava/util/List;\n 331: aload 14\n 333: invokevirtual #104 // Method ListValue.getValues:()Ljava/util/List;\n 336: invokestatic #108 // Method checkOrder:(Ljava/util/List;Ljava/util/List;)LOrder;\n 339: getstatic #114 // Field Order.RIGHT:LOrder;\n 342: if_acmpne 352\n 345: iload 11\n 347: iconst_1\n 348: iadd\n 349: goto 353\n 352: iconst_0\n 353: invokestatic #120 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 356: aload 20\n 358: swap\n 359: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 364: pop\n 365: goto 248\n 368: aload 4\n 370: checkcast #48 // class java/util/List\n 373: nop\n 374: checkcast #51 // class java/lang/Iterable\n 377: invokestatic #124 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 380: ireturn\n\n private static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: iconst_2\n 1: anewarray #100 // class ListValue\n 4: astore_2\n 5: aload_2\n 6: iconst_0\n 7: ldc #151 // String [[2]]\n 9: iconst_0\n 10: aconst_null\n 11: iconst_3\n 12: aconst_null\n 13: invokestatic #87 // Method parseList$default:(Ljava/lang/String;I[IILjava/lang/Object;)LListValue;\n 16: aastore\n 17: aload_2\n 18: iconst_1\n 19: ldc #153 // String [[6]]\n 21: iconst_0\n 22: aconst_null\n 23: iconst_3\n 24: aconst_null\n 25: invokestatic #87 // Method parseList$default:(Ljava/lang/String;I[IILjava/lang/Object;)LListValue;\n 28: aastore\n 29: aload_2\n 30: invokestatic #157 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 33: astore_1\n 34: aload_0\n 35: checkcast #51 // class java/lang/Iterable\n 38: astore_3\n 39: nop\n 40: iconst_0\n 41: istore 4\n 43: aload_3\n 44: astore 5\n 46: new #59 // class java/util/ArrayList\n 49: dup\n 50: invokespecial #159 // Method java/util/ArrayList.\"<init>\":()V\n 53: checkcast #67 // class java/util/Collection\n 56: astore 6\n 58: iconst_0\n 59: istore 7\n 61: aload 5\n 63: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 68: astore 8\n 70: aload 8\n 72: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 77: ifeq 134\n 80: aload 8\n 82: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 87: astore 9\n 89: aload 9\n 91: checkcast #83 // class java/lang/String\n 94: astore 10\n 96: iconst_0\n 97: istore 11\n 99: aload 10\n 101: checkcast #161 // class java/lang/CharSequence\n 104: invokeinterface #165, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 109: ifle 116\n 112: iconst_1\n 113: goto 117\n 116: iconst_0\n 117: nop\n 118: ifeq 70\n 121: aload 6\n 123: aload 9\n 125: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 130: pop\n 131: goto 70\n 134: aload 6\n 136: checkcast #48 // class java/util/List\n 139: nop\n 140: checkcast #51 // class java/lang/Iterable\n 143: astore_3\n 144: nop\n 145: iconst_0\n 146: istore 4\n 148: aload_3\n 149: astore 5\n 151: new #59 // class java/util/ArrayList\n 154: dup\n 155: aload_3\n 156: bipush 10\n 158: invokestatic #63 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 161: invokespecial #65 // Method java/util/ArrayList.\"<init>\":(I)V\n 164: checkcast #67 // class java/util/Collection\n 167: astore 6\n 169: iconst_0\n 170: istore 7\n 172: aload 5\n 174: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 179: astore 8\n 181: aload 8\n 183: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 188: ifeq 235\n 191: aload 8\n 193: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 198: astore 9\n 200: aload 6\n 202: aload 9\n 204: checkcast #83 // class java/lang/String\n 207: astore 10\n 209: astore 15\n 211: iconst_0\n 212: istore 11\n 214: aload 10\n 216: iconst_0\n 217: aconst_null\n 218: iconst_3\n 219: aconst_null\n 220: invokestatic #87 // Method parseList$default:(Ljava/lang/String;I[IILjava/lang/Object;)LListValue;\n 223: aload 15\n 225: swap\n 226: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 231: pop\n 232: goto 181\n 235: aload 6\n 237: checkcast #48 // class java/util/List\n 240: nop\n 241: astore_2\n 242: aload_2\n 243: checkcast #67 // class java/util/Collection\n 246: aload_1\n 247: checkcast #51 // class java/lang/Iterable\n 250: invokestatic #169 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 253: checkcast #51 // class java/lang/Iterable\n 256: getstatic #175 // Field ListValueComparator.INSTANCE:LListValueComparator;\n 259: checkcast #177 // class java/util/Comparator\n 262: invokestatic #181 // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;\n 265: checkcast #51 // class java/lang/Iterable\n 268: astore_3\n 269: nop\n 270: iconst_0\n 271: istore 4\n 273: aload_3\n 274: astore 5\n 276: new #59 // class java/util/ArrayList\n 279: dup\n 280: aload_3\n 281: bipush 10\n 283: invokestatic #63 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 286: invokespecial #65 // Method java/util/ArrayList.\"<init>\":(I)V\n 289: checkcast #67 // class java/util/Collection\n 292: astore 6\n 294: iconst_0\n 295: istore 7\n 297: iconst_0\n 298: istore 8\n 300: aload 5\n 302: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 307: astore 9\n 309: aload 9\n 311: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 316: ifeq 395\n 319: aload 9\n 321: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 326: astore 10\n 328: aload 6\n 330: iload 8\n 332: iinc 8, 1\n 335: istore 11\n 337: iload 11\n 339: ifge 345\n 342: invokestatic #94 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 345: iload 11\n 347: aload 10\n 349: checkcast #100 // class ListValue\n 352: astore 12\n 354: istore 13\n 356: astore 15\n 358: iconst_0\n 359: istore 14\n 361: aload_1\n 362: aload 12\n 364: invokeinterface #184, 2 // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z\n 369: ifeq 379\n 372: iload 13\n 374: iconst_1\n 375: iadd\n 376: goto 380\n 379: iconst_1\n 380: invokestatic #120 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 383: aload 15\n 385: swap\n 386: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 391: pop\n 392: goto 309\n 395: aload 6\n 397: checkcast #48 // class java/util/List\n 400: nop\n 401: checkcast #51 // class java/lang/Iterable\n 404: astore_3\n 405: nop\n 406: iconst_0\n 407: istore 4\n 409: aload_3\n 410: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 415: astore 5\n 417: aload 5\n 419: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 424: ifne 437\n 427: new #186 // class java/lang/UnsupportedOperationException\n 430: dup\n 431: ldc #188 // String Empty collection can\\'t be reduced.\n 433: invokespecial #189 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 436: athrow\n 437: aload 5\n 439: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 444: astore 6\n 446: aload 5\n 448: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 453: ifeq 497\n 456: aload 6\n 458: aload 5\n 460: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 465: checkcast #191 // class java/lang/Number\n 468: invokevirtual #194 // Method java/lang/Number.intValue:()I\n 471: istore 7\n 473: checkcast #191 // class java/lang/Number\n 476: invokevirtual #194 // Method java/lang/Number.intValue:()I\n 479: istore 8\n 481: iconst_0\n 482: istore 9\n 484: iload 8\n 486: iload 7\n 488: imul\n 489: invokestatic #120 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 492: astore 6\n 494: goto 446\n 497: aload 6\n 499: checkcast #191 // class java/lang/Number\n 502: invokevirtual #194 // Method java/lang/Number.intValue:()I\n 505: ireturn\n\n private static final ListValue parseList(java.lang.String, int, int[]);\n Code:\n 0: aload_0\n 1: iload_1\n 2: invokevirtual #222 // Method java/lang/String.charAt:(I)C\n 5: bipush 91\n 7: if_icmpne 14\n 10: iconst_1\n 11: goto 15\n 14: iconst_0\n 15: ifne 38\n 18: iconst_0\n 19: istore 4\n 21: ldc #224 // String This is not start of the list\n 23: astore 4\n 25: new #20 // class java/lang/IllegalStateException\n 28: dup\n 29: aload 4\n 31: invokevirtual #228 // Method java/lang/Object.toString:()Ljava/lang/String;\n 34: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 37: athrow\n 38: iload_1\n 39: iconst_1\n 40: iadd\n 41: istore_3\n 42: new #59 // class java/util/ArrayList\n 45: dup\n 46: invokespecial #159 // Method java/util/ArrayList.\"<init>\":()V\n 49: checkcast #48 // class java/util/List\n 52: astore 4\n 54: iload_3\n 55: aload_0\n 56: checkcast #161 // class java/lang/CharSequence\n 59: invokestatic #234 // Method kotlin/text/StringsKt.getLastIndex:(Ljava/lang/CharSequence;)I\n 62: if_icmpgt 234\n 65: aload_0\n 66: iload_3\n 67: invokevirtual #222 // Method java/lang/String.charAt:(I)C\n 70: lookupswitch { // 3\n 44: 104\n 91: 115\n 93: 112\n default: 142\n }\n 104: iinc 3, 1\n 107: iload_3\n 108: pop\n 109: goto 54\n 112: goto 234\n 115: aload_0\n 116: iload_3\n 117: aload_2\n 118: invokestatic #236 // Method parseList:(Ljava/lang/String;I[I)LListValue;\n 121: astore 5\n 123: aload 4\n 125: aload 5\n 127: invokeinterface #237, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 132: pop\n 133: aload_2\n 134: iconst_0\n 135: iaload\n 136: iconst_1\n 137: iadd\n 138: istore_3\n 139: goto 54\n 142: aload_0\n 143: checkcast #161 // class java/lang/CharSequence\n 146: iconst_2\n 147: newarray char\n 149: astore 6\n 151: aload 6\n 153: iconst_0\n 154: bipush 44\n 156: castore\n 157: aload 6\n 159: iconst_1\n 160: bipush 93\n 162: castore\n 163: aload 6\n 165: iload_3\n 166: iconst_0\n 167: iconst_4\n 168: aconst_null\n 169: invokestatic #241 // Method kotlin/text/StringsKt.indexOfAny$default:(Ljava/lang/CharSequence;[CIZILjava/lang/Object;)I\n 172: istore 5\n 174: nop\n 175: aload_0\n 176: iload_3\n 177: iload 5\n 179: invokevirtual #245 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 182: dup\n 183: ldc #247 // String substring(...)\n 185: invokestatic #253 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 188: invokestatic #257 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 191: istore 6\n 193: aload 4\n 195: new #259 // class IntValue\n 198: dup\n 199: iload 6\n 201: invokespecial #260 // Method IntValue.\"<init>\":(I)V\n 204: invokeinterface #237, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 209: pop\n 210: aload_0\n 211: iload 5\n 213: invokevirtual #222 // Method java/lang/String.charAt:(I)C\n 216: bipush 44\n 218: if_icmpne 228\n 221: iload 5\n 223: iconst_1\n 224: iadd\n 225: goto 230\n 228: iload 5\n 230: istore_3\n 231: goto 54\n 234: aload_2\n 235: iconst_0\n 236: iload_3\n 237: iastore\n 238: new #100 // class ListValue\n 241: dup\n 242: aload 4\n 244: invokespecial #263 // Method ListValue.\"<init>\":(Ljava/util/List;)V\n 247: areturn\n\n static ListValue parseList$default(java.lang.String, int, int[], int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 8\n 6: iconst_0\n 7: istore_1\n 8: iload_3\n 9: iconst_2\n 10: iand\n 11: ifeq 27\n 14: iconst_1\n 15: newarray int\n 17: astore 5\n 19: aload 5\n 21: iconst_0\n 22: iload_1\n 23: iastore\n 24: aload 5\n 26: astore_2\n 27: aload_0\n 28: iload_1\n 29: aload_2\n 30: invokestatic #236 // Method parseList:(Ljava/lang/String;I[I)LListValue;\n 33: areturn\n\n private static final Order checkOrder(java.util.List<? extends Value>, java.util.List<? extends Value>);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: aload_0\n 3: checkcast #67 // class java/util/Collection\n 6: invokeinterface #276, 1 // InterfaceMethod java/util/Collection.size:()I\n 11: istore_3\n 12: iload_2\n 13: iload_3\n 14: if_icmpge 185\n 17: iload_2\n 18: aload_1\n 19: invokestatic #278 // Method kotlin/collections/CollectionsKt.getLastIndex:(Ljava/util/List;)I\n 22: if_icmple 29\n 25: getstatic #281 // Field Order.WRONG:LOrder;\n 28: areturn\n 29: aload_0\n 30: iload_2\n 31: invokeinterface #98, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 36: checkcast #283 // class Value\n 39: astore 4\n 41: aload_1\n 42: iload_2\n 43: invokeinterface #98, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 48: checkcast #283 // class Value\n 51: astore 5\n 53: aload 4\n 55: instanceof #259 // class IntValue\n 58: ifeq 115\n 61: aload 5\n 63: instanceof #259 // class IntValue\n 66: ifeq 115\n 69: aload 4\n 71: checkcast #259 // class IntValue\n 74: invokevirtual #286 // Method IntValue.getValue:()I\n 77: aload 5\n 79: checkcast #259 // class IntValue\n 82: invokevirtual #286 // Method IntValue.getValue:()I\n 85: if_icmpge 92\n 88: getstatic #114 // Field Order.RIGHT:LOrder;\n 91: areturn\n 92: aload 4\n 94: checkcast #259 // class IntValue\n 97: invokevirtual #286 // Method IntValue.getValue:()I\n 100: aload 5\n 102: checkcast #259 // class IntValue\n 105: invokevirtual #286 // Method IntValue.getValue:()I\n 108: if_icmple 179\n 111: getstatic #281 // Field Order.WRONG:LOrder;\n 114: areturn\n 115: aload 4\n 117: instanceof #100 // class ListValue\n 120: ifeq 134\n 123: aload 4\n 125: checkcast #100 // class ListValue\n 128: invokevirtual #104 // Method ListValue.getValues:()Ljava/util/List;\n 131: goto 139\n 134: aload 4\n 136: invokestatic #289 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 139: aload 5\n 141: instanceof #100 // class ListValue\n 144: ifeq 158\n 147: aload 5\n 149: checkcast #100 // class ListValue\n 152: invokevirtual #104 // Method ListValue.getValues:()Ljava/util/List;\n 155: goto 163\n 158: aload 5\n 160: invokestatic #289 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 163: invokestatic #108 // Method checkOrder:(Ljava/util/List;Ljava/util/List;)LOrder;\n 166: astore 6\n 168: aload 6\n 170: getstatic #292 // Field Order.UNKNOWN:LOrder;\n 173: if_acmpeq 179\n 176: aload 6\n 178: areturn\n 179: iinc 2, 1\n 182: goto 12\n 185: aload_0\n 186: invokeinterface #293, 1 // InterfaceMethod java/util/List.size:()I\n 191: aload_1\n 192: invokeinterface #293, 1 // InterfaceMethod java/util/List.size:()I\n 197: if_icmpge 206\n 200: getstatic #114 // Field Order.RIGHT:LOrder;\n 203: goto 209\n 206: getstatic #292 // Field Order.UNKNOWN:LOrder;\n 209: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #302 // Method main:()V\n 3: return\n\n public static final Order access$checkOrder(java.util.List, java.util.List);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #108 // Method checkOrder:(Ljava/util/List;Ljava/util/List;)LOrder;\n 5: areturn\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day03.kt
fun main() { val testInput = readInput("Day03_test") check(part1(testInput) == 157) check(part2(testInput) == 70) val input = readInput("Day03") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { return input.sumOf(::calculatePriority) } private fun part2(input: List<String>): Int { return input .chunked(3) { group -> commonPriority(group[0], group[1], group[2]) } .sum() } private fun calculatePriority(row: String): Int { val second = row.takeLast(row.length / 2).toSet() row.forEach { ch -> if (ch in second) { return ch.toPriority() } } error("Not found") } private fun commonPriority(first: String, second: String, third: String): Int { val secondSet = second.toSet() val thirdSet = third.toSet() first.forEach { ch -> if (ch in secondSet && ch in thirdSet) { return ch.toPriority() } } error("Not found") } private fun Char.toPriority(): Int { return if (this.isLowerCase()) { 1 + code - 'a'.code } else { 27 + code - 'A'.code } }
[ { "class_path": "Kvest__AOC2022__6409e65/Day03Kt.class", "javap": "Compiled from \"Day03.kt\"\npublic final class Day03Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day03_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: sipush 157\n 13: if_icmpne 20\n 16: iconst_1\n 17: goto 21\n 20: iconst_0\n 21: ifne 34\n 24: new #20 // class java/lang/IllegalStateException\n 27: dup\n 28: ldc #22 // String Check failed.\n 30: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 33: athrow\n 34: aload_0\n 35: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 38: bipush 70\n 40: if_icmpne 47\n 43: iconst_1\n 44: goto 48\n 47: iconst_0\n 48: ifne 61\n 51: new #20 // class java/lang/IllegalStateException\n 54: dup\n 55: ldc #22 // String Check failed.\n 57: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 60: athrow\n 61: ldc #31 // String Day03\n 63: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 66: astore_1\n 67: aload_1\n 68: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 71: istore_2\n 72: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 75: iload_2\n 76: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 79: aload_1\n 80: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 83: istore_2\n 84: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 87: iload_2\n 88: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 91: return\n\n private static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #51 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 60\n 23: aload_3\n 24: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 29: astore 4\n 31: iload_2\n 32: aload 4\n 34: checkcast #67 // class java/lang/String\n 37: astore 5\n 39: istore 7\n 41: iconst_0\n 42: istore 6\n 44: aload 5\n 46: invokestatic #71 // Method calculatePriority:(Ljava/lang/String;)I\n 49: istore 8\n 51: iload 7\n 53: iload 8\n 55: iadd\n 56: istore_2\n 57: goto 14\n 60: iload_2\n 61: ireturn\n\n private static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #51 // class java/lang/Iterable\n 4: iconst_3\n 5: invokedynamic #94, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 10: invokestatic #100 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;ILkotlin/jvm/functions/Function1;)Ljava/util/List;\n 13: checkcast #51 // class java/lang/Iterable\n 16: invokestatic #104 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 19: ireturn\n\n private static final int calculatePriority(java.lang.String);\n Code:\n 0: aload_0\n 1: aload_0\n 2: invokevirtual #108 // Method java/lang/String.length:()I\n 5: iconst_2\n 6: idiv\n 7: invokestatic #114 // Method kotlin/text/StringsKt.takeLast:(Ljava/lang/String;I)Ljava/lang/String;\n 10: checkcast #116 // class java/lang/CharSequence\n 13: invokestatic #120 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 16: astore_1\n 17: aload_0\n 18: checkcast #116 // class java/lang/CharSequence\n 21: astore_2\n 22: iconst_0\n 23: istore_3\n 24: iconst_0\n 25: istore 4\n 27: iload 4\n 29: aload_2\n 30: invokeinterface #121, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 35: if_icmpge 83\n 38: aload_2\n 39: iload 4\n 41: invokeinterface #125, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 46: istore 5\n 48: iload 5\n 50: istore 6\n 52: iconst_0\n 53: istore 7\n 55: aload_1\n 56: iload 6\n 58: invokestatic #131 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 61: invokeinterface #137, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 66: ifeq 75\n 69: iload 6\n 71: invokestatic #141 // Method toPriority:(C)I\n 74: ireturn\n 75: nop\n 76: nop\n 77: iinc 4, 1\n 80: goto 27\n 83: nop\n 84: new #20 // class java/lang/IllegalStateException\n 87: dup\n 88: ldc #143 // String Not found\n 90: invokevirtual #147 // Method java/lang/Object.toString:()Ljava/lang/String;\n 93: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 96: athrow\n\n private static final int commonPriority(java.lang.String, java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #116 // class java/lang/CharSequence\n 4: invokestatic #120 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 7: astore_3\n 8: aload_2\n 9: checkcast #116 // class java/lang/CharSequence\n 12: invokestatic #120 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 15: astore 4\n 17: aload_0\n 18: checkcast #116 // class java/lang/CharSequence\n 21: astore 5\n 23: iconst_0\n 24: istore 6\n 26: iconst_0\n 27: istore 7\n 29: iload 7\n 31: aload 5\n 33: invokeinterface #121, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 38: if_icmpge 102\n 41: aload 5\n 43: iload 7\n 45: invokeinterface #125, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 50: istore 8\n 52: iload 8\n 54: istore 9\n 56: iconst_0\n 57: istore 10\n 59: aload_3\n 60: iload 9\n 62: invokestatic #131 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 65: invokeinterface #137, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 70: ifeq 94\n 73: aload 4\n 75: iload 9\n 77: invokestatic #131 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 80: invokeinterface #137, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 85: ifeq 94\n 88: iload 9\n 90: invokestatic #141 // Method toPriority:(C)I\n 93: ireturn\n 94: nop\n 95: nop\n 96: iinc 7, 1\n 99: goto 29\n 102: nop\n 103: new #20 // class java/lang/IllegalStateException\n 106: dup\n 107: ldc #143 // String Not found\n 109: invokevirtual #147 // Method java/lang/Object.toString:()Ljava/lang/String;\n 112: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 115: athrow\n\n private static final int toPriority(char);\n Code:\n 0: iload_0\n 1: invokestatic #168 // Method java/lang/Character.isLowerCase:(C)Z\n 4: ifeq 16\n 7: iconst_1\n 8: iload_0\n 9: iadd\n 10: bipush 97\n 12: isub\n 13: goto 23\n 16: bipush 27\n 18: iload_0\n 19: iadd\n 20: bipush 65\n 22: isub\n 23: 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 int part2$lambda$0(java.util.List);\n Code:\n 0: aload_0\n 1: ldc #176 // String group\n 3: invokestatic #182 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iconst_0\n 8: invokeinterface #186, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 13: checkcast #67 // class java/lang/String\n 16: aload_0\n 17: iconst_1\n 18: invokeinterface #186, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 23: checkcast #67 // class java/lang/String\n 26: aload_0\n 27: iconst_2\n 28: invokeinterface #186, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 33: checkcast #67 // class java/lang/String\n 36: invokestatic #188 // Method commonPriority:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I\n 39: ireturn\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day02.kt
fun main() { val testInput = readInput("Day02_test") check(part1(testInput) == 15) check(part2(testInput) == 12) val input = readInput("Day02") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { return input.sumOf(String::toScore) } private fun part2(input: List<String>): Int { return input .map(String::correctMove) .sumOf(String::toScore) } private val SCORES = mapOf( "AX" to 4, "AY" to 8, "AZ" to 3, "BX" to 1, "BY" to 5, "BZ" to 9, "CX" to 7, "CY" to 2, "CZ" to 6, ) private fun String.toScore(): Int { return SCORES.getValue("${this[0]}${this[2]}") } private val CORRECTIONS = mapOf( "AX" to "A Z", "AY" to "A X", "AZ" to "A Y", "BX" to "B X", "BY" to "B Y", "BZ" to "B Z", "CX" to "C Y", "CY" to "C Z", "CZ" to "C X", ) private fun String.correctMove(): String { return CORRECTIONS.getValue("${this[0]}${this[2]}") }
[ { "class_path": "Kvest__AOC2022__6409e65/Day02Kt.class", "javap": "Compiled from \"Day02.kt\"\npublic final class Day02Kt {\n private static final java.util.Map<java.lang.String, java.lang.Integer> SCORES;\n\n private static final java.util.Map<java.lang.String, java.lang.String> CORRECTIONS;\n\n public static final void main();\n Code:\n 0: ldc #8 // String Day02_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: bipush 15\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 33\n 23: new #20 // class java/lang/IllegalStateException\n 26: dup\n 27: ldc #22 // String Check failed.\n 29: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 32: athrow\n 33: aload_0\n 34: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 37: bipush 12\n 39: if_icmpne 46\n 42: iconst_1\n 43: goto 47\n 46: iconst_0\n 47: ifne 60\n 50: new #20 // class java/lang/IllegalStateException\n 53: dup\n 54: ldc #22 // String Check failed.\n 56: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 59: athrow\n 60: ldc #31 // String Day02\n 62: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 65: astore_1\n 66: aload_1\n 67: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 70: istore_2\n 71: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 74: iload_2\n 75: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 78: aload_1\n 79: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 82: istore_2\n 83: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 86: iload_2\n 87: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 90: return\n\n private static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #51 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 60\n 23: aload_3\n 24: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 29: astore 4\n 31: iload_2\n 32: aload 4\n 34: checkcast #67 // class java/lang/String\n 37: astore 5\n 39: istore 7\n 41: iconst_0\n 42: istore 6\n 44: aload 5\n 46: invokestatic #71 // Method toScore:(Ljava/lang/String;)I\n 49: istore 8\n 51: iload 7\n 53: iload 8\n 55: iadd\n 56: istore_2\n 57: goto 14\n 60: iload_2\n 61: ireturn\n\n private static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #51 // class java/lang/Iterable\n 4: astore_1\n 5: nop\n 6: iconst_0\n 7: istore_2\n 8: aload_1\n 9: astore_3\n 10: new #77 // class java/util/ArrayList\n 13: dup\n 14: aload_1\n 15: bipush 10\n 17: invokestatic #83 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #85 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #87 // class java/util/Collection\n 26: astore 4\n 28: iconst_0\n 29: istore 5\n 31: aload_3\n 32: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 37: astore 6\n 39: aload 6\n 41: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 46: ifeq 89\n 49: aload 6\n 51: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 56: astore 7\n 58: aload 4\n 60: aload 7\n 62: checkcast #67 // class java/lang/String\n 65: astore 8\n 67: astore 10\n 69: iconst_0\n 70: istore 9\n 72: aload 8\n 74: invokestatic #91 // Method correctMove:(Ljava/lang/String;)Ljava/lang/String;\n 77: aload 10\n 79: swap\n 80: invokeinterface #95, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 85: pop\n 86: goto 39\n 89: aload 4\n 91: checkcast #48 // class java/util/List\n 94: nop\n 95: checkcast #51 // class java/lang/Iterable\n 98: astore_1\n 99: iconst_0\n 100: istore_2\n 101: aload_1\n 102: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 107: astore_3\n 108: aload_3\n 109: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 114: ifeq 154\n 117: aload_3\n 118: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 123: astore 4\n 125: iload_2\n 126: aload 4\n 128: checkcast #67 // class java/lang/String\n 131: astore 5\n 133: istore 10\n 135: iconst_0\n 136: istore 6\n 138: aload 5\n 140: invokestatic #71 // Method toScore:(Ljava/lang/String;)I\n 143: istore 11\n 145: iload 10\n 147: iload 11\n 149: iadd\n 150: istore_2\n 151: goto 108\n 154: iload_2\n 155: ireturn\n\n private static final int toScore(java.lang.String);\n Code:\n 0: getstatic #110 // Field SCORES:Ljava/util/Map;\n 3: new #112 // class java/lang/StringBuilder\n 6: dup\n 7: invokespecial #114 // Method java/lang/StringBuilder.\"<init>\":()V\n 10: aload_0\n 11: iconst_0\n 12: invokevirtual #118 // Method java/lang/String.charAt:(I)C\n 15: invokevirtual #122 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 18: aload_0\n 19: iconst_2\n 20: invokevirtual #118 // Method java/lang/String.charAt:(I)C\n 23: invokevirtual #122 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 26: invokevirtual #126 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 29: invokestatic #132 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 32: checkcast #134 // class java/lang/Number\n 35: invokevirtual #138 // Method java/lang/Number.intValue:()I\n 38: ireturn\n\n private static final java.lang.String correctMove(java.lang.String);\n Code:\n 0: getstatic #142 // Field CORRECTIONS:Ljava/util/Map;\n 3: new #112 // class java/lang/StringBuilder\n 6: dup\n 7: invokespecial #114 // Method java/lang/StringBuilder.\"<init>\":()V\n 10: aload_0\n 11: iconst_0\n 12: invokevirtual #118 // Method java/lang/String.charAt:(I)C\n 15: invokevirtual #122 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 18: aload_0\n 19: iconst_2\n 20: invokevirtual #118 // Method java/lang/String.charAt:(I)C\n 23: invokevirtual #122 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 26: invokevirtual #126 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 29: invokestatic #132 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 32: checkcast #67 // class java/lang/String\n 35: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #146 // Method main:()V\n 3: return\n\n static {};\n Code:\n 0: bipush 9\n 2: anewarray #151 // class kotlin/Pair\n 5: astore_0\n 6: aload_0\n 7: iconst_0\n 8: ldc #153 // String AX\n 10: iconst_4\n 11: invokestatic #159 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 14: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 17: aastore\n 18: aload_0\n 19: iconst_1\n 20: ldc #167 // String AY\n 22: bipush 8\n 24: invokestatic #159 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 27: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 30: aastore\n 31: aload_0\n 32: iconst_2\n 33: ldc #169 // String AZ\n 35: iconst_3\n 36: invokestatic #159 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 39: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 42: aastore\n 43: aload_0\n 44: iconst_3\n 45: ldc #171 // String BX\n 47: iconst_1\n 48: invokestatic #159 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 51: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 54: aastore\n 55: aload_0\n 56: iconst_4\n 57: ldc #173 // String BY\n 59: iconst_5\n 60: invokestatic #159 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 63: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 66: aastore\n 67: aload_0\n 68: iconst_5\n 69: ldc #175 // String BZ\n 71: bipush 9\n 73: invokestatic #159 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 76: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 79: aastore\n 80: aload_0\n 81: bipush 6\n 83: ldc #177 // String CX\n 85: bipush 7\n 87: invokestatic #159 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 90: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 93: aastore\n 94: aload_0\n 95: bipush 7\n 97: ldc #179 // String CY\n 99: iconst_2\n 100: invokestatic #159 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 103: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 106: aastore\n 107: aload_0\n 108: bipush 8\n 110: ldc #181 // String CZ\n 112: bipush 6\n 114: invokestatic #159 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 117: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 120: aastore\n 121: aload_0\n 122: invokestatic #185 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 125: putstatic #110 // Field SCORES:Ljava/util/Map;\n 128: bipush 9\n 130: anewarray #151 // class kotlin/Pair\n 133: astore_0\n 134: aload_0\n 135: iconst_0\n 136: ldc #153 // String AX\n 138: ldc #187 // String A Z\n 140: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 143: aastore\n 144: aload_0\n 145: iconst_1\n 146: ldc #167 // String AY\n 148: ldc #189 // String A X\n 150: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 153: aastore\n 154: aload_0\n 155: iconst_2\n 156: ldc #169 // String AZ\n 158: ldc #191 // String A Y\n 160: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 163: aastore\n 164: aload_0\n 165: iconst_3\n 166: ldc #171 // String BX\n 168: ldc #193 // String B X\n 170: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 173: aastore\n 174: aload_0\n 175: iconst_4\n 176: ldc #173 // String BY\n 178: ldc #195 // String B Y\n 180: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 183: aastore\n 184: aload_0\n 185: iconst_5\n 186: ldc #175 // String BZ\n 188: ldc #197 // String B Z\n 190: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 193: aastore\n 194: aload_0\n 195: bipush 6\n 197: ldc #177 // String CX\n 199: ldc #199 // String C Y\n 201: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 204: aastore\n 205: aload_0\n 206: bipush 7\n 208: ldc #179 // String CY\n 210: ldc #201 // String C Z\n 212: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 215: aastore\n 216: aload_0\n 217: bipush 8\n 219: ldc #181 // String CZ\n 221: ldc #203 // String C X\n 223: invokestatic #165 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 226: aastore\n 227: aload_0\n 228: invokestatic #185 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 231: putstatic #142 // Field CORRECTIONS:Ljava/util/Map;\n 234: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day12.kt
import java.util.* fun main() { val testInput = readInput("Day12_test") check(part1(testInput) == 31) check(part2(testInput) == 29) val input = readInput("Day12") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>, ): Int = solve(input, startMarkers = setOf('S')) private fun part2(input: List<String>, ): Int = solve(input, startMarkers = setOf('S', 'a')) private fun solve(input: List<String>, startMarkers: Set<Char>): Int { val area = input.toMatrix() val starts = input.findAllChars(startMarkers) val end = input.findChar('E') val visited = mutableSetOf<IJ>() val queue = PriorityQueue<Item>() starts.forEach { queue.offer(Item(0, it)) } while (queue.isNotEmpty()) { val (steps, ij) = queue.poll() if (ij in visited) { continue } if (ij == end) { return steps } val (i, j) = ij if (i > 0 && (area[i - 1][j] - area[i][j]) <= 1) { queue.offer(Item(steps + 1, IJ(i - 1, j))) } if (j > 0 && (area[i][j - 1] - area[i][j]) <= 1) { queue.offer(Item(steps + 1, IJ(i, j - 1))) } if (i < area.lastIndex && (area[i + 1][j] - area[i][j]) <= 1) { queue.offer(Item(steps + 1, IJ(i + 1, j))) } if (j < area[i].lastIndex && (area[i][j + 1] - area[i][j]) <= 1) { queue.offer(Item(steps + 1, IJ(i, j + 1))) } visited.add(ij) } error("Path not found") } private fun List<String>.toMatrix(): Matrix { return Array(this.size) { i -> IntArray(this[i].length) { j -> when (this[i][j]) { 'S' -> 0 'E' -> 'z'.code - 'a'.code else -> this[i][j].code - 'a'.code } } } } private fun List<String>.findChar(target: Char): IJ { this.forEachIndexed { i, row -> row.forEachIndexed { j, ch -> if (ch == target) { return IJ(i, j) } } } error("$target not found") } private fun List<String>.findAllChars(targets: Set<Char>): List<IJ> { val result = mutableListOf<IJ>() this.forEachIndexed { i, row -> row.forEachIndexed { j, ch -> if (ch in targets) { result.add(IJ(i, j)) } } } return result }
[ { "class_path": "Kvest__AOC2022__6409e65/Day12Kt.class", "javap": "Compiled from \"Day12.kt\"\npublic final class Day12Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day12_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: bipush 31\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 33\n 23: new #20 // class java/lang/IllegalStateException\n 26: dup\n 27: ldc #22 // String Check failed.\n 29: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 32: athrow\n 33: aload_0\n 34: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 37: bipush 29\n 39: if_icmpne 46\n 42: iconst_1\n 43: goto 47\n 46: iconst_0\n 47: ifne 60\n 50: new #20 // class java/lang/IllegalStateException\n 53: dup\n 54: ldc #22 // String Check failed.\n 56: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 59: athrow\n 60: ldc #31 // String Day12\n 62: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 65: astore_1\n 66: aload_1\n 67: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 70: istore_2\n 71: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 74: iload_2\n 75: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 78: aload_1\n 79: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 82: istore_2\n 83: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 86: iload_2\n 87: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 90: return\n\n private static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: bipush 83\n 3: invokestatic #55 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 6: invokestatic #61 // Method kotlin/collections/SetsKt.setOf:(Ljava/lang/Object;)Ljava/util/Set;\n 9: invokestatic #65 // Method solve:(Ljava/util/List;Ljava/util/Set;)I\n 12: ireturn\n\n private static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: iconst_2\n 2: anewarray #51 // class java/lang/Character\n 5: astore_1\n 6: aload_1\n 7: iconst_0\n 8: bipush 83\n 10: invokestatic #55 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 13: aastore\n 14: aload_1\n 15: iconst_1\n 16: bipush 97\n 18: invokestatic #55 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 21: aastore\n 22: aload_1\n 23: invokestatic #68 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 26: invokestatic #65 // Method solve:(Ljava/util/List;Ljava/util/Set;)I\n 29: ireturn\n\n private static final int solve(java.util.List<java.lang.String>, java.util.Set<java.lang.Character>);\n Code:\n 0: aload_0\n 1: invokestatic #73 // Method toMatrix:(Ljava/util/List;)[[I\n 4: astore_2\n 5: aload_0\n 6: aload_1\n 7: invokestatic #77 // Method findAllChars:(Ljava/util/List;Ljava/util/Set;)Ljava/util/List;\n 10: astore_3\n 11: aload_0\n 12: bipush 69\n 14: invokestatic #81 // Method findChar:(Ljava/util/List;C)LIJ;\n 17: astore 4\n 19: new #83 // class java/util/LinkedHashSet\n 22: dup\n 23: invokespecial #85 // Method java/util/LinkedHashSet.\"<init>\":()V\n 26: checkcast #87 // class java/util/Set\n 29: astore 5\n 31: new #89 // class java/util/PriorityQueue\n 34: dup\n 35: invokespecial #90 // Method java/util/PriorityQueue.\"<init>\":()V\n 38: astore 6\n 40: aload_3\n 41: checkcast #92 // class java/lang/Iterable\n 44: astore 7\n 46: iconst_0\n 47: istore 8\n 49: aload 7\n 51: invokeinterface #96, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 56: astore 9\n 58: aload 9\n 60: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 65: ifeq 108\n 68: aload 9\n 70: invokeinterface #106, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 75: astore 10\n 77: aload 10\n 79: checkcast #108 // class IJ\n 82: astore 11\n 84: iconst_0\n 85: istore 12\n 87: aload 6\n 89: new #110 // class Item\n 92: dup\n 93: iconst_0\n 94: aload 11\n 96: invokespecial #113 // Method Item.\"<init>\":(ILIJ;)V\n 99: invokevirtual #117 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z\n 102: pop\n 103: nop\n 104: nop\n 105: goto 58\n 108: nop\n 109: aload 6\n 111: checkcast #119 // class java/util/Collection\n 114: invokeinterface #122, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 119: ifne 126\n 122: iconst_1\n 123: goto 127\n 126: iconst_0\n 127: ifeq 447\n 130: aload 6\n 132: invokevirtual #125 // Method java/util/PriorityQueue.poll:()Ljava/lang/Object;\n 135: checkcast #110 // class Item\n 138: astore 7\n 140: aload 7\n 142: invokevirtual #129 // Method Item.component1:()I\n 145: istore 8\n 147: aload 7\n 149: invokevirtual #133 // Method Item.component2:()LIJ;\n 152: astore 9\n 154: aload 5\n 156: aload 9\n 158: invokeinterface #136, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 163: ifeq 169\n 166: goto 109\n 169: aload 9\n 171: aload 4\n 173: invokestatic #142 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 176: ifeq 182\n 179: iload 8\n 181: ireturn\n 182: aload 9\n 184: invokevirtual #143 // Method IJ.component1:()I\n 187: istore 10\n 189: aload 9\n 191: invokevirtual #145 // Method IJ.component2:()I\n 194: istore 11\n 196: iload 10\n 198: ifle 252\n 201: aload_2\n 202: iload 10\n 204: iconst_1\n 205: isub\n 206: aaload\n 207: iload 11\n 209: iaload\n 210: aload_2\n 211: iload 10\n 213: aaload\n 214: iload 11\n 216: iaload\n 217: isub\n 218: iconst_1\n 219: if_icmpgt 252\n 222: aload 6\n 224: new #110 // class Item\n 227: dup\n 228: iload 8\n 230: iconst_1\n 231: iadd\n 232: new #108 // class IJ\n 235: dup\n 236: iload 10\n 238: iconst_1\n 239: isub\n 240: iload 11\n 242: invokespecial #148 // Method IJ.\"<init>\":(II)V\n 245: invokespecial #113 // Method Item.\"<init>\":(ILIJ;)V\n 248: invokevirtual #117 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z\n 251: pop\n 252: iload 11\n 254: ifle 308\n 257: aload_2\n 258: iload 10\n 260: aaload\n 261: iload 11\n 263: iconst_1\n 264: isub\n 265: iaload\n 266: aload_2\n 267: iload 10\n 269: aaload\n 270: iload 11\n 272: iaload\n 273: isub\n 274: iconst_1\n 275: if_icmpgt 308\n 278: aload 6\n 280: new #110 // class Item\n 283: dup\n 284: iload 8\n 286: iconst_1\n 287: iadd\n 288: new #108 // class IJ\n 291: dup\n 292: iload 10\n 294: iload 11\n 296: iconst_1\n 297: isub\n 298: invokespecial #148 // Method IJ.\"<init>\":(II)V\n 301: invokespecial #113 // Method Item.\"<init>\":(ILIJ;)V\n 304: invokevirtual #117 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z\n 307: pop\n 308: iload 10\n 310: aload_2\n 311: checkcast #150 // class \"[Ljava/lang/Object;\"\n 314: invokestatic #156 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 317: if_icmpge 371\n 320: aload_2\n 321: iload 10\n 323: iconst_1\n 324: iadd\n 325: aaload\n 326: iload 11\n 328: iaload\n 329: aload_2\n 330: iload 10\n 332: aaload\n 333: iload 11\n 335: iaload\n 336: isub\n 337: iconst_1\n 338: if_icmpgt 371\n 341: aload 6\n 343: new #110 // class Item\n 346: dup\n 347: iload 8\n 349: iconst_1\n 350: iadd\n 351: new #108 // class IJ\n 354: dup\n 355: iload 10\n 357: iconst_1\n 358: iadd\n 359: iload 11\n 361: invokespecial #148 // Method IJ.\"<init>\":(II)V\n 364: invokespecial #113 // Method Item.\"<init>\":(ILIJ;)V\n 367: invokevirtual #117 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z\n 370: pop\n 371: iload 11\n 373: aload_2\n 374: iload 10\n 376: aaload\n 377: invokestatic #159 // Method kotlin/collections/ArraysKt.getLastIndex:([I)I\n 380: if_icmpge 434\n 383: aload_2\n 384: iload 10\n 386: aaload\n 387: iload 11\n 389: iconst_1\n 390: iadd\n 391: iaload\n 392: aload_2\n 393: iload 10\n 395: aaload\n 396: iload 11\n 398: iaload\n 399: isub\n 400: iconst_1\n 401: if_icmpgt 434\n 404: aload 6\n 406: new #110 // class Item\n 409: dup\n 410: iload 8\n 412: iconst_1\n 413: iadd\n 414: new #108 // class IJ\n 417: dup\n 418: iload 10\n 420: iload 11\n 422: iconst_1\n 423: iadd\n 424: invokespecial #148 // Method IJ.\"<init>\":(II)V\n 427: invokespecial #113 // Method Item.\"<init>\":(ILIJ;)V\n 430: invokevirtual #117 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z\n 433: pop\n 434: aload 5\n 436: aload 9\n 438: invokeinterface #162, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 443: pop\n 444: goto 109\n 447: new #20 // class java/lang/IllegalStateException\n 450: dup\n 451: ldc #164 // String Path not found\n 453: invokevirtual #168 // Method java/lang/Object.toString:()Ljava/lang/String;\n 456: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 459: athrow\n\n private static final int[][] toMatrix(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: aload_0\n 3: invokeinterface #195, 1 // InterfaceMethod java/util/List.size:()I\n 8: istore_2\n 9: iload_2\n 10: anewarray #197 // class \"[I\"\n 13: astore_3\n 14: iload_1\n 15: iload_2\n 16: if_icmpge 160\n 19: iload_1\n 20: istore 4\n 22: aload_3\n 23: iload 4\n 25: iconst_0\n 26: istore 5\n 28: aload_0\n 29: iload 4\n 31: invokeinterface #201, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 36: checkcast #203 // class java/lang/String\n 39: invokevirtual #206 // Method java/lang/String.length:()I\n 42: istore 6\n 44: iload 6\n 46: newarray int\n 48: astore 7\n 50: istore 10\n 52: astore 9\n 54: iload 5\n 56: iload 6\n 58: if_icmpge 147\n 61: iload 5\n 63: istore 8\n 65: aload 7\n 67: iload 8\n 69: aload_0\n 70: iload 4\n 72: invokeinterface #201, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 77: checkcast #203 // class java/lang/String\n 80: iload 8\n 82: invokevirtual #210 // Method java/lang/String.charAt:(I)C\n 85: lookupswitch { // 2\n 69: 116\n 83: 112\n default: 121\n }\n 112: iconst_0\n 113: goto 140\n 116: bipush 25\n 118: goto 140\n 121: aload_0\n 122: iload 4\n 124: invokeinterface #201, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 129: checkcast #203 // class java/lang/String\n 132: iload 8\n 134: invokevirtual #210 // Method java/lang/String.charAt:(I)C\n 137: bipush 97\n 139: isub\n 140: iastore\n 141: iinc 5, 1\n 144: goto 54\n 147: aload 9\n 149: iload 10\n 151: aload 7\n 153: aastore\n 154: iinc 1, 1\n 157: goto 14\n 160: aload_3\n 161: areturn\n\n private static final IJ findChar(java.util.List<java.lang.String>, char);\n Code:\n 0: aload_0\n 1: checkcast #92 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: iconst_0\n 8: istore 4\n 10: aload_2\n 11: invokeinterface #96, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 16: astore 5\n 18: aload 5\n 20: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 25: ifeq 151\n 28: aload 5\n 30: invokeinterface #106, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 35: astore 6\n 37: iload 4\n 39: iinc 4, 1\n 42: istore 7\n 44: iload 7\n 46: ifge 52\n 49: invokestatic #217 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 52: iload 7\n 54: aload 6\n 56: checkcast #203 // class java/lang/String\n 59: astore 8\n 61: istore 9\n 63: iconst_0\n 64: istore 10\n 66: aload 8\n 68: checkcast #219 // class java/lang/CharSequence\n 71: astore 11\n 73: iconst_0\n 74: istore 12\n 76: iconst_0\n 77: istore 13\n 79: iconst_0\n 80: istore 14\n 82: iload 14\n 84: aload 11\n 86: invokeinterface #220, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 91: if_icmpge 145\n 94: aload 11\n 96: iload 14\n 98: invokeinterface #221, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 103: istore 15\n 105: iload 13\n 107: iinc 13, 1\n 110: iload 15\n 112: istore 16\n 114: istore 17\n 116: iconst_0\n 117: istore 18\n 119: iload 16\n 121: iload_1\n 122: if_icmpne 137\n 125: new #108 // class IJ\n 128: dup\n 129: iload 9\n 131: iload 17\n 133: invokespecial #148 // Method IJ.\"<init>\":(II)V\n 136: areturn\n 137: nop\n 138: nop\n 139: iinc 14, 1\n 142: goto 82\n 145: nop\n 146: nop\n 147: nop\n 148: goto 18\n 151: nop\n 152: new #20 // class java/lang/IllegalStateException\n 155: dup\n 156: new #223 // class java/lang/StringBuilder\n 159: dup\n 160: invokespecial #224 // Method java/lang/StringBuilder.\"<init>\":()V\n 163: iload_1\n 164: invokevirtual #228 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 167: ldc #230 // String not found\n 169: invokevirtual #233 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 172: invokevirtual #234 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 175: invokevirtual #168 // Method java/lang/Object.toString:()Ljava/lang/String;\n 178: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 181: athrow\n\n private static final java.util.List<IJ> findAllChars(java.util.List<java.lang.String>, java.util.Set<java.lang.Character>);\n Code:\n 0: new #250 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #251 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #48 // class java/util/List\n 10: astore_2\n 11: aload_0\n 12: checkcast #92 // 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: aload_3\n 23: invokeinterface #96, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 28: astore 6\n 30: aload 6\n 32: invokeinterface #102, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 37: ifeq 177\n 40: aload 6\n 42: invokeinterface #106, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 47: astore 7\n 49: iload 5\n 51: iinc 5, 1\n 54: istore 8\n 56: iload 8\n 58: ifge 64\n 61: invokestatic #217 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 64: iload 8\n 66: aload 7\n 68: checkcast #203 // class java/lang/String\n 71: astore 9\n 73: istore 10\n 75: iconst_0\n 76: istore 11\n 78: aload 9\n 80: checkcast #219 // class java/lang/CharSequence\n 83: astore 12\n 85: iconst_0\n 86: istore 13\n 88: iconst_0\n 89: istore 14\n 91: iconst_0\n 92: istore 15\n 94: iload 15\n 96: aload 12\n 98: invokeinterface #220, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 103: if_icmpge 171\n 106: aload 12\n 108: iload 15\n 110: invokeinterface #221, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 115: istore 16\n 117: iload 14\n 119: iinc 14, 1\n 122: iload 16\n 124: istore 17\n 126: istore 18\n 128: iconst_0\n 129: istore 19\n 131: aload_1\n 132: iload 17\n 134: invokestatic #55 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 137: invokeinterface #136, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 142: ifeq 163\n 145: aload_2\n 146: new #108 // class IJ\n 149: dup\n 150: iload 10\n 152: iload 18\n 154: invokespecial #148 // Method IJ.\"<init>\":(II)V\n 157: invokeinterface #252, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 162: pop\n 163: nop\n 164: nop\n 165: iinc 15, 1\n 168: goto 94\n 171: nop\n 172: nop\n 173: nop\n 174: goto 30\n 177: nop\n 178: aload_2\n 179: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #260 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day24.kt
import java.util.* fun main() { val testInput = readInput("Day24_test") val testMap = BlizzardMap(testInput) check(part1(testMap) == 18) check(part2(testMap) == 54) val input = readInput("Day24") val map = BlizzardMap(input) println(part1(map)) println(part2(map)) } private fun part1(map: BlizzardMap): Int { val initialMap = map[0] val startI = 0 val startJ = initialMap[startI].indexOfFirst { it } val targetI = initialMap.lastIndex val targetJ = initialMap[targetI].indexOfFirst { it } return solve( map = map, startMinute = 0, startI = startI, startJ = startJ, targetI = targetI, targetJ = targetJ, ) } private fun part2(map: BlizzardMap): Int { val initialMap = map[0] val startI = 0 val startJ = initialMap[startI].indexOfFirst { it } val targetI = initialMap.lastIndex val targetJ = initialMap[targetI].indexOfFirst { it } val m1 = solve( map = map, startMinute = 0, startI = startI, startJ = startJ, targetI = targetI, targetJ = targetJ, ) val m2 = solve( map = map, startMinute = m1, startI = targetI, startJ = targetJ, targetI = startI, targetJ = startJ, ) val m3 = solve( map = map, startMinute = m2, startI = startI, startJ = startJ, targetI = targetI, targetJ = targetJ, ) return m3 } private fun solve( map: BlizzardMap, startMinute: Int, startI: Int, startJ: Int, targetI: Int, targetJ: Int ): Int { val queue = PriorityQueue<Item>() queue.offer(Item(startMinute, IJ(startI, startJ))) val visited = mutableSetOf<Int>() while (queue.isNotEmpty()) { val (minute, ij) = queue.poll() val (i, j) = ij val key = minute * 1_000_000 + i * 1_000 + j if (key in visited) { continue } visited.add(key) if (i == targetI && j == targetJ) { return minute } val currentMap = map[minute + 1] if (currentMap[i][j]) { queue.offer(Item(minute + 1, IJ(i, j))) } if (i > 0 && currentMap[i - 1][j]) { queue.offer(Item(minute + 1, IJ(i - 1, j))) } if (i < currentMap.lastIndex && currentMap[i + 1][j]) { queue.offer(Item(minute + 1, IJ(i + 1, j))) } if (j > 0 && currentMap[i][j - 1]) { queue.offer(Item(minute + 1, IJ(i, j - 1))) } if (j < currentMap[i].lastIndex && currentMap[i][j + 1]) { queue.offer(Item(minute + 1, IJ(i, j + 1))) } } error("Path not found") } private class BlizzardMap(initialState: List<String>) { private val cache = mutableListOf<BooleanMatrix>() private val template: BooleanMatrix private val blizzards: List<Blizzard> init { blizzards = buildList { initialState.forEachIndexed { i, row -> row.forEachIndexed { j, ch -> when (ch) { '>' -> add(Blizzard(MutableIJ(i, j), BlizzardDirection.RIGHT)) 'v' -> add(Blizzard(MutableIJ(i, j), BlizzardDirection.DOWN)) '<' -> add(Blizzard(MutableIJ(i, j), BlizzardDirection.LEFT)) '^' -> add(Blizzard(MutableIJ(i, j), BlizzardDirection.UP)) } } } } template = Array(initialState.size) { i -> BooleanArray(initialState[i].length) { j -> initialState[i][j] != '#' } } //generate default map generateNextMap() } operator fun get(i: Int): BooleanMatrix { while (cache.lastIndex < i) { generateNextMap() } return cache[i] } private fun generateNextMap() { val next = template.deepCopyOf() blizzards.forEach { with(it) { next[position.i][position.j] = false //Also, move blizzard to the new position when (direction) { BlizzardDirection.RIGHT -> position.j = if (position.j < (template[0].lastIndex - 1)) { position.j + 1 } else { 1 } BlizzardDirection.DOWN -> position.i = if (position.i < (template.lastIndex - 1)) { position.i + 1 } else { 1 } BlizzardDirection.LEFT -> position.j = if (position.j > 1) { position.j - 1 } else { template[0].lastIndex - 1 } BlizzardDirection.UP -> position.i = if (position.i > 1) { position.i - 1 } else { template.lastIndex - 1 } } } } cache.add(next) } } private enum class BlizzardDirection { RIGHT, DOWN, LEFT, UP } private class Blizzard( val position: MutableIJ, val direction: BlizzardDirection, )
[ { "class_path": "Kvest__AOC2022__6409e65/Day24Kt.class", "javap": "Compiled from \"Day24.kt\"\npublic final class Day24Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day24_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: new #16 // class BlizzardMap\n 9: dup\n 10: aload_0\n 11: invokespecial #20 // Method BlizzardMap.\"<init>\":(Ljava/util/List;)V\n 14: astore_1\n 15: aload_1\n 16: invokestatic #24 // Method part1:(LBlizzardMap;)I\n 19: bipush 18\n 21: if_icmpne 28\n 24: iconst_1\n 25: goto 29\n 28: iconst_0\n 29: ifne 42\n 32: new #26 // class java/lang/IllegalStateException\n 35: dup\n 36: ldc #28 // String Check failed.\n 38: invokespecial #31 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 41: athrow\n 42: aload_1\n 43: invokestatic #34 // Method part2:(LBlizzardMap;)I\n 46: bipush 54\n 48: if_icmpne 55\n 51: iconst_1\n 52: goto 56\n 55: iconst_0\n 56: ifne 69\n 59: new #26 // class java/lang/IllegalStateException\n 62: dup\n 63: ldc #28 // String Check failed.\n 65: invokespecial #31 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 68: athrow\n 69: ldc #36 // String Day24\n 71: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 74: astore_2\n 75: new #16 // class BlizzardMap\n 78: dup\n 79: aload_2\n 80: invokespecial #20 // Method BlizzardMap.\"<init>\":(Ljava/util/List;)V\n 83: astore_3\n 84: aload_3\n 85: invokestatic #24 // Method part1:(LBlizzardMap;)I\n 88: istore 4\n 90: getstatic #42 // Field java/lang/System.out:Ljava/io/PrintStream;\n 93: iload 4\n 95: invokevirtual #48 // Method java/io/PrintStream.println:(I)V\n 98: aload_3\n 99: invokestatic #34 // Method part2:(LBlizzardMap;)I\n 102: istore 4\n 104: getstatic #42 // Field java/lang/System.out:Ljava/io/PrintStream;\n 107: iload 4\n 109: invokevirtual #48 // Method java/io/PrintStream.println:(I)V\n 112: return\n\n private static final int part1(BlizzardMap);\n Code:\n 0: aload_0\n 1: iconst_0\n 2: invokevirtual #60 // Method BlizzardMap.get:(I)[[Z\n 5: astore_1\n 6: iconst_0\n 7: istore_2\n 8: aload_1\n 9: iload_2\n 10: aaload\n 11: astore 4\n 13: iconst_0\n 14: istore 5\n 16: iconst_0\n 17: istore 6\n 19: aload 4\n 21: arraylength\n 22: istore 7\n 24: iload 6\n 26: iload 7\n 28: if_icmpge 57\n 31: aload 4\n 33: iload 6\n 35: baload\n 36: istore 8\n 38: iconst_0\n 39: istore 9\n 41: iload 8\n 43: ifeq 51\n 46: iload 6\n 48: goto 58\n 51: iinc 6, 1\n 54: goto 24\n 57: iconst_m1\n 58: istore_3\n 59: aload_1\n 60: checkcast #62 // class \"[Ljava/lang/Object;\"\n 63: invokestatic #68 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 66: istore 4\n 68: aload_1\n 69: iload 4\n 71: aaload\n 72: astore 6\n 74: iconst_0\n 75: istore 7\n 77: iconst_0\n 78: istore 8\n 80: aload 6\n 82: arraylength\n 83: istore 9\n 85: iload 8\n 87: iload 9\n 89: if_icmpge 118\n 92: aload 6\n 94: iload 8\n 96: baload\n 97: istore 10\n 99: iconst_0\n 100: istore 11\n 102: iload 10\n 104: ifeq 112\n 107: iload 8\n 109: goto 119\n 112: iinc 8, 1\n 115: goto 85\n 118: iconst_m1\n 119: istore 5\n 121: aload_0\n 122: iconst_0\n 123: iload_2\n 124: iload_3\n 125: iload 4\n 127: iload 5\n 129: invokestatic #72 // Method solve:(LBlizzardMap;IIIII)I\n 132: ireturn\n\n private static final int part2(BlizzardMap);\n Code:\n 0: aload_0\n 1: iconst_0\n 2: invokevirtual #60 // Method BlizzardMap.get:(I)[[Z\n 5: astore_1\n 6: iconst_0\n 7: istore_2\n 8: aload_1\n 9: iload_2\n 10: aaload\n 11: astore 4\n 13: iconst_0\n 14: istore 5\n 16: iconst_0\n 17: istore 6\n 19: aload 4\n 21: arraylength\n 22: istore 7\n 24: iload 6\n 26: iload 7\n 28: if_icmpge 57\n 31: aload 4\n 33: iload 6\n 35: baload\n 36: istore 8\n 38: iconst_0\n 39: istore 9\n 41: iload 8\n 43: ifeq 51\n 46: iload 6\n 48: goto 58\n 51: iinc 6, 1\n 54: goto 24\n 57: iconst_m1\n 58: istore_3\n 59: aload_1\n 60: checkcast #62 // class \"[Ljava/lang/Object;\"\n 63: invokestatic #68 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 66: istore 4\n 68: aload_1\n 69: iload 4\n 71: aaload\n 72: astore 6\n 74: iconst_0\n 75: istore 7\n 77: iconst_0\n 78: istore 8\n 80: aload 6\n 82: arraylength\n 83: istore 9\n 85: iload 8\n 87: iload 9\n 89: if_icmpge 118\n 92: aload 6\n 94: iload 8\n 96: baload\n 97: istore 10\n 99: iconst_0\n 100: istore 11\n 102: iload 10\n 104: ifeq 112\n 107: iload 8\n 109: goto 119\n 112: iinc 8, 1\n 115: goto 85\n 118: iconst_m1\n 119: istore 5\n 121: aload_0\n 122: iconst_0\n 123: iload_2\n 124: iload_3\n 125: iload 4\n 127: iload 5\n 129: invokestatic #72 // Method solve:(LBlizzardMap;IIIII)I\n 132: istore 6\n 134: aload_0\n 135: iload 6\n 137: iload 4\n 139: iload 5\n 141: iload_2\n 142: iload_3\n 143: invokestatic #72 // Method solve:(LBlizzardMap;IIIII)I\n 146: istore 7\n 148: aload_0\n 149: iload 7\n 151: iload_2\n 152: iload_3\n 153: iload 4\n 155: iload 5\n 157: invokestatic #72 // Method solve:(LBlizzardMap;IIIII)I\n 160: istore 8\n 162: iload 8\n 164: ireturn\n\n private static final int solve(BlizzardMap, int, int, int, int, int);\n Code:\n 0: new #96 // class java/util/PriorityQueue\n 3: dup\n 4: invokespecial #98 // Method java/util/PriorityQueue.\"<init>\":()V\n 7: astore 6\n 9: aload 6\n 11: new #100 // class Item\n 14: dup\n 15: iload_1\n 16: new #102 // class IJ\n 19: dup\n 20: iload_2\n 21: iload_3\n 22: invokespecial #105 // Method IJ.\"<init>\":(II)V\n 25: invokespecial #108 // Method Item.\"<init>\":(ILIJ;)V\n 28: invokevirtual #112 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z\n 31: pop\n 32: new #114 // class java/util/LinkedHashSet\n 35: dup\n 36: invokespecial #115 // Method java/util/LinkedHashSet.\"<init>\":()V\n 39: checkcast #117 // class java/util/Set\n 42: astore 7\n 44: aload 6\n 46: checkcast #119 // class java/util/Collection\n 49: invokeinterface #123, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 54: ifne 61\n 57: iconst_1\n 58: goto 62\n 61: iconst_0\n 62: ifeq 428\n 65: aload 6\n 67: invokevirtual #127 // Method java/util/PriorityQueue.poll:()Ljava/lang/Object;\n 70: checkcast #100 // class Item\n 73: astore 8\n 75: aload 8\n 77: invokevirtual #131 // Method Item.component1:()I\n 80: istore 9\n 82: aload 8\n 84: invokevirtual #135 // Method Item.component2:()LIJ;\n 87: astore 10\n 89: aload 10\n 91: invokevirtual #136 // Method IJ.component1:()I\n 94: istore 11\n 96: aload 10\n 98: invokevirtual #138 // Method IJ.component2:()I\n 101: istore 12\n 103: iload 9\n 105: ldc #139 // int 1000000\n 107: imul\n 108: iload 11\n 110: sipush 1000\n 113: imul\n 114: iadd\n 115: iload 12\n 117: iadd\n 118: istore 13\n 120: aload 7\n 122: iload 13\n 124: invokestatic #145 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 127: invokeinterface #148, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 132: ifeq 138\n 135: goto 44\n 138: aload 7\n 140: iload 13\n 142: invokestatic #145 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 145: invokeinterface #151, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 150: pop\n 151: iload 11\n 153: iload 4\n 155: if_icmpne 168\n 158: iload 12\n 160: iload 5\n 162: if_icmpne 168\n 165: iload 9\n 167: ireturn\n 168: aload_0\n 169: iload 9\n 171: iconst_1\n 172: iadd\n 173: invokevirtual #60 // Method BlizzardMap.get:(I)[[Z\n 176: astore 14\n 178: aload 14\n 180: iload 11\n 182: aaload\n 183: iload 12\n 185: baload\n 186: ifeq 217\n 189: aload 6\n 191: new #100 // class Item\n 194: dup\n 195: iload 9\n 197: iconst_1\n 198: iadd\n 199: new #102 // class IJ\n 202: dup\n 203: iload 11\n 205: iload 12\n 207: invokespecial #105 // Method IJ.\"<init>\":(II)V\n 210: invokespecial #108 // Method Item.\"<init>\":(ILIJ;)V\n 213: invokevirtual #112 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z\n 216: pop\n 217: iload 11\n 219: ifle 265\n 222: aload 14\n 224: iload 11\n 226: iconst_1\n 227: isub\n 228: aaload\n 229: iload 12\n 231: baload\n 232: ifeq 265\n 235: aload 6\n 237: new #100 // class Item\n 240: dup\n 241: iload 9\n 243: iconst_1\n 244: iadd\n 245: new #102 // class IJ\n 248: dup\n 249: iload 11\n 251: iconst_1\n 252: isub\n 253: iload 12\n 255: invokespecial #105 // Method IJ.\"<init>\":(II)V\n 258: invokespecial #108 // Method Item.\"<init>\":(ILIJ;)V\n 261: invokevirtual #112 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z\n 264: pop\n 265: iload 11\n 267: aload 14\n 269: checkcast #62 // class \"[Ljava/lang/Object;\"\n 272: invokestatic #68 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 275: if_icmpge 321\n 278: aload 14\n 280: iload 11\n 282: iconst_1\n 283: iadd\n 284: aaload\n 285: iload 12\n 287: baload\n 288: ifeq 321\n 291: aload 6\n 293: new #100 // class Item\n 296: dup\n 297: iload 9\n 299: iconst_1\n 300: iadd\n 301: new #102 // class IJ\n 304: dup\n 305: iload 11\n 307: iconst_1\n 308: iadd\n 309: iload 12\n 311: invokespecial #105 // Method IJ.\"<init>\":(II)V\n 314: invokespecial #108 // Method Item.\"<init>\":(ILIJ;)V\n 317: invokevirtual #112 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z\n 320: pop\n 321: iload 12\n 323: ifle 369\n 326: aload 14\n 328: iload 11\n 330: aaload\n 331: iload 12\n 333: iconst_1\n 334: isub\n 335: baload\n 336: ifeq 369\n 339: aload 6\n 341: new #100 // class Item\n 344: dup\n 345: iload 9\n 347: iconst_1\n 348: iadd\n 349: new #102 // class IJ\n 352: dup\n 353: iload 11\n 355: iload 12\n 357: iconst_1\n 358: isub\n 359: invokespecial #105 // Method IJ.\"<init>\":(II)V\n 362: invokespecial #108 // Method Item.\"<init>\":(ILIJ;)V\n 365: invokevirtual #112 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z\n 368: pop\n 369: iload 12\n 371: aload 14\n 373: iload 11\n 375: aaload\n 376: invokestatic #154 // Method kotlin/collections/ArraysKt.getLastIndex:([Z)I\n 379: if_icmpge 44\n 382: aload 14\n 384: iload 11\n 386: aaload\n 387: iload 12\n 389: iconst_1\n 390: iadd\n 391: baload\n 392: ifeq 44\n 395: aload 6\n 397: new #100 // class Item\n 400: dup\n 401: iload 9\n 403: iconst_1\n 404: iadd\n 405: new #102 // class IJ\n 408: dup\n 409: iload 11\n 411: iload 12\n 413: iconst_1\n 414: iadd\n 415: invokespecial #105 // Method IJ.\"<init>\":(II)V\n 418: invokespecial #108 // Method Item.\"<init>\":(ILIJ;)V\n 421: invokevirtual #112 // Method java/util/PriorityQueue.offer:(Ljava/lang/Object;)Z\n 424: pop\n 425: goto 44\n 428: new #26 // class java/lang/IllegalStateException\n 431: dup\n 432: ldc #156 // String Path not found\n 434: invokevirtual #160 // Method java/lang/Object.toString:()Ljava/lang/String;\n 437: invokespecial #31 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 440: athrow\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #175 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day09.kt
import kotlin.math.abs import kotlin.math.sign fun main() { val testInput1 = readInput("Day09_test1") val testInput2 = readInput("Day09_test2") check(part1(testInput1) == 13) check(part2(testInput1) == 1) check(part2(testInput2) == 36) val input = readInput("Day09") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int = solve(input, ropeSize = 2) private fun part2(input: List<String>): Int = solve(input, ropeSize = 10) private fun solve(input: List<String>, ropeSize: Int): Int { val rope = List(ropeSize) { MutableXY(0, 0) } val adjacentKnots = rope.windowed(2, 1) val head = rope.first() val tail = rope.last() val visitedCells = mutableSetOf<XY>() var dx = 0 var dy = 0 input.forEach { action -> val cnt = action.substringAfter(" ").toInt() when { action.startsWith("L") -> { dx = -1 dy = 0 } action.startsWith("R") -> { dx = 1 dy = 0 } action.startsWith("U") -> { dx = 0 dy = 1 } action.startsWith("D") -> { dx = 0 dy = -1 } } repeat(cnt) { head.x += dx head.y += dy adjacentKnots.forEach { (first, second) -> adjustKnotes(first, second) } visitedCells.add(tail.toXY()) } } return visitedCells.size } private fun adjustKnotes(first: MutableXY, second: MutableXY) { if (abs(first.x - second.x) >= 2 || abs(first.y - second.y) >= 2) { second.x = second.x + 1 * (first.x - second.x).sign second.y = second.y + 1 * (first.y - second.y).sign } }
[ { "class_path": "Kvest__AOC2022__6409e65/Day09Kt.class", "javap": "Compiled from \"Day09.kt\"\npublic final class Day09Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day09_test1\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: astore_0\n 6: ldc #16 // String Day09_test2\n 8: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 11: astore_1\n 12: aload_0\n 13: invokestatic #20 // Method part1:(Ljava/util/List;)I\n 16: bipush 13\n 18: if_icmpne 25\n 21: iconst_1\n 22: goto 26\n 25: iconst_0\n 26: ifne 39\n 29: new #22 // class java/lang/IllegalStateException\n 32: dup\n 33: ldc #24 // String Check failed.\n 35: invokespecial #28 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 38: athrow\n 39: aload_0\n 40: invokestatic #31 // Method part2:(Ljava/util/List;)I\n 43: iconst_1\n 44: if_icmpne 51\n 47: iconst_1\n 48: goto 52\n 51: iconst_0\n 52: ifne 65\n 55: new #22 // class java/lang/IllegalStateException\n 58: dup\n 59: ldc #24 // String Check failed.\n 61: invokespecial #28 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 64: athrow\n 65: aload_1\n 66: invokestatic #31 // Method part2:(Ljava/util/List;)I\n 69: bipush 36\n 71: if_icmpne 78\n 74: iconst_1\n 75: goto 79\n 78: iconst_0\n 79: ifne 92\n 82: new #22 // class java/lang/IllegalStateException\n 85: dup\n 86: ldc #24 // String Check failed.\n 88: invokespecial #28 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 91: athrow\n 92: ldc #33 // String Day09\n 94: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 97: astore_2\n 98: aload_2\n 99: invokestatic #20 // Method part1:(Ljava/util/List;)I\n 102: istore_3\n 103: getstatic #39 // Field java/lang/System.out:Ljava/io/PrintStream;\n 106: iload_3\n 107: invokevirtual #45 // Method java/io/PrintStream.println:(I)V\n 110: aload_2\n 111: invokestatic #31 // Method part2:(Ljava/util/List;)I\n 114: istore_3\n 115: getstatic #39 // Field java/lang/System.out:Ljava/io/PrintStream;\n 118: iload_3\n 119: invokevirtual #45 // Method java/io/PrintStream.println:(I)V\n 122: return\n\n private static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: iconst_2\n 2: invokestatic #56 // Method solve:(Ljava/util/List;I)I\n 5: ireturn\n\n private static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: bipush 10\n 3: invokestatic #56 // Method solve:(Ljava/util/List;I)I\n 6: ireturn\n\n private static final int solve(java.util.List<java.lang.String>, int);\n Code:\n 0: new #59 // class java/util/ArrayList\n 3: dup\n 4: iload_1\n 5: invokespecial #61 // Method java/util/ArrayList.\"<init>\":(I)V\n 8: astore_3\n 9: iconst_0\n 10: istore 4\n 12: iload 4\n 14: iload_1\n 15: if_icmpge 54\n 18: iload 4\n 20: istore 5\n 22: aload_3\n 23: iload 5\n 25: istore 6\n 27: astore 27\n 29: iconst_0\n 30: istore 7\n 32: new #63 // class MutableXY\n 35: dup\n 36: iconst_0\n 37: iconst_0\n 38: invokespecial #66 // Method MutableXY.\"<init>\":(II)V\n 41: aload 27\n 43: swap\n 44: invokevirtual #70 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 47: pop\n 48: iinc 4, 1\n 51: goto 12\n 54: aload_3\n 55: checkcast #51 // class java/util/List\n 58: astore_2\n 59: aload_2\n 60: checkcast #72 // class java/lang/Iterable\n 63: iconst_2\n 64: iconst_1\n 65: iconst_0\n 66: iconst_4\n 67: aconst_null\n 68: invokestatic #78 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZILjava/lang/Object;)Ljava/util/List;\n 71: astore_3\n 72: aload_2\n 73: invokestatic #82 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 76: checkcast #63 // class MutableXY\n 79: astore 4\n 81: aload_2\n 82: invokestatic #85 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 85: checkcast #63 // class MutableXY\n 88: astore 5\n 90: new #87 // class java/util/LinkedHashSet\n 93: dup\n 94: invokespecial #89 // Method java/util/LinkedHashSet.\"<init>\":()V\n 97: checkcast #91 // class java/util/Set\n 100: astore 6\n 102: iconst_0\n 103: istore 7\n 105: iconst_0\n 106: istore 8\n 108: aload_0\n 109: checkcast #72 // class java/lang/Iterable\n 112: astore 9\n 114: iconst_0\n 115: istore 10\n 117: aload 9\n 119: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 124: astore 11\n 126: aload 11\n 128: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 133: ifeq 410\n 136: aload 11\n 138: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 143: astore 12\n 145: aload 12\n 147: checkcast #107 // class java/lang/String\n 150: astore 13\n 152: iconst_0\n 153: istore 14\n 155: aload 13\n 157: ldc #109 // String\n 159: aconst_null\n 160: iconst_2\n 161: aconst_null\n 162: invokestatic #115 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 165: invokestatic #121 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 168: istore 15\n 170: nop\n 171: aload 13\n 173: ldc #123 // String L\n 175: iconst_0\n 176: iconst_2\n 177: aconst_null\n 178: invokestatic #127 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 181: ifeq 193\n 184: iconst_m1\n 185: istore 7\n 187: iconst_0\n 188: istore 8\n 190: goto 256\n 193: aload 13\n 195: ldc #129 // String R\n 197: iconst_0\n 198: iconst_2\n 199: aconst_null\n 200: invokestatic #127 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 203: ifeq 215\n 206: iconst_1\n 207: istore 7\n 209: iconst_0\n 210: istore 8\n 212: goto 256\n 215: aload 13\n 217: ldc #131 // String U\n 219: iconst_0\n 220: iconst_2\n 221: aconst_null\n 222: invokestatic #127 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 225: ifeq 237\n 228: iconst_0\n 229: istore 7\n 231: iconst_1\n 232: istore 8\n 234: goto 256\n 237: aload 13\n 239: ldc #133 // String D\n 241: iconst_0\n 242: iconst_2\n 243: aconst_null\n 244: invokestatic #127 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 247: ifeq 256\n 250: iconst_0\n 251: istore 7\n 253: iconst_m1\n 254: istore 8\n 256: iconst_0\n 257: istore 16\n 259: iload 16\n 261: iload 15\n 263: if_icmpge 405\n 266: iload 16\n 268: istore 17\n 270: iconst_0\n 271: istore 18\n 273: aload 4\n 275: aload 4\n 277: invokevirtual #137 // Method MutableXY.getX:()I\n 280: iload 7\n 282: iadd\n 283: invokevirtual #140 // Method MutableXY.setX:(I)V\n 286: aload 4\n 288: aload 4\n 290: invokevirtual #143 // Method MutableXY.getY:()I\n 293: iload 8\n 295: iadd\n 296: invokevirtual #146 // Method MutableXY.setY:(I)V\n 299: aload_3\n 300: checkcast #72 // class java/lang/Iterable\n 303: astore 19\n 305: iconst_0\n 306: istore 20\n 308: aload 19\n 310: invokeinterface #95, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 315: astore 21\n 317: aload 21\n 319: invokeinterface #101, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 324: ifeq 384\n 327: aload 21\n 329: invokeinterface #105, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 334: astore 22\n 336: aload 22\n 338: checkcast #51 // class java/util/List\n 341: astore 23\n 343: iconst_0\n 344: istore 24\n 346: aload 23\n 348: iconst_0\n 349: invokeinterface #150, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 354: checkcast #63 // class MutableXY\n 357: astore 25\n 359: aload 23\n 361: iconst_1\n 362: invokeinterface #150, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 367: checkcast #63 // class MutableXY\n 370: astore 26\n 372: aload 25\n 374: aload 26\n 376: invokestatic #154 // Method adjustKnotes:(LMutableXY;LMutableXY;)V\n 379: nop\n 380: nop\n 381: goto 317\n 384: nop\n 385: aload 6\n 387: aload 5\n 389: invokevirtual #158 // Method MutableXY.toXY:()LXY;\n 392: invokeinterface #159, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 397: pop\n 398: nop\n 399: iinc 16, 1\n 402: goto 259\n 405: nop\n 406: nop\n 407: goto 126\n 410: nop\n 411: aload 6\n 413: invokeinterface #162, 1 // InterfaceMethod java/util/Set.size:()I\n 418: ireturn\n\n private static final void adjustKnotes(MutableXY, MutableXY);\n Code:\n 0: aload_0\n 1: invokevirtual #137 // Method MutableXY.getX:()I\n 4: aload_1\n 5: invokevirtual #137 // Method MutableXY.getX:()I\n 8: isub\n 9: invokestatic #193 // Method java/lang/Math.abs:(I)I\n 12: iconst_2\n 13: if_icmpge 32\n 16: aload_0\n 17: invokevirtual #143 // Method MutableXY.getY:()I\n 20: aload_1\n 21: invokevirtual #143 // Method MutableXY.getY:()I\n 24: isub\n 25: invokestatic #193 // Method java/lang/Math.abs:(I)I\n 28: iconst_2\n 29: if_icmplt 78\n 32: aload_1\n 33: aload_1\n 34: invokevirtual #137 // Method MutableXY.getX:()I\n 37: iconst_1\n 38: aload_0\n 39: invokevirtual #137 // Method MutableXY.getX:()I\n 42: aload_1\n 43: invokevirtual #137 // Method MutableXY.getX:()I\n 46: isub\n 47: invokestatic #198 // Method kotlin/math/MathKt.getSign:(I)I\n 50: imul\n 51: iadd\n 52: invokevirtual #140 // Method MutableXY.setX:(I)V\n 55: aload_1\n 56: aload_1\n 57: invokevirtual #143 // Method MutableXY.getY:()I\n 60: iconst_1\n 61: aload_0\n 62: invokevirtual #143 // Method MutableXY.getY:()I\n 65: aload_1\n 66: invokevirtual #143 // Method MutableXY.getY:()I\n 69: isub\n 70: invokestatic #198 // Method kotlin/math/MathKt.getSign:(I)I\n 73: imul\n 74: iadd\n 75: invokevirtual #146 // Method MutableXY.setY:(I)V\n 78: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #201 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day19.kt
import kotlin.math.max import kotlin.math.min fun main() { val testInput = readInput("Day19_test") val testBlueprints = testInput.map(Blueprint.Companion::fromString) check(part1(testBlueprints) == 33) val input = readInput("Day19") val blueprints = input.map(Blueprint.Companion::fromString) println(part1(blueprints)) println(part2(blueprints)) } private fun part1(blueprints: List<Blueprint>): Int { return blueprints.sumOf { it.number * calculateMaxGeodes(it, 24) } } private fun part2(blueprints: List<Blueprint>): Int { return calculateMaxGeodes(blueprints[0], 32) * calculateMaxGeodes(blueprints[1], 32) * calculateMaxGeodes(blueprints[2], 32) } private fun calculateMaxGeodes( blueprint: Blueprint, minutesLeft: Int, memo: MutableMap<Long, Int> = mutableMapOf(), oreRobotsCount: Int = 1, clayRobotsCount: Int = 0, obsidianRobotsCount: Int = 0, geodesRobotsCount: Int = 0, oreCount: Int = 0, clayCount: Int = 0, obsidianCount: Int = 0, geodesCount: Int = 0, ): Int { if (minutesLeft == 0) { return geodesCount } //Throw out resources, which can't be potentially spend by the end of the minutesLeft. //This reduces a lot of recursive calls because it collapse overlapping states val oreForKey = min(oreCount, minutesLeft * blueprint.oreMax) val clayForKey = min(clayCount, minutesLeft * blueprint.clayMax) val obsidianForKey = min(obsidianCount, minutesLeft * blueprint.obsidianMax) val key = minutesLeft * 1_000_000_000_000_000_000L + oreRobotsCount * 10_000_000_000_000_000L + clayRobotsCount * 100_000_000_000_000L + obsidianRobotsCount * 1000_000_000_000L + geodesRobotsCount * 10_000_000_000L + oreForKey * 100_000_000L + clayForKey * 1_000_000L + obsidianForKey * 10_000L + geodesCount * 100L if (key in memo) { return memo.getValue(key) } var result = 0 val canBuildOreRobot = oreCount >= blueprint.oreForOreRobot && oreRobotsCount < blueprint.oreMax val canBuildClayRobot = oreCount >= blueprint.oreForClayRobot && clayRobotsCount < blueprint.clayMax val canBuildObsidianRobot = oreCount >= blueprint.oreForObsidianRobot && clayCount >= blueprint.clayForObsidianRobot && obsidianCount <= blueprint.obsidianMax val canBuildGeodeRobot = oreCount >= blueprint.oreForGeodeRobot && obsidianCount >= blueprint.obsidianForGeodeRobot if (canBuildGeodeRobot) { result = max( result, calculateMaxGeodes( blueprint = blueprint, minutesLeft = minutesLeft - 1, memo = memo, oreRobotsCount = oreRobotsCount, clayRobotsCount = clayRobotsCount, obsidianRobotsCount = obsidianRobotsCount, geodesRobotsCount = geodesRobotsCount + 1, oreCount = oreCount + oreRobotsCount - blueprint.oreForGeodeRobot, clayCount = clayCount + clayRobotsCount, obsidianCount = obsidianCount + obsidianRobotsCount - blueprint.obsidianForGeodeRobot, geodesCount = geodesCount + geodesRobotsCount ) ) } if (canBuildObsidianRobot) { result = max( result, calculateMaxGeodes( blueprint = blueprint, minutesLeft = minutesLeft - 1, memo = memo, oreRobotsCount = oreRobotsCount, clayRobotsCount = clayRobotsCount, obsidianRobotsCount = obsidianRobotsCount + 1, geodesRobotsCount = geodesRobotsCount, oreCount = oreCount + oreRobotsCount - blueprint.oreForObsidianRobot, clayCount = clayCount + clayRobotsCount - blueprint.clayForObsidianRobot, obsidianCount = obsidianCount + obsidianRobotsCount, geodesCount = geodesCount + geodesRobotsCount ) ) } if (canBuildClayRobot) { result = max( result, calculateMaxGeodes( blueprint = blueprint, minutesLeft = minutesLeft - 1, memo = memo, oreRobotsCount = oreRobotsCount, clayRobotsCount = clayRobotsCount + 1, obsidianRobotsCount = obsidianRobotsCount, geodesRobotsCount = geodesRobotsCount, oreCount = oreCount + oreRobotsCount - blueprint.oreForClayRobot, clayCount = clayCount + clayRobotsCount, obsidianCount = obsidianCount + obsidianRobotsCount, geodesCount = geodesCount + geodesRobotsCount ) ) } if (canBuildOreRobot) { result = max( result, calculateMaxGeodes( blueprint = blueprint, minutesLeft = minutesLeft - 1, memo = memo, oreRobotsCount = oreRobotsCount + 1, clayRobotsCount = clayRobotsCount, obsidianRobotsCount = obsidianRobotsCount, geodesRobotsCount = geodesRobotsCount, oreCount = oreCount + oreRobotsCount - blueprint.oreForOreRobot, clayCount = clayCount + clayRobotsCount, obsidianCount = obsidianCount + obsidianRobotsCount, geodesCount = geodesCount + geodesRobotsCount ) ) } result = max( result, calculateMaxGeodes( blueprint = blueprint, minutesLeft = minutesLeft - 1, memo = memo, oreRobotsCount = oreRobotsCount, clayRobotsCount = clayRobotsCount, obsidianRobotsCount = obsidianRobotsCount, geodesRobotsCount = geodesRobotsCount, oreCount = oreCount + oreRobotsCount, clayCount = clayCount + clayRobotsCount, obsidianCount = obsidianCount + obsidianRobotsCount, geodesCount = geodesCount + geodesRobotsCount ) ) memo[key] = result return result } private val BLUEPRINT_FORMAT = Regex("Blueprint (\\d+): Each ore robot costs (\\d+) ore. Each clay robot costs (\\d+) ore. Each obsidian robot costs (\\d+) ore and (\\d+) clay. Each geode robot costs (\\d+) ore and (\\d+) obsidian.") private class Blueprint( val number: Int, val oreForOreRobot: Int, val oreForClayRobot: Int, val oreForObsidianRobot: Int, val clayForObsidianRobot: Int, val oreForGeodeRobot: Int, val obsidianForGeodeRobot: Int, ) { val oreMax: Int by lazy { maxOf(oreForOreRobot, oreForClayRobot, oreForObsidianRobot, oreForGeodeRobot) } val clayMax: Int get() = clayForObsidianRobot val obsidianMax: Int get() = obsidianForGeodeRobot companion object { fun fromString(str: String): Blueprint { val match = BLUEPRINT_FORMAT.find(str) val (number, oreForOreRobot, oreForClayRobot, oreForObsidianRobot, clayForObsidianRobot, oreForGeodeRobot, obsidianForGeodeRobot) = requireNotNull( match ).destructured return Blueprint( number.toInt(), oreForOreRobot.toInt(), oreForClayRobot.toInt(), oreForObsidianRobot.toInt(), clayForObsidianRobot.toInt(), oreForGeodeRobot.toInt(), obsidianForGeodeRobot.toInt() ) } } }
[ { "class_path": "Kvest__AOC2022__6409e65/Day19Kt.class", "javap": "Compiled from \"Day19.kt\"\npublic final class Day19Kt {\n private static final kotlin.text.Regex BLUEPRINT_FORMAT;\n\n public static final void main();\n Code:\n 0: ldc #8 // String Day19_test\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_2\n 11: getstatic #22 // Field Blueprint.Companion:LBlueprint$Companion;\n 14: astore_3\n 15: iconst_0\n 16: istore 4\n 18: aload_2\n 19: astore 5\n 21: new #24 // class java/util/ArrayList\n 24: dup\n 25: aload_2\n 26: bipush 10\n 28: invokestatic #30 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 31: invokespecial #34 // Method java/util/ArrayList.\"<init>\":(I)V\n 34: checkcast #36 // class java/util/Collection\n 37: astore 6\n 39: iconst_0\n 40: istore 7\n 42: aload 5\n 44: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 49: astore 8\n 51: aload 8\n 53: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 58: ifeq 102\n 61: aload 8\n 63: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 68: astore 9\n 70: aload 6\n 72: aload 9\n 74: checkcast #52 // class java/lang/String\n 77: astore 10\n 79: astore 14\n 81: iconst_0\n 82: istore 11\n 84: aload_3\n 85: aload 10\n 87: invokevirtual #58 // Method Blueprint$Companion.fromString:(Ljava/lang/String;)LBlueprint;\n 90: aload 14\n 92: swap\n 93: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 98: pop\n 99: goto 51\n 102: aload 6\n 104: checkcast #64 // class java/util/List\n 107: nop\n 108: astore_1\n 109: aload_1\n 110: invokestatic #68 // Method part1:(Ljava/util/List;)I\n 113: bipush 33\n 115: if_icmpne 122\n 118: iconst_1\n 119: goto 123\n 122: iconst_0\n 123: ifne 136\n 126: new #70 // class java/lang/IllegalStateException\n 129: dup\n 130: ldc #72 // String Check failed.\n 132: invokespecial #75 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 135: athrow\n 136: ldc #77 // String Day19\n 138: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 141: astore_2\n 142: aload_2\n 143: checkcast #16 // class java/lang/Iterable\n 146: astore 4\n 148: getstatic #22 // Field Blueprint.Companion:LBlueprint$Companion;\n 151: astore 5\n 153: iconst_0\n 154: istore 6\n 156: aload 4\n 158: astore 7\n 160: new #24 // class java/util/ArrayList\n 163: dup\n 164: aload 4\n 166: bipush 10\n 168: invokestatic #30 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 171: invokespecial #34 // Method java/util/ArrayList.\"<init>\":(I)V\n 174: checkcast #36 // class java/util/Collection\n 177: astore 8\n 179: iconst_0\n 180: istore 9\n 182: aload 7\n 184: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 189: astore 10\n 191: aload 10\n 193: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 198: ifeq 243\n 201: aload 10\n 203: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 208: astore 11\n 210: aload 8\n 212: aload 11\n 214: checkcast #52 // class java/lang/String\n 217: astore 12\n 219: astore 14\n 221: iconst_0\n 222: istore 13\n 224: aload 5\n 226: aload 12\n 228: invokevirtual #58 // Method Blueprint$Companion.fromString:(Ljava/lang/String;)LBlueprint;\n 231: aload 14\n 233: swap\n 234: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 239: pop\n 240: goto 191\n 243: aload 8\n 245: checkcast #64 // class java/util/List\n 248: nop\n 249: astore_3\n 250: aload_3\n 251: invokestatic #68 // Method part1:(Ljava/util/List;)I\n 254: istore 4\n 256: getstatic #83 // Field java/lang/System.out:Ljava/io/PrintStream;\n 259: iload 4\n 261: invokevirtual #88 // Method java/io/PrintStream.println:(I)V\n 264: aload_3\n 265: invokestatic #91 // Method part2:(Ljava/util/List;)I\n 268: istore 4\n 270: getstatic #83 // Field java/lang/System.out:Ljava/io/PrintStream;\n 273: iload 4\n 275: invokevirtual #88 // Method java/io/PrintStream.println:(I)V\n 278: return\n\n private static final int part1(java.util.List<Blueprint>);\n Code:\n 0: aload_0\n 1: checkcast #16 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #40, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #46, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 81\n 23: aload_3\n 24: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 29: astore 4\n 31: iload_2\n 32: aload 4\n 34: checkcast #18 // class Blueprint\n 37: astore 5\n 39: istore 7\n 41: iconst_0\n 42: istore 6\n 44: aload 5\n 46: invokevirtual #115 // Method Blueprint.getNumber:()I\n 49: aload 5\n 51: bipush 24\n 53: aconst_null\n 54: iconst_0\n 55: iconst_0\n 56: iconst_0\n 57: iconst_0\n 58: iconst_0\n 59: iconst_0\n 60: iconst_0\n 61: iconst_0\n 62: sipush 2044\n 65: aconst_null\n 66: invokestatic #119 // Method calculateMaxGeodes$default:(LBlueprint;ILjava/util/Map;IIIIIIIIILjava/lang/Object;)I\n 69: imul\n 70: istore 8\n 72: iload 7\n 74: iload 8\n 76: iadd\n 77: istore_2\n 78: goto 14\n 81: iload_2\n 82: ireturn\n\n private static final int part2(java.util.List<Blueprint>);\n Code:\n 0: aload_0\n 1: iconst_0\n 2: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #18 // class Blueprint\n 10: bipush 32\n 12: aconst_null\n 13: iconst_0\n 14: iconst_0\n 15: iconst_0\n 16: iconst_0\n 17: iconst_0\n 18: iconst_0\n 19: iconst_0\n 20: iconst_0\n 21: sipush 2044\n 24: aconst_null\n 25: invokestatic #119 // Method calculateMaxGeodes$default:(LBlueprint;ILjava/util/Map;IIIIIIIIILjava/lang/Object;)I\n 28: aload_0\n 29: iconst_1\n 30: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 35: checkcast #18 // class Blueprint\n 38: bipush 32\n 40: aconst_null\n 41: iconst_0\n 42: iconst_0\n 43: iconst_0\n 44: iconst_0\n 45: iconst_0\n 46: iconst_0\n 47: iconst_0\n 48: iconst_0\n 49: sipush 2044\n 52: aconst_null\n 53: invokestatic #119 // Method calculateMaxGeodes$default:(LBlueprint;ILjava/util/Map;IIIIIIIIILjava/lang/Object;)I\n 56: imul\n 57: aload_0\n 58: iconst_2\n 59: invokeinterface #126, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 64: checkcast #18 // class Blueprint\n 67: bipush 32\n 69: aconst_null\n 70: iconst_0\n 71: iconst_0\n 72: iconst_0\n 73: iconst_0\n 74: iconst_0\n 75: iconst_0\n 76: iconst_0\n 77: iconst_0\n 78: sipush 2044\n 81: aconst_null\n 82: invokestatic #119 // Method calculateMaxGeodes$default:(LBlueprint;ILjava/util/Map;IIIIIIIIILjava/lang/Object;)I\n 85: imul\n 86: ireturn\n\n private static final int calculateMaxGeodes(Blueprint, int, java.util.Map<java.lang.Long, java.lang.Integer>, int, int, int, int, int, int, int, int);\n Code:\n 0: iload_1\n 1: ifne 7\n 4: iload 10\n 6: ireturn\n 7: iload 7\n 9: iload_1\n 10: aload_0\n 11: invokevirtual #132 // Method Blueprint.getOreMax:()I\n 14: imul\n 15: invokestatic #138 // Method java/lang/Math.min:(II)I\n 18: istore 11\n 20: iload 8\n 22: iload_1\n 23: aload_0\n 24: invokevirtual #141 // Method Blueprint.getClayMax:()I\n 27: imul\n 28: invokestatic #138 // Method java/lang/Math.min:(II)I\n 31: istore 12\n 33: iload 9\n 35: iload_1\n 36: aload_0\n 37: invokevirtual #144 // Method Blueprint.getObsidianMax:()I\n 40: imul\n 41: invokestatic #138 // Method java/lang/Math.min:(II)I\n 44: istore 13\n 46: iload_1\n 47: i2l\n 48: ldc2_w #145 // long 1000000000000000000l\n 51: lmul\n 52: iload_3\n 53: i2l\n 54: ldc2_w #147 // long 10000000000000000l\n 57: lmul\n 58: ladd\n 59: iload 4\n 61: i2l\n 62: ldc2_w #149 // long 100000000000000l\n 65: lmul\n 66: ladd\n 67: iload 5\n 69: i2l\n 70: ldc2_w #151 // long 1000000000000l\n 73: lmul\n 74: ladd\n 75: iload 6\n 77: i2l\n 78: ldc2_w #153 // long 10000000000l\n 81: lmul\n 82: ladd\n 83: iload 11\n 85: i2l\n 86: ldc2_w #155 // long 100000000l\n 89: lmul\n 90: ladd\n 91: iload 12\n 93: i2l\n 94: ldc2_w #157 // long 1000000l\n 97: lmul\n 98: ladd\n 99: iload 13\n 101: i2l\n 102: ldc2_w #159 // long 10000l\n 105: lmul\n 106: ladd\n 107: iload 10\n 109: i2l\n 110: ldc2_w #161 // long 100l\n 113: lmul\n 114: ladd\n 115: lstore 14\n 117: lload 14\n 119: invokestatic #168 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 122: aload_2\n 123: swap\n 124: invokeinterface #173, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 129: ifeq 148\n 132: aload_2\n 133: lload 14\n 135: invokestatic #168 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 138: invokestatic #179 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 141: checkcast #181 // class java/lang/Number\n 144: invokevirtual #184 // Method java/lang/Number.intValue:()I\n 147: ireturn\n 148: iconst_0\n 149: istore 16\n 151: iload 7\n 153: aload_0\n 154: invokevirtual #187 // Method Blueprint.getOreForOreRobot:()I\n 157: if_icmplt 172\n 160: iload_3\n 161: aload_0\n 162: invokevirtual #132 // Method Blueprint.getOreMax:()I\n 165: if_icmpge 172\n 168: iconst_1\n 169: goto 173\n 172: iconst_0\n 173: istore 17\n 175: iload 7\n 177: aload_0\n 178: invokevirtual #190 // Method Blueprint.getOreForClayRobot:()I\n 181: if_icmplt 197\n 184: iload 4\n 186: aload_0\n 187: invokevirtual #141 // Method Blueprint.getClayMax:()I\n 190: if_icmpge 197\n 193: iconst_1\n 194: goto 198\n 197: iconst_0\n 198: istore 18\n 200: iload 7\n 202: aload_0\n 203: invokevirtual #193 // Method Blueprint.getOreForObsidianRobot:()I\n 206: if_icmplt 231\n 209: iload 8\n 211: aload_0\n 212: invokevirtual #196 // Method Blueprint.getClayForObsidianRobot:()I\n 215: if_icmplt 231\n 218: iload 9\n 220: aload_0\n 221: invokevirtual #144 // Method Blueprint.getObsidianMax:()I\n 224: if_icmpgt 231\n 227: iconst_1\n 228: goto 232\n 231: iconst_0\n 232: istore 19\n 234: iload 7\n 236: aload_0\n 237: invokevirtual #199 // Method Blueprint.getOreForGeodeRobot:()I\n 240: if_icmplt 256\n 243: iload 9\n 245: aload_0\n 246: invokevirtual #202 // Method Blueprint.getObsidianForGeodeRobot:()I\n 249: if_icmplt 256\n 252: iconst_1\n 253: goto 257\n 256: iconst_0\n 257: istore 20\n 259: iload 20\n 261: ifeq 317\n 264: iload 16\n 266: aload_0\n 267: iload_1\n 268: iconst_1\n 269: isub\n 270: aload_2\n 271: iload_3\n 272: iload 4\n 274: iload 5\n 276: iload 6\n 278: iconst_1\n 279: iadd\n 280: iload 7\n 282: iload_3\n 283: iadd\n 284: aload_0\n 285: invokevirtual #199 // Method Blueprint.getOreForGeodeRobot:()I\n 288: isub\n 289: iload 8\n 291: iload 4\n 293: iadd\n 294: iload 9\n 296: iload 5\n 298: iadd\n 299: aload_0\n 300: invokevirtual #202 // Method Blueprint.getObsidianForGeodeRobot:()I\n 303: isub\n 304: iload 10\n 306: iload 6\n 308: iadd\n 309: invokestatic #204 // Method calculateMaxGeodes:(LBlueprint;ILjava/util/Map;IIIIIIII)I\n 312: invokestatic #207 // Method java/lang/Math.max:(II)I\n 315: istore 16\n 317: iload 19\n 319: ifeq 375\n 322: iload 16\n 324: aload_0\n 325: iload_1\n 326: iconst_1\n 327: isub\n 328: aload_2\n 329: iload_3\n 330: iload 4\n 332: iload 5\n 334: iconst_1\n 335: iadd\n 336: iload 6\n 338: iload 7\n 340: iload_3\n 341: iadd\n 342: aload_0\n 343: invokevirtual #193 // Method Blueprint.getOreForObsidianRobot:()I\n 346: isub\n 347: iload 8\n 349: iload 4\n 351: iadd\n 352: aload_0\n 353: invokevirtual #196 // Method Blueprint.getClayForObsidianRobot:()I\n 356: isub\n 357: iload 9\n 359: iload 5\n 361: iadd\n 362: iload 10\n 364: iload 6\n 366: iadd\n 367: invokestatic #204 // Method calculateMaxGeodes:(LBlueprint;ILjava/util/Map;IIIIIIII)I\n 370: invokestatic #207 // Method java/lang/Math.max:(II)I\n 373: istore 16\n 375: iload 18\n 377: ifeq 428\n 380: iload 16\n 382: aload_0\n 383: iload_1\n 384: iconst_1\n 385: isub\n 386: aload_2\n 387: iload_3\n 388: iload 4\n 390: iconst_1\n 391: iadd\n 392: iload 5\n 394: iload 6\n 396: iload 7\n 398: iload_3\n 399: iadd\n 400: aload_0\n 401: invokevirtual #190 // Method Blueprint.getOreForClayRobot:()I\n 404: isub\n 405: iload 8\n 407: iload 4\n 409: iadd\n 410: iload 9\n 412: iload 5\n 414: iadd\n 415: iload 10\n 417: iload 6\n 419: iadd\n 420: invokestatic #204 // Method calculateMaxGeodes:(LBlueprint;ILjava/util/Map;IIIIIIII)I\n 423: invokestatic #207 // Method java/lang/Math.max:(II)I\n 426: istore 16\n 428: iload 17\n 430: ifeq 481\n 433: iload 16\n 435: aload_0\n 436: iload_1\n 437: iconst_1\n 438: isub\n 439: aload_2\n 440: iload_3\n 441: iconst_1\n 442: iadd\n 443: iload 4\n 445: iload 5\n 447: iload 6\n 449: iload 7\n 451: iload_3\n 452: iadd\n 453: aload_0\n 454: invokevirtual #187 // Method Blueprint.getOreForOreRobot:()I\n 457: isub\n 458: iload 8\n 460: iload 4\n 462: iadd\n 463: iload 9\n 465: iload 5\n 467: iadd\n 468: iload 10\n 470: iload 6\n 472: iadd\n 473: invokestatic #204 // Method calculateMaxGeodes:(LBlueprint;ILjava/util/Map;IIIIIIII)I\n 476: invokestatic #207 // Method java/lang/Math.max:(II)I\n 479: istore 16\n 481: iload 16\n 483: aload_0\n 484: iload_1\n 485: iconst_1\n 486: isub\n 487: aload_2\n 488: iload_3\n 489: iload 4\n 491: iload 5\n 493: iload 6\n 495: iload 7\n 497: iload_3\n 498: iadd\n 499: iload 8\n 501: iload 4\n 503: iadd\n 504: iload 9\n 506: iload 5\n 508: iadd\n 509: iload 10\n 511: iload 6\n 513: iadd\n 514: invokestatic #204 // Method calculateMaxGeodes:(LBlueprint;ILjava/util/Map;IIIIIIII)I\n 517: invokestatic #207 // Method java/lang/Math.max:(II)I\n 520: istore 16\n 522: lload 14\n 524: invokestatic #168 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 527: astore 21\n 529: iload 16\n 531: invokestatic #212 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 534: astore 22\n 536: aload_2\n 537: aload 21\n 539: aload 22\n 541: invokeinterface #216, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 546: pop\n 547: iload 16\n 549: ireturn\n\n static int calculateMaxGeodes$default(Blueprint, int, java.util.Map, int, int, int, int, int, int, int, int, int, java.lang.Object);\n Code:\n 0: iload 11\n 2: iconst_4\n 3: iand\n 4: ifeq 18\n 7: new #241 // class java/util/LinkedHashMap\n 10: dup\n 11: invokespecial #243 // Method java/util/LinkedHashMap.\"<init>\":()V\n 14: checkcast #170 // class java/util/Map\n 17: astore_2\n 18: iload 11\n 20: bipush 8\n 22: iand\n 23: ifeq 28\n 26: iconst_1\n 27: istore_3\n 28: iload 11\n 30: bipush 16\n 32: iand\n 33: ifeq 39\n 36: iconst_0\n 37: istore 4\n 39: iload 11\n 41: bipush 32\n 43: iand\n 44: ifeq 50\n 47: iconst_0\n 48: istore 5\n 50: iload 11\n 52: bipush 64\n 54: iand\n 55: ifeq 61\n 58: iconst_0\n 59: istore 6\n 61: iload 11\n 63: sipush 128\n 66: iand\n 67: ifeq 73\n 70: iconst_0\n 71: istore 7\n 73: iload 11\n 75: sipush 256\n 78: iand\n 79: ifeq 85\n 82: iconst_0\n 83: istore 8\n 85: iload 11\n 87: sipush 512\n 90: iand\n 91: ifeq 97\n 94: iconst_0\n 95: istore 9\n 97: iload 11\n 99: sipush 1024\n 102: iand\n 103: ifeq 109\n 106: iconst_0\n 107: istore 10\n 109: aload_0\n 110: iload_1\n 111: aload_2\n 112: iload_3\n 113: iload 4\n 115: iload 5\n 117: iload 6\n 119: iload 7\n 121: iload 8\n 123: iload 9\n 125: iload 10\n 127: invokestatic #204 // Method calculateMaxGeodes:(LBlueprint;ILjava/util/Map;IIIIIIII)I\n 130: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #246 // Method main:()V\n 3: return\n\n public static final kotlin.text.Regex access$getBLUEPRINT_FORMAT$p();\n Code:\n 0: getstatic #254 // Field BLUEPRINT_FORMAT:Lkotlin/text/Regex;\n 3: areturn\n\n static {};\n Code:\n 0: new #257 // class kotlin/text/Regex\n 3: dup\n 4: ldc_w #259 // String Blueprint (\\\\d+): Each ore robot costs (\\\\d+) ore. Each clay robot costs (\\\\d+) ore. Each obsidian robot costs (\\\\d+) ore and (\\\\d+) clay. Each geode robot costs (\\\\d+) ore and (\\\\d+) obsidian.\n 7: invokespecial #260 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 10: putstatic #254 // Field BLUEPRINT_FORMAT:Lkotlin/text/Regex;\n 13: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day18.kt
import kotlin.math.max fun main() { val testInput = readInput("Day18_test") check(part1(testInput) == 64) check(part2(testInput) == 58) val input = readInput("Day18") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { val cubes = input.to3DMatrix() return solve(input, cubes) } private fun part2(input: List<String>): Int { val cubes = input.to3DMatrix() val water = fillWithWater(cubes) return solve(input, water) } private fun solve(input: List<String>, emptyCubes: Boolean3DMatrix): Int { return input.sumOf { var cnt = 0 val (xStr,yStr,zStr) = it.split(",") val x = xStr.toInt() val y = yStr.toInt() val z = zStr.toInt() if (emptyCubes.isEmpty(x + 1, y, z)) cnt++ if (emptyCubes.isEmpty(x - 1, y, z)) cnt++ if (emptyCubes.isEmpty(x, y + 1, z)) cnt++ if (emptyCubes.isEmpty(x, y - 1, z)) cnt++ if (emptyCubes.isEmpty(x, y, z + 1)) cnt++ if (emptyCubes.isEmpty(x, y, z - 1)) cnt++ cnt } } private fun List<String>.to3DMatrix(): Boolean3DMatrix { var xMax = 0 var yMax = 0 var zMax = 0 this.forEach { val (x,y,z) = it.split(",") xMax = max(xMax, x.toInt()) yMax = max(yMax, y.toInt()) zMax = max(zMax, z.toInt()) } val result = Array(xMax + 1) { Array(yMax + 1) { BooleanArray(zMax + 1) } } this.forEach { val (x, y, z) = it.split(",") result[x.toInt()][y.toInt()][z.toInt()] = true } return result } private fun fillWithWater(cubes: Boolean3DMatrix): Boolean3DMatrix { val result = Array(cubes.size) { Array(cubes[0].size) { BooleanArray(cubes[0][0].size) { true } } } val xLastIndex = cubes.lastIndex val yLastIndex = cubes[0].lastIndex val zLastIndex = cubes[0][0].lastIndex for (x in cubes.indices) { for (y in cubes[0].indices) { fill(cubes, result, x, y, 0) fill(cubes, result, x, y, zLastIndex) } } for (x in cubes.indices) { for (z in cubes[0][0].indices) { fill(cubes, result, x, 0, z) fill(cubes, result, x, yLastIndex, z) } } for (y in cubes[0].indices) { for (z in cubes[0][0].indices) { fill(cubes, result, 0, y, z) fill(cubes, result, xLastIndex, y, z) } } return result } private fun fill(cubes: Boolean3DMatrix, water: Boolean3DMatrix, x: Int, y: Int, z: Int) { if (!water.isXYZInside(x, y, z) || cubes[x][y][z] || !water[x][y][z]) { return } water[x][y][z] = false fill(cubes, water, x + 1, y, z) fill(cubes, water, x - 1, y, z) fill(cubes, water, x, y + 1, z) fill(cubes, water, x, y - 1, z) fill(cubes, water, x, y, z + 1) fill(cubes, water, x, y, z - 1) } private fun Boolean3DMatrix.isEmpty(x: Int, y: Int, z: Int): Boolean { return if (this.isXYZInside(x, y, z)) { !this[x][y][z] } else { true } } private fun Boolean3DMatrix.isXYZInside(x: Int, y: Int, z: Int): Boolean { return (x in this.indices && y in this[x].indices && z in this[x][y].indices) }
[ { "class_path": "Kvest__AOC2022__6409e65/Day18Kt.class", "javap": "Compiled from \"Day18.kt\"\npublic final class Day18Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day18_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: bipush 64\n 12: if_icmpne 19\n 15: iconst_1\n 16: goto 20\n 19: iconst_0\n 20: ifne 33\n 23: new #20 // class java/lang/IllegalStateException\n 26: dup\n 27: ldc #22 // String Check failed.\n 29: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 32: athrow\n 33: aload_0\n 34: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 37: bipush 58\n 39: if_icmpne 46\n 42: iconst_1\n 43: goto 47\n 46: iconst_0\n 47: ifne 60\n 50: new #20 // class java/lang/IllegalStateException\n 53: dup\n 54: ldc #22 // String Check failed.\n 56: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 59: athrow\n 60: ldc #31 // String Day18\n 62: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 65: astore_1\n 66: aload_1\n 67: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 70: istore_2\n 71: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 74: iload_2\n 75: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 78: aload_1\n 79: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 82: istore_2\n 83: getstatic #37 // Field java/lang/System.out:Ljava/io/PrintStream;\n 86: iload_2\n 87: invokevirtual #43 // Method java/io/PrintStream.println:(I)V\n 90: return\n\n private static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #53 // Method to3DMatrix:(Ljava/util/List;)[[[Z\n 4: astore_1\n 5: aload_0\n 6: aload_1\n 7: invokestatic #57 // Method solve:(Ljava/util/List;[[[Z)I\n 10: ireturn\n\n private static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #53 // Method to3DMatrix:(Ljava/util/List;)[[[Z\n 4: astore_1\n 5: aload_1\n 6: invokestatic #63 // Method fillWithWater:([[[Z)[[[Z\n 9: astore_2\n 10: aload_0\n 11: aload_2\n 12: invokestatic #57 // Method solve:(Ljava/util/List;[[[Z)I\n 15: ireturn\n\n private static final int solve(java.util.List<java.lang.String>, boolean[][][]);\n Code:\n 0: aload_0\n 1: checkcast #67 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore 4\n 15: aload 4\n 17: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 22: ifeq 260\n 25: aload 4\n 27: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 32: astore 5\n 34: iload_3\n 35: aload 5\n 37: checkcast #83 // class java/lang/String\n 40: astore 6\n 42: istore 16\n 44: iconst_0\n 45: istore 7\n 47: iconst_0\n 48: istore 8\n 50: aload 6\n 52: checkcast #85 // class java/lang/CharSequence\n 55: iconst_1\n 56: anewarray #83 // class java/lang/String\n 59: astore 9\n 61: aload 9\n 63: iconst_0\n 64: ldc #87 // String ,\n 66: aastore\n 67: aload 9\n 69: iconst_0\n 70: iconst_0\n 71: bipush 6\n 73: aconst_null\n 74: invokestatic #93 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 77: astore 10\n 79: aload 10\n 81: iconst_0\n 82: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 87: checkcast #83 // class java/lang/String\n 90: astore 9\n 92: aload 10\n 94: iconst_1\n 95: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 100: checkcast #83 // class java/lang/String\n 103: astore 11\n 105: aload 10\n 107: iconst_2\n 108: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 113: checkcast #83 // class java/lang/String\n 116: astore 12\n 118: aload 9\n 120: invokestatic #103 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 123: istore 13\n 125: aload 11\n 127: invokestatic #103 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 130: istore 14\n 132: aload 12\n 134: invokestatic #103 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 137: istore 15\n 139: aload_1\n 140: iload 13\n 142: iconst_1\n 143: iadd\n 144: iload 14\n 146: iload 15\n 148: invokestatic #107 // Method isEmpty:([[[ZIII)Z\n 151: ifeq 157\n 154: iinc 8, 1\n 157: aload_1\n 158: iload 13\n 160: iconst_1\n 161: isub\n 162: iload 14\n 164: iload 15\n 166: invokestatic #107 // Method isEmpty:([[[ZIII)Z\n 169: ifeq 175\n 172: iinc 8, 1\n 175: aload_1\n 176: iload 13\n 178: iload 14\n 180: iconst_1\n 181: iadd\n 182: iload 15\n 184: invokestatic #107 // Method isEmpty:([[[ZIII)Z\n 187: ifeq 193\n 190: iinc 8, 1\n 193: aload_1\n 194: iload 13\n 196: iload 14\n 198: iconst_1\n 199: isub\n 200: iload 15\n 202: invokestatic #107 // Method isEmpty:([[[ZIII)Z\n 205: ifeq 211\n 208: iinc 8, 1\n 211: aload_1\n 212: iload 13\n 214: iload 14\n 216: iload 15\n 218: iconst_1\n 219: iadd\n 220: invokestatic #107 // Method isEmpty:([[[ZIII)Z\n 223: ifeq 229\n 226: iinc 8, 1\n 229: aload_1\n 230: iload 13\n 232: iload 14\n 234: iload 15\n 236: iconst_1\n 237: isub\n 238: invokestatic #107 // Method isEmpty:([[[ZIII)Z\n 241: ifeq 247\n 244: iinc 8, 1\n 247: iload 8\n 249: istore 17\n 251: iload 16\n 253: iload 17\n 255: iadd\n 256: istore_3\n 257: goto 15\n 260: iload_3\n 261: ireturn\n\n private static final boolean[][][] to3DMatrix(java.util.List<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 #67 // class java/lang/Iterable\n 10: astore 4\n 12: iconst_0\n 13: istore 5\n 15: aload 4\n 17: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 22: astore 6\n 24: aload 6\n 26: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 31: ifeq 159\n 34: aload 6\n 36: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 41: astore 7\n 43: aload 7\n 45: checkcast #83 // class java/lang/String\n 48: astore 8\n 50: iconst_0\n 51: istore 9\n 53: aload 8\n 55: checkcast #85 // class java/lang/CharSequence\n 58: iconst_1\n 59: anewarray #83 // class java/lang/String\n 62: astore 10\n 64: aload 10\n 66: iconst_0\n 67: ldc #87 // String ,\n 69: aastore\n 70: aload 10\n 72: iconst_0\n 73: iconst_0\n 74: bipush 6\n 76: aconst_null\n 77: invokestatic #93 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 80: astore 11\n 82: aload 11\n 84: iconst_0\n 85: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 90: checkcast #83 // class java/lang/String\n 93: astore 10\n 95: aload 11\n 97: iconst_1\n 98: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 103: checkcast #83 // class java/lang/String\n 106: astore 12\n 108: aload 11\n 110: iconst_2\n 111: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 116: checkcast #83 // class java/lang/String\n 119: astore 13\n 121: nop\n 122: iload_1\n 123: aload 10\n 125: invokestatic #103 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 128: invokestatic #127 // Method java/lang/Math.max:(II)I\n 131: istore_1\n 132: nop\n 133: iload_2\n 134: aload 12\n 136: invokestatic #103 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 139: invokestatic #127 // Method java/lang/Math.max:(II)I\n 142: istore_2\n 143: nop\n 144: iload_3\n 145: aload 13\n 147: invokestatic #103 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 150: invokestatic #127 // Method java/lang/Math.max:(II)I\n 153: istore_3\n 154: nop\n 155: nop\n 156: goto 24\n 159: nop\n 160: iconst_0\n 161: istore 5\n 163: iload_1\n 164: iconst_1\n 165: iadd\n 166: istore 6\n 168: iload 6\n 170: anewarray #129 // class \"[[Z\"\n 173: astore 7\n 175: iload 5\n 177: iload 6\n 179: if_icmpge 249\n 182: iload 5\n 184: istore 8\n 186: aload 7\n 188: iload 8\n 190: iconst_0\n 191: istore 9\n 193: iload_2\n 194: iconst_1\n 195: iadd\n 196: istore 10\n 198: iload 10\n 200: anewarray #131 // class \"[Z\"\n 203: astore 11\n 205: istore 16\n 207: astore 15\n 209: iload 9\n 211: iload 10\n 213: if_icmpge 236\n 216: iload 9\n 218: istore 12\n 220: aload 11\n 222: iload 12\n 224: iload_3\n 225: iconst_1\n 226: iadd\n 227: newarray boolean\n 229: aastore\n 230: iinc 9, 1\n 233: goto 209\n 236: aload 15\n 238: iload 16\n 240: aload 11\n 242: aastore\n 243: iinc 5, 1\n 246: goto 175\n 249: aload 7\n 251: astore 4\n 253: aload_0\n 254: checkcast #67 // class java/lang/Iterable\n 257: astore 5\n 259: iconst_0\n 260: istore 6\n 262: aload 5\n 264: invokeinterface #71, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 269: astore 7\n 271: aload 7\n 273: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 278: ifeq 394\n 281: aload 7\n 283: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 288: astore 8\n 290: aload 8\n 292: checkcast #83 // class java/lang/String\n 295: astore 9\n 297: iconst_0\n 298: istore 10\n 300: aload 9\n 302: checkcast #85 // class java/lang/CharSequence\n 305: iconst_1\n 306: anewarray #83 // class java/lang/String\n 309: astore 11\n 311: aload 11\n 313: iconst_0\n 314: ldc #87 // String ,\n 316: aastore\n 317: aload 11\n 319: iconst_0\n 320: iconst_0\n 321: bipush 6\n 323: aconst_null\n 324: invokestatic #93 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 327: astore 12\n 329: aload 12\n 331: iconst_0\n 332: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 337: checkcast #83 // class java/lang/String\n 340: astore 11\n 342: aload 12\n 344: iconst_1\n 345: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 350: checkcast #83 // class java/lang/String\n 353: astore 13\n 355: aload 12\n 357: iconst_2\n 358: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 363: checkcast #83 // class java/lang/String\n 366: astore 14\n 368: aload 4\n 370: aload 11\n 372: invokestatic #103 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 375: aaload\n 376: aload 13\n 378: invokestatic #103 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 381: aaload\n 382: aload 14\n 384: invokestatic #103 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 387: iconst_1\n 388: bastore\n 389: nop\n 390: nop\n 391: goto 271\n 394: nop\n 395: aload 4\n 397: areturn\n\n private static final boolean[][][] fillWithWater(boolean[][][]);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: aload_0\n 3: checkcast #145 // class \"[Ljava/lang/Object;\"\n 6: arraylength\n 7: istore_3\n 8: iload_3\n 9: anewarray #129 // class \"[[Z\"\n 12: astore 4\n 14: iload_2\n 15: iload_3\n 16: if_icmpge 134\n 19: iload_2\n 20: istore 5\n 22: aload 4\n 24: iload 5\n 26: iconst_0\n 27: istore 6\n 29: aload_0\n 30: iconst_0\n 31: aaload\n 32: checkcast #145 // class \"[Ljava/lang/Object;\"\n 35: arraylength\n 36: istore 7\n 38: iload 7\n 40: anewarray #131 // class \"[Z\"\n 43: astore 8\n 45: istore 15\n 47: astore 14\n 49: iload 6\n 51: iload 7\n 53: if_icmpge 121\n 56: iload 6\n 58: istore 9\n 60: aload 8\n 62: iload 9\n 64: iconst_0\n 65: istore 10\n 67: aload_0\n 68: iconst_0\n 69: aaload\n 70: iconst_0\n 71: aaload\n 72: arraylength\n 73: istore 11\n 75: iload 11\n 77: newarray boolean\n 79: astore 12\n 81: istore 17\n 83: astore 16\n 85: iload 10\n 87: iload 11\n 89: if_icmpge 108\n 92: iload 10\n 94: istore 13\n 96: aload 12\n 98: iload 13\n 100: iconst_1\n 101: bastore\n 102: iinc 10, 1\n 105: goto 85\n 108: aload 16\n 110: iload 17\n 112: aload 12\n 114: aastore\n 115: iinc 6, 1\n 118: goto 49\n 121: aload 14\n 123: iload 15\n 125: aload 8\n 127: aastore\n 128: iinc 2, 1\n 131: goto 14\n 134: aload 4\n 136: astore_1\n 137: aload_0\n 138: checkcast #145 // class \"[Ljava/lang/Object;\"\n 141: invokestatic #151 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 144: istore_2\n 145: aload_0\n 146: iconst_0\n 147: aaload\n 148: checkcast #145 // class \"[Ljava/lang/Object;\"\n 151: invokestatic #151 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I\n 154: istore_3\n 155: aload_0\n 156: iconst_0\n 157: aaload\n 158: iconst_0\n 159: aaload\n 160: invokestatic #154 // Method kotlin/collections/ArraysKt.getLastIndex:([Z)I\n 163: istore 4\n 165: iconst_0\n 166: istore 5\n 168: aload_0\n 169: checkcast #145 // class \"[Ljava/lang/Object;\"\n 172: arraylength\n 173: istore 6\n 175: iload 5\n 177: iload 6\n 179: if_icmpge 234\n 182: iconst_0\n 183: istore 7\n 185: aload_0\n 186: iconst_0\n 187: aaload\n 188: checkcast #145 // class \"[Ljava/lang/Object;\"\n 191: arraylength\n 192: istore 8\n 194: iload 7\n 196: iload 8\n 198: if_icmpge 228\n 201: aload_0\n 202: aload_1\n 203: iload 5\n 205: iload 7\n 207: iconst_0\n 208: invokestatic #158 // Method fill:([[[Z[[[ZIII)V\n 211: aload_0\n 212: aload_1\n 213: iload 5\n 215: iload 7\n 217: iload 4\n 219: invokestatic #158 // Method fill:([[[Z[[[ZIII)V\n 222: iinc 7, 1\n 225: goto 194\n 228: iinc 5, 1\n 231: goto 175\n 234: iconst_0\n 235: istore 5\n 237: aload_0\n 238: checkcast #145 // class \"[Ljava/lang/Object;\"\n 241: arraylength\n 242: istore 6\n 244: iload 5\n 246: iload 6\n 248: if_icmpge 301\n 251: iconst_0\n 252: istore 7\n 254: aload_0\n 255: iconst_0\n 256: aaload\n 257: iconst_0\n 258: aaload\n 259: arraylength\n 260: istore 8\n 262: iload 7\n 264: iload 8\n 266: if_icmpge 295\n 269: aload_0\n 270: aload_1\n 271: iload 5\n 273: iconst_0\n 274: iload 7\n 276: invokestatic #158 // Method fill:([[[Z[[[ZIII)V\n 279: aload_0\n 280: aload_1\n 281: iload 5\n 283: iload_3\n 284: iload 7\n 286: invokestatic #158 // Method fill:([[[Z[[[ZIII)V\n 289: iinc 7, 1\n 292: goto 262\n 295: iinc 5, 1\n 298: goto 244\n 301: iconst_0\n 302: istore 5\n 304: aload_0\n 305: iconst_0\n 306: aaload\n 307: checkcast #145 // class \"[Ljava/lang/Object;\"\n 310: arraylength\n 311: istore 6\n 313: iload 5\n 315: iload 6\n 317: if_icmpge 370\n 320: iconst_0\n 321: istore 7\n 323: aload_0\n 324: iconst_0\n 325: aaload\n 326: iconst_0\n 327: aaload\n 328: arraylength\n 329: istore 8\n 331: iload 7\n 333: iload 8\n 335: if_icmpge 364\n 338: aload_0\n 339: aload_1\n 340: iconst_0\n 341: iload 5\n 343: iload 7\n 345: invokestatic #158 // Method fill:([[[Z[[[ZIII)V\n 348: aload_0\n 349: aload_1\n 350: iload_2\n 351: iload 5\n 353: iload 7\n 355: invokestatic #158 // Method fill:([[[Z[[[ZIII)V\n 358: iinc 7, 1\n 361: goto 331\n 364: iinc 5, 1\n 367: goto 313\n 370: aload_1\n 371: areturn\n\n private static final void fill(boolean[][][], boolean[][][], int, int, int);\n Code:\n 0: aload_1\n 1: iload_2\n 2: iload_3\n 3: iload 4\n 5: invokestatic #164 // Method isXYZInside:([[[ZIII)Z\n 8: ifeq 33\n 11: aload_0\n 12: iload_2\n 13: aaload\n 14: iload_3\n 15: aaload\n 16: iload 4\n 18: baload\n 19: ifne 33\n 22: aload_1\n 23: iload_2\n 24: aaload\n 25: iload_3\n 26: aaload\n 27: iload 4\n 29: baload\n 30: ifne 34\n 33: return\n 34: aload_1\n 35: iload_2\n 36: aaload\n 37: iload_3\n 38: aaload\n 39: iload 4\n 41: iconst_0\n 42: bastore\n 43: aload_0\n 44: aload_1\n 45: iload_2\n 46: iconst_1\n 47: iadd\n 48: iload_3\n 49: iload 4\n 51: invokestatic #158 // Method fill:([[[Z[[[ZIII)V\n 54: aload_0\n 55: aload_1\n 56: iload_2\n 57: iconst_1\n 58: isub\n 59: iload_3\n 60: iload 4\n 62: invokestatic #158 // Method fill:([[[Z[[[ZIII)V\n 65: aload_0\n 66: aload_1\n 67: iload_2\n 68: iload_3\n 69: iconst_1\n 70: iadd\n 71: iload 4\n 73: invokestatic #158 // Method fill:([[[Z[[[ZIII)V\n 76: aload_0\n 77: aload_1\n 78: iload_2\n 79: iload_3\n 80: iconst_1\n 81: isub\n 82: iload 4\n 84: invokestatic #158 // Method fill:([[[Z[[[ZIII)V\n 87: aload_0\n 88: aload_1\n 89: iload_2\n 90: iload_3\n 91: iload 4\n 93: iconst_1\n 94: iadd\n 95: invokestatic #158 // Method fill:([[[Z[[[ZIII)V\n 98: aload_0\n 99: aload_1\n 100: iload_2\n 101: iload_3\n 102: iload 4\n 104: iconst_1\n 105: isub\n 106: invokestatic #158 // Method fill:([[[Z[[[ZIII)V\n 109: return\n\n private static final boolean isEmpty(boolean[][][], int, int, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: iload_2\n 3: iload_3\n 4: invokestatic #164 // Method isXYZInside:([[[ZIII)Z\n 7: ifeq 28\n 10: aload_0\n 11: iload_1\n 12: aaload\n 13: iload_2\n 14: aaload\n 15: iload_3\n 16: baload\n 17: ifne 24\n 20: iconst_1\n 21: goto 29\n 24: iconst_0\n 25: goto 29\n 28: iconst_1\n 29: ireturn\n\n private static final boolean isXYZInside(boolean[][][], int, int, int);\n Code:\n 0: iconst_0\n 1: iload_1\n 2: if_icmpgt 22\n 5: iload_1\n 6: aload_0\n 7: checkcast #145 // class \"[Ljava/lang/Object;\"\n 10: arraylength\n 11: if_icmpge 18\n 14: iconst_1\n 15: goto 23\n 18: iconst_0\n 19: goto 23\n 22: iconst_0\n 23: ifeq 85\n 26: iconst_0\n 27: iload_2\n 28: if_icmpgt 50\n 31: iload_2\n 32: aload_0\n 33: iload_1\n 34: aaload\n 35: checkcast #145 // class \"[Ljava/lang/Object;\"\n 38: arraylength\n 39: if_icmpge 46\n 42: iconst_1\n 43: goto 51\n 46: iconst_0\n 47: goto 51\n 50: iconst_0\n 51: ifeq 85\n 54: iconst_0\n 55: iload_3\n 56: if_icmpgt 77\n 59: iload_3\n 60: aload_0\n 61: iload_1\n 62: aaload\n 63: iload_2\n 64: aaload\n 65: arraylength\n 66: if_icmpge 73\n 69: iconst_1\n 70: goto 78\n 73: iconst_0\n 74: goto 78\n 77: iconst_0\n 78: ifeq 85\n 81: iconst_1\n 82: goto 86\n 85: iconst_0\n 86: ireturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #169 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day08.kt
fun main() { val testInput = readInput("Day08_test").toMatrix() check(part1(testInput) == 21) check(part2(testInput) == 8) val input = readInput("Day08").toMatrix() println(part1(input)) println(part2(input)) } private fun part1(input: Matrix): Int { val width = input[0].size val height = input.size var result = height * 2 + width * 2 - 4 val used = Array(height) { BooleanArray(width) { false } } val row = IntArray(width) { input[0][it] } val column = IntArray(height) { input[it][0] } fun updateResult(i: Int, j: Int) { if (!used[i][j]) { ++result used[i][j] = true } } fun checkItem(i: Int, j: Int) { if (input[i][j] > column[i]) { updateResult(i, j) column[i] = input[i][j] } if (input[i][j] > row[j]) { updateResult(i, j) row[j] = input[i][j] } } //top-to-bottom, left-to-right pass for (i in 1..(height - 2)) { for (j in 1..(width - 2)) { checkItem(i, j) } } for (i in 1..(height - 2)) { column[i] = input[i][width - 1] } for (j in 1..(width - 2)) { row[j] = input[height - 1][j] } //bottom-to-top, right-to-left pass for (i in (height - 2) downTo 1) { for (j in (width - 2) downTo 1) { checkItem(i, j) } } return result } private fun part2(input: Matrix): Int { var result = 0 val width = input[0].size val height = input.size for (i in 1..(height - 2)) { for (j in 1..(width - 2)) { val digit = input[i][j] var top = i - 1 while (top > 0 && digit > input[top][j]) { --top } var left = j - 1 while (left > 0 && digit > input[i][left]) { --left } var right = j + 1 while (right < width - 1 && digit > input[i][right]) { ++right } var bottom = i + 1 while (bottom < height - 1 && digit > input[bottom][j]) { ++bottom } val mul = (i - top) * (j - left) * (right - j) * (bottom - i) if (mul > result) { result = mul } } } return result } private fun List<String>.toMatrix(): Matrix { return Array(this.size) { i -> IntArray(this[i].length) { j -> this[i][j].digitToInt() } } }
[ { "class_path": "Kvest__AOC2022__6409e65/Day08Kt.class", "javap": "Compiled from \"Day08.kt\"\npublic final class Day08Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day08_test\n 2: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 5: invokestatic #18 // Method toMatrix:(Ljava/util/List;)[[I\n 8: astore_0\n 9: aload_0\n 10: invokestatic #22 // Method part1:([[I)I\n 13: bipush 21\n 15: if_icmpne 22\n 18: iconst_1\n 19: goto 23\n 22: iconst_0\n 23: ifne 36\n 26: new #24 // class java/lang/IllegalStateException\n 29: dup\n 30: ldc #26 // String Check failed.\n 32: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 35: athrow\n 36: aload_0\n 37: invokestatic #33 // Method part2:([[I)I\n 40: bipush 8\n 42: if_icmpne 49\n 45: iconst_1\n 46: goto 50\n 49: iconst_0\n 50: ifne 63\n 53: new #24 // class java/lang/IllegalStateException\n 56: dup\n 57: ldc #26 // String Check failed.\n 59: invokespecial #30 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 62: athrow\n 63: ldc #35 // String Day08\n 65: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 68: invokestatic #18 // Method toMatrix:(Ljava/util/List;)[[I\n 71: astore_1\n 72: aload_1\n 73: invokestatic #22 // Method part1:([[I)I\n 76: istore_2\n 77: getstatic #41 // Field java/lang/System.out:Ljava/io/PrintStream;\n 80: iload_2\n 81: invokevirtual #47 // Method java/io/PrintStream.println:(I)V\n 84: aload_1\n 85: invokestatic #33 // Method part2:([[I)I\n 88: istore_2\n 89: getstatic #41 // Field java/lang/System.out:Ljava/io/PrintStream;\n 92: iload_2\n 93: invokevirtual #47 // Method java/io/PrintStream.println:(I)V\n 96: return\n\n private static final int part1(int[][]);\n Code:\n 0: aload_0\n 1: iconst_0\n 2: aaload\n 3: arraylength\n 4: istore_1\n 5: aload_0\n 6: checkcast #53 // class \"[Ljava/lang/Object;\"\n 9: arraylength\n 10: istore_2\n 11: new #55 // class kotlin/jvm/internal/Ref$IntRef\n 14: dup\n 15: invokespecial #57 // Method kotlin/jvm/internal/Ref$IntRef.\"<init>\":()V\n 18: astore_3\n 19: aload_3\n 20: iload_2\n 21: iconst_2\n 22: imul\n 23: iload_1\n 24: iconst_2\n 25: imul\n 26: iadd\n 27: iconst_4\n 28: isub\n 29: putfield #61 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 32: iconst_0\n 33: istore 5\n 35: iload_2\n 36: anewarray #63 // class \"[Z\"\n 39: astore 6\n 41: iload 5\n 43: iload_2\n 44: if_icmpge 102\n 47: iload 5\n 49: istore 7\n 51: aload 6\n 53: iload 7\n 55: iconst_0\n 56: istore 8\n 58: iload_1\n 59: newarray boolean\n 61: astore 9\n 63: istore 12\n 65: astore 11\n 67: iload 8\n 69: iload_1\n 70: if_icmpge 89\n 73: iload 8\n 75: istore 10\n 77: aload 9\n 79: iload 10\n 81: iconst_0\n 82: bastore\n 83: iinc 8, 1\n 86: goto 67\n 89: aload 11\n 91: iload 12\n 93: aload 9\n 95: aastore\n 96: iinc 5, 1\n 99: goto 41\n 102: aload 6\n 104: astore 4\n 106: iconst_0\n 107: istore 6\n 109: iload_1\n 110: newarray int\n 112: astore 7\n 114: iload 6\n 116: iload_1\n 117: if_icmpge 141\n 120: iload 6\n 122: istore 8\n 124: aload 7\n 126: iload 8\n 128: aload_0\n 129: iconst_0\n 130: aaload\n 131: iload 8\n 133: iaload\n 134: iastore\n 135: iinc 6, 1\n 138: goto 114\n 141: aload 7\n 143: astore 5\n 145: iconst_0\n 146: istore 7\n 148: iload_2\n 149: newarray int\n 151: astore 8\n 153: iload 7\n 155: iload_2\n 156: if_icmpge 180\n 159: iload 7\n 161: istore 9\n 163: aload 8\n 165: iload 9\n 167: aload_0\n 168: iload 9\n 170: aaload\n 171: iconst_0\n 172: iaload\n 173: iastore\n 174: iinc 7, 1\n 177: goto 153\n 180: aload 8\n 182: astore 6\n 184: iconst_1\n 185: istore 7\n 187: iload_2\n 188: iconst_2\n 189: isub\n 190: istore 8\n 192: iload 7\n 194: iload 8\n 196: if_icmpgt 255\n 199: iconst_1\n 200: istore 9\n 202: iload_1\n 203: iconst_2\n 204: isub\n 205: istore 10\n 207: iload 9\n 209: iload 10\n 211: if_icmpgt 242\n 214: aload_0\n 215: aload 6\n 217: aload 5\n 219: aload 4\n 221: aload_3\n 222: iload 7\n 224: iload 9\n 226: invokestatic #67 // Method part1$checkItem:([[I[I[I[[ZLkotlin/jvm/internal/Ref$IntRef;II)V\n 229: iload 9\n 231: iload 10\n 233: if_icmpeq 242\n 236: iinc 9, 1\n 239: goto 214\n 242: iload 7\n 244: iload 8\n 246: if_icmpeq 255\n 249: iinc 7, 1\n 252: goto 199\n 255: iconst_1\n 256: istore 7\n 258: iload_2\n 259: iconst_2\n 260: isub\n 261: istore 8\n 263: iload 7\n 265: iload 8\n 267: if_icmpgt 296\n 270: aload 6\n 272: iload 7\n 274: aload_0\n 275: iload 7\n 277: aaload\n 278: iload_1\n 279: iconst_1\n 280: isub\n 281: iaload\n 282: iastore\n 283: iload 7\n 285: iload 8\n 287: if_icmpeq 296\n 290: iinc 7, 1\n 293: goto 270\n 296: iconst_1\n 297: istore 7\n 299: iload_1\n 300: iconst_2\n 301: isub\n 302: istore 8\n 304: iload 7\n 306: iload 8\n 308: if_icmpgt 337\n 311: aload 5\n 313: iload 7\n 315: aload_0\n 316: iload_2\n 317: iconst_1\n 318: isub\n 319: aaload\n 320: iload 7\n 322: iaload\n 323: iastore\n 324: iload 7\n 326: iload 8\n 328: if_icmpeq 337\n 331: iinc 7, 1\n 334: goto 311\n 337: iload_2\n 338: iconst_2\n 339: isub\n 340: istore 7\n 342: iconst_0\n 343: iload 7\n 345: if_icmpge 386\n 348: iload_1\n 349: iconst_2\n 350: isub\n 351: istore 8\n 353: iconst_0\n 354: iload 8\n 356: if_icmpge 380\n 359: aload_0\n 360: aload 6\n 362: aload 5\n 364: aload 4\n 366: aload_3\n 367: iload 7\n 369: iload 8\n 371: invokestatic #67 // Method part1$checkItem:([[I[I[I[[ZLkotlin/jvm/internal/Ref$IntRef;II)V\n 374: iinc 8, -1\n 377: goto 353\n 380: iinc 7, -1\n 383: goto 342\n 386: aload_3\n 387: getfield #61 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 390: ireturn\n\n private static final int part2(int[][]);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: aload_0\n 3: iconst_0\n 4: aaload\n 5: arraylength\n 6: istore_2\n 7: aload_0\n 8: checkcast #53 // class \"[Ljava/lang/Object;\"\n 11: arraylength\n 12: istore_3\n 13: iconst_1\n 14: istore 4\n 16: iload_3\n 17: iconst_2\n 18: isub\n 19: istore 5\n 21: iload 4\n 23: iload 5\n 25: if_icmpgt 234\n 28: iconst_1\n 29: istore 6\n 31: iload_2\n 32: iconst_2\n 33: isub\n 34: istore 7\n 36: iload 6\n 38: iload 7\n 40: if_icmpgt 221\n 43: aload_0\n 44: iload 4\n 46: aaload\n 47: iload 6\n 49: iaload\n 50: istore 8\n 52: iload 4\n 54: iconst_1\n 55: isub\n 56: istore 9\n 58: iload 9\n 60: ifle 81\n 63: iload 8\n 65: aload_0\n 66: iload 9\n 68: aaload\n 69: iload 6\n 71: iaload\n 72: if_icmple 81\n 75: iinc 9, -1\n 78: goto 58\n 81: iload 6\n 83: iconst_1\n 84: isub\n 85: istore 10\n 87: iload 10\n 89: ifle 110\n 92: iload 8\n 94: aload_0\n 95: iload 4\n 97: aaload\n 98: iload 10\n 100: iaload\n 101: if_icmple 110\n 104: iinc 10, -1\n 107: goto 87\n 110: iload 6\n 112: iconst_1\n 113: iadd\n 114: istore 11\n 116: iload 11\n 118: iload_2\n 119: iconst_1\n 120: isub\n 121: if_icmpge 142\n 124: iload 8\n 126: aload_0\n 127: iload 4\n 129: aaload\n 130: iload 11\n 132: iaload\n 133: if_icmple 142\n 136: iinc 11, 1\n 139: goto 116\n 142: iload 4\n 144: iconst_1\n 145: iadd\n 146: istore 12\n 148: iload 12\n 150: iload_3\n 151: iconst_1\n 152: isub\n 153: if_icmpge 174\n 156: iload 8\n 158: aload_0\n 159: iload 12\n 161: aaload\n 162: iload 6\n 164: iaload\n 165: if_icmple 174\n 168: iinc 12, 1\n 171: goto 148\n 174: iload 4\n 176: iload 9\n 178: isub\n 179: iload 6\n 181: iload 10\n 183: isub\n 184: imul\n 185: iload 11\n 187: iload 6\n 189: isub\n 190: imul\n 191: iload 12\n 193: iload 4\n 195: isub\n 196: imul\n 197: istore 13\n 199: iload 13\n 201: iload_1\n 202: if_icmple 208\n 205: iload 13\n 207: istore_1\n 208: iload 6\n 210: iload 7\n 212: if_icmpeq 221\n 215: iinc 6, 1\n 218: goto 43\n 221: iload 4\n 223: iload 5\n 225: if_icmpeq 234\n 228: iinc 4, 1\n 231: goto 28\n 234: iload_1\n 235: ireturn\n\n private static final int[][] toMatrix(java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore_1\n 2: aload_0\n 3: invokeinterface #93, 1 // InterfaceMethod java/util/List.size:()I\n 8: istore_2\n 9: iload_2\n 10: anewarray #80 // class \"[I\"\n 13: astore_3\n 14: iload_1\n 15: iload_2\n 16: if_icmpge 108\n 19: iload_1\n 20: istore 4\n 22: aload_3\n 23: iload 4\n 25: iconst_0\n 26: istore 5\n 28: aload_0\n 29: iload 4\n 31: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 36: checkcast #99 // class java/lang/String\n 39: invokevirtual #102 // Method java/lang/String.length:()I\n 42: istore 6\n 44: iload 6\n 46: newarray int\n 48: astore 7\n 50: istore 10\n 52: astore 9\n 54: iload 5\n 56: iload 6\n 58: if_icmpge 95\n 61: iload 5\n 63: istore 8\n 65: aload 7\n 67: iload 8\n 69: aload_0\n 70: iload 4\n 72: invokeinterface #97, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 77: checkcast #99 // class java/lang/String\n 80: iload 8\n 82: invokevirtual #106 // Method java/lang/String.charAt:(I)C\n 85: invokestatic #112 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 88: iastore\n 89: iinc 5, 1\n 92: goto 54\n 95: aload 9\n 97: iload 10\n 99: aload 7\n 101: aastore\n 102: iinc 1, 1\n 105: goto 14\n 108: aload_3\n 109: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #117 // Method main:()V\n 3: return\n\n private static final void part1$updateResult(boolean[][], kotlin.jvm.internal.Ref$IntRef, int, int);\n Code:\n 0: aload_0\n 1: iload_2\n 2: aaload\n 3: iload_3\n 4: baload\n 5: ifne 29\n 8: aload_1\n 9: aload_1\n 10: getfield #61 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 13: iconst_1\n 14: iadd\n 15: putfield #61 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 18: aload_1\n 19: getfield #61 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 22: pop\n 23: aload_0\n 24: iload_2\n 25: aaload\n 26: iload_3\n 27: iconst_1\n 28: bastore\n 29: return\n\n private static final void part1$checkItem(int[][], int[], int[], boolean[][], kotlin.jvm.internal.Ref$IntRef, int, int);\n Code:\n 0: aload_0\n 1: iload 5\n 3: aaload\n 4: iload 6\n 6: iaload\n 7: aload_1\n 8: iload 5\n 10: iaload\n 11: if_icmple 35\n 14: aload_3\n 15: aload 4\n 17: iload 5\n 19: iload 6\n 21: invokestatic #123 // Method part1$updateResult:([[ZLkotlin/jvm/internal/Ref$IntRef;II)V\n 24: aload_1\n 25: iload 5\n 27: aload_0\n 28: iload 5\n 30: aaload\n 31: iload 6\n 33: iaload\n 34: iastore\n 35: aload_0\n 36: iload 5\n 38: aaload\n 39: iload 6\n 41: iaload\n 42: aload_2\n 43: iload 6\n 45: iaload\n 46: if_icmple 70\n 49: aload_3\n 50: aload 4\n 52: iload 5\n 54: iload 6\n 56: invokestatic #123 // Method part1$updateResult:([[ZLkotlin/jvm/internal/Ref$IntRef;II)V\n 59: aload_2\n 60: iload 6\n 62: aload_0\n 63: iload 5\n 65: aaload\n 66: iload 6\n 68: iaload\n 69: iastore\n 70: return\n}\n", "javap_err": "" } ]
Kvest__AOC2022__6409e65/src/Day01.kt
fun main() { // test if implementation meets criteria from the description, like: val testInput = readInput("Day01_test") check(part1(testInput) == 24000) check(part2(testInput) == 45000) val input = readInput("Day01") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Int { return input.toCalories().maxOrNull() ?: 0 } private fun part2(input: List<String>): Int { return input .toCalories() .sorted() .takeLast(3) .sum() } private fun List<String>.toCalories(): List<Int> { val result = mutableListOf<Int>() var current = 0 this.forEach { row -> if (row.isEmpty()) { result.add(current) current = 0 } else { current += row.toInt() } } result.add(current) return result }
[ { "class_path": "Kvest__AOC2022__6409e65/Day01Kt.class", "javap": "Compiled from \"Day01.kt\"\npublic final class Day01Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day01_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: sipush 24000\n 13: if_icmpne 20\n 16: iconst_1\n 17: goto 21\n 20: iconst_0\n 21: ifne 34\n 24: new #20 // class java/lang/IllegalStateException\n 27: dup\n 28: ldc #22 // String Check failed.\n 30: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 33: athrow\n 34: aload_0\n 35: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 38: ldc #30 // int 45000\n 40: if_icmpne 47\n 43: iconst_1\n 44: goto 48\n 47: iconst_0\n 48: ifne 61\n 51: new #20 // class java/lang/IllegalStateException\n 54: dup\n 55: ldc #22 // String Check failed.\n 57: invokespecial #26 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 60: athrow\n 61: ldc #32 // String Day01\n 63: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 66: astore_1\n 67: aload_1\n 68: invokestatic #18 // Method part1:(Ljava/util/List;)I\n 71: istore_2\n 72: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 75: iload_2\n 76: invokevirtual #44 // Method java/io/PrintStream.println:(I)V\n 79: aload_1\n 80: invokestatic #29 // Method part2:(Ljava/util/List;)I\n 83: istore_2\n 84: getstatic #38 // Field java/lang/System.out:Ljava/io/PrintStream;\n 87: iload_2\n 88: invokevirtual #44 // Method java/io/PrintStream.println:(I)V\n 91: return\n\n private static final int part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #54 // Method toCalories:(Ljava/util/List;)Ljava/util/List;\n 4: checkcast #56 // class java/lang/Iterable\n 7: invokestatic #62 // Method kotlin/collections/CollectionsKt.maxOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 10: checkcast #64 // class java/lang/Integer\n 13: dup\n 14: ifnull 23\n 17: invokevirtual #68 // Method java/lang/Integer.intValue:()I\n 20: goto 25\n 23: pop\n 24: iconst_0\n 25: ireturn\n\n private static final int part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #54 // Method toCalories:(Ljava/util/List;)Ljava/util/List;\n 4: checkcast #56 // class java/lang/Iterable\n 7: invokestatic #72 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 10: iconst_3\n 11: invokestatic #76 // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;\n 14: checkcast #56 // class java/lang/Iterable\n 17: invokestatic #80 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 20: ireturn\n\n private static final java.util.List<java.lang.Integer> toCalories(java.util.List<java.lang.String>);\n Code:\n 0: new #83 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #85 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #49 // class java/util/List\n 10: astore_1\n 11: iconst_0\n 12: istore_2\n 13: aload_0\n 14: checkcast #56 // class java/lang/Iterable\n 17: astore_3\n 18: iconst_0\n 19: istore 4\n 21: aload_3\n 22: invokeinterface #89, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 27: astore 5\n 29: aload 5\n 31: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 36: ifeq 108\n 39: aload 5\n 41: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 46: astore 6\n 48: aload 6\n 50: checkcast #101 // class java/lang/String\n 53: astore 7\n 55: iconst_0\n 56: istore 8\n 58: aload 7\n 60: checkcast #103 // class java/lang/CharSequence\n 63: invokeinterface #106, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 68: ifne 75\n 71: iconst_1\n 72: goto 76\n 75: iconst_0\n 76: ifeq 95\n 79: aload_1\n 80: iload_2\n 81: invokestatic #110 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 84: invokeinterface #114, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 89: pop\n 90: iconst_0\n 91: istore_2\n 92: goto 103\n 95: iload_2\n 96: aload 7\n 98: invokestatic #118 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 101: iadd\n 102: istore_2\n 103: nop\n 104: nop\n 105: goto 29\n 108: nop\n 109: aload_1\n 110: iload_2\n 111: invokestatic #110 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 114: invokeinterface #114, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 119: pop\n 120: aload_1\n 121: areturn\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": "" } ]
Kvest__AOC2022__6409e65/src/Day11.kt
import java.util.* fun main() { val testInput = readInput("Day11_test") check(part1(testInput) == 10605L) check(part2(testInput) == 2713310158L) val input = readInput("Day11") println(part1(input)) println(part2(input)) } private fun part1(input: List<String>): Long { val monkeys = input.toMonkeys() val worryLevelAdjuster = WorryLevelAdjuster { worryLevel -> worryLevel / 3 } return solve(monkeys, roundsCount = 20, worryLevelAdjuster) } private fun part2(input: List<String>): Long { val monkeys = input.toMonkeys() //Use divider in order to avoid overflow of the worryLevel's variable val divider = monkeys.fold(1L) { acc, monkey -> acc * monkey.test.testValue } val worryLevelAdjuster = WorryLevelAdjuster { worryLevel -> worryLevel % divider } return solve(monkeys, roundsCount = 10_000, worryLevelAdjuster) } private fun solve( monkeys: List<Monkey>, roundsCount: Int, worryLevelAdjuster: WorryLevelAdjuster ): Long { val counts = LongArray(monkeys.size) { 0 } val redirectListener = RedirectListener { monkeyNumber, worryLevel -> monkeys[monkeyNumber].items.addLast(worryLevel) } repeat(roundsCount) { monkeys.forEachIndexed { index, monkey -> //monkey will inspect "monkey.items.size" in this round counts[index] += monkey.items.size.toLong() monkey.round(worryLevelAdjuster, redirectListener) } } counts.sortDescending() return counts[0] * counts[1] } private fun List<String>.toMonkeys(): List<Monkey> = this.chunked(7).map(List<String>::toMonkey) private fun List<String>.toMonkey(): Monkey { val initialItems = this[1] .substringAfter("Starting items: ") .split(", ") .map { it.toLong() } val operation = Operation.fromString(this[2]) val testValue = this[3].substringAfter("Test: divisible by ").toLong() val trueDestination = this[4].substringAfter("If true: throw to monkey ").toInt() val falseDestination = this[5].substringAfter("If false: throw to monkey ").toInt() val test = Test( testValue = testValue, trueDestination = trueDestination, falseDestination = falseDestination ) return Monkey(initialItems, operation, test) } private fun interface RedirectListener { fun redirect(monkeyNumber: Int, worryLevel: Long) } private fun interface WorryLevelAdjuster { fun adjust(worryLevel: Long): Long } private class Monkey( initialItems: List<Long>, val operation: Operation, val test: Test ) { val items = LinkedList(initialItems) fun round(worryLevelAdjuster: WorryLevelAdjuster, redirectListener: RedirectListener) { while (items.isNotEmpty()) { var worryLevel = items.pollFirst() worryLevel = operation.perform(worryLevel) worryLevel = worryLevelAdjuster.adjust(worryLevel) val monkeyNumber = test.test(worryLevel) redirectListener.redirect(monkeyNumber, worryLevel) } } } sealed interface Operation { fun perform(worryLevel: Long): Long companion object { fun fromString(operation: String): Operation { return when { operation.contains("Operation: new = old * old") -> SqrOperation operation.contains("Operation: new = old +") -> AdditionOperation( incValue = operation.substringAfter("Operation: new = old + ").toLong() ) operation.contains("Operation: new = old *") -> MultiplicationOperation( factor = operation.substringAfter("Operation: new = old * ").toLong() ) else -> error("Unknown operation $operation") } } } class AdditionOperation(private val incValue: Long) : Operation { override fun perform(worryLevel: Long): Long = worryLevel + incValue } class MultiplicationOperation(private val factor: Long) : Operation { override fun perform(worryLevel: Long): Long = worryLevel * factor } object SqrOperation : Operation { override fun perform(worryLevel: Long): Long = worryLevel * worryLevel } } private class Test( val testValue: Long, val trueDestination: Int, val falseDestination: Int, ) { fun test(worryLevel: Long): Int = if (worryLevel % testValue == 0L) trueDestination else falseDestination }
[ { "class_path": "Kvest__AOC2022__6409e65/Day11Kt.class", "javap": "Compiled from \"Day11.kt\"\npublic final class Day11Kt {\n public static final void main();\n Code:\n 0: ldc #8 // String Day11_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: ldc2_w #19 // long 10605l\n 13: lcmp\n 14: ifne 21\n 17: iconst_1\n 18: goto 22\n 21: iconst_0\n 22: ifne 35\n 25: new #22 // class java/lang/IllegalStateException\n 28: dup\n 29: ldc #24 // String Check failed.\n 31: invokespecial #28 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 34: athrow\n 35: aload_0\n 36: invokestatic #31 // Method part2:(Ljava/util/List;)J\n 39: ldc2_w #32 // long 2713310158l\n 42: lcmp\n 43: ifne 50\n 46: iconst_1\n 47: goto 51\n 50: iconst_0\n 51: ifne 64\n 54: new #22 // class java/lang/IllegalStateException\n 57: dup\n 58: ldc #24 // String Check failed.\n 60: invokespecial #28 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 63: athrow\n 64: ldc #35 // String Day11\n 66: invokestatic #14 // Method UtilsKt.readInput:(Ljava/lang/String;)Ljava/util/List;\n 69: astore_1\n 70: aload_1\n 71: invokestatic #18 // Method part1:(Ljava/util/List;)J\n 74: lstore_2\n 75: getstatic #41 // Field java/lang/System.out:Ljava/io/PrintStream;\n 78: lload_2\n 79: invokevirtual #47 // Method java/io/PrintStream.println:(J)V\n 82: aload_1\n 83: invokestatic #31 // Method part2:(Ljava/util/List;)J\n 86: lstore_2\n 87: getstatic #41 // Field java/lang/System.out:Ljava/io/PrintStream;\n 90: lload_2\n 91: invokevirtual #47 // Method java/io/PrintStream.println:(J)V\n 94: return\n\n private static final long part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #57 // Method toMonkeys:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: invokedynamic #74, 0 // InvokeDynamic #0:adjust:()LWorryLevelAdjuster;\n 10: astore_2\n 11: aload_1\n 12: bipush 20\n 14: aload_2\n 15: invokestatic #78 // Method solve:(Ljava/util/List;ILWorryLevelAdjuster;)J\n 18: lreturn\n\n private static final long part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: invokestatic #57 // Method toMonkeys:(Ljava/util/List;)Ljava/util/List;\n 4: astore_1\n 5: aload_1\n 6: checkcast #83 // class java/lang/Iterable\n 9: astore 4\n 11: lconst_1\n 12: lstore 5\n 14: iconst_0\n 15: istore 7\n 17: lload 5\n 19: lstore 8\n 21: aload 4\n 23: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 28: astore 10\n 30: aload 10\n 32: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 37: ifeq 79\n 40: aload 10\n 42: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 47: astore 11\n 49: lload 8\n 51: aload 11\n 53: checkcast #99 // class Monkey\n 56: astore 12\n 58: lstore 13\n 60: iconst_0\n 61: istore 15\n 63: lload 13\n 65: aload 12\n 67: invokevirtual #103 // Method Monkey.getTest:()LTest;\n 70: invokevirtual #109 // Method Test.getTestValue:()J\n 73: lmul\n 74: lstore 8\n 76: goto 30\n 79: lload 8\n 81: lstore_2\n 82: lload_2\n 83: invokedynamic #117, 0 // InvokeDynamic #1:adjust:(J)LWorryLevelAdjuster;\n 88: astore 4\n 90: aload_1\n 91: sipush 10000\n 94: aload 4\n 96: invokestatic #78 // Method solve:(Ljava/util/List;ILWorryLevelAdjuster;)J\n 99: lreturn\n\n private static final long solve(java.util.List<Monkey>, int, WorryLevelAdjuster);\n Code:\n 0: iconst_0\n 1: istore 4\n 3: aload_0\n 4: invokeinterface #136, 1 // InterfaceMethod java/util/List.size:()I\n 9: istore 5\n 11: iload 5\n 13: newarray long\n 15: astore 6\n 17: iload 4\n 19: iload 5\n 21: if_icmpge 40\n 24: iload 4\n 26: istore 7\n 28: aload 6\n 30: iload 7\n 32: lconst_0\n 33: lastore\n 34: iinc 4, 1\n 37: goto 17\n 40: aload 6\n 42: astore_3\n 43: aload_0\n 44: invokedynamic #147, 0 // InvokeDynamic #2:redirect:(Ljava/util/List;)LRedirectListener;\n 49: astore 4\n 51: iconst_0\n 52: istore 5\n 54: iload 5\n 56: iload_1\n 57: if_icmpge 175\n 60: iload 5\n 62: istore 6\n 64: iconst_0\n 65: istore 7\n 67: aload_0\n 68: checkcast #83 // class java/lang/Iterable\n 71: astore 8\n 73: iconst_0\n 74: istore 9\n 76: iconst_0\n 77: istore 10\n 79: aload 8\n 81: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 86: astore 11\n 88: aload 11\n 90: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 95: ifeq 167\n 98: aload 11\n 100: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 105: astore 12\n 107: iload 10\n 109: iinc 10, 1\n 112: istore 13\n 114: iload 13\n 116: ifge 122\n 119: invokestatic #152 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 122: iload 13\n 124: aload 12\n 126: checkcast #99 // class Monkey\n 129: astore 14\n 131: istore 15\n 133: iconst_0\n 134: istore 16\n 136: aload_3\n 137: iload 15\n 139: aload_3\n 140: iload 15\n 142: laload\n 143: aload 14\n 145: invokevirtual #156 // Method Monkey.getItems:()Ljava/util/LinkedList;\n 148: invokevirtual #159 // Method java/util/LinkedList.size:()I\n 151: i2l\n 152: ladd\n 153: lastore\n 154: aload 14\n 156: aload_2\n 157: aload 4\n 159: invokevirtual #163 // Method Monkey.round:(LWorryLevelAdjuster;LRedirectListener;)V\n 162: nop\n 163: nop\n 164: goto 88\n 167: nop\n 168: nop\n 169: iinc 5, 1\n 172: goto 54\n 175: aload_3\n 176: invokestatic #169 // Method kotlin/collections/ArraysKt.sortDescending:([J)V\n 179: aload_3\n 180: iconst_0\n 181: laload\n 182: aload_3\n 183: iconst_1\n 184: laload\n 185: lmul\n 186: lreturn\n\n private static final java.util.List<Monkey> toMonkeys(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #83 // class java/lang/Iterable\n 4: bipush 7\n 6: invokestatic #192 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;I)Ljava/util/List;\n 9: checkcast #83 // class java/lang/Iterable\n 12: astore_1\n 13: iconst_0\n 14: istore_2\n 15: aload_1\n 16: astore_3\n 17: new #194 // class java/util/ArrayList\n 20: dup\n 21: aload_1\n 22: bipush 10\n 24: invokestatic #198 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 27: invokespecial #201 // Method java/util/ArrayList.\"<init>\":(I)V\n 30: checkcast #203 // class java/util/Collection\n 33: astore 4\n 35: iconst_0\n 36: istore 5\n 38: aload_3\n 39: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 6\n 46: aload 6\n 48: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 96\n 56: aload 6\n 58: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 7\n 65: aload 4\n 67: aload 7\n 69: checkcast #52 // class java/util/List\n 72: astore 8\n 74: astore 10\n 76: iconst_0\n 77: istore 9\n 79: aload 8\n 81: invokestatic #207 // Method toMonkey:(Ljava/util/List;)LMonkey;\n 84: aload 10\n 86: swap\n 87: invokeinterface #211, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 92: pop\n 93: goto 46\n 96: aload 4\n 98: checkcast #52 // class java/util/List\n 101: nop\n 102: areturn\n\n private static final Monkey toMonkey(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: iconst_1\n 2: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #228 // class java/lang/String\n 10: ldc #230 // String Starting items:\n 12: aconst_null\n 13: iconst_2\n 14: aconst_null\n 15: invokestatic #236 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 18: checkcast #238 // class java/lang/CharSequence\n 21: iconst_1\n 22: anewarray #228 // class java/lang/String\n 25: astore_2\n 26: aload_2\n 27: iconst_0\n 28: ldc #240 // String ,\n 30: aastore\n 31: aload_2\n 32: iconst_0\n 33: iconst_0\n 34: bipush 6\n 36: aconst_null\n 37: invokestatic #244 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 40: checkcast #83 // class java/lang/Iterable\n 43: astore_2\n 44: nop\n 45: iconst_0\n 46: istore_3\n 47: aload_2\n 48: astore 4\n 50: new #194 // class java/util/ArrayList\n 53: dup\n 54: aload_2\n 55: bipush 10\n 57: invokestatic #198 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 60: invokespecial #201 // Method java/util/ArrayList.\"<init>\":(I)V\n 63: checkcast #203 // class java/util/Collection\n 66: astore 5\n 68: iconst_0\n 69: istore 6\n 71: aload 4\n 73: invokeinterface #87, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 78: astore 7\n 80: aload 7\n 82: invokeinterface #93, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 87: ifeq 134\n 90: aload 7\n 92: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 97: astore 8\n 99: aload 5\n 101: aload 8\n 103: checkcast #228 // class java/lang/String\n 106: astore 9\n 108: astore 11\n 110: iconst_0\n 111: istore 10\n 113: aload 9\n 115: invokestatic #250 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 118: nop\n 119: invokestatic #254 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 122: aload 11\n 124: swap\n 125: invokeinterface #211, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 130: pop\n 131: goto 80\n 134: aload 5\n 136: checkcast #52 // class java/util/List\n 139: nop\n 140: astore_1\n 141: getstatic #260 // Field Operation.Companion:LOperation$Companion;\n 144: aload_0\n 145: iconst_2\n 146: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 151: checkcast #228 // class java/lang/String\n 154: invokevirtual #266 // Method Operation$Companion.fromString:(Ljava/lang/String;)LOperation;\n 157: astore_2\n 158: aload_0\n 159: iconst_3\n 160: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 165: checkcast #228 // class java/lang/String\n 168: ldc_w #268 // String Test: divisible by\n 171: aconst_null\n 172: iconst_2\n 173: aconst_null\n 174: invokestatic #236 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 177: invokestatic #250 // Method java/lang/Long.parseLong:(Ljava/lang/String;)J\n 180: lstore_3\n 181: aload_0\n 182: iconst_4\n 183: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 188: checkcast #228 // class java/lang/String\n 191: ldc_w #270 // String If true: throw to monkey\n 194: aconst_null\n 195: iconst_2\n 196: aconst_null\n 197: invokestatic #236 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 200: invokestatic #276 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 203: istore 5\n 205: aload_0\n 206: iconst_5\n 207: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 212: checkcast #228 // class java/lang/String\n 215: ldc_w #278 // String If false: throw to monkey\n 218: aconst_null\n 219: iconst_2\n 220: aconst_null\n 221: invokestatic #236 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 224: invokestatic #276 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 227: istore 6\n 229: new #105 // class Test\n 232: dup\n 233: lload_3\n 234: iload 5\n 236: iload 6\n 238: invokespecial #281 // Method Test.\"<init>\":(JII)V\n 241: astore 7\n 243: new #99 // class Monkey\n 246: dup\n 247: aload_1\n 248: aload_2\n 249: aload 7\n 251: invokespecial #284 // Method Monkey.\"<init>\":(Ljava/util/List;LOperation;LTest;)V\n 254: areturn\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #298 // Method main:()V\n 3: return\n\n private static final long part1$lambda$0(long);\n Code:\n 0: lload_0\n 1: iconst_3\n 2: i2l\n 3: ldiv\n 4: lreturn\n\n private static final long part2$lambda$2(long, long);\n Code:\n 0: lload_2\n 1: lload_0\n 2: lrem\n 3: lreturn\n\n private static final void solve$lambda$3(java.util.List, int, long);\n Code:\n 0: aload_0\n 1: iload_1\n 2: invokeinterface #226, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #99 // class Monkey\n 10: invokevirtual #156 // Method Monkey.getItems:()Ljava/util/LinkedList;\n 13: lload_2\n 14: invokestatic #254 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 17: invokevirtual #306 // Method java/util/LinkedList.addLast:(Ljava/lang/Object;)V\n 20: return\n}\n", "javap_err": "" } ]
getupminaaa__Algorithm__01187e2/Algorithm/src/main/kotlin/programmers/level1/personalInfoCollectionValidityPeriod.kt
import java.util.* fun main() { val solution = Solution() val terms: Array<String> = arrayOf("A 6", "B 12", "C 3") val privacies: Array<String> = arrayOf("2021.05.02 A", "2021.07.01 B", "2022.02.19 C", "2022.02.20 C") solution.solution(today = "2022.05.19", terms, privacies) } class Solution { fun solution(today: String, terms: Array<String>, privacies: Array<String>): IntArray { var answer: IntArray = intArrayOf() //오늘 날짜 변환 var tDates: Int = 0 val todayArray: List<String> = today.split(".", ".") tDates += todayArray[0].toInt() * 12 * 28 tDates += todayArray[1].toInt() * 28 tDates += todayArray[2].toInt() for (i in privacies.indices) { var pDates: Int = 0 val privaciesArray: List<String> = privacies[i].split(".", ".", " ") pDates += privaciesArray[0].toInt() * 12 * 28 pDates += privaciesArray[1].toInt() * 28 pDates += privaciesArray[2].toInt() for (j in terms.indices) { if (terms[j].split("\\s+".toRegex()).first() == privaciesArray[3]) { pDates += terms[j].split("\\s+".toRegex()).last().toInt() * 28 if (tDates >= pDates) { answer += i + 1 } } } } print(Arrays.toString(answer)) return answer } }
[ { "class_path": "getupminaaa__Algorithm__01187e2/PersonalInfoCollectionValidityPeriodKt.class", "javap": "Compiled from \"personalInfoCollectionValidityPeriod.kt\"\npublic final class PersonalInfoCollectionValidityPeriodKt {\n public static final void main();\n Code:\n 0: new #8 // class Solution\n 3: dup\n 4: invokespecial #11 // Method Solution.\"<init>\":()V\n 7: astore_0\n 8: iconst_3\n 9: anewarray #13 // class java/lang/String\n 12: astore_2\n 13: aload_2\n 14: iconst_0\n 15: ldc #15 // String A 6\n 17: aastore\n 18: aload_2\n 19: iconst_1\n 20: ldc #17 // String B 12\n 22: aastore\n 23: aload_2\n 24: iconst_2\n 25: ldc #19 // String C 3\n 27: aastore\n 28: aload_2\n 29: astore_1\n 30: iconst_4\n 31: anewarray #13 // class java/lang/String\n 34: astore_3\n 35: aload_3\n 36: iconst_0\n 37: ldc #21 // String 2021.05.02 A\n 39: aastore\n 40: aload_3\n 41: iconst_1\n 42: ldc #23 // String 2021.07.01 B\n 44: aastore\n 45: aload_3\n 46: iconst_2\n 47: ldc #25 // String 2022.02.19 C\n 49: aastore\n 50: aload_3\n 51: iconst_3\n 52: ldc #27 // String 2022.02.20 C\n 54: aastore\n 55: aload_3\n 56: astore_2\n 57: aload_0\n 58: ldc #29 // String 2022.05.19\n 60: aload_1\n 61: aload_2\n 62: invokevirtual #33 // Method Solution.solution:(Ljava/lang/String;[Ljava/lang/String;[Ljava/lang/String;)[I\n 65: pop\n 66: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #40 // Method main:()V\n 3: return\n}\n", "javap_err": "" } ]
saikatsgupta__aoc-2022-in-kotlin__2c491a9/src/Day03.kt
fun main() { fun Char.getPriority(): Int { return when { isUpperCase() -> code - 'A'.code + 27 else -> code - 'a'.code + 1 } } fun part1(input: List<String>): Int { return input.sumOf { val compartment1 = it.take(it.length / 2) val compartment2 = it.takeLast(it.length / 2) (compartment1.toSet() intersect compartment2.toSet()).single().getPriority() } } fun part2(input: List<String>): Int { return (input.indices step 3) .map { listOf(input[it].toSet(), input[it + 1].toSet(), input[it + 2].toSet()) } .sumOf { ((it[0] intersect it[1]) intersect it[2]).single().getPriority() } } }
[ { "class_path": "saikatsgupta__aoc-2022-in-kotlin__2c491a9/Day03Kt.class", "javap": "Compiled from \"Day03.kt\"\npublic final class Day03Kt {\n public static final void main();\n Code:\n 0: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #9 // Method main:()V\n 3: return\n\n private static final int main$getPriority(char);\n Code:\n 0: nop\n 1: iload_0\n 2: invokestatic #19 // Method java/lang/Character.isUpperCase:(C)Z\n 5: ifeq 18\n 8: iload_0\n 9: bipush 65\n 11: isub\n 12: bipush 27\n 14: iadd\n 15: goto 24\n 18: iload_0\n 19: bipush 97\n 21: isub\n 22: iconst_1\n 23: iadd\n 24: ireturn\n\n private static final int main$part1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #26 // class java/lang/Iterable\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: invokeinterface #30, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore_3\n 14: aload_3\n 15: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 20: ifeq 123\n 23: aload_3\n 24: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 29: astore 4\n 31: iload_2\n 32: aload 4\n 34: checkcast #42 // class java/lang/String\n 37: astore 5\n 39: istore 9\n 41: iconst_0\n 42: istore 6\n 44: aload 5\n 46: aload 5\n 48: invokevirtual #46 // Method java/lang/String.length:()I\n 51: iconst_2\n 52: idiv\n 53: invokestatic #52 // Method kotlin/text/StringsKt.take:(Ljava/lang/String;I)Ljava/lang/String;\n 56: astore 7\n 58: aload 5\n 60: aload 5\n 62: invokevirtual #46 // Method java/lang/String.length:()I\n 65: iconst_2\n 66: idiv\n 67: invokestatic #55 // Method kotlin/text/StringsKt.takeLast:(Ljava/lang/String;I)Ljava/lang/String;\n 70: astore 8\n 72: aload 7\n 74: checkcast #57 // class java/lang/CharSequence\n 77: invokestatic #61 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 80: checkcast #26 // class java/lang/Iterable\n 83: aload 8\n 85: checkcast #57 // class java/lang/CharSequence\n 88: invokestatic #61 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 91: checkcast #26 // class java/lang/Iterable\n 94: invokestatic #67 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 97: checkcast #26 // class java/lang/Iterable\n 100: invokestatic #71 // Method kotlin/collections/CollectionsKt.single:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 103: checkcast #15 // class java/lang/Character\n 106: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 109: invokestatic #77 // Method main$getPriority:(C)I\n 112: istore 10\n 114: iload 9\n 116: iload 10\n 118: iadd\n 119: istore_2\n 120: goto 14\n 123: iload_2\n 124: ireturn\n\n private static final int main$part2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: checkcast #88 // class java/util/Collection\n 4: invokestatic #92 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 7: checkcast #94 // class kotlin/ranges/IntProgression\n 10: iconst_3\n 11: invokestatic #100 // Method kotlin/ranges/RangesKt.step:(Lkotlin/ranges/IntProgression;I)Lkotlin/ranges/IntProgression;\n 14: checkcast #26 // class java/lang/Iterable\n 17: astore_1\n 18: nop\n 19: iconst_0\n 20: istore_2\n 21: aload_1\n 22: astore_3\n 23: new #102 // class java/util/ArrayList\n 26: dup\n 27: aload_1\n 28: bipush 10\n 30: invokestatic #106 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 33: invokespecial #110 // Method java/util/ArrayList.\"<init>\":(I)V\n 36: checkcast #88 // class java/util/Collection\n 39: astore 4\n 41: iconst_0\n 42: istore 5\n 44: aload_3\n 45: invokeinterface #30, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 6\n 52: aload 6\n 54: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 164\n 62: aload 6\n 64: checkcast #112 // class kotlin/collections/IntIterator\n 67: invokevirtual #115 // Method kotlin/collections/IntIterator.nextInt:()I\n 70: istore 7\n 72: aload 4\n 74: iload 7\n 76: istore 8\n 78: astore 11\n 80: iconst_0\n 81: istore 9\n 83: iconst_3\n 84: anewarray #117 // class java/util/Set\n 87: astore 10\n 89: aload 10\n 91: iconst_0\n 92: aload_0\n 93: iload 8\n 95: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 100: checkcast #57 // class java/lang/CharSequence\n 103: invokestatic #61 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 106: aastore\n 107: aload 10\n 109: iconst_1\n 110: aload_0\n 111: iload 8\n 113: iconst_1\n 114: iadd\n 115: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 120: checkcast #57 // class java/lang/CharSequence\n 123: invokestatic #61 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 126: aastore\n 127: aload 10\n 129: iconst_2\n 130: aload_0\n 131: iload 8\n 133: iconst_2\n 134: iadd\n 135: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 140: checkcast #57 // class java/lang/CharSequence\n 143: invokestatic #61 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 146: aastore\n 147: aload 10\n 149: invokestatic #127 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 152: aload 11\n 154: swap\n 155: invokeinterface #131, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 160: pop\n 161: goto 52\n 164: aload 4\n 166: checkcast #119 // class java/util/List\n 169: nop\n 170: checkcast #26 // class java/lang/Iterable\n 173: astore_1\n 174: iconst_0\n 175: istore_2\n 176: aload_1\n 177: invokeinterface #30, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 182: astore_3\n 183: aload_3\n 184: invokeinterface #36, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 189: ifeq 281\n 192: aload_3\n 193: invokeinterface #40, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 198: astore 4\n 200: iload_2\n 201: aload 4\n 203: checkcast #119 // class java/util/List\n 206: astore 5\n 208: istore 11\n 210: iconst_0\n 211: istore 6\n 213: aload 5\n 215: iconst_0\n 216: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 221: checkcast #26 // class java/lang/Iterable\n 224: aload 5\n 226: iconst_1\n 227: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 232: checkcast #26 // class java/lang/Iterable\n 235: invokestatic #67 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 238: checkcast #26 // class java/lang/Iterable\n 241: aload 5\n 243: iconst_2\n 244: invokeinterface #123, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 249: checkcast #26 // class java/lang/Iterable\n 252: invokestatic #67 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 255: checkcast #26 // class java/lang/Iterable\n 258: invokestatic #71 // Method kotlin/collections/CollectionsKt.single:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 261: checkcast #15 // class java/lang/Character\n 264: invokevirtual #75 // Method java/lang/Character.charValue:()C\n 267: invokestatic #77 // Method main$getPriority:(C)I\n 270: istore 12\n 272: iload 11\n 274: iload 12\n 276: iadd\n 277: istore_2\n 278: goto 183\n 281: iload_2\n 282: ireturn\n}\n", "javap_err": "" } ]
iam-abbas__cs-algorithms__d04aa8f/Kotlin/heap_sort_in_kotlin.kt
var heapSize = 0 fun left(i: Int): Int { return 2 * i } fun right(i: Int): Int { return 2 * i + 1 } fun swap(A: Array<Int>, i: Int, j: Int) { var temp = A[i] A[i] = A[j] A[j] = temp } fun max_heapify(A: Array<Int>, i: Int) { var l = left(i); var r = right(i); var largest: Int; if ((l <= heapSize - 1) && (A[l] > A[i])) { largest = l; } else largest = i if ((r <= heapSize - 1) && (A[r] > A[l])) { largest = r } if (largest != i) { swap(A, i, largest); max_heapify(A, largest); } } fun buildMaxheap(A: Array<Int>) { heapSize = A.size for (i in heapSize / 2 downTo 0) { max_heapify(A, i) } } fun heap_sort(A: Array<Int>) { buildMaxheap(A) for (i in A.size - 1 downTo 1) { swap(A, i, 0) heapSize = heapSize - 1 max_heapify(A, 0) } } fun main(arg: Array<String>) { print("Enter no. of elements :") var n = readLine()!!.toInt() println("Enter elements : ") var A = Array(n, { 0 }) for (i in 0 until n) A[i] = readLine()!!.toInt() heap_sort(A) println("Sorted array is : ") for (i in 0 until n) print("${A[i]} ") }
[ { "class_path": "iam-abbas__cs-algorithms__d04aa8f/Heap_sort_in_kotlinKt.class", "javap": "Compiled from \"heap_sort_in_kotlin.kt\"\npublic final class Heap_sort_in_kotlinKt {\n private static int heapSize;\n\n public static final int getHeapSize();\n Code:\n 0: getstatic #10 // Field heapSize:I\n 3: ireturn\n\n public static final void setHeapSize(int);\n Code:\n 0: iload_0\n 1: putstatic #10 // Field heapSize:I\n 4: return\n\n public static final int left(int);\n Code:\n 0: iconst_2\n 1: iload_0\n 2: imul\n 3: ireturn\n\n public static final int right(int);\n Code:\n 0: iconst_2\n 1: iload_0\n 2: imul\n 3: iconst_1\n 4: iadd\n 5: ireturn\n\n public static final void swap(java.lang.Integer[], int, int);\n Code:\n 0: aload_0\n 1: ldc #22 // String A\n 3: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iload_1\n 8: aaload\n 9: invokevirtual #33 // Method java/lang/Integer.intValue:()I\n 12: istore_3\n 13: aload_0\n 14: iload_1\n 15: aload_0\n 16: iload_2\n 17: aaload\n 18: aastore\n 19: aload_0\n 20: iload_2\n 21: iload_3\n 22: invokestatic #37 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 25: aastore\n 26: return\n\n public static final void max_heapify(java.lang.Integer[], int);\n Code:\n 0: aload_0\n 1: ldc #22 // String A\n 3: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_1\n 7: invokestatic #44 // Method left:(I)I\n 10: istore_2\n 11: iload_1\n 12: invokestatic #46 // Method right:(I)I\n 15: istore_3\n 16: iconst_0\n 17: istore 4\n 19: iload_2\n 20: getstatic #10 // Field heapSize:I\n 23: iconst_1\n 24: isub\n 25: if_icmpgt 49\n 28: aload_0\n 29: iload_2\n 30: aaload\n 31: invokevirtual #33 // Method java/lang/Integer.intValue:()I\n 34: aload_0\n 35: iload_1\n 36: aaload\n 37: invokevirtual #33 // Method java/lang/Integer.intValue:()I\n 40: if_icmple 49\n 43: iload_2\n 44: istore 4\n 46: goto 52\n 49: iload_1\n 50: istore 4\n 52: iload_3\n 53: getstatic #10 // Field heapSize:I\n 56: iconst_1\n 57: isub\n 58: if_icmpgt 79\n 61: aload_0\n 62: iload_3\n 63: aaload\n 64: invokevirtual #33 // Method java/lang/Integer.intValue:()I\n 67: aload_0\n 68: iload_2\n 69: aaload\n 70: invokevirtual #33 // Method java/lang/Integer.intValue:()I\n 73: if_icmple 79\n 76: iload_3\n 77: istore 4\n 79: iload 4\n 81: iload_1\n 82: if_icmpeq 98\n 85: aload_0\n 86: iload_1\n 87: iload 4\n 89: invokestatic #48 // Method swap:([Ljava/lang/Integer;II)V\n 92: aload_0\n 93: iload 4\n 95: invokestatic #50 // Method max_heapify:([Ljava/lang/Integer;I)V\n 98: return\n\n public static final void buildMaxheap(java.lang.Integer[]);\n Code:\n 0: aload_0\n 1: ldc #22 // String A\n 3: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: arraylength\n 8: putstatic #10 // Field heapSize:I\n 11: getstatic #10 // Field heapSize:I\n 14: iconst_2\n 15: idiv\n 16: istore_1\n 17: iconst_m1\n 18: iload_1\n 19: if_icmpge 33\n 22: aload_0\n 23: iload_1\n 24: invokestatic #50 // Method max_heapify:([Ljava/lang/Integer;I)V\n 27: iinc 1, -1\n 30: goto 17\n 33: return\n\n public static final void heap_sort(java.lang.Integer[]);\n Code:\n 0: aload_0\n 1: ldc #22 // String A\n 3: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #58 // Method buildMaxheap:([Ljava/lang/Integer;)V\n 10: aload_0\n 11: arraylength\n 12: iconst_1\n 13: isub\n 14: istore_1\n 15: iconst_0\n 16: iload_1\n 17: if_icmpge 45\n 20: aload_0\n 21: iload_1\n 22: iconst_0\n 23: invokestatic #48 // Method swap:([Ljava/lang/Integer;II)V\n 26: getstatic #10 // Field heapSize:I\n 29: iconst_1\n 30: isub\n 31: putstatic #10 // Field heapSize:I\n 34: aload_0\n 35: iconst_0\n 36: invokestatic #50 // Method max_heapify:([Ljava/lang/Integer;I)V\n 39: iinc 1, -1\n 42: goto 15\n 45: return\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #62 // String arg\n 3: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #64 // String Enter no. of elements :\n 8: getstatic #70 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: swap\n 12: invokevirtual #76 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 15: invokestatic #82 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 18: dup\n 19: invokestatic #85 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 22: invokestatic #89 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 25: istore_1\n 26: ldc #91 // String Enter elements :\n 28: getstatic #70 // Field java/lang/System.out:Ljava/io/PrintStream;\n 31: swap\n 32: invokevirtual #94 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 35: iconst_0\n 36: istore_3\n 37: iload_1\n 38: istore 4\n 40: iload 4\n 42: anewarray #30 // class java/lang/Integer\n 45: astore 5\n 47: iload_3\n 48: iload 4\n 50: if_icmpge 71\n 53: iload_3\n 54: istore 6\n 56: aload 5\n 58: iload 6\n 60: iconst_0\n 61: invokestatic #37 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 64: aastore\n 65: iinc 3, 1\n 68: goto 47\n 71: aload 5\n 73: astore_2\n 74: iconst_0\n 75: istore_3\n 76: iload_1\n 77: istore 4\n 79: iload_3\n 80: iload 4\n 82: if_icmpge 107\n 85: aload_2\n 86: iload_3\n 87: invokestatic #82 // Method kotlin/io/ConsoleKt.readLine:()Ljava/lang/String;\n 90: dup\n 91: invokestatic #85 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 94: invokestatic #89 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 97: invokestatic #37 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 100: aastore\n 101: iinc 3, 1\n 104: goto 79\n 107: aload_2\n 108: invokestatic #96 // Method heap_sort:([Ljava/lang/Integer;)V\n 111: ldc #98 // String Sorted array is :\n 113: getstatic #70 // Field java/lang/System.out:Ljava/io/PrintStream;\n 116: swap\n 117: invokevirtual #94 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 120: iconst_0\n 121: istore_3\n 122: iload_1\n 123: istore 4\n 125: iload_3\n 126: iload 4\n 128: if_icmpge 168\n 131: new #100 // class java/lang/StringBuilder\n 134: dup\n 135: invokespecial #104 // Method java/lang/StringBuilder.\"<init>\":()V\n 138: aload_2\n 139: iload_3\n 140: aaload\n 141: invokevirtual #33 // Method java/lang/Integer.intValue:()I\n 144: invokevirtual #108 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 147: ldc #110 // String\n 149: invokevirtual #113 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 152: invokevirtual #116 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 155: getstatic #70 // Field java/lang/System.out:Ljava/io/PrintStream;\n 158: swap\n 159: invokevirtual #76 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 162: iinc 3, 1\n 165: goto 125\n 168: return\n\n static {};\n Code:\n 0: return\n}\n", "javap_err": "" } ]