kt_path
stringlengths 35
167
| kt_source
stringlengths 626
28.9k
| classes
listlengths 1
17
|
|---|---|---|
lernejo__korekto-toolkit__df998e7/src/main/kotlin/com/github/lernejo/korekto/toolkit/misc/Distances.kt
|
package com.github.lernejo.korekto.toolkit.misc
import java.util.*
import java.util.stream.Collectors
import java.util.stream.Stream
import kotlin.math.min
object Distances {
private fun minimum(a: Int, b: Int, c: Int): Int {
return min(min(a, b), c)
}
fun levenshteinDistance(lhs: CharSequence?, rhs: CharSequence?): Int {
val distance = Array(lhs!!.length + 1) {
IntArray(
rhs!!.length + 1
)
}
for (i in 0..lhs.length) distance[i][0] = i
for (j in 1..rhs!!.length) distance[0][j] = j
for (i in 1..lhs.length) for (j in 1..rhs.length) distance[i][j] = minimum(
distance[i - 1][j] + 1,
distance[i][j - 1] + 1,
distance[i - 1][j - 1] + if (lhs[i - 1] == rhs[j - 1]) 0 else 1
)
return distance[lhs.length][rhs.length]
}
fun isWordsIncludedApprox(left: String, right: String, wordLevenshteinDistance: Int): Boolean {
val leftWords = words(left).collect(Collectors.toList())
val rightWords = words(right).collect(Collectors.toList())
val shorterList = if (rightWords.size > leftWords.size) leftWords else rightWords
val longerList: MutableList<String?> = if (rightWords.size > leftWords.size) rightWords else leftWords
for (shortListWord in shorterList) {
if (!contains(longerList, shortListWord, wordLevenshteinDistance)) {
return false
}
}
return true
}
private fun contains(words: MutableList<String?>, match: String?, maxLevenshteinDistance: Int): Boolean {
var contained = false
var matched: String? = null
for (word in words) {
if (levenshteinDistance(word, match) <= maxLevenshteinDistance) {
contained = true
matched = word
break
}
}
if (contained) {
words.remove(matched)
}
return contained
}
fun countWords(text: String): Int {
return words(text).count().toInt()
}
private fun words(sentence: String): Stream<String?> {
return Arrays.stream(sentence.split("\\s+".toRegex()).toTypedArray())
.filter { s: String? -> s!!.trim { it <= ' ' }.isNotEmpty() }
}
fun longestCommonSubSequence(a: String, b: String): Int {
return lCSubStr(a.toCharArray(), b.toCharArray(), a.length, b.length)
}
private fun lCSubStr(X: CharArray, Y: CharArray, m: Int, n: Int): Int {
// Create a table to store lengths of longest common suffixes of
// substrings. Note that LCSuff[i][j] contains length of longest
// common suffix of X[0..i-1] and Y[0..j-1]. The first row and
// first column entries have no logical meaning, they are used only
// for simplicity of program
val lCStuff = Array(m + 1) { IntArray(n + 1) }
var result = 0 // To store length of the longest common substring
// Following steps build LCSuff[m+1][n+1] in bottom up fashion
for (i in 0..m) {
for (j in 0..n) {
if (i == 0 || j == 0) lCStuff[i][j] = 0 else if (X[i - 1] == Y[j - 1]) {
lCStuff[i][j] = lCStuff[i - 1][j - 1] + 1
result = Integer.max(result, lCStuff[i][j])
} else lCStuff[i][j] = 0
}
}
return result
}
}
|
[
{
"class_path": "lernejo__korekto-toolkit__df998e7/com/github/lernejo/korekto/toolkit/misc/Distances.class",
"javap": "Compiled from \"Distances.kt\"\npublic final class com.github.lernejo.korekto.toolkit.misc.Distances {\n public static final com.github.lernejo.korekto.toolkit.misc.Distances INSTANCE;\n\n private com.github.lernejo.korekto.toolkit.misc.Distances();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int minimum(int, int, int);\n Code:\n 0: nop\n 1: iload_1\n 2: iload_2\n 3: invokestatic #18 // Method java/lang/Math.min:(II)I\n 6: iload_3\n 7: invokestatic #18 // Method java/lang/Math.min:(II)I\n 10: ireturn\n\n public final int levenshteinDistance(java.lang.CharSequence, java.lang.CharSequence);\n Code:\n 0: iconst_0\n 1: istore 4\n 3: aload_1\n 4: dup\n 5: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 8: invokeinterface #37, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 13: iconst_1\n 14: iadd\n 15: istore 5\n 17: iload 5\n 19: anewarray #39 // class \"[I\"\n 22: astore 6\n 24: iload 4\n 26: iload 5\n 28: if_icmpge 60\n 31: iload 4\n 33: istore 7\n 35: aload 6\n 37: iload 7\n 39: aload_2\n 40: dup\n 41: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 44: invokeinterface #37, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 49: iconst_1\n 50: iadd\n 51: newarray int\n 53: aastore\n 54: iinc 4, 1\n 57: goto 24\n 60: aload 6\n 62: astore_3\n 63: iconst_0\n 64: istore 4\n 66: aload_1\n 67: invokeinterface #37, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 72: istore 5\n 74: iload 4\n 76: iload 5\n 78: if_icmpgt 102\n 81: aload_3\n 82: iload 4\n 84: aaload\n 85: iconst_0\n 86: iload 4\n 88: iastore\n 89: iload 4\n 91: iload 5\n 93: if_icmpeq 102\n 96: iinc 4, 1\n 99: goto 81\n 102: iconst_1\n 103: istore 4\n 105: aload_2\n 106: dup\n 107: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 110: invokeinterface #37, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 115: istore 5\n 117: iload 4\n 119: iload 5\n 121: if_icmpgt 145\n 124: aload_3\n 125: iconst_0\n 126: aaload\n 127: iload 4\n 129: iload 4\n 131: iastore\n 132: iload 4\n 134: iload 5\n 136: if_icmpeq 145\n 139: iinc 4, 1\n 142: goto 124\n 145: iconst_1\n 146: istore 4\n 148: aload_1\n 149: invokeinterface #37, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 154: istore 5\n 156: iload 4\n 158: iload 5\n 160: if_icmpgt 280\n 163: iconst_1\n 164: istore 6\n 166: aload_2\n 167: invokeinterface #37, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 172: istore 7\n 174: iload 6\n 176: iload 7\n 178: if_icmpgt 267\n 181: aload_3\n 182: iload 4\n 184: aaload\n 185: iload 6\n 187: aload_0\n 188: aload_3\n 189: iload 4\n 191: iconst_1\n 192: isub\n 193: aaload\n 194: iload 6\n 196: iaload\n 197: iconst_1\n 198: iadd\n 199: aload_3\n 200: iload 4\n 202: aaload\n 203: iload 6\n 205: iconst_1\n 206: isub\n 207: iaload\n 208: iconst_1\n 209: iadd\n 210: aload_3\n 211: iload 4\n 213: iconst_1\n 214: isub\n 215: aaload\n 216: iload 6\n 218: iconst_1\n 219: isub\n 220: iaload\n 221: aload_1\n 222: iload 4\n 224: iconst_1\n 225: isub\n 226: invokeinterface #43, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 231: aload_2\n 232: iload 6\n 234: iconst_1\n 235: isub\n 236: invokeinterface #43, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 241: if_icmpne 248\n 244: iconst_0\n 245: goto 249\n 248: iconst_1\n 249: iadd\n 250: invokespecial #45 // Method minimum:(III)I\n 253: iastore\n 254: iload 6\n 256: iload 7\n 258: if_icmpeq 267\n 261: iinc 6, 1\n 264: goto 181\n 267: iload 4\n 269: iload 5\n 271: if_icmpeq 280\n 274: iinc 4, 1\n 277: goto 163\n 280: aload_3\n 281: aload_1\n 282: invokeinterface #37, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 287: aaload\n 288: aload_2\n 289: invokeinterface #37, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 294: iaload\n 295: ireturn\n\n public final boolean isWordsIncludedApprox(java.lang.String, java.lang.String, int);\n Code:\n 0: aload_1\n 1: ldc #58 // String left\n 3: invokestatic #62 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #64 // String right\n 9: invokestatic #62 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_1\n 14: invokespecial #68 // Method words:(Ljava/lang/String;)Ljava/util/stream/Stream;\n 17: invokestatic #74 // Method java/util/stream/Collectors.toList:()Ljava/util/stream/Collector;\n 20: invokeinterface #80, 2 // InterfaceMethod java/util/stream/Stream.collect:(Ljava/util/stream/Collector;)Ljava/lang/Object;\n 25: checkcast #82 // class java/util/List\n 28: astore 4\n 30: aload_0\n 31: aload_2\n 32: invokespecial #68 // Method words:(Ljava/lang/String;)Ljava/util/stream/Stream;\n 35: invokestatic #74 // Method java/util/stream/Collectors.toList:()Ljava/util/stream/Collector;\n 38: invokeinterface #80, 2 // InterfaceMethod java/util/stream/Stream.collect:(Ljava/util/stream/Collector;)Ljava/lang/Object;\n 43: checkcast #82 // class java/util/List\n 46: astore 5\n 48: aload 5\n 50: invokeinterface #85, 1 // InterfaceMethod java/util/List.size:()I\n 55: aload 4\n 57: invokeinterface #85, 1 // InterfaceMethod java/util/List.size:()I\n 62: if_icmple 70\n 65: aload 4\n 67: goto 72\n 70: aload 5\n 72: astore 6\n 74: aload 5\n 76: invokeinterface #85, 1 // InterfaceMethod java/util/List.size:()I\n 81: aload 4\n 83: invokeinterface #85, 1 // InterfaceMethod java/util/List.size:()I\n 88: if_icmple 101\n 91: aload 5\n 93: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 96: aload 5\n 98: goto 108\n 101: aload 4\n 103: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 106: aload 4\n 108: astore 7\n 110: aload 6\n 112: invokeinterface #89, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 117: astore 8\n 119: aload 8\n 121: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 126: ifeq 155\n 129: aload 8\n 131: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 136: checkcast #101 // class java/lang/String\n 139: astore 9\n 141: aload_0\n 142: aload 7\n 144: aload 9\n 146: iload_3\n 147: invokespecial #105 // Method contains:(Ljava/util/List;Ljava/lang/String;I)Z\n 150: ifne 119\n 153: iconst_0\n 154: ireturn\n 155: iconst_1\n 156: ireturn\n\n private final boolean contains(java.util.List<java.lang.String>, java.lang.String, int);\n Code:\n 0: iconst_0\n 1: istore 4\n 3: aconst_null\n 4: astore 5\n 6: aload_1\n 7: invokeinterface #89, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 12: astore 6\n 14: aload 6\n 16: invokeinterface #95, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 21: ifeq 63\n 24: aload 6\n 26: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 31: checkcast #101 // class java/lang/String\n 34: astore 7\n 36: aload_0\n 37: aload 7\n 39: checkcast #33 // class java/lang/CharSequence\n 42: aload_2\n 43: checkcast #33 // class java/lang/CharSequence\n 46: invokevirtual #116 // Method levenshteinDistance:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)I\n 49: iload_3\n 50: if_icmpgt 14\n 53: iconst_1\n 54: istore 4\n 56: aload 7\n 58: astore 5\n 60: goto 63\n 63: iload 4\n 65: ifeq 77\n 68: aload_1\n 69: aload 5\n 71: invokeinterface #120, 2 // InterfaceMethod java/util/List.remove:(Ljava/lang/Object;)Z\n 76: pop\n 77: iload 4\n 79: ireturn\n\n public final int countWords(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #130 // String text\n 3: invokestatic #62 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: invokespecial #68 // Method words:(Ljava/lang/String;)Ljava/util/stream/Stream;\n 11: invokeinterface #134, 1 // InterfaceMethod java/util/stream/Stream.count:()J\n 16: l2i\n 17: ireturn\n\n private final java.util.stream.Stream<java.lang.String> words(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #33 // class java/lang/CharSequence\n 4: astore_2\n 5: new #137 // class kotlin/text/Regex\n 8: dup\n 9: ldc #139 // String \\\\s+\n 11: invokespecial #142 // 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 #146 // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 25: checkcast #148 // class java/util/Collection\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: aload 4\n 37: iconst_0\n 38: anewarray #101 // class java/lang/String\n 41: invokeinterface #152, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 46: invokestatic #158 // Method java/util/Arrays.stream:([Ljava/lang/Object;)Ljava/util/stream/Stream;\n 49: invokedynamic #178, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 54: invokedynamic #188, 0 // InvokeDynamic #1:test:(Lkotlin/jvm/functions/Function1;)Ljava/util/function/Predicate;\n 59: invokeinterface #192, 2 // InterfaceMethod java/util/stream/Stream.filter:(Ljava/util/function/Predicate;)Ljava/util/stream/Stream;\n 64: dup\n 65: ldc #194 // String filter(...)\n 67: invokestatic #197 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 70: areturn\n\n public final int longestCommonSubSequence(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #205 // String a\n 3: invokestatic #62 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #206 // String b\n 9: invokestatic #62 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_1\n 14: invokevirtual #210 // Method java/lang/String.toCharArray:()[C\n 17: dup\n 18: ldc #212 // String toCharArray(...)\n 20: invokestatic #197 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 23: aload_2\n 24: invokevirtual #210 // Method java/lang/String.toCharArray:()[C\n 27: dup\n 28: ldc #212 // String toCharArray(...)\n 30: invokestatic #197 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 33: aload_1\n 34: invokevirtual #213 // Method java/lang/String.length:()I\n 37: aload_2\n 38: invokevirtual #213 // Method java/lang/String.length:()I\n 41: invokespecial #217 // Method lCSubStr:([C[CII)I\n 44: ireturn\n\n private final int lCSubStr(char[], char[], int, int);\n Code:\n 0: iconst_0\n 1: istore 6\n 3: iload_3\n 4: iconst_1\n 5: iadd\n 6: istore 7\n 8: iload 7\n 10: anewarray #39 // class \"[I\"\n 13: astore 8\n 15: iload 6\n 17: iload 7\n 19: if_icmpge 43\n 22: iload 6\n 24: istore 9\n 26: aload 8\n 28: iload 9\n 30: iload 4\n 32: iconst_1\n 33: iadd\n 34: newarray int\n 36: aastore\n 37: iinc 6, 1\n 40: goto 15\n 43: aload 8\n 45: astore 5\n 47: iconst_0\n 48: istore 6\n 50: iconst_0\n 51: istore 7\n 53: iload 7\n 55: iload_3\n 56: if_icmpgt 180\n 59: iconst_0\n 60: istore 8\n 62: iload 8\n 64: iload 4\n 66: if_icmpgt 168\n 69: iload 7\n 71: ifeq 79\n 74: iload 8\n 76: ifne 91\n 79: aload 5\n 81: iload 7\n 83: aaload\n 84: iload 8\n 86: iconst_0\n 87: iastore\n 88: goto 155\n 91: aload_1\n 92: iload 7\n 94: iconst_1\n 95: isub\n 96: caload\n 97: aload_2\n 98: iload 8\n 100: iconst_1\n 101: isub\n 102: caload\n 103: if_icmpne 146\n 106: aload 5\n 108: iload 7\n 110: aaload\n 111: iload 8\n 113: aload 5\n 115: iload 7\n 117: iconst_1\n 118: isub\n 119: aaload\n 120: iload 8\n 122: iconst_1\n 123: isub\n 124: iaload\n 125: iconst_1\n 126: iadd\n 127: iastore\n 128: iload 6\n 130: aload 5\n 132: iload 7\n 134: aaload\n 135: iload 8\n 137: iaload\n 138: invokestatic #222 // Method java/lang/Integer.max:(II)I\n 141: istore 6\n 143: goto 155\n 146: aload 5\n 148: iload 7\n 150: aaload\n 151: iload 8\n 153: iconst_0\n 154: iastore\n 155: iload 8\n 157: iload 4\n 159: if_icmpeq 168\n 162: iinc 8, 1\n 165: goto 69\n 168: iload 7\n 170: iload_3\n 171: if_icmpeq 180\n 174: iinc 7, 1\n 177: goto 59\n 180: iload 6\n 182: ireturn\n\n private static final boolean words$lambda$1(java.lang.String);\n Code:\n 0: aload_0\n 1: dup\n 2: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 5: astore_1\n 6: iconst_0\n 7: istore_2\n 8: aload_1\n 9: checkcast #33 // class java/lang/CharSequence\n 12: astore_3\n 13: iconst_0\n 14: istore 4\n 16: iconst_0\n 17: istore 5\n 19: aload_3\n 20: invokeinterface #37, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 25: iconst_1\n 26: isub\n 27: istore 6\n 29: iconst_0\n 30: istore 7\n 32: iload 5\n 34: iload 6\n 36: if_icmpgt 119\n 39: iload 7\n 41: ifne 49\n 44: iload 5\n 46: goto 51\n 49: iload 6\n 51: istore 8\n 53: aload_3\n 54: iload 8\n 56: invokeinterface #43, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 61: istore 9\n 63: iconst_0\n 64: istore 10\n 66: iload 9\n 68: bipush 32\n 70: invokestatic #233 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 73: ifgt 80\n 76: iconst_1\n 77: goto 81\n 80: iconst_0\n 81: istore 9\n 83: iload 7\n 85: ifne 105\n 88: iload 9\n 90: ifne 99\n 93: iconst_1\n 94: istore 7\n 96: goto 32\n 99: iinc 5, 1\n 102: goto 32\n 105: iload 9\n 107: ifne 113\n 110: goto 119\n 113: iinc 6, -1\n 116: goto 32\n 119: aload_3\n 120: iload 5\n 122: iload 6\n 124: iconst_1\n 125: iadd\n 126: invokeinterface #237, 3 // InterfaceMethod java/lang/CharSequence.subSequence:(II)Ljava/lang/CharSequence;\n 131: invokevirtual #241 // Method java/lang/Object.toString:()Ljava/lang/String;\n 134: checkcast #33 // class java/lang/CharSequence\n 137: invokeinterface #37, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 142: ifle 149\n 145: iconst_1\n 146: goto 150\n 149: iconst_0\n 150: ireturn\n\n private static final boolean words$lambda$2(kotlin.jvm.functions.Function1, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokeinterface #257, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #259 // class java/lang/Boolean\n 10: invokevirtual #262 // Method java/lang/Boolean.booleanValue:()Z\n 13: ireturn\n\n static {};\n Code:\n 0: new #2 // class com/github/lernejo/korekto/toolkit/misc/Distances\n 3: dup\n 4: invokespecial #268 // Method \"<init>\":()V\n 7: putstatic #271 // Field INSTANCE:Lcom/github/lernejo/korekto/toolkit/misc/Distances;\n 10: return\n}\n",
"javap_err": ""
}
] |
asher-stern__sudoku__73ee63a/src/main/kotlin/com/learn/sudoku/Sudoku.kt
|
package com.learn.sudoku
import java.io.File
typealias Board = Array<Array<Int?>> // Row first. For example, b[1][3] means second row forth column.
fun main(args: Array<String>)
{
val board = Sudoku.read(args[0])
println(Sudoku.print(board))
println((1..11).joinToString("") { "=" } )
if(!Sudoku.solve(board)) println("Unsolvable.")
}
object Sudoku
{
fun read(filename: String): Board =
File(filename).useLines { lines ->
lines.take(9).map { line -> line.map { if (it.isDigit()) it.toString().toInt() else null }.toTypedArray() }
.toList().toTypedArray()
}
fun print(board: Board): String =
board.withIndex().joinToString("\n") { (i, r) ->
val columnString = r.withIndex().joinToString("") { (ci, c) ->
(if ((ci>0)&&(0==(ci%3))) "|" else "") + (c?.toString()?:" ")
}
(if ((i>0)&&(0==(i%3))) (1..11).joinToString("", postfix = "\n") { "-" } else "") + columnString
}
fun solve(board: Board): Boolean = solve(board, 0, 0)
private fun solve(board: Board, row: Int, column: Int): Boolean
{
if (board[row][column] == null)
{
for (value in 1..9)
{
if (!violates(value, row, column, board))
{
board[row][column] = value
if ( (row == 8) && (column == 8) )
{
println(print(board))
return true
}
else
{
val (nextRow, nextColumn) = next(row, column)
if (solve(board, nextRow, nextColumn))
{
return true
}
}
board[row][column] = null
}
}
return false
}
else
{
if ( (row == 8) && (column == 8) )
{
println(print(board))
return true
}
else
{
val (nextRow, nextColumn) = next(row, column)
return solve(board, nextRow, nextColumn)
}
}
}
private fun next(row: Int, column: Int): Pair<Int, Int>
{
if (column < 8) return Pair(row, column + 1)
else return Pair(row + 1, 0)
}
private fun violates(value: Int, row: Int, column: Int, board: Board): Boolean
{
return violatesRow(value, row, column, board) ||
violatesColumn(value, row, column, board) ||
violatesSquare(value, row, column, board)
}
private fun violatesRow(value: Int, row: Int, column: Int, board: Board): Boolean =
(0 until 9).any { (it != column) && (board[row][it] == value) }
private fun violatesColumn(value: Int, row: Int, column: Int, board: Board): Boolean =
(0 until 9).any { (it != row) && (board[it][column] == value) }
private fun violatesSquare(value: Int, row: Int, column: Int, board: Board): Boolean
{
val rowBegin = (row/3)*3
val columnBegin = (column/3)*3
for (r in rowBegin until (rowBegin+3))
{
for (c in columnBegin until (columnBegin+3))
{
if ( (r != row) && (c != column) )
{
if (board[r][c] == value)
{
return true
}
}
}
}
return false
}
}
|
[
{
"class_path": "asher-stern__sudoku__73ee63a/com/learn/sudoku/SudokuKt.class",
"javap": "Compiled from \"Sudoku.kt\"\npublic final class com.learn.sudoku.SudokuKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String args\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #21 // Field com/learn/sudoku/Sudoku.INSTANCE:Lcom/learn/sudoku/Sudoku;\n 9: aload_0\n 10: iconst_0\n 11: aaload\n 12: invokevirtual #25 // Method com/learn/sudoku/Sudoku.read:(Ljava/lang/String;)[[Ljava/lang/Integer;\n 15: astore_1\n 16: getstatic #21 // Field com/learn/sudoku/Sudoku.INSTANCE:Lcom/learn/sudoku/Sudoku;\n 19: aload_1\n 20: invokevirtual #29 // Method com/learn/sudoku/Sudoku.print:([[Ljava/lang/Integer;)Ljava/lang/String;\n 23: getstatic #35 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: swap\n 27: invokevirtual #41 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 30: new #43 // class kotlin/ranges/IntRange\n 33: dup\n 34: iconst_1\n 35: bipush 11\n 37: invokespecial #47 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 40: checkcast #49 // class java/lang/Iterable\n 43: ldc #51 // String\n 45: checkcast #53 // class java/lang/CharSequence\n 48: aconst_null\n 49: aconst_null\n 50: iconst_0\n 51: aconst_null\n 52: invokedynamic #73, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 57: bipush 30\n 59: aconst_null\n 60: invokestatic #79 // 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 63: getstatic #35 // Field java/lang/System.out:Ljava/io/PrintStream;\n 66: swap\n 67: invokevirtual #41 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 70: getstatic #21 // Field com/learn/sudoku/Sudoku.INSTANCE:Lcom/learn/sudoku/Sudoku;\n 73: aload_1\n 74: invokevirtual #83 // Method com/learn/sudoku/Sudoku.solve:([[Ljava/lang/Integer;)Z\n 77: ifne 89\n 80: ldc #85 // String Unsolvable.\n 82: getstatic #35 // Field java/lang/System.out:Ljava/io/PrintStream;\n 85: swap\n 86: invokevirtual #41 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 89: return\n\n private static final java.lang.CharSequence main$lambda$0(int);\n Code:\n 0: ldc #91 // String =\n 2: checkcast #53 // class java/lang/CharSequence\n 5: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "asher-stern__sudoku__73ee63a/com/learn/sudoku/Sudoku.class",
"javap": "Compiled from \"Sudoku.kt\"\npublic final class com.learn.sudoku.Sudoku {\n public static final com.learn.sudoku.Sudoku INSTANCE;\n\n private com.learn.sudoku.Sudoku();\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.Integer[][] read(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #17 // String filename\n 3: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #25 // class java/io/File\n 9: dup\n 10: aload_1\n 11: invokespecial #28 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 14: astore_2\n 15: getstatic #34 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 18: astore_3\n 19: iconst_0\n 20: istore 4\n 22: aload_2\n 23: astore 5\n 25: sipush 8192\n 28: istore 6\n 30: aload 5\n 32: astore 7\n 34: new #36 // class java/io/InputStreamReader\n 37: dup\n 38: new #38 // class java/io/FileInputStream\n 41: dup\n 42: aload 7\n 44: invokespecial #41 // Method java/io/FileInputStream.\"<init>\":(Ljava/io/File;)V\n 47: checkcast #43 // class java/io/InputStream\n 50: aload_3\n 51: invokespecial #46 // Method java/io/InputStreamReader.\"<init>\":(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V\n 54: checkcast #48 // class java/io/Reader\n 57: astore 7\n 59: aload 7\n 61: instanceof #50 // class java/io/BufferedReader\n 64: ifeq 75\n 67: aload 7\n 69: checkcast #50 // class java/io/BufferedReader\n 72: goto 86\n 75: new #50 // class java/io/BufferedReader\n 78: dup\n 79: aload 7\n 81: iload 6\n 83: invokespecial #53 // Method java/io/BufferedReader.\"<init>\":(Ljava/io/Reader;I)V\n 86: checkcast #55 // class java/io/Closeable\n 89: astore 5\n 91: aconst_null\n 92: astore 6\n 94: nop\n 95: aload 5\n 97: checkcast #50 // class java/io/BufferedReader\n 100: astore 7\n 102: iconst_0\n 103: istore 8\n 105: aload 7\n 107: invokestatic #61 // Method kotlin/io/TextStreamsKt.lineSequence:(Ljava/io/BufferedReader;)Lkotlin/sequences/Sequence;\n 110: astore 9\n 112: iconst_0\n 113: istore 10\n 115: aload 9\n 117: bipush 9\n 119: invokestatic #67 // Method kotlin/sequences/SequencesKt.take:(Lkotlin/sequences/Sequence;I)Lkotlin/sequences/Sequence;\n 122: invokedynamic #86, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 127: invokestatic #90 // Method kotlin/sequences/SequencesKt.map:(Lkotlin/sequences/Sequence;Lkotlin/jvm/functions/Function1;)Lkotlin/sequences/Sequence;\n 130: invokestatic #94 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 133: checkcast #96 // class java/util/Collection\n 136: astore 11\n 138: iconst_0\n 139: istore 12\n 141: aload 11\n 143: astore 13\n 145: aload 13\n 147: iconst_0\n 148: anewarray #98 // class \"[Ljava/lang/Integer;\"\n 151: invokeinterface #102, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 156: checkcast #104 // class \"[[Ljava/lang/Integer;\"\n 159: nop\n 160: astore 7\n 162: aload 5\n 164: aload 6\n 166: invokestatic #110 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 169: aload 7\n 171: goto 195\n 174: astore 8\n 176: aload 8\n 178: astore 6\n 180: aload 8\n 182: athrow\n 183: astore 8\n 185: aload 5\n 187: aload 6\n 189: invokestatic #110 // Method kotlin/io/CloseableKt.closeFinally:(Ljava/io/Closeable;Ljava/lang/Throwable;)V\n 192: aload 8\n 194: athrow\n 195: nop\n 196: checkcast #104 // class \"[[Ljava/lang/Integer;\"\n 199: areturn\n Exception table:\n from to target type\n 94 162 174 Class java/lang/Throwable\n 94 162 183 any\n 174 183 183 any\n 183 185 183 any\n\n public final java.lang.String print(java.lang.Integer[][]);\n Code:\n 0: aload_1\n 1: ldc #136 // String board\n 3: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #138 // class \"[Ljava/lang/Object;\"\n 10: invokestatic #144 // Method kotlin/collections/ArraysKt.withIndex:([Ljava/lang/Object;)Ljava/lang/Iterable;\n 13: ldc #146 // String \\n\n 15: checkcast #148 // class java/lang/CharSequence\n 18: aconst_null\n 19: aconst_null\n 20: iconst_0\n 21: aconst_null\n 22: invokedynamic #155, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 27: bipush 30\n 29: aconst_null\n 30: invokestatic #161 // 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 33: areturn\n\n public final boolean solve(java.lang.Integer[][]);\n Code:\n 0: aload_1\n 1: ldc #136 // String board\n 3: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: aload_1\n 8: iconst_0\n 9: iconst_0\n 10: invokespecial #166 // Method solve:([[Ljava/lang/Integer;II)Z\n 13: ireturn\n\n private final boolean solve(java.lang.Integer[][], int, int);\n Code:\n 0: aload_1\n 1: iload_2\n 2: aaload\n 3: iload_3\n 4: aaload\n 5: ifnonnull 128\n 8: iconst_1\n 9: istore 4\n 11: iload 4\n 13: bipush 10\n 15: if_icmpge 126\n 18: aload_0\n 19: iload 4\n 21: iload_2\n 22: iload_3\n 23: aload_1\n 24: invokespecial #170 // Method violates:(III[[Ljava/lang/Integer;)Z\n 27: ifne 120\n 30: aload_1\n 31: iload_2\n 32: aaload\n 33: iload_3\n 34: iload 4\n 36: invokestatic #176 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 39: aastore\n 40: iload_2\n 41: bipush 8\n 43: if_icmpne 66\n 46: iload_3\n 47: bipush 8\n 49: if_icmpne 66\n 52: aload_0\n 53: aload_1\n 54: invokevirtual #178 // Method print:([[Ljava/lang/Integer;)Ljava/lang/String;\n 57: getstatic #184 // Field java/lang/System.out:Ljava/io/PrintStream;\n 60: swap\n 61: invokevirtual #190 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 64: iconst_1\n 65: ireturn\n 66: aload_0\n 67: iload_2\n 68: iload_3\n 69: invokespecial #194 // Method next:(II)Lkotlin/Pair;\n 72: astore 5\n 74: aload 5\n 76: invokevirtual #200 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 79: checkcast #202 // class java/lang/Number\n 82: invokevirtual #206 // Method java/lang/Number.intValue:()I\n 85: istore 6\n 87: aload 5\n 89: invokevirtual #209 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 92: checkcast #202 // class java/lang/Number\n 95: invokevirtual #206 // Method java/lang/Number.intValue:()I\n 98: istore 7\n 100: aload_0\n 101: aload_1\n 102: iload 6\n 104: iload 7\n 106: invokespecial #166 // Method solve:([[Ljava/lang/Integer;II)Z\n 109: ifeq 114\n 112: iconst_1\n 113: ireturn\n 114: aload_1\n 115: iload_2\n 116: aaload\n 117: iload_3\n 118: aconst_null\n 119: aastore\n 120: iinc 4, 1\n 123: goto 11\n 126: iconst_0\n 127: ireturn\n 128: iload_2\n 129: bipush 8\n 131: if_icmpne 154\n 134: iload_3\n 135: bipush 8\n 137: if_icmpne 154\n 140: aload_0\n 141: aload_1\n 142: invokevirtual #178 // Method print:([[Ljava/lang/Integer;)Ljava/lang/String;\n 145: getstatic #184 // Field java/lang/System.out:Ljava/io/PrintStream;\n 148: swap\n 149: invokevirtual #190 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 152: iconst_1\n 153: ireturn\n 154: aload_0\n 155: iload_2\n 156: iload_3\n 157: invokespecial #194 // Method next:(II)Lkotlin/Pair;\n 160: astore 4\n 162: aload 4\n 164: invokevirtual #200 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 167: checkcast #202 // class java/lang/Number\n 170: invokevirtual #206 // Method java/lang/Number.intValue:()I\n 173: istore 5\n 175: aload 4\n 177: invokevirtual #209 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 180: checkcast #202 // class java/lang/Number\n 183: invokevirtual #206 // Method java/lang/Number.intValue:()I\n 186: istore 6\n 188: aload_0\n 189: aload_1\n 190: iload 5\n 192: iload 6\n 194: invokespecial #166 // Method solve:([[Ljava/lang/Integer;II)Z\n 197: ireturn\n\n private final kotlin.Pair<java.lang.Integer, java.lang.Integer> next(int, int);\n Code:\n 0: iload_2\n 1: bipush 8\n 3: if_icmpge 24\n 6: new #196 // class kotlin/Pair\n 9: dup\n 10: iload_1\n 11: invokestatic #176 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 14: iload_2\n 15: iconst_1\n 16: iadd\n 17: invokestatic #176 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 20: invokespecial #218 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 23: areturn\n 24: new #196 // class kotlin/Pair\n 27: dup\n 28: iload_1\n 29: iconst_1\n 30: iadd\n 31: invokestatic #176 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 34: iconst_0\n 35: invokestatic #176 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 38: invokespecial #218 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 41: areturn\n\n private final boolean violates(int, int, int, java.lang.Integer[][]);\n Code:\n 0: aload_0\n 1: iload_1\n 2: iload_2\n 3: iload_3\n 4: aload 4\n 6: invokespecial #221 // Method violatesRow:(III[[Ljava/lang/Integer;)Z\n 9: ifne 36\n 12: aload_0\n 13: iload_1\n 14: iload_2\n 15: iload_3\n 16: aload 4\n 18: invokespecial #224 // Method violatesColumn:(III[[Ljava/lang/Integer;)Z\n 21: ifne 36\n 24: aload_0\n 25: iload_1\n 26: iload_2\n 27: iload_3\n 28: aload 4\n 30: invokespecial #227 // Method violatesSquare:(III[[Ljava/lang/Integer;)Z\n 33: ifeq 40\n 36: iconst_1\n 37: goto 41\n 40: iconst_0\n 41: ireturn\n\n private final boolean violatesRow(int, int, int, java.lang.Integer[][]);\n Code:\n 0: iconst_0\n 1: bipush 9\n 3: invokestatic #233 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 6: checkcast #235 // class java/lang/Iterable\n 9: astore 5\n 11: iconst_0\n 12: istore 6\n 14: aload 5\n 16: instanceof #96 // class java/util/Collection\n 19: ifeq 39\n 22: aload 5\n 24: checkcast #96 // class java/util/Collection\n 27: invokeinterface #239, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 32: ifeq 39\n 35: iconst_0\n 36: goto 120\n 39: aload 5\n 41: invokeinterface #243, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 46: astore 7\n 48: aload 7\n 50: invokeinterface #248, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 55: ifeq 119\n 58: aload 7\n 60: checkcast #250 // class kotlin/collections/IntIterator\n 63: invokevirtual #253 // Method kotlin/collections/IntIterator.nextInt:()I\n 66: istore 8\n 68: iload 8\n 70: istore 9\n 72: iconst_0\n 73: istore 10\n 75: iload 9\n 77: iload_3\n 78: if_icmpeq 111\n 81: aload 4\n 83: iload_2\n 84: aaload\n 85: iload 9\n 87: aaload\n 88: iload_1\n 89: istore 11\n 91: dup\n 92: ifnonnull 99\n 95: pop\n 96: goto 111\n 99: invokevirtual #254 // Method java/lang/Integer.intValue:()I\n 102: iload 11\n 104: if_icmpne 111\n 107: iconst_1\n 108: goto 112\n 111: iconst_0\n 112: ifeq 48\n 115: iconst_1\n 116: goto 120\n 119: iconst_0\n 120: ireturn\n\n private final boolean violatesColumn(int, int, int, java.lang.Integer[][]);\n Code:\n 0: iconst_0\n 1: bipush 9\n 3: invokestatic #233 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 6: checkcast #235 // class java/lang/Iterable\n 9: astore 5\n 11: iconst_0\n 12: istore 6\n 14: aload 5\n 16: instanceof #96 // class java/util/Collection\n 19: ifeq 39\n 22: aload 5\n 24: checkcast #96 // class java/util/Collection\n 27: invokeinterface #239, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 32: ifeq 39\n 35: iconst_0\n 36: goto 120\n 39: aload 5\n 41: invokeinterface #243, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 46: astore 7\n 48: aload 7\n 50: invokeinterface #248, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 55: ifeq 119\n 58: aload 7\n 60: checkcast #250 // class kotlin/collections/IntIterator\n 63: invokevirtual #253 // Method kotlin/collections/IntIterator.nextInt:()I\n 66: istore 8\n 68: iload 8\n 70: istore 9\n 72: iconst_0\n 73: istore 10\n 75: iload 9\n 77: iload_2\n 78: if_icmpeq 111\n 81: aload 4\n 83: iload 9\n 85: aaload\n 86: iload_3\n 87: aaload\n 88: iload_1\n 89: istore 11\n 91: dup\n 92: ifnonnull 99\n 95: pop\n 96: goto 111\n 99: invokevirtual #254 // Method java/lang/Integer.intValue:()I\n 102: iload 11\n 104: if_icmpne 111\n 107: iconst_1\n 108: goto 112\n 111: iconst_0\n 112: ifeq 48\n 115: iconst_1\n 116: goto 120\n 119: iconst_0\n 120: ireturn\n\n private final boolean violatesSquare(int, int, int, java.lang.Integer[][]);\n Code:\n 0: iload_2\n 1: iconst_3\n 2: idiv\n 3: iconst_3\n 4: imul\n 5: istore 5\n 7: iload_3\n 8: iconst_3\n 9: idiv\n 10: iconst_3\n 11: imul\n 12: istore 6\n 14: iload 5\n 16: istore 7\n 18: iload 5\n 20: iconst_3\n 21: iadd\n 22: istore 8\n 24: iload 7\n 26: iload 8\n 28: if_icmpge 101\n 31: iload 6\n 33: istore 9\n 35: iload 6\n 37: iconst_3\n 38: iadd\n 39: istore 10\n 41: iload 9\n 43: iload 10\n 45: if_icmpge 95\n 48: iload 7\n 50: iload_2\n 51: if_icmpeq 89\n 54: iload 9\n 56: iload_3\n 57: if_icmpeq 89\n 60: aload 4\n 62: iload 7\n 64: aaload\n 65: iload 9\n 67: aaload\n 68: iload_1\n 69: istore 11\n 71: dup\n 72: ifnonnull 79\n 75: pop\n 76: goto 89\n 79: invokevirtual #254 // Method java/lang/Integer.intValue:()I\n 82: iload 11\n 84: if_icmpne 89\n 87: iconst_1\n 88: ireturn\n 89: iinc 9, 1\n 92: goto 41\n 95: iinc 7, 1\n 98: goto 24\n 101: iconst_0\n 102: ireturn\n\n private static final java.lang.Integer[] read$lambda$2$lambda$1(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc_w #267 // String line\n 4: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: checkcast #148 // class java/lang/CharSequence\n 11: astore_1\n 12: iconst_0\n 13: istore_2\n 14: aload_1\n 15: astore_3\n 16: new #269 // class java/util/ArrayList\n 19: dup\n 20: aload_1\n 21: invokeinterface #272, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 26: invokespecial #275 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #96 // class java/util/Collection\n 32: astore 4\n 34: iconst_0\n 35: istore 5\n 37: iconst_0\n 38: istore 6\n 40: iload 6\n 42: aload_3\n 43: invokeinterface #272, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 48: if_icmpge 110\n 51: aload_3\n 52: iload 6\n 54: invokeinterface #279, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 59: istore 7\n 61: aload 4\n 63: iload 7\n 65: istore 8\n 67: astore 10\n 69: iconst_0\n 70: istore 9\n 72: iload 8\n 74: invokestatic #285 // Method java/lang/Character.isDigit:(C)Z\n 77: ifeq 94\n 80: iload 8\n 82: invokestatic #288 // Method java/lang/String.valueOf:(C)Ljava/lang/String;\n 85: invokestatic #292 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 88: invokestatic #176 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 91: goto 95\n 94: aconst_null\n 95: aload 10\n 97: swap\n 98: invokeinterface #296, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 103: pop\n 104: iinc 6, 1\n 107: goto 40\n 110: aload 4\n 112: checkcast #298 // class java/util/List\n 115: nop\n 116: checkcast #96 // class java/util/Collection\n 119: astore_1\n 120: nop\n 121: iconst_0\n 122: istore_2\n 123: aload_1\n 124: astore_3\n 125: aload_3\n 126: iconst_0\n 127: anewarray #172 // class java/lang/Integer\n 130: invokeinterface #102, 2 // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;\n 135: checkcast #98 // class \"[Ljava/lang/Integer;\"\n 138: areturn\n\n private static final java.lang.CharSequence print$lambda$5$lambda$3(kotlin.collections.IndexedValue);\n Code:\n 0: aload_0\n 1: ldc_w #310 // String <destruct>\n 4: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokevirtual #314 // Method kotlin/collections/IndexedValue.component1:()I\n 11: istore_1\n 12: aload_0\n 13: invokevirtual #315 // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;\n 16: checkcast #172 // class java/lang/Integer\n 19: astore_2\n 20: new #317 // class java/lang/StringBuilder\n 23: dup\n 24: invokespecial #318 // Method java/lang/StringBuilder.\"<init>\":()V\n 27: iload_1\n 28: ifle 43\n 31: iload_1\n 32: iconst_3\n 33: irem\n 34: ifne 43\n 37: ldc_w #320 // String |\n 40: goto 46\n 43: ldc_w #322 // String\n 46: invokevirtual #326 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 49: aload_2\n 50: dup\n 51: ifnull 61\n 54: invokevirtual #330 // Method java/lang/Integer.toString:()Ljava/lang/String;\n 57: dup\n 58: ifnonnull 65\n 61: pop\n 62: ldc_w #332 // String\n 65: invokevirtual #326 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 68: invokevirtual #333 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 71: checkcast #148 // class java/lang/CharSequence\n 74: areturn\n\n private static final java.lang.CharSequence print$lambda$5$lambda$4(int);\n Code:\n 0: ldc_w #339 // String -\n 3: checkcast #148 // class java/lang/CharSequence\n 6: areturn\n\n private static final java.lang.CharSequence print$lambda$5(kotlin.collections.IndexedValue);\n Code:\n 0: aload_0\n 1: ldc_w #310 // String <destruct>\n 4: invokestatic #23 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_0\n 8: invokevirtual #314 // Method kotlin/collections/IndexedValue.component1:()I\n 11: istore_1\n 12: aload_0\n 13: invokevirtual #315 // Method kotlin/collections/IndexedValue.component2:()Ljava/lang/Object;\n 16: checkcast #98 // class \"[Ljava/lang/Integer;\"\n 19: astore_2\n 20: aload_2\n 21: invokestatic #144 // Method kotlin/collections/ArraysKt.withIndex:([Ljava/lang/Object;)Ljava/lang/Iterable;\n 24: ldc_w #322 // String\n 27: checkcast #148 // class java/lang/CharSequence\n 30: aconst_null\n 31: aconst_null\n 32: iconst_0\n 33: aconst_null\n 34: invokedynamic #343, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function1;\n 39: bipush 30\n 41: aconst_null\n 42: invokestatic #161 // 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 45: astore_3\n 46: new #317 // class java/lang/StringBuilder\n 49: dup\n 50: invokespecial #318 // Method java/lang/StringBuilder.\"<init>\":()V\n 53: iload_1\n 54: ifle 104\n 57: iload_1\n 58: iconst_3\n 59: irem\n 60: ifne 104\n 63: new #345 // class kotlin/ranges/IntRange\n 66: dup\n 67: iconst_1\n 68: bipush 11\n 70: invokespecial #348 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 73: checkcast #235 // class java/lang/Iterable\n 76: ldc_w #322 // String\n 79: checkcast #148 // class java/lang/CharSequence\n 82: aconst_null\n 83: ldc #146 // String \\n\n 85: checkcast #148 // class java/lang/CharSequence\n 88: iconst_0\n 89: aconst_null\n 90: invokedynamic #354, 0 // InvokeDynamic #3:invoke:()Lkotlin/jvm/functions/Function1;\n 95: bipush 26\n 97: aconst_null\n 98: invokestatic #161 // 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 101: goto 107\n 104: ldc_w #322 // String\n 107: invokevirtual #326 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 110: aload_3\n 111: invokevirtual #326 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 114: invokevirtual #333 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 117: checkcast #148 // class java/lang/CharSequence\n 120: areturn\n\n static {};\n Code:\n 0: new #2 // class com/learn/sudoku/Sudoku\n 3: dup\n 4: invokespecial #358 // Method \"<init>\":()V\n 7: putstatic #361 // Field INSTANCE:Lcom/learn/sudoku/Sudoku;\n 10: return\n}\n",
"javap_err": ""
}
] |
GirZ0n__SPBU-Homework-2__05f2bda/src/main/kotlin/homeworks/homework8/task1/model/MinimaxAlgorithm.kt
|
package homeworks.homework7.task2.model
object MinimaxAlgorithm {
private const val MAX_VALUE = 1000
private const val MIN_VALUE = -MAX_VALUE
private const val BASIC_VALUE = 10
fun getBestMove(board: Array<CharArray>, playerSign: Char, opponentSign: Char, emptySign: Char): Pair<Int, Int> {
var bestValue = MIN_VALUE
var bestMove = Pair(-1, -1)
for (i in 0..2) {
for (j in 0..2) {
if (board[i][j] == emptySign) {
board[i][j] = playerSign
val moveValue = minimax(board, false, playerSign, opponentSign, emptySign)
val move = Pair(i, j)
board[i][j] = emptySign // Undo
bestMove = move.takeIf { bestValue < moveValue } ?: bestMove
bestValue = moveValue.takeIf { bestValue < it } ?: bestValue
}
}
}
return bestMove
}
private fun minimax(
board: Array<CharArray>,
isPlayer: Boolean, // !isPlayer = isOpponent
playerSign: Char,
opponentSign: Char,
emptySign: Char
): Int {
val score = evaluateCurrentState(board, playerSign, opponentSign)
return if (score == BASIC_VALUE) {
score
} else if (score == -BASIC_VALUE) {
score
} else if (!isMovesLeft(board, emptySign)) {
0
} else if (isPlayer) {
playerHandling(board, isPlayer, playerSign, opponentSign, emptySign)
} else {
opponentHandling(board, isPlayer, playerSign, opponentSign, emptySign)
}
}
private fun playerHandling(
board: Array<CharArray>,
isPlayer: Boolean,
playerSign: Char,
opponentSign: Char,
emptySign: Char
): Int {
var best = MIN_VALUE
for (i in 0..2) {
for (j in 0..2) {
if (board[i][j] == emptySign) {
board[i][j] = playerSign
best = best.coerceAtLeast(minimax(board, !isPlayer, playerSign, opponentSign, emptySign))
board[i][j] = emptySign // Undo
}
}
}
return best
}
private fun opponentHandling(
board: Array<CharArray>,
isPlayer: Boolean,
playerSign: Char,
opponentSign: Char,
emptySign: Char
): Int {
var best = MAX_VALUE
for (i in 0..2) {
for (j in 0..2) {
if (board[i][j] == emptySign) {
board[i][j] = opponentSign
best = best.coerceAtMost(minimax(board, !isPlayer, playerSign, opponentSign, emptySign))
board[i][j] = emptySign // Undo
}
}
}
return best
}
private fun isMovesLeft(board: Array<CharArray>, emptySign: Char): Boolean {
for (raw in board) {
for (elem in raw) {
if (elem == emptySign) {
return true
}
}
}
return false
}
private fun evaluateCurrentState(board: Array<CharArray>, playerSign: Char, opponentSign: Char): Int {
val results = emptyList<Int>().toMutableList()
results.add(checkRowsForWinningCombinations(board, playerSign, opponentSign))
results.add(checkColumnsForWinningCombinations(board, playerSign, opponentSign))
results.add(checkMainDiagonalForWinningCombination(board, playerSign, opponentSign))
results.add(checkAntidiagonalForWinningCombination(board, playerSign, opponentSign))
for (result in results) {
if (result == BASIC_VALUE || result == -BASIC_VALUE) {
return result
}
}
return 0
}
/*
The following 4 functions return:
BASIC_VALUE - when player wins;
-BASIC_VALUE - when opponent wins;
0 - when tie.
*/
private fun checkRowsForWinningCombinations(board: Array<CharArray>, playerSign: Char, opponentSign: Char): Int {
for (row in 0..2) {
if (board[row][0] == board[row][1] && board[row][1] == board[row][2]) {
return if (board[row][0] == playerSign) {
BASIC_VALUE
} else if (board[row][0] == opponentSign) {
-BASIC_VALUE
} else continue
}
}
return 0
}
private fun checkColumnsForWinningCombinations(board: Array<CharArray>, playerSign: Char, opponentSign: Char): Int {
for (column in 0..2) {
if (board[0][column] == board[1][column] && board[1][column] == board[2][column]) {
return if (board[0][column] == playerSign) {
BASIC_VALUE
} else if (board[0][column] == opponentSign) {
-BASIC_VALUE
} else continue
}
}
return 0
}
private fun checkMainDiagonalForWinningCombination(
board: Array<CharArray>,
playerSign: Char,
opponentSign: Char
): Int {
if (board[0][0] == board[1][1] && board[1][1] == board[2][2]) {
return when (board[1][1]) {
playerSign -> BASIC_VALUE
opponentSign -> -BASIC_VALUE
else -> 0
}
}
return 0
}
private fun checkAntidiagonalForWinningCombination(
board: Array<CharArray>,
playerSign: Char,
opponentSign: Char
): Int {
if (board[0][2] == board[1][1] && board[1][1] == board[2][0]) {
return when (board[1][1]) {
playerSign -> BASIC_VALUE
opponentSign -> -BASIC_VALUE
else -> 0
}
}
return 0
}
}
|
[
{
"class_path": "GirZ0n__SPBU-Homework-2__05f2bda/homeworks/homework7/task2/model/MinimaxAlgorithm.class",
"javap": "Compiled from \"MinimaxAlgorithm.kt\"\npublic final class homeworks.homework7.task2.model.MinimaxAlgorithm {\n public static final homeworks.homework7.task2.model.MinimaxAlgorithm INSTANCE;\n\n private static final int MAX_VALUE;\n\n private static final int MIN_VALUE;\n\n private static final int BASIC_VALUE;\n\n private homeworks.homework7.task2.model.MinimaxAlgorithm();\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<java.lang.Integer, java.lang.Integer> getBestMove(char[][], char, char, char);\n Code:\n 0: aload_1\n 1: ldc #16 // String board\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iconst_0\n 7: istore 5\n 9: sipush -1000\n 12: istore 5\n 14: new #24 // class kotlin/Pair\n 17: dup\n 18: iconst_m1\n 19: invokestatic #30 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 22: iconst_m1\n 23: invokestatic #30 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 26: invokespecial #33 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 29: astore 6\n 31: iconst_0\n 32: istore 7\n 34: iload 7\n 36: iconst_3\n 37: if_icmpge 218\n 40: iconst_0\n 41: istore 8\n 43: iload 8\n 45: iconst_3\n 46: if_icmpge 212\n 49: aload_1\n 50: iload 7\n 52: aaload\n 53: iload 8\n 55: caload\n 56: iload 4\n 58: if_icmpne 206\n 61: aload_1\n 62: iload 7\n 64: aaload\n 65: iload 8\n 67: iload_2\n 68: castore\n 69: aload_0\n 70: aload_1\n 71: iconst_0\n 72: iload_2\n 73: iload_3\n 74: iload 4\n 76: invokespecial #37 // Method minimax:([[CZCCC)I\n 79: istore 9\n 81: new #24 // class kotlin/Pair\n 84: dup\n 85: iload 7\n 87: invokestatic #30 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 90: iload 8\n 92: invokestatic #30 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 95: invokespecial #33 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 98: astore 10\n 100: aload_1\n 101: iload 7\n 103: aaload\n 104: iload 8\n 106: iload 4\n 108: castore\n 109: aload 10\n 111: astore 11\n 113: aload 11\n 115: astore 12\n 117: iconst_0\n 118: istore 13\n 120: iload 5\n 122: iload 9\n 124: if_icmpge 131\n 127: iconst_1\n 128: goto 132\n 131: iconst_0\n 132: ifeq 140\n 135: aload 11\n 137: goto 141\n 140: aconst_null\n 141: dup\n 142: ifnonnull 148\n 145: pop\n 146: aload 6\n 148: astore 6\n 150: iload 9\n 152: invokestatic #30 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 155: astore 11\n 157: aload 11\n 159: checkcast #39 // class java/lang/Number\n 162: invokevirtual #43 // Method java/lang/Number.intValue:()I\n 165: istore 12\n 167: iconst_0\n 168: istore 13\n 170: iload 5\n 172: iload 12\n 174: if_icmpge 181\n 177: iconst_1\n 178: goto 182\n 181: iconst_0\n 182: ifeq 190\n 185: aload 11\n 187: goto 191\n 190: aconst_null\n 191: dup\n 192: ifnull 201\n 195: invokevirtual #44 // Method java/lang/Integer.intValue:()I\n 198: goto 204\n 201: pop\n 202: iload 5\n 204: istore 5\n 206: iinc 8, 1\n 209: goto 43\n 212: iinc 7, 1\n 215: goto 34\n 218: aload 6\n 220: areturn\n\n private final int minimax(char[][], boolean, char, char, char);\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_3\n 3: iload 4\n 5: invokespecial #65 // Method evaluateCurrentState:([[CCC)I\n 8: istore 6\n 10: iload 6\n 12: bipush 10\n 14: if_icmpne 22\n 17: iload 6\n 19: goto 77\n 22: iload 6\n 24: bipush -10\n 26: if_icmpne 34\n 29: iload 6\n 31: goto 77\n 34: aload_0\n 35: aload_1\n 36: iload 5\n 38: invokespecial #69 // Method isMovesLeft:([[CC)Z\n 41: ifne 48\n 44: iconst_0\n 45: goto 77\n 48: iload_2\n 49: ifeq 66\n 52: aload_0\n 53: aload_1\n 54: iload_2\n 55: iload_3\n 56: iload 4\n 58: iload 5\n 60: invokespecial #72 // Method playerHandling:([[CZCCC)I\n 63: goto 77\n 66: aload_0\n 67: aload_1\n 68: iload_2\n 69: iload_3\n 70: iload 4\n 72: iload 5\n 74: invokespecial #75 // Method opponentHandling:([[CZCCC)I\n 77: ireturn\n\n private final int playerHandling(char[][], boolean, char, char, char);\n Code:\n 0: sipush -1000\n 3: istore 6\n 5: iconst_0\n 6: istore 7\n 8: iload 7\n 10: iconst_3\n 11: if_icmpge 90\n 14: iconst_0\n 15: istore 8\n 17: iload 8\n 19: iconst_3\n 20: if_icmpge 84\n 23: aload_1\n 24: iload 7\n 26: aaload\n 27: iload 8\n 29: caload\n 30: iload 5\n 32: if_icmpne 78\n 35: aload_1\n 36: iload 7\n 38: aaload\n 39: iload 8\n 41: iload_3\n 42: castore\n 43: iload 6\n 45: aload_0\n 46: aload_1\n 47: iload_2\n 48: ifne 55\n 51: iconst_1\n 52: goto 56\n 55: iconst_0\n 56: iload_3\n 57: iload 4\n 59: iload 5\n 61: invokespecial #37 // Method minimax:([[CZCCC)I\n 64: invokestatic #84 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 67: istore 6\n 69: aload_1\n 70: iload 7\n 72: aaload\n 73: iload 8\n 75: iload 5\n 77: castore\n 78: iinc 8, 1\n 81: goto 17\n 84: iinc 7, 1\n 87: goto 8\n 90: iload 6\n 92: ireturn\n\n private final int opponentHandling(char[][], boolean, char, char, char);\n Code:\n 0: sipush 1000\n 3: istore 6\n 5: iconst_0\n 6: istore 7\n 8: iload 7\n 10: iconst_3\n 11: if_icmpge 91\n 14: iconst_0\n 15: istore 8\n 17: iload 8\n 19: iconst_3\n 20: if_icmpge 85\n 23: aload_1\n 24: iload 7\n 26: aaload\n 27: iload 8\n 29: caload\n 30: iload 5\n 32: if_icmpne 79\n 35: aload_1\n 36: iload 7\n 38: aaload\n 39: iload 8\n 41: iload 4\n 43: castore\n 44: iload 6\n 46: aload_0\n 47: aload_1\n 48: iload_2\n 49: ifne 56\n 52: iconst_1\n 53: goto 57\n 56: iconst_0\n 57: iload_3\n 58: iload 4\n 60: iload 5\n 62: invokespecial #37 // Method minimax:([[CZCCC)I\n 65: invokestatic #88 // Method kotlin/ranges/RangesKt.coerceAtMost:(II)I\n 68: istore 6\n 70: aload_1\n 71: iload 7\n 73: aaload\n 74: iload 8\n 76: iload 5\n 78: castore\n 79: iinc 8, 1\n 82: goto 17\n 85: iinc 7, 1\n 88: goto 8\n 91: iload 6\n 93: ireturn\n\n private final boolean isMovesLeft(char[][], char);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: aload_1\n 3: checkcast #90 // class \"[Ljava/lang/Object;\"\n 6: arraylength\n 7: istore 4\n 9: iload_3\n 10: iload 4\n 12: if_icmpge 62\n 15: aload_1\n 16: iload_3\n 17: aaload\n 18: astore 5\n 20: iconst_0\n 21: istore 6\n 23: aload 5\n 25: arraylength\n 26: istore 7\n 28: iload 6\n 30: iload 7\n 32: if_icmpge 56\n 35: aload 5\n 37: iload 6\n 39: caload\n 40: istore 8\n 42: iload 8\n 44: iload_2\n 45: if_icmpne 50\n 48: iconst_1\n 49: ireturn\n 50: iinc 6, 1\n 53: goto 28\n 56: iinc 3, 1\n 59: goto 9\n 62: iconst_0\n 63: ireturn\n\n private final int evaluateCurrentState(char[][], char, char);\n Code:\n 0: invokestatic #100 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 3: checkcast #102 // class java/util/Collection\n 6: invokestatic #106 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 9: astore 4\n 11: aload 4\n 13: aload_0\n 14: aload_1\n 15: iload_2\n 16: iload_3\n 17: invokespecial #109 // Method checkRowsForWinningCombinations:([[CCC)I\n 20: invokestatic #30 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 23: invokeinterface #115, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 28: pop\n 29: aload 4\n 31: aload_0\n 32: aload_1\n 33: iload_2\n 34: iload_3\n 35: invokespecial #118 // Method checkColumnsForWinningCombinations:([[CCC)I\n 38: invokestatic #30 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 41: invokeinterface #115, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 46: pop\n 47: aload 4\n 49: aload_0\n 50: aload_1\n 51: iload_2\n 52: iload_3\n 53: invokespecial #121 // Method checkMainDiagonalForWinningCombination:([[CCC)I\n 56: invokestatic #30 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 59: invokeinterface #115, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 64: pop\n 65: aload 4\n 67: aload_0\n 68: aload_1\n 69: iload_2\n 70: iload_3\n 71: invokespecial #124 // Method checkAntidiagonalForWinningCombination:([[CCC)I\n 74: invokestatic #30 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 77: invokeinterface #115, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 82: pop\n 83: aload 4\n 85: invokeinterface #128, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 90: astore 5\n 92: aload 5\n 94: invokeinterface #134, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 99: ifeq 150\n 102: aload 5\n 104: invokeinterface #138, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 109: checkcast #39 // class java/lang/Number\n 112: invokevirtual #43 // Method java/lang/Number.intValue:()I\n 115: istore 6\n 117: iload 6\n 119: lookupswitch { // 2\n -10: 144\n 10: 144\n default: 147\n }\n 144: iload 6\n 146: ireturn\n 147: goto 92\n 150: iconst_0\n 151: ireturn\n\n private final int checkRowsForWinningCombinations(char[][], char, char);\n Code:\n 0: iconst_0\n 1: istore 4\n 3: iload 4\n 5: iconst_3\n 6: if_icmpge 79\n 9: aload_1\n 10: iload 4\n 12: aaload\n 13: iconst_0\n 14: caload\n 15: aload_1\n 16: iload 4\n 18: aaload\n 19: iconst_1\n 20: caload\n 21: if_icmpne 73\n 24: aload_1\n 25: iload 4\n 27: aaload\n 28: iconst_1\n 29: caload\n 30: aload_1\n 31: iload 4\n 33: aaload\n 34: iconst_2\n 35: caload\n 36: if_icmpne 73\n 39: aload_1\n 40: iload 4\n 42: aaload\n 43: iconst_0\n 44: caload\n 45: iload_2\n 46: if_icmpne 54\n 49: bipush 10\n 51: goto 72\n 54: aload_1\n 55: iload 4\n 57: aaload\n 58: iconst_0\n 59: caload\n 60: iload_3\n 61: if_icmpne 69\n 64: bipush -10\n 66: goto 72\n 69: goto 73\n 72: ireturn\n 73: iinc 4, 1\n 76: goto 3\n 79: iconst_0\n 80: ireturn\n\n private final int checkColumnsForWinningCombinations(char[][], char, char);\n Code:\n 0: iconst_0\n 1: istore 4\n 3: iload 4\n 5: iconst_3\n 6: if_icmpge 79\n 9: aload_1\n 10: iconst_0\n 11: aaload\n 12: iload 4\n 14: caload\n 15: aload_1\n 16: iconst_1\n 17: aaload\n 18: iload 4\n 20: caload\n 21: if_icmpne 73\n 24: aload_1\n 25: iconst_1\n 26: aaload\n 27: iload 4\n 29: caload\n 30: aload_1\n 31: iconst_2\n 32: aaload\n 33: iload 4\n 35: caload\n 36: if_icmpne 73\n 39: aload_1\n 40: iconst_0\n 41: aaload\n 42: iload 4\n 44: caload\n 45: iload_2\n 46: if_icmpne 54\n 49: bipush 10\n 51: goto 72\n 54: aload_1\n 55: iconst_0\n 56: aaload\n 57: iload 4\n 59: caload\n 60: iload_3\n 61: if_icmpne 69\n 64: bipush -10\n 66: goto 72\n 69: goto 73\n 72: ireturn\n 73: iinc 4, 1\n 76: goto 3\n 79: iconst_0\n 80: ireturn\n\n private final int checkMainDiagonalForWinningCombination(char[][], char, char);\n Code:\n 0: aload_1\n 1: iconst_0\n 2: aaload\n 3: iconst_0\n 4: caload\n 5: aload_1\n 6: iconst_1\n 7: aaload\n 8: iconst_1\n 9: caload\n 10: if_icmpne 57\n 13: aload_1\n 14: iconst_1\n 15: aaload\n 16: iconst_1\n 17: caload\n 18: aload_1\n 19: iconst_2\n 20: aaload\n 21: iconst_2\n 22: caload\n 23: if_icmpne 57\n 26: aload_1\n 27: iconst_1\n 28: aaload\n 29: iconst_1\n 30: caload\n 31: istore 4\n 33: iload 4\n 35: iload_2\n 36: if_icmpne 44\n 39: bipush 10\n 41: goto 56\n 44: iload 4\n 46: iload_3\n 47: if_icmpne 55\n 50: bipush -10\n 52: goto 56\n 55: iconst_0\n 56: ireturn\n 57: iconst_0\n 58: ireturn\n\n private final int checkAntidiagonalForWinningCombination(char[][], char, char);\n Code:\n 0: aload_1\n 1: iconst_0\n 2: aaload\n 3: iconst_2\n 4: caload\n 5: aload_1\n 6: iconst_1\n 7: aaload\n 8: iconst_1\n 9: caload\n 10: if_icmpne 57\n 13: aload_1\n 14: iconst_1\n 15: aaload\n 16: iconst_1\n 17: caload\n 18: aload_1\n 19: iconst_2\n 20: aaload\n 21: iconst_0\n 22: caload\n 23: if_icmpne 57\n 26: aload_1\n 27: iconst_1\n 28: aaload\n 29: iconst_1\n 30: caload\n 31: istore 4\n 33: iload 4\n 35: iload_2\n 36: if_icmpne 44\n 39: bipush 10\n 41: goto 56\n 44: iload 4\n 46: iload_3\n 47: if_icmpne 55\n 50: bipush -10\n 52: goto 56\n 55: iconst_0\n 56: ireturn\n 57: iconst_0\n 58: ireturn\n\n static {};\n Code:\n 0: new #2 // class homeworks/homework7/task2/model/MinimaxAlgorithm\n 3: dup\n 4: invokespecial #145 // Method \"<init>\":()V\n 7: putstatic #148 // Field INSTANCE:Lhomeworks/homework7/task2/model/MinimaxAlgorithm;\n 10: return\n}\n",
"javap_err": ""
}
] |
nschulzke__mancala-puzzle-solver__b130d3b/src/main/kotlin/Main.kt
|
package com.nschulzke
enum class Stars {
One, Two, Three;
}
private val mancalaIndices = setOf(6, 13)
data class Puzzle(
private val board: List<Int>,
private val turns: Int,
private val targets: List<Pair<Stars, Int>>,
val steps: List<Int> = emptyList(),
) {
fun onBottom(pit: Int): Boolean =
pit in 0..5
fun onTop(pit: Int): Boolean =
pit in 7..12
fun opposite(pit: Int): Int =
when (pit) {
0 -> 12
1 -> 11
2 -> 10
3 -> 9
4 -> 8
5 -> 7
7 -> 5
8 -> 4
9 -> 3
10 -> 2
11 -> 1
12 -> 0
else -> throw IllegalArgumentException("Pit $pit has no opposite")
}
fun move(pit: Int): Puzzle {
if (board[pit] == 0) {
throw Error("Cannot move empty pit")
}
if (pit in mancalaIndices) {
throw Error("Cannot move mancala")
}
val mutableBoard = board.toMutableList()
val stones = mutableBoard[pit]
mutableBoard[pit] = 0
var index = pit
for (i in 1..stones) {
index = (index + 1) % mutableBoard.size
mutableBoard[index]++
}
// If the final pit is opposite of another pit that is not empty, capture all pieces
if (index !in mancalaIndices) {
val oppositeIndex = opposite(index)
val mancala = if (onBottom(index)) {
6
} else {
13
}
if (mutableBoard[index] == 1 && mutableBoard[oppositeIndex] > 0) {
mutableBoard[mancala] += mutableBoard[oppositeIndex] + 1
mutableBoard[index] = 0
mutableBoard[oppositeIndex] = 0
}
}
return this.copy(
board = mutableBoard,
turns = if (index !in mancalaIndices) {
turns - 1
} else {
turns
},
steps = steps + pit
)
}
private fun pitToString(index: Int): String =
board[index].toString().padStart(2, ' ')
fun score(): Int =
board[6] + board[13]
fun starRating(): Stars? =
targets.lastOrNull { score() >= it.second }?.first
fun isComplete(): Boolean =
turns <= 0 || starRating() == Stars.Three
fun nonEmptyPitIndices(): Iterable<Int> =
board.indices.filter { board[it] > 0 && !mancalaIndices.contains(it) }
override fun toString(): String {
return """
| ${pitToString(12)} ${pitToString(11)} ${pitToString(10)} ${pitToString(9)} ${pitToString(8)} ${pitToString(7)}
|${pitToString(13)} ${pitToString(6)}
| ${pitToString(0)} ${pitToString(1)} ${pitToString(2)} ${pitToString(3)} ${pitToString(4)} ${pitToString(5)}
|${turns} turns left
""".trimMargin()
}
}
class Solver {
// Use a search tree to find the minimum number of moves to get 3 stars' worth of stones in the mancalas.
fun solve(startingPuzzle: Puzzle): Puzzle? {
val queue = mutableListOf(startingPuzzle)
val visited = mutableSetOf(startingPuzzle)
while (queue.isNotEmpty()) {
val puzzle = queue.removeAt(0)
if (puzzle.isComplete()) {
if (puzzle.starRating() == Stars.Three) {
return puzzle
}
} else {
for (pit in puzzle.nonEmptyPitIndices()) {
val nextGame = puzzle.move(pit)
if (nextGame !in visited) {
queue.add(nextGame)
visited.add(nextGame)
}
}
}
}
return null
}
companion object {
@JvmStatic
fun main(args: Array<String>) {
val puzzle = Puzzle(
board = mutableListOf(
1, 0, 3, 0, 4, 0, 0,
1, 0, 0, 0, 2, 0, 0,
),
turns = 3,
targets = listOf(
Stars.One to 8,
Stars.Two to 9,
Stars.Three to 10,
),
)
println(puzzle)
val solver = Solver()
val solution = solver.solve(puzzle)
if (solution == null) {
println("No solution found.")
} else {
solution.steps.fold(puzzle) { acc, next ->
acc.move(next).also { println("\nAfter moving $next:\n$it") }
}
}
}
}
}
|
[
{
"class_path": "nschulzke__mancala-puzzle-solver__b130d3b/com/nschulzke/MainKt.class",
"javap": "Compiled from \"Main.kt\"\npublic final class com.nschulzke.MainKt {\n private static final java.util.Set<java.lang.Integer> mancalaIndices;\n\n public static final java.util.Set access$getMancalaIndices$p();\n Code:\n 0: getstatic #10 // Field mancalaIndices:Ljava/util/Set;\n 3: areturn\n\n static {};\n Code:\n 0: iconst_2\n 1: anewarray #14 // class java/lang/Integer\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: bipush 6\n 9: invokestatic #18 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 12: aastore\n 13: aload_0\n 14: iconst_1\n 15: bipush 13\n 17: invokestatic #18 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 20: aastore\n 21: aload_0\n 22: invokestatic #24 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 25: putstatic #10 // Field mancalaIndices:Ljava/util/Set;\n 28: return\n}\n",
"javap_err": ""
}
] |
analogrelay__advent-of-code__006343d/2019/src/main/kotlin/adventofcode/day04/main.kt
|
package adventofcode.day04
fun main(args: Array<String>) {
if (args.size < 2) {
System.err.println("Usage: adventofcode day04 <START> <END>")
System.exit(1)
}
val start = args[0].toInt()
val end = args[1].toInt()
println("Computing passwords in range $start - $end")
val part1Passwords = (start..end).filter { isValidPassword(it, true) }
println("[Part 1] Number of valid passwords: ${part1Passwords.size}")
val part2Passwords = (start..end).filter { isValidPassword(it, false) }
// for(invalidPassword in part1Passwords.minus(part2Passwords)) {
// println("[Part 2] Invalid: $invalidPassword")
// }
// for(validPassword in part2Passwords) {
// println("[Part 2] Valid: $validPassword")
// }
println("[Part 2] Number of valid passwords: ${part2Passwords.size}")
}
fun Int.iterateDigits(): List<Int> {
var number = this
return generateSequence {
if (number == 0) {
null
} else {
val digit = number % 10
number = number / 10
digit
}
}.toList().reversed()
}
fun isValidPassword(candidate: Int, allowMoreThanTwoDigitSequence: Boolean): Boolean {
var last = -1
var activeSequenceLength = 0
var hasValidSequence = false
for (digit in candidate.iterateDigits()) {
if (last >= 0) {
if (last > digit) {
// Digits must be ascending
return false;
}
if (allowMoreThanTwoDigitSequence) {
if(last == digit) {
hasValidSequence = true
}
}
else if (last != digit) {
if (activeSequenceLength == 2) {
// Found a sequence of exactly two digits
hasValidSequence = true
}
activeSequenceLength = 0
}
}
activeSequenceLength += 1
last = digit
}
return hasValidSequence || activeSequenceLength == 2
}
|
[
{
"class_path": "analogrelay__advent-of-code__006343d/adventofcode/day04/MainKt.class",
"javap": "Compiled from \"main.kt\"\npublic final class adventofcode.day04.MainKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String args\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: arraylength\n 8: iconst_2\n 9: if_icmpge 24\n 12: getstatic #21 // Field java/lang/System.err:Ljava/io/PrintStream;\n 15: ldc #23 // String Usage: adventofcode day04 <START> <END>\n 17: invokevirtual #29 // Method java/io/PrintStream.println:(Ljava/lang/String;)V\n 20: iconst_1\n 21: invokestatic #33 // Method java/lang/System.exit:(I)V\n 24: aload_0\n 25: iconst_0\n 26: aaload\n 27: invokestatic #39 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 30: istore_1\n 31: aload_0\n 32: iconst_1\n 33: aaload\n 34: invokestatic #39 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 37: istore_2\n 38: new #41 // class java/lang/StringBuilder\n 41: dup\n 42: invokespecial #45 // Method java/lang/StringBuilder.\"<init>\":()V\n 45: ldc #47 // String Computing passwords in range\n 47: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 50: iload_1\n 51: invokevirtual #54 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 54: ldc #56 // String -\n 56: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 59: iload_2\n 60: invokevirtual #54 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 63: invokevirtual #60 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 66: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 69: swap\n 70: invokevirtual #66 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 73: new #68 // class kotlin/ranges/IntRange\n 76: dup\n 77: iload_1\n 78: iload_2\n 79: invokespecial #71 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 82: checkcast #73 // class java/lang/Iterable\n 85: astore 4\n 87: iconst_0\n 88: istore 5\n 90: aload 4\n 92: astore 6\n 94: new #75 // class java/util/ArrayList\n 97: dup\n 98: invokespecial #76 // Method java/util/ArrayList.\"<init>\":()V\n 101: checkcast #78 // class java/util/Collection\n 104: astore 7\n 106: iconst_0\n 107: istore 8\n 109: aload 6\n 111: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 116: astore 9\n 118: aload 9\n 120: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 125: ifeq 172\n 128: aload 9\n 130: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 135: astore 10\n 137: aload 10\n 139: checkcast #94 // class java/lang/Number\n 142: invokevirtual #98 // Method java/lang/Number.intValue:()I\n 145: istore 11\n 147: iconst_0\n 148: istore 12\n 150: iload 11\n 152: iconst_1\n 153: invokestatic #102 // Method isValidPassword:(IZ)Z\n 156: ifeq 118\n 159: aload 7\n 161: aload 10\n 163: invokeinterface #106, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 168: pop\n 169: goto 118\n 172: aload 7\n 174: checkcast #108 // class java/util/List\n 177: nop\n 178: astore_3\n 179: new #41 // class java/lang/StringBuilder\n 182: dup\n 183: invokespecial #45 // Method java/lang/StringBuilder.\"<init>\":()V\n 186: ldc #110 // String [Part 1] Number of valid passwords:\n 188: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 191: aload_3\n 192: invokeinterface #113, 1 // InterfaceMethod java/util/List.size:()I\n 197: invokevirtual #54 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 200: invokevirtual #60 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 203: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 206: swap\n 207: invokevirtual #66 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 210: new #68 // class kotlin/ranges/IntRange\n 213: dup\n 214: iload_1\n 215: iload_2\n 216: invokespecial #71 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 219: checkcast #73 // class java/lang/Iterable\n 222: astore 5\n 224: iconst_0\n 225: istore 6\n 227: aload 5\n 229: astore 7\n 231: new #75 // class java/util/ArrayList\n 234: dup\n 235: invokespecial #76 // Method java/util/ArrayList.\"<init>\":()V\n 238: checkcast #78 // class java/util/Collection\n 241: astore 8\n 243: iconst_0\n 244: istore 9\n 246: aload 7\n 248: invokeinterface #82, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 253: astore 10\n 255: aload 10\n 257: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 262: ifeq 309\n 265: aload 10\n 267: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 272: astore 11\n 274: aload 11\n 276: checkcast #94 // class java/lang/Number\n 279: invokevirtual #98 // Method java/lang/Number.intValue:()I\n 282: istore 12\n 284: iconst_0\n 285: istore 13\n 287: iload 12\n 289: iconst_0\n 290: invokestatic #102 // Method isValidPassword:(IZ)Z\n 293: ifeq 255\n 296: aload 8\n 298: aload 11\n 300: invokeinterface #106, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 305: pop\n 306: goto 255\n 309: aload 8\n 311: checkcast #108 // class java/util/List\n 314: nop\n 315: astore 4\n 317: new #41 // class java/lang/StringBuilder\n 320: dup\n 321: invokespecial #45 // Method java/lang/StringBuilder.\"<init>\":()V\n 324: ldc #115 // String [Part 2] Number of valid passwords:\n 326: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 329: aload 4\n 331: invokeinterface #113, 1 // InterfaceMethod java/util/List.size:()I\n 336: invokevirtual #54 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 339: invokevirtual #60 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 342: getstatic #63 // Field java/lang/System.out:Ljava/io/PrintStream;\n 345: swap\n 346: invokevirtual #66 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 349: return\n\n public static final java.util.List<java.lang.Integer> iterateDigits(int);\n Code:\n 0: new #140 // class kotlin/jvm/internal/Ref$IntRef\n 3: dup\n 4: invokespecial #141 // Method kotlin/jvm/internal/Ref$IntRef.\"<init>\":()V\n 7: astore_1\n 8: aload_1\n 9: iload_0\n 10: putfield #144 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 13: aload_1\n 14: invokedynamic #163, 0 // InvokeDynamic #0:invoke:(Lkotlin/jvm/internal/Ref$IntRef;)Lkotlin/jvm/functions/Function0;\n 19: invokestatic #169 // Method kotlin/sequences/SequencesKt.generateSequence:(Lkotlin/jvm/functions/Function0;)Lkotlin/sequences/Sequence;\n 22: invokestatic #173 // Method kotlin/sequences/SequencesKt.toList:(Lkotlin/sequences/Sequence;)Ljava/util/List;\n 25: checkcast #73 // class java/lang/Iterable\n 28: invokestatic #179 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 31: areturn\n\n public static final boolean isValidPassword(int, boolean);\n Code:\n 0: iconst_m1\n 1: istore_2\n 2: iconst_0\n 3: istore_3\n 4: iconst_0\n 5: istore 4\n 7: iload_0\n 8: invokestatic #184 // Method iterateDigits:(I)Ljava/util/List;\n 11: invokeinterface #185, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 16: astore 5\n 18: aload 5\n 20: invokeinterface #88, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 25: ifeq 96\n 28: aload 5\n 30: invokeinterface #92, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 35: checkcast #94 // class java/lang/Number\n 38: invokevirtual #98 // Method java/lang/Number.intValue:()I\n 41: istore 6\n 43: iload_2\n 44: iflt 87\n 47: iload_2\n 48: iload 6\n 50: if_icmple 55\n 53: iconst_0\n 54: ireturn\n 55: iload_1\n 56: ifeq 71\n 59: iload_2\n 60: iload 6\n 62: if_icmpne 87\n 65: iconst_1\n 66: istore 4\n 68: goto 87\n 71: iload_2\n 72: iload 6\n 74: if_icmpeq 87\n 77: iload_3\n 78: iconst_2\n 79: if_icmpne 85\n 82: iconst_1\n 83: istore 4\n 85: iconst_0\n 86: istore_3\n 87: iinc 3, 1\n 90: iload 6\n 92: istore_2\n 93: goto 18\n 96: iload 4\n 98: ifne 106\n 101: iload_3\n 102: iconst_2\n 103: if_icmpne 110\n 106: iconst_1\n 107: goto 111\n 110: iconst_0\n 111: ireturn\n\n private static final java.lang.Integer iterateDigits$lambda$2(kotlin.jvm.internal.Ref$IntRef);\n Code:\n 0: aload_0\n 1: getfield #144 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 4: ifne 11\n 7: aconst_null\n 8: goto 34\n 11: aload_0\n 12: getfield #144 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 15: bipush 10\n 17: irem\n 18: istore_1\n 19: aload_0\n 20: aload_0\n 21: getfield #144 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 24: bipush 10\n 26: idiv\n 27: putfield #144 // Field kotlin/jvm/internal/Ref$IntRef.element:I\n 30: iload_1\n 31: invokestatic #196 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 34: areturn\n}\n",
"javap_err": ""
}
] |
analogrelay__advent-of-code__006343d/2019/src/main/kotlin/adventofcode/day03/main.kt
|
package adventofcode.day03
import java.io.File
data class Point(val x: Int, val y: Int) {
public fun moveLeft(distance: Int)= Point(x - distance, y)
public fun moveRight(distance: Int)= Point(x + distance, y)
public fun moveUp(distance: Int)= Point(x, y + distance)
public fun moveDown(distance: Int)= Point(x, y - distance)
public fun iterateLeft(distance: Int) = (1..distance).map { Point(x - it, y) }
public fun iterateRight(distance: Int) = (1..distance).map { Point(x + it, y) }
public fun iterateUp(distance: Int) = (1..distance).map { Point(x, y + it) }
public fun iterateDown(distance: Int) = (1..distance).map { Point(x, y - it) }
public fun manhattenDistance(p2: Point): Int =
Math.abs(x - p2.x) + Math.abs(y - p2.y)
}
data class Line(val start: Point, val end: Point) {
public fun hasPoint(p: Point): Boolean {
val minX = Math.min(start.x, end.x)
val maxX = Math.max(start.x, end.x)
val minY = Math.min(start.y, end.y)
val maxY = Math.max(start.y, end.y)
return p.x >= minX && p.x <= maxX && p.y >= minY && p.y <= maxY
}
public fun intersects(other: Line): Point? {
// Generate the intersection
val intersection = if (end.y == start.y) {
Point(other.start.x, start.y)
} else {
Point(start.x, other.start.y)
}
// Check if the intersection is on both lines
if (other.hasPoint(intersection) && hasPoint(intersection)) {
return intersection
} else {
return null
}
}
}
fun main(args: Array<String>) {
val inputFile = if (args.size < 1) {
System.err.println("Usage: adventofcode day03 <INPUT FILE>")
System.exit(1)
throw Exception("Whoop")
} else {
args[0]
}
val wires = File(inputFile).readLines().map(::parseItem)
// println("[Part 1] Wire #1 ${wires[0]}")
// println("[Part 1] Wire #2 ${wires[1]}")
val intersections = (wires[0] intersect wires[1]).filterNot { it.x == 0 && it.y == 0 }
val best = intersections.minBy {
println("[Part 1] Intersection at $it")
it.manhattenDistance(Point(0, 0))
}
if (best == null) {
println("[Part 1] No intersection found.")
} else {
val distance = best.manhattenDistance(Point(0, 0))
println("[Part 1] Closest intersection is $best (distance: $distance)")
}
// Now compute the best intersection by distance along the line
val bestBySteps = intersections.map {
// Add two to include the end points
Pair(it, wires[0].indexOf(it) + wires[1].indexOf(it) + 2)
}.minBy { it.second }
if (bestBySteps == null) {
println("[Part 2] No intersection found.")
} else {
println("[Part 2] Closest intersection is ${bestBySteps.first} (distance: ${bestBySteps.second})")
}
}
fun parseItem(line: String): List<Point> {
var prev = Point(0, 0)
return line.split(",").flatMap {
val start = prev
val distance = it.substring(1).toInt()
when (it[0]) {
'L' -> {
prev = start.moveLeft(distance)
start.iterateLeft(distance)
}
'R' -> {
prev = start.moveRight(distance)
start.iterateRight(distance)
}
'D' -> {
prev = start.moveDown(distance)
start.iterateDown(distance)
}
'U' -> {
prev = start.moveUp(distance)
start.iterateUp(distance)
}
else -> throw Exception("Invalid direction: ${it[0]}")
}
}
}
|
[
{
"class_path": "analogrelay__advent-of-code__006343d/adventofcode/day03/MainKt.class",
"javap": "Compiled from \"main.kt\"\npublic final class adventofcode.day03.MainKt {\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String args\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: arraylength\n 8: iconst_1\n 9: if_icmpge 34\n 12: getstatic #21 // Field java/lang/System.err:Ljava/io/PrintStream;\n 15: ldc #23 // String Usage: adventofcode day03 <INPUT FILE>\n 17: invokevirtual #29 // Method java/io/PrintStream.println:(Ljava/lang/String;)V\n 20: iconst_1\n 21: invokestatic #33 // Method java/lang/System.exit:(I)V\n 24: new #35 // class java/lang/Exception\n 27: dup\n 28: ldc #37 // String Whoop\n 30: invokespecial #40 // Method java/lang/Exception.\"<init>\":(Ljava/lang/String;)V\n 33: athrow\n 34: aload_0\n 35: iconst_0\n 36: aaload\n 37: astore_1\n 38: new #42 // class java/io/File\n 41: dup\n 42: aload_1\n 43: invokespecial #43 // Method java/io/File.\"<init>\":(Ljava/lang/String;)V\n 46: aconst_null\n 47: iconst_1\n 48: aconst_null\n 49: invokestatic #49 // Method kotlin/io/FilesKt.readLines$default:(Ljava/io/File;Ljava/nio/charset/Charset;ILjava/lang/Object;)Ljava/util/List;\n 52: checkcast #51 // class java/lang/Iterable\n 55: astore_3\n 56: iconst_0\n 57: istore 4\n 59: aload_3\n 60: astore 5\n 62: new #53 // class java/util/ArrayList\n 65: dup\n 66: aload_3\n 67: bipush 10\n 69: invokestatic #59 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 72: invokespecial #61 // Method java/util/ArrayList.\"<init>\":(I)V\n 75: checkcast #63 // class java/util/Collection\n 78: astore 6\n 80: iconst_0\n 81: istore 7\n 83: aload 5\n 85: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 90: astore 8\n 92: aload 8\n 94: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 99: ifeq 142\n 102: aload 8\n 104: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 109: astore 9\n 111: aload 6\n 113: aload 9\n 115: checkcast #79 // class java/lang/String\n 118: astore 10\n 120: astore 15\n 122: iconst_0\n 123: istore 11\n 125: aload 10\n 127: invokestatic #83 // Method parseItem:(Ljava/lang/String;)Ljava/util/List;\n 130: aload 15\n 132: swap\n 133: invokeinterface #87, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 138: pop\n 139: goto 92\n 142: aload 6\n 144: checkcast #89 // class java/util/List\n 147: nop\n 148: astore_2\n 149: aload_2\n 150: iconst_0\n 151: invokeinterface #93, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 156: checkcast #51 // class java/lang/Iterable\n 159: aload_2\n 160: iconst_1\n 161: invokeinterface #93, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 166: checkcast #51 // class java/lang/Iterable\n 169: invokestatic #97 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 172: checkcast #51 // class java/lang/Iterable\n 175: astore 4\n 177: iconst_0\n 178: istore 5\n 180: aload 4\n 182: astore 6\n 184: new #53 // class java/util/ArrayList\n 187: dup\n 188: invokespecial #100 // Method java/util/ArrayList.\"<init>\":()V\n 191: checkcast #63 // class java/util/Collection\n 194: astore 7\n 196: iconst_0\n 197: istore 8\n 199: aload 6\n 201: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 206: astore 9\n 208: aload 9\n 210: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 215: ifeq 274\n 218: aload 9\n 220: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 225: astore 10\n 227: aload 10\n 229: checkcast #102 // class adventofcode/day03/Point\n 232: astore 11\n 234: iconst_0\n 235: istore 12\n 237: aload 11\n 239: invokevirtual #106 // Method adventofcode/day03/Point.getX:()I\n 242: ifne 257\n 245: aload 11\n 247: invokevirtual #109 // Method adventofcode/day03/Point.getY:()I\n 250: ifne 257\n 253: iconst_1\n 254: goto 258\n 257: iconst_0\n 258: ifne 208\n 261: aload 7\n 263: aload 10\n 265: invokeinterface #87, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 270: pop\n 271: goto 208\n 274: aload 7\n 276: checkcast #89 // class java/util/List\n 279: nop\n 280: astore_3\n 281: aload_3\n 282: checkcast #51 // class java/lang/Iterable\n 285: astore 5\n 287: iconst_0\n 288: istore 6\n 290: aload 5\n 292: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 297: astore 7\n 299: aload 7\n 301: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 306: ifne 317\n 309: new #111 // class java/util/NoSuchElementException\n 312: dup\n 313: invokespecial #112 // Method java/util/NoSuchElementException.\"<init>\":()V\n 316: athrow\n 317: aload 7\n 319: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 324: astore 8\n 326: aload 7\n 328: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 333: ifne 341\n 336: aload 8\n 338: goto 483\n 341: aload 8\n 343: checkcast #102 // class adventofcode/day03/Point\n 346: astore 9\n 348: iconst_0\n 349: istore 10\n 351: new #114 // class java/lang/StringBuilder\n 354: dup\n 355: invokespecial #115 // Method java/lang/StringBuilder.\"<init>\":()V\n 358: ldc #117 // String [Part 1] Intersection at\n 360: invokevirtual #121 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 363: aload 9\n 365: invokevirtual #124 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 368: invokevirtual #128 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 371: getstatic #131 // Field java/lang/System.out:Ljava/io/PrintStream;\n 374: swap\n 375: invokevirtual #134 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 378: aload 9\n 380: new #102 // class adventofcode/day03/Point\n 383: dup\n 384: iconst_0\n 385: iconst_0\n 386: invokespecial #137 // Method adventofcode/day03/Point.\"<init>\":(II)V\n 389: invokevirtual #141 // Method adventofcode/day03/Point.manhattenDistance:(Ladventofcode/day03/Point;)I\n 392: istore 9\n 394: aload 7\n 396: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 401: astore 10\n 403: aload 10\n 405: checkcast #102 // class adventofcode/day03/Point\n 408: astore 11\n 410: iconst_0\n 411: istore 12\n 413: new #114 // class java/lang/StringBuilder\n 416: dup\n 417: invokespecial #115 // Method java/lang/StringBuilder.\"<init>\":()V\n 420: ldc #117 // String [Part 1] Intersection at\n 422: invokevirtual #121 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 425: aload 11\n 427: invokevirtual #124 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 430: invokevirtual #128 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 433: getstatic #131 // Field java/lang/System.out:Ljava/io/PrintStream;\n 436: swap\n 437: invokevirtual #134 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 440: aload 11\n 442: new #102 // class adventofcode/day03/Point\n 445: dup\n 446: iconst_0\n 447: iconst_0\n 448: invokespecial #137 // Method adventofcode/day03/Point.\"<init>\":(II)V\n 451: invokevirtual #141 // Method adventofcode/day03/Point.manhattenDistance:(Ladventofcode/day03/Point;)I\n 454: istore 11\n 456: iload 9\n 458: iload 11\n 460: if_icmple 471\n 463: aload 10\n 465: astore 8\n 467: iload 11\n 469: istore 9\n 471: aload 7\n 473: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 478: ifne 394\n 481: aload 8\n 483: checkcast #102 // class adventofcode/day03/Point\n 486: astore 4\n 488: aload 4\n 490: ifnonnull 505\n 493: ldc #143 // String [Part 1] No intersection found.\n 495: getstatic #131 // Field java/lang/System.out:Ljava/io/PrintStream;\n 498: swap\n 499: invokevirtual #134 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 502: goto 563\n 505: aload 4\n 507: new #102 // class adventofcode/day03/Point\n 510: dup\n 511: iconst_0\n 512: iconst_0\n 513: invokespecial #137 // Method adventofcode/day03/Point.\"<init>\":(II)V\n 516: invokevirtual #141 // Method adventofcode/day03/Point.manhattenDistance:(Ladventofcode/day03/Point;)I\n 519: istore 5\n 521: new #114 // class java/lang/StringBuilder\n 524: dup\n 525: invokespecial #115 // Method java/lang/StringBuilder.\"<init>\":()V\n 528: ldc #145 // String [Part 1] Closest intersection is\n 530: invokevirtual #121 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 533: aload 4\n 535: invokevirtual #124 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 538: ldc #147 // String (distance:\n 540: invokevirtual #121 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 543: iload 5\n 545: invokevirtual #150 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 548: bipush 41\n 550: invokevirtual #153 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 553: invokevirtual #128 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 556: getstatic #131 // Field java/lang/System.out:Ljava/io/PrintStream;\n 559: swap\n 560: invokevirtual #134 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 563: aload_3\n 564: checkcast #51 // class java/lang/Iterable\n 567: astore 6\n 569: iconst_0\n 570: istore 7\n 572: aload 6\n 574: astore 8\n 576: new #53 // class java/util/ArrayList\n 579: dup\n 580: aload 6\n 582: bipush 10\n 584: invokestatic #59 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 587: invokespecial #61 // Method java/util/ArrayList.\"<init>\":(I)V\n 590: checkcast #63 // class java/util/Collection\n 593: astore 9\n 595: iconst_0\n 596: istore 10\n 598: aload 8\n 600: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 605: astore 11\n 607: aload 11\n 609: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 614: ifeq 701\n 617: aload 11\n 619: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 624: astore 12\n 626: aload 9\n 628: aload 12\n 630: checkcast #102 // class adventofcode/day03/Point\n 633: astore 13\n 635: astore 15\n 637: iconst_0\n 638: istore 14\n 640: new #155 // class kotlin/Pair\n 643: dup\n 644: aload 13\n 646: aload_2\n 647: iconst_0\n 648: invokeinterface #93, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 653: checkcast #89 // class java/util/List\n 656: aload 13\n 658: invokeinterface #159, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 663: aload_2\n 664: iconst_1\n 665: invokeinterface #93, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 670: checkcast #89 // class java/util/List\n 673: aload 13\n 675: invokeinterface #159, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 680: iadd\n 681: iconst_2\n 682: iadd\n 683: invokestatic #165 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 686: invokespecial #168 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 689: aload 15\n 691: swap\n 692: invokeinterface #87, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 697: pop\n 698: goto 607\n 701: aload 9\n 703: checkcast #89 // class java/util/List\n 706: nop\n 707: checkcast #51 // class java/lang/Iterable\n 710: astore 6\n 712: nop\n 713: iconst_0\n 714: istore 7\n 716: aload 6\n 718: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 723: astore 8\n 725: aload 8\n 727: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 732: ifne 743\n 735: new #111 // class java/util/NoSuchElementException\n 738: dup\n 739: invokespecial #112 // Method java/util/NoSuchElementException.\"<init>\":()V\n 742: athrow\n 743: aload 8\n 745: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 750: astore 9\n 752: aload 8\n 754: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 759: ifne 767\n 762: aload 9\n 764: goto 849\n 767: aload 9\n 769: checkcast #155 // class kotlin/Pair\n 772: astore 10\n 774: iconst_0\n 775: istore 11\n 777: aload 10\n 779: invokevirtual #171 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 782: checkcast #173 // class java/lang/Number\n 785: invokevirtual #176 // Method java/lang/Number.intValue:()I\n 788: istore 10\n 790: aload 8\n 792: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 797: astore 11\n 799: aload 11\n 801: checkcast #155 // class kotlin/Pair\n 804: astore 12\n 806: iconst_0\n 807: istore 13\n 809: aload 12\n 811: invokevirtual #171 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 814: checkcast #173 // class java/lang/Number\n 817: invokevirtual #176 // Method java/lang/Number.intValue:()I\n 820: istore 12\n 822: iload 10\n 824: iload 12\n 826: if_icmple 837\n 829: aload 11\n 831: astore 9\n 833: iload 12\n 835: istore 10\n 837: aload 8\n 839: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 844: ifne 790\n 847: aload 9\n 849: checkcast #155 // class kotlin/Pair\n 852: astore 5\n 854: aload 5\n 856: ifnonnull 871\n 859: ldc #178 // String [Part 2] No intersection found.\n 861: getstatic #131 // Field java/lang/System.out:Ljava/io/PrintStream;\n 864: swap\n 865: invokevirtual #134 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 868: goto 925\n 871: new #114 // class java/lang/StringBuilder\n 874: dup\n 875: invokespecial #115 // Method java/lang/StringBuilder.\"<init>\":()V\n 878: ldc #180 // String [Part 2] Closest intersection is\n 880: invokevirtual #121 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 883: aload 5\n 885: invokevirtual #183 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 888: invokevirtual #124 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 891: ldc #147 // String (distance:\n 893: invokevirtual #121 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 896: aload 5\n 898: invokevirtual #171 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 901: checkcast #173 // class java/lang/Number\n 904: invokevirtual #176 // Method java/lang/Number.intValue:()I\n 907: invokevirtual #150 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 910: bipush 41\n 912: invokevirtual #153 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 915: invokevirtual #128 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 918: getstatic #131 // Field java/lang/System.out:Ljava/io/PrintStream;\n 921: swap\n 922: invokevirtual #134 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 925: return\n\n public static final java.util.List<adventofcode.day03.Point> parseItem(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #228 // String line\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aconst_null\n 7: astore_1\n 8: new #102 // class adventofcode/day03/Point\n 11: dup\n 12: iconst_0\n 13: iconst_0\n 14: invokespecial #137 // Method adventofcode/day03/Point.\"<init>\":(II)V\n 17: astore_1\n 18: aload_0\n 19: checkcast #230 // class java/lang/CharSequence\n 22: iconst_1\n 23: anewarray #79 // class java/lang/String\n 26: astore_2\n 27: aload_2\n 28: iconst_0\n 29: ldc #232 // String ,\n 31: aastore\n 32: aload_2\n 33: iconst_0\n 34: iconst_0\n 35: bipush 6\n 37: aconst_null\n 38: invokestatic #238 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 41: checkcast #51 // class java/lang/Iterable\n 44: astore_2\n 45: iconst_0\n 46: istore_3\n 47: aload_2\n 48: astore 4\n 50: new #53 // class java/util/ArrayList\n 53: dup\n 54: invokespecial #100 // Method java/util/ArrayList.\"<init>\":()V\n 57: checkcast #63 // class java/util/Collection\n 60: astore 5\n 62: iconst_0\n 63: istore 6\n 65: aload 4\n 67: invokeinterface #67, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 72: astore 7\n 74: aload 7\n 76: invokeinterface #73, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 81: ifeq 294\n 84: aload 7\n 86: invokeinterface #77, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 91: astore 8\n 93: aload 8\n 95: checkcast #79 // class java/lang/String\n 98: astore 9\n 100: iconst_0\n 101: istore 10\n 103: aload_1\n 104: astore 11\n 106: nop\n 107: aload 9\n 109: iconst_1\n 110: invokevirtual #242 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 113: dup\n 114: ldc #244 // String substring(...)\n 116: invokestatic #247 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 119: invokestatic #251 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 122: istore 12\n 124: aload 9\n 126: iconst_0\n 127: invokevirtual #255 // Method java/lang/String.charAt:(I)C\n 130: lookupswitch { // 4\n 68: 208\n 76: 172\n 82: 190\n 85: 226\n default: 244\n }\n 172: aload 11\n 174: iload 12\n 176: invokevirtual #259 // Method adventofcode/day03/Point.moveLeft:(I)Ladventofcode/day03/Point;\n 179: astore_1\n 180: aload 11\n 182: iload 12\n 184: invokevirtual #263 // Method adventofcode/day03/Point.iterateLeft:(I)Ljava/util/List;\n 187: goto 277\n 190: aload 11\n 192: iload 12\n 194: invokevirtual #266 // Method adventofcode/day03/Point.moveRight:(I)Ladventofcode/day03/Point;\n 197: astore_1\n 198: aload 11\n 200: iload 12\n 202: invokevirtual #269 // Method adventofcode/day03/Point.iterateRight:(I)Ljava/util/List;\n 205: goto 277\n 208: aload 11\n 210: iload 12\n 212: invokevirtual #272 // Method adventofcode/day03/Point.moveDown:(I)Ladventofcode/day03/Point;\n 215: astore_1\n 216: aload 11\n 218: iload 12\n 220: invokevirtual #275 // Method adventofcode/day03/Point.iterateDown:(I)Ljava/util/List;\n 223: goto 277\n 226: aload 11\n 228: iload 12\n 230: invokevirtual #278 // Method adventofcode/day03/Point.moveUp:(I)Ladventofcode/day03/Point;\n 233: astore_1\n 234: aload 11\n 236: iload 12\n 238: invokevirtual #281 // Method adventofcode/day03/Point.iterateUp:(I)Ljava/util/List;\n 241: goto 277\n 244: new #35 // class java/lang/Exception\n 247: dup\n 248: new #114 // class java/lang/StringBuilder\n 251: dup\n 252: invokespecial #115 // Method java/lang/StringBuilder.\"<init>\":()V\n 255: ldc_w #283 // String Invalid direction:\n 258: invokevirtual #121 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 261: aload 9\n 263: iconst_0\n 264: invokevirtual #255 // Method java/lang/String.charAt:(I)C\n 267: invokevirtual #153 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 270: invokevirtual #128 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 273: invokespecial #40 // Method java/lang/Exception.\"<init>\":(Ljava/lang/String;)V\n 276: athrow\n 277: checkcast #51 // class java/lang/Iterable\n 280: nop\n 281: astore 9\n 283: aload 5\n 285: aload 9\n 287: invokestatic #287 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 290: pop\n 291: goto 74\n 294: aload 5\n 296: checkcast #89 // class java/util/List\n 299: nop\n 300: areturn\n}\n",
"javap_err": ""
}
] |
dwbullok__kool__5121acb/common/src/main/kotlin/com/codeviking/kxg/math/Partition.kt
|
package com.codeviking.kxg.math
import kotlin.math.*
/**
* Partitions items with the given comparator. After partitioning, all elements left of k are smaller
* than all elements right of k with respect to the given comparator function.
*
* This method implements the Floyd-Rivest selection algorithm:
* https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm
*/
fun <T> MutableList<T>.partition(k: Int, cmp: (T, T) -> Int) = partition(indices, k, cmp)
fun <T> MutableList<T>.partition(rng: IntRange, k: Int, cmp: (T, T) -> Int) {
var left = rng.first
var right = rng.last
while (right > left) {
if (right - left > 600) {
val n = right - left + 1
val i = k - left + 1
val z = ln(n.toDouble())
val s = 0.5 * exp(2.0 * z / 3.0)
val sd = 0.5 * sqrt(z * s * (n - s) / n) * sign(i - n / 2.0)
val newLeft = max(left, (k - i * s / n + sd).toInt())
val newRight = min(right, (k + (n - i) * s / n + sd).toInt())
partition(newLeft..newRight, k, cmp)
}
val t = get(k)
var i = left
var j = right
swap(left, k)
if (cmp(get(right), t) > 0) {
swap(right, left)
}
while (i < j) {
swap( i, j)
i++
j--
while (cmp(get(i), t) < 0) {
i++
}
while (cmp(get(j), t) > 0) {
j--
}
}
if (cmp(get(left), t) == 0) {
swap(left, j)
} else {
j++
swap(j, right)
}
if (j <= k) {
left = j + 1
}
if (k <= j) {
right = j - 1
}
}
}
private fun <T> MutableList<T>.swap(a: Int, b: Int) {
this[a] = this[b].also { this[b] = this[a] }
}
|
[
{
"class_path": "dwbullok__kool__5121acb/com/codeviking/kxg/math/PartitionKt.class",
"javap": "Compiled from \"Partition.kt\"\npublic final class com.codeviking.kxg.math.PartitionKt {\n public static final <T> void partition(java.util.List<T>, int, kotlin.jvm.functions.Function2<? super T, ? super T, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #10 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #18 // String cmp\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: aload_0\n 14: checkcast #20 // class java/util/Collection\n 17: invokestatic #26 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 20: iload_1\n 21: aload_2\n 22: invokestatic #29 // Method partition:(Ljava/util/List;Lkotlin/ranges/IntRange;ILkotlin/jvm/functions/Function2;)V\n 25: return\n\n public static final <T> void partition(java.util.List<T>, kotlin.ranges.IntRange, int, kotlin.jvm.functions.Function2<? super T, ? super T, java.lang.Integer>);\n Code:\n 0: aload_0\n 1: ldc #10 // String <this>\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #37 // String rng\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_3\n 13: ldc #18 // String cmp\n 15: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_1\n 19: invokevirtual #43 // Method kotlin/ranges/IntRange.getFirst:()I\n 22: istore 4\n 24: aload_1\n 25: invokevirtual #46 // Method kotlin/ranges/IntRange.getLast:()I\n 28: istore 5\n 30: iload 5\n 32: iload 4\n 34: if_icmple 414\n 37: iload 5\n 39: iload 4\n 41: isub\n 42: sipush 600\n 45: if_icmple 200\n 48: iload 5\n 50: iload 4\n 52: isub\n 53: iconst_1\n 54: iadd\n 55: istore 6\n 57: iload_2\n 58: iload 4\n 60: isub\n 61: iconst_1\n 62: iadd\n 63: istore 7\n 65: iload 6\n 67: i2d\n 68: invokestatic #52 // Method java/lang/Math.log:(D)D\n 71: dstore 8\n 73: ldc2_w #53 // double 0.5d\n 76: ldc2_w #55 // double 2.0d\n 79: dload 8\n 81: dmul\n 82: ldc2_w #57 // double 3.0d\n 85: ddiv\n 86: invokestatic #61 // Method java/lang/Math.exp:(D)D\n 89: dmul\n 90: dstore 10\n 92: ldc2_w #53 // double 0.5d\n 95: dload 8\n 97: dload 10\n 99: dmul\n 100: iload 6\n 102: i2d\n 103: dload 10\n 105: dsub\n 106: dmul\n 107: iload 6\n 109: i2d\n 110: ddiv\n 111: invokestatic #64 // Method java/lang/Math.sqrt:(D)D\n 114: dmul\n 115: iload 7\n 117: i2d\n 118: iload 6\n 120: i2d\n 121: ldc2_w #55 // double 2.0d\n 124: ddiv\n 125: dsub\n 126: invokestatic #67 // Method java/lang/Math.signum:(D)D\n 129: dmul\n 130: dstore 12\n 132: iload 4\n 134: iload_2\n 135: i2d\n 136: iload 7\n 138: i2d\n 139: dload 10\n 141: dmul\n 142: iload 6\n 144: i2d\n 145: ddiv\n 146: dsub\n 147: dload 12\n 149: dadd\n 150: d2i\n 151: invokestatic #71 // Method java/lang/Math.max:(II)I\n 154: istore 14\n 156: iload 5\n 158: iload_2\n 159: i2d\n 160: iload 6\n 162: iload 7\n 164: isub\n 165: i2d\n 166: dload 10\n 168: dmul\n 169: iload 6\n 171: i2d\n 172: ddiv\n 173: dadd\n 174: dload 12\n 176: dadd\n 177: d2i\n 178: invokestatic #74 // Method java/lang/Math.min:(II)I\n 181: istore 15\n 183: aload_0\n 184: new #39 // class kotlin/ranges/IntRange\n 187: dup\n 188: iload 14\n 190: iload 15\n 192: invokespecial #78 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 195: iload_2\n 196: aload_3\n 197: invokestatic #29 // Method partition:(Ljava/util/List;Lkotlin/ranges/IntRange;ILkotlin/jvm/functions/Function2;)V\n 200: aload_0\n 201: iload_2\n 202: invokeinterface #84, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 207: astore 6\n 209: iload 4\n 211: istore 7\n 213: iload 5\n 215: istore 8\n 217: aload_0\n 218: iload 4\n 220: iload_2\n 221: invokestatic #88 // Method swap:(Ljava/util/List;II)V\n 224: aload_3\n 225: aload_0\n 226: iload 5\n 228: invokeinterface #84, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 233: aload 6\n 235: invokeinterface #94, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 240: checkcast #96 // class java/lang/Number\n 243: invokevirtual #99 // Method java/lang/Number.intValue:()I\n 246: ifle 257\n 249: aload_0\n 250: iload 5\n 252: iload 4\n 254: invokestatic #88 // Method swap:(Ljava/util/List;II)V\n 257: iload 7\n 259: iload 8\n 261: if_icmpge 340\n 264: aload_0\n 265: iload 7\n 267: iload 8\n 269: invokestatic #88 // Method swap:(Ljava/util/List;II)V\n 272: iinc 7, 1\n 275: iinc 8, -1\n 278: aload_3\n 279: aload_0\n 280: iload 7\n 282: invokeinterface #84, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 287: aload 6\n 289: invokeinterface #94, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 294: checkcast #96 // class java/lang/Number\n 297: invokevirtual #99 // Method java/lang/Number.intValue:()I\n 300: ifge 309\n 303: iinc 7, 1\n 306: goto 278\n 309: aload_3\n 310: aload_0\n 311: iload 8\n 313: invokeinterface #84, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 318: aload 6\n 320: invokeinterface #94, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 325: checkcast #96 // class java/lang/Number\n 328: invokevirtual #99 // Method java/lang/Number.intValue:()I\n 331: ifle 257\n 334: iinc 8, -1\n 337: goto 309\n 340: aload_3\n 341: aload_0\n 342: iload 4\n 344: invokeinterface #84, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 349: aload 6\n 351: invokeinterface #94, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 356: checkcast #96 // class java/lang/Number\n 359: invokevirtual #99 // Method java/lang/Number.intValue:()I\n 362: ifne 376\n 365: aload_0\n 366: iload 4\n 368: iload 8\n 370: invokestatic #88 // Method swap:(Ljava/util/List;II)V\n 373: goto 387\n 376: iinc 8, 1\n 379: aload_0\n 380: iload 8\n 382: iload 5\n 384: invokestatic #88 // Method swap:(Ljava/util/List;II)V\n 387: iload 8\n 389: iload_2\n 390: if_icmpgt 399\n 393: iload 8\n 395: iconst_1\n 396: iadd\n 397: istore 4\n 399: iload_2\n 400: iload 8\n 402: if_icmpgt 30\n 405: iload 8\n 407: iconst_1\n 408: isub\n 409: istore 5\n 411: goto 30\n 414: return\n\n private static final <T> void swap(java.util.List<T>, int, int);\n Code:\n 0: aload_0\n 1: iload_1\n 2: aload_0\n 3: iload_2\n 4: invokeinterface #84, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 9: astore_3\n 10: aload_3\n 11: astore 4\n 13: istore 7\n 15: astore 6\n 17: iconst_0\n 18: istore 5\n 20: aload_0\n 21: iload_2\n 22: aload_0\n 23: iload_1\n 24: invokeinterface #84, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 29: invokeinterface #118, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 34: pop\n 35: getstatic #124 // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;\n 38: astore 8\n 40: aload 6\n 42: iload 7\n 44: aload_3\n 45: invokeinterface #118, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 50: pop\n 51: return\n}\n",
"javap_err": ""
}
] |
borisskert__kotlin-katas__0659b33/src/main/kotlin/helpthebookseller/StockList.kt
|
package solution
/**
* https://www.codewars.com/kata/54dc6f5a224c26032800005c/train/kotlin
*/
object StockList {
fun stockSummary(lstOfArt: Array<String>, lstOfCat: Array<String>): String {
if (lstOfArt.isEmpty()) {
return ""
}
val stock = lstOfArt
.map(::readOne)
.groupBy { it.category }
.map { (key, value) ->
StockItem(key, value.sumOf { it.quantity })
}
.associateBy { it.category }
return lstOfCat
.map {
stock[it] ?: StockItem(it, 0)
}
.joinToString(" - ") {
"(${it.category} : ${it.quantity})"
}
}
}
data class StockItem(val category: String, val quantity: Int) {
}
val stockItemPattern = """([A-Z][A-Z0-9]+) ([0-9]+)""".toRegex()
fun readOne(input: String): StockItem {
val match = stockItemPattern.matchEntire(input)
val groups = match!!.groups
val category = groups[1]!!.value
val quantity = groups[2]!!.value
return StockItem(category.take(1), quantity.toInt())
}
|
[
{
"class_path": "borisskert__kotlin-katas__0659b33/solution/StockList.class",
"javap": "Compiled from \"StockList.kt\"\npublic final class solution.StockList {\n public static final solution.StockList INSTANCE;\n\n private solution.StockList();\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 stockSummary(java.lang.String[], java.lang.String[]);\n Code:\n 0: aload_1\n 1: ldc #15 // String lstOfArt\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 lstOfCat\n 9: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: arraylength\n 14: ifne 21\n 17: iconst_1\n 18: goto 22\n 21: iconst_0\n 22: ifeq 28\n 25: ldc #25 // String\n 27: areturn\n 28: aload_1\n 29: astore 4\n 31: nop\n 32: iconst_0\n 33: istore 5\n 35: aload 4\n 37: astore 6\n 39: new #27 // class java/util/ArrayList\n 42: dup\n 43: aload 4\n 45: arraylength\n 46: invokespecial #30 // Method java/util/ArrayList.\"<init>\":(I)V\n 49: checkcast #32 // class java/util/Collection\n 52: astore 7\n 54: iconst_0\n 55: istore 8\n 57: iconst_0\n 58: istore 9\n 60: aload 6\n 62: arraylength\n 63: istore 10\n 65: iload 9\n 67: iload 10\n 69: if_icmpge 110\n 72: aload 6\n 74: iload 9\n 76: aaload\n 77: astore 11\n 79: aload 7\n 81: aload 11\n 83: astore 12\n 85: astore 25\n 87: iconst_0\n 88: istore 13\n 90: aload 12\n 92: invokestatic #38 // Method solution/StockListKt.readOne:(Ljava/lang/String;)Lsolution/StockItem;\n 95: aload 25\n 97: swap\n 98: invokeinterface #42, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 103: pop\n 104: iinc 9, 1\n 107: goto 65\n 110: aload 7\n 112: checkcast #44 // class java/util/List\n 115: nop\n 116: checkcast #46 // class java/lang/Iterable\n 119: astore 4\n 121: nop\n 122: iconst_0\n 123: istore 5\n 125: aload 4\n 127: astore 6\n 129: new #48 // class java/util/LinkedHashMap\n 132: dup\n 133: invokespecial #49 // Method java/util/LinkedHashMap.\"<init>\":()V\n 136: checkcast #51 // class java/util/Map\n 139: astore 7\n 141: iconst_0\n 142: istore 8\n 144: aload 6\n 146: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 151: astore 9\n 153: aload 9\n 155: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 160: ifeq 265\n 163: aload 9\n 165: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 170: astore 10\n 172: aload 10\n 174: checkcast #67 // class solution/StockItem\n 177: astore 11\n 179: iconst_0\n 180: istore 12\n 182: aload 11\n 184: invokevirtual #71 // Method solution/StockItem.getCategory:()Ljava/lang/String;\n 187: astore 13\n 189: aload 7\n 191: astore 14\n 193: iconst_0\n 194: istore 15\n 196: aload 14\n 198: aload 13\n 200: invokeinterface #75, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 205: astore 16\n 207: aload 16\n 209: ifnonnull 244\n 212: iconst_0\n 213: istore 17\n 215: new #27 // class java/util/ArrayList\n 218: dup\n 219: invokespecial #76 // Method java/util/ArrayList.\"<init>\":()V\n 222: checkcast #44 // class java/util/List\n 225: astore 17\n 227: aload 14\n 229: aload 13\n 231: aload 17\n 233: invokeinterface #80, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 238: pop\n 239: aload 17\n 241: goto 246\n 244: aload 16\n 246: nop\n 247: checkcast #44 // class java/util/List\n 250: astore 11\n 252: aload 11\n 254: aload 10\n 256: invokeinterface #81, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 261: pop\n 262: goto 153\n 265: aload 7\n 267: nop\n 268: astore 4\n 270: nop\n 271: iconst_0\n 272: istore 5\n 274: aload 4\n 276: astore 6\n 278: new #27 // class java/util/ArrayList\n 281: dup\n 282: aload 4\n 284: invokeinterface #85, 1 // InterfaceMethod java/util/Map.size:()I\n 289: invokespecial #30 // Method java/util/ArrayList.\"<init>\":(I)V\n 292: checkcast #32 // class java/util/Collection\n 295: astore 7\n 297: iconst_0\n 298: istore 8\n 300: aload 6\n 302: invokeinterface #89, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 307: invokeinterface #92, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 312: astore 9\n 314: aload 9\n 316: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 321: ifeq 479\n 324: aload 9\n 326: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 331: checkcast #94 // class java/util/Map$Entry\n 334: astore 10\n 336: aload 7\n 338: aload 10\n 340: astore 11\n 342: astore 25\n 344: iconst_0\n 345: istore 12\n 347: aload 11\n 349: invokeinterface #97, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 354: checkcast #99 // class java/lang/String\n 357: astore 13\n 359: aload 11\n 361: invokeinterface #102, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 366: checkcast #44 // class java/util/List\n 369: astore 14\n 371: aload 13\n 373: aload 14\n 375: checkcast #46 // class java/lang/Iterable\n 378: astore 15\n 380: astore 16\n 382: iconst_0\n 383: istore 18\n 385: aload 15\n 387: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 392: astore 19\n 394: aload 19\n 396: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 401: ifeq 444\n 404: aload 19\n 406: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 411: astore 20\n 413: iload 18\n 415: aload 20\n 417: checkcast #67 // class solution/StockItem\n 420: astore 21\n 422: istore 22\n 424: iconst_0\n 425: istore 23\n 427: aload 21\n 429: invokevirtual #105 // Method solution/StockItem.getQuantity:()I\n 432: istore 24\n 434: iload 22\n 436: iload 24\n 438: iadd\n 439: istore 18\n 441: goto 394\n 444: iload 18\n 446: istore 22\n 448: aload 16\n 450: iload 22\n 452: istore 26\n 454: astore 27\n 456: new #67 // class solution/StockItem\n 459: dup\n 460: aload 27\n 462: iload 26\n 464: invokespecial #108 // Method solution/StockItem.\"<init>\":(Ljava/lang/String;I)V\n 467: aload 25\n 469: swap\n 470: invokeinterface #42, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 475: pop\n 476: goto 314\n 479: aload 7\n 481: checkcast #44 // class java/util/List\n 484: nop\n 485: checkcast #46 // class java/lang/Iterable\n 488: astore 4\n 490: nop\n 491: iconst_0\n 492: istore 5\n 494: aload 4\n 496: bipush 10\n 498: invokestatic #114 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 501: invokestatic #120 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 504: bipush 16\n 506: invokestatic #126 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 509: istore 6\n 511: aload 4\n 513: astore 7\n 515: new #48 // class java/util/LinkedHashMap\n 518: dup\n 519: iload 6\n 521: invokespecial #127 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 524: checkcast #51 // class java/util/Map\n 527: astore 8\n 529: iconst_0\n 530: istore 9\n 532: aload 7\n 534: invokeinterface #55, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 539: astore 10\n 541: aload 10\n 543: invokeinterface #61, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 548: ifeq 593\n 551: aload 10\n 553: invokeinterface #65, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 558: astore 11\n 560: aload 8\n 562: aload 11\n 564: checkcast #67 // class solution/StockItem\n 567: astore 12\n 569: astore 25\n 571: iconst_0\n 572: istore 13\n 574: aload 12\n 576: invokevirtual #71 // Method solution/StockItem.getCategory:()Ljava/lang/String;\n 579: aload 25\n 581: swap\n 582: aload 11\n 584: invokeinterface #80, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 589: pop\n 590: goto 541\n 593: aload 8\n 595: nop\n 596: astore_3\n 597: aload_2\n 598: astore 4\n 600: nop\n 601: iconst_0\n 602: istore 5\n 604: aload 4\n 606: astore 6\n 608: new #27 // class java/util/ArrayList\n 611: dup\n 612: aload 4\n 614: arraylength\n 615: invokespecial #30 // Method java/util/ArrayList.\"<init>\":(I)V\n 618: checkcast #32 // class java/util/Collection\n 621: astore 7\n 623: iconst_0\n 624: istore 8\n 626: iconst_0\n 627: istore 9\n 629: aload 6\n 631: arraylength\n 632: istore 10\n 634: iload 9\n 636: iload 10\n 638: if_icmpge 700\n 641: aload 6\n 643: iload 9\n 645: aaload\n 646: astore 11\n 648: aload 7\n 650: aload 11\n 652: astore 12\n 654: astore 25\n 656: iconst_0\n 657: istore 13\n 659: aload_3\n 660: aload 12\n 662: invokeinterface #75, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 667: checkcast #67 // class solution/StockItem\n 670: dup\n 671: ifnonnull 685\n 674: pop\n 675: new #67 // class solution/StockItem\n 678: dup\n 679: aload 12\n 681: iconst_0\n 682: invokespecial #108 // Method solution/StockItem.\"<init>\":(Ljava/lang/String;I)V\n 685: aload 25\n 687: swap\n 688: invokeinterface #42, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 693: pop\n 694: iinc 9, 1\n 697: goto 634\n 700: aload 7\n 702: checkcast #44 // class java/util/List\n 705: nop\n 706: checkcast #46 // class java/lang/Iterable\n 709: ldc #129 // String -\n 711: checkcast #131 // class java/lang/CharSequence\n 714: aconst_null\n 715: aconst_null\n 716: iconst_0\n 717: aconst_null\n 718: invokedynamic #149, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 723: bipush 30\n 725: aconst_null\n 726: invokestatic #153 // 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 729: areturn\n\n private static final java.lang.CharSequence stockSummary$lambda$5(solution.StockItem);\n Code:\n 0: aload_0\n 1: ldc #200 // String it\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #202 // class java/lang/StringBuilder\n 9: dup\n 10: invokespecial #203 // Method java/lang/StringBuilder.\"<init>\":()V\n 13: bipush 40\n 15: invokevirtual #207 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 18: aload_0\n 19: invokevirtual #71 // Method solution/StockItem.getCategory:()Ljava/lang/String;\n 22: invokevirtual #210 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 25: ldc #212 // String :\n 27: invokevirtual #210 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 30: aload_0\n 31: invokevirtual #105 // Method solution/StockItem.getQuantity:()I\n 34: invokevirtual #215 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 37: bipush 41\n 39: invokevirtual #207 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 42: invokevirtual #218 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 45: checkcast #131 // class java/lang/CharSequence\n 48: areturn\n\n static {};\n Code:\n 0: new #2 // class solution/StockList\n 3: dup\n 4: invokespecial #220 // Method \"<init>\":()V\n 7: putstatic #223 // Field INSTANCE:Lsolution/StockList;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "borisskert__kotlin-katas__0659b33/solution/StockListKt.class",
"javap": "Compiled from \"StockList.kt\"\npublic final class solution.StockListKt {\n private static final kotlin.text.Regex stockItemPattern;\n\n public static final kotlin.text.Regex getStockItemPattern();\n Code:\n 0: getstatic #11 // Field stockItemPattern:Lkotlin/text/Regex;\n 3: areturn\n\n public static final solution.StockItem readOne(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #15 // String input\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #11 // Field stockItemPattern:Lkotlin/text/Regex;\n 9: aload_0\n 10: checkcast #23 // class java/lang/CharSequence\n 13: invokevirtual #29 // Method kotlin/text/Regex.matchEntire:(Ljava/lang/CharSequence;)Lkotlin/text/MatchResult;\n 16: astore_1\n 17: aload_1\n 18: dup\n 19: invokestatic #33 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 22: invokeinterface #39, 1 // InterfaceMethod kotlin/text/MatchResult.getGroups:()Lkotlin/text/MatchGroupCollection;\n 27: astore_2\n 28: aload_2\n 29: iconst_1\n 30: invokeinterface #45, 2 // InterfaceMethod kotlin/text/MatchGroupCollection.get:(I)Lkotlin/text/MatchGroup;\n 35: dup\n 36: invokestatic #33 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 39: invokevirtual #51 // Method kotlin/text/MatchGroup.getValue:()Ljava/lang/String;\n 42: astore_3\n 43: aload_2\n 44: iconst_2\n 45: invokeinterface #45, 2 // InterfaceMethod kotlin/text/MatchGroupCollection.get:(I)Lkotlin/text/MatchGroup;\n 50: dup\n 51: invokestatic #33 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 54: invokevirtual #51 // Method kotlin/text/MatchGroup.getValue:()Ljava/lang/String;\n 57: astore 4\n 59: new #53 // class solution/StockItem\n 62: dup\n 63: aload_3\n 64: iconst_1\n 65: invokestatic #59 // Method kotlin/text/StringsKt.take:(Ljava/lang/String;I)Ljava/lang/String;\n 68: aload 4\n 70: invokestatic #65 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 73: invokespecial #69 // Method solution/StockItem.\"<init>\":(Ljava/lang/String;I)V\n 76: areturn\n\n static {};\n Code:\n 0: new #25 // class kotlin/text/Regex\n 3: dup\n 4: ldc #80 // String ([A-Z][A-Z0-9]+) ([0-9]+)\n 6: invokespecial #83 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: putstatic #11 // Field stockItemPattern:Lkotlin/text/Regex;\n 12: return\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day15.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
import java.util.PriorityQueue
object Day15 {
data class RiskPath(val currentCost: Int, val row: Int, val col: Int)
private fun solve(lines: List<String>, shouldExpandGrid: Boolean = false): Int {
val rawGrid = parseLines(lines)
val grid = if (shouldExpandGrid) expandGrid(rawGrid) else rawGrid
val pq = PriorityQueue<RiskPath> { a, b ->
a.currentCost.compareTo(b.currentCost)
}
pq.add(RiskPath(0, 0, 0))
val directions = listOf(-1 to 0, 1 to 0, 0 to -1, 0 to 1)
val minCosts = mutableMapOf<Pair<Int, Int>, Int>()
minCosts[0 to 0] = 0
while (true) {
val top = pq.remove()!!
if (top.row == grid.size - 1 && top.col == grid[0].size - 1) {
return top.currentCost
}
directions.forEach { (dx, dy) ->
val x = top.row + dx
val y = top.col + dy
if (x >= 0 && x < grid.size && y >= 0 && y < grid[0].size) {
val newCost = top.currentCost + grid[x][y]
if (newCost < (minCosts[x to y] ?: Integer.MAX_VALUE)) {
pq.add(RiskPath(newCost, x, y))
minCosts[x to y] = newCost
}
}
}
}
}
private fun parseLines(lines: List<String>): List<List<Int>> {
return lines.map { line ->
line.map(Char::digitToInt)
}
}
private fun expandGrid(grid: List<List<Int>>): List<List<Int>> {
val newGrid = Array(grid.size * 5) { Array(grid[0].size * 5) { 0 } }
for (i in grid.indices) {
for (j in grid[0].indices) {
for (k in 0 until 5) {
for (x in 0 until 5) {
val ni = i + grid.size * k
val nj = j + grid[0].size * x
newGrid[ni][nj] = grid[i][j] + k + x
while (newGrid[ni][nj] > 9) {
newGrid[ni][nj] -= 9
}
}
}
}
}
return newGrid.map(Array<Int>::toList)
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input15.txt"), Charsets.UTF_8)
val solution1 = solve(lines, shouldExpandGrid = false)
println(solution1)
val solution2 = solve(lines, shouldExpandGrid = true)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day15.class",
"javap": "Compiled from \"Day15.kt\"\npublic final class org.aoc2021.Day15 {\n public static final org.aoc2021.Day15 INSTANCE;\n\n private org.aoc2021.Day15();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int solve(java.util.List<java.lang.String>, boolean);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #17 // Method parseLines:(Ljava/util/List;)Ljava/util/List;\n 5: astore_3\n 6: iload_2\n 7: ifeq 18\n 10: aload_0\n 11: aload_3\n 12: invokespecial #20 // Method expandGrid:(Ljava/util/List;)Ljava/util/List;\n 15: goto 19\n 18: aload_3\n 19: astore 4\n 21: new #22 // class java/util/PriorityQueue\n 24: dup\n 25: invokedynamic #42, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;\n 30: invokedynamic #53, 0 // InvokeDynamic #1:compare:(Lkotlin/jvm/functions/Function2;)Ljava/util/Comparator;\n 35: invokespecial #56 // Method java/util/PriorityQueue.\"<init>\":(Ljava/util/Comparator;)V\n 38: astore 5\n 40: aload 5\n 42: new #58 // class org/aoc2021/Day15$RiskPath\n 45: dup\n 46: iconst_0\n 47: iconst_0\n 48: iconst_0\n 49: invokespecial #61 // Method org/aoc2021/Day15$RiskPath.\"<init>\":(III)V\n 52: invokevirtual #65 // Method java/util/PriorityQueue.add:(Ljava/lang/Object;)Z\n 55: pop\n 56: iconst_4\n 57: anewarray #67 // class kotlin/Pair\n 60: astore 7\n 62: aload 7\n 64: iconst_0\n 65: iconst_m1\n 66: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 69: iconst_0\n 70: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 73: invokestatic #79 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 76: aastore\n 77: aload 7\n 79: iconst_1\n 80: iconst_1\n 81: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 84: iconst_0\n 85: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 88: invokestatic #79 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 91: aastore\n 92: aload 7\n 94: iconst_2\n 95: iconst_0\n 96: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 99: iconst_m1\n 100: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 103: invokestatic #79 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 106: aastore\n 107: aload 7\n 109: iconst_3\n 110: iconst_0\n 111: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 114: iconst_1\n 115: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 118: invokestatic #79 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 121: aastore\n 122: aload 7\n 124: invokestatic #85 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 127: astore 6\n 129: new #87 // class java/util/LinkedHashMap\n 132: dup\n 133: invokespecial #88 // Method java/util/LinkedHashMap.\"<init>\":()V\n 136: checkcast #90 // class java/util/Map\n 139: astore 7\n 141: aload 7\n 143: iconst_0\n 144: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 147: iconst_0\n 148: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 151: invokestatic #79 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 154: iconst_0\n 155: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 158: invokeinterface #93, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 163: pop\n 164: nop\n 165: aload 5\n 167: invokevirtual #97 // Method java/util/PriorityQueue.remove:()Ljava/lang/Object;\n 170: dup\n 171: invokestatic #103 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 174: checkcast #58 // class org/aoc2021/Day15$RiskPath\n 177: astore 8\n 179: aload 8\n 181: invokevirtual #107 // Method org/aoc2021/Day15$RiskPath.getRow:()I\n 184: aload 4\n 186: invokeinterface #112, 1 // InterfaceMethod java/util/List.size:()I\n 191: iconst_1\n 192: isub\n 193: if_icmpne 228\n 196: aload 8\n 198: invokevirtual #115 // Method org/aoc2021/Day15$RiskPath.getCol:()I\n 201: aload 4\n 203: iconst_0\n 204: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 209: checkcast #109 // class java/util/List\n 212: invokeinterface #112, 1 // InterfaceMethod java/util/List.size:()I\n 217: iconst_1\n 218: isub\n 219: if_icmpne 228\n 222: aload 8\n 224: invokevirtual #122 // Method org/aoc2021/Day15$RiskPath.getCurrentCost:()I\n 227: ireturn\n 228: aload 6\n 230: checkcast #124 // class java/lang/Iterable\n 233: astore 9\n 235: iconst_0\n 236: istore 10\n 238: aload 9\n 240: invokeinterface #128, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 245: astore 11\n 247: aload 11\n 249: invokeinterface #134, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 254: ifeq 493\n 257: aload 11\n 259: invokeinterface #137, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 264: astore 12\n 266: aload 12\n 268: checkcast #67 // class kotlin/Pair\n 271: astore 13\n 273: iconst_0\n 274: istore 14\n 276: aload 13\n 278: invokevirtual #140 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 281: checkcast #142 // class java/lang/Number\n 284: invokevirtual #145 // Method java/lang/Number.intValue:()I\n 287: istore 15\n 289: aload 13\n 291: invokevirtual #148 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 294: checkcast #142 // class java/lang/Number\n 297: invokevirtual #145 // Method java/lang/Number.intValue:()I\n 300: istore 16\n 302: aload 8\n 304: invokevirtual #107 // Method org/aoc2021/Day15$RiskPath.getRow:()I\n 307: iload 15\n 309: iadd\n 310: istore 17\n 312: aload 8\n 314: invokevirtual #115 // Method org/aoc2021/Day15$RiskPath.getCol:()I\n 317: iload 16\n 319: iadd\n 320: istore 18\n 322: iload 17\n 324: iflt 488\n 327: iload 17\n 329: aload 4\n 331: invokeinterface #112, 1 // InterfaceMethod java/util/List.size:()I\n 336: if_icmpge 488\n 339: iload 18\n 341: iflt 488\n 344: iload 18\n 346: aload 4\n 348: iconst_0\n 349: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 354: checkcast #109 // class java/util/List\n 357: invokeinterface #112, 1 // InterfaceMethod java/util/List.size:()I\n 362: if_icmpge 488\n 365: aload 8\n 367: invokevirtual #122 // Method org/aoc2021/Day15$RiskPath.getCurrentCost:()I\n 370: aload 4\n 372: iload 17\n 374: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 379: checkcast #109 // class java/util/List\n 382: iload 18\n 384: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 389: checkcast #142 // class java/lang/Number\n 392: invokevirtual #145 // Method java/lang/Number.intValue:()I\n 395: iadd\n 396: istore 19\n 398: iload 19\n 400: aload 7\n 402: iload 17\n 404: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 407: iload 18\n 409: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 412: invokestatic #79 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 415: invokeinterface #151, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 420: checkcast #69 // class java/lang/Integer\n 423: dup\n 424: ifnull 433\n 427: invokevirtual #152 // Method java/lang/Integer.intValue:()I\n 430: goto 436\n 433: pop\n 434: ldc #153 // int 2147483647\n 436: if_icmpge 488\n 439: aload 5\n 441: new #58 // class org/aoc2021/Day15$RiskPath\n 444: dup\n 445: iload 19\n 447: iload 17\n 449: iload 18\n 451: invokespecial #61 // Method org/aoc2021/Day15$RiskPath.\"<init>\":(III)V\n 454: invokevirtual #65 // Method java/util/PriorityQueue.add:(Ljava/lang/Object;)Z\n 457: pop\n 458: iload 19\n 460: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 463: astore 20\n 465: aload 7\n 467: iload 17\n 469: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 472: iload 18\n 474: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 477: invokestatic #79 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 480: aload 20\n 482: invokeinterface #93, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 487: pop\n 488: nop\n 489: nop\n 490: goto 247\n 493: nop\n 494: goto 164\n\n static int solve$default(org.aoc2021.Day15, java.util.List, boolean, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_2\n 2: iand\n 3: ifeq 8\n 6: iconst_0\n 7: istore_2\n 8: aload_0\n 9: aload_1\n 10: iload_2\n 11: invokespecial #182 // Method solve:(Ljava/util/List;Z)I\n 14: ireturn\n\n private final java.util.List<java.util.List<java.lang.Integer>> parseLines(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #124 // 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 #185 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #189 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #192 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #194 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #128, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #134, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 188\n 50: aload 7\n 52: invokeinterface #137, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #196 // class java/lang/String\n 66: astore 9\n 68: astore 21\n 70: iconst_0\n 71: istore 10\n 73: aload 9\n 75: checkcast #198 // class java/lang/CharSequence\n 78: astore 11\n 80: iconst_0\n 81: istore 12\n 83: aload 11\n 85: astore 13\n 87: new #185 // class java/util/ArrayList\n 90: dup\n 91: aload 11\n 93: invokeinterface #201, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 98: invokespecial #192 // Method java/util/ArrayList.\"<init>\":(I)V\n 101: checkcast #194 // class java/util/Collection\n 104: astore 14\n 106: iconst_0\n 107: istore 15\n 109: iconst_0\n 110: istore 16\n 112: iload 16\n 114: aload 13\n 116: invokeinterface #201, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 121: if_icmpge 169\n 124: aload 13\n 126: iload 16\n 128: invokeinterface #205, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 133: istore 17\n 135: aload 14\n 137: iload 17\n 139: istore 18\n 141: astore 19\n 143: iconst_0\n 144: istore 20\n 146: iload 18\n 148: invokestatic #211 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 151: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 154: aload 19\n 156: swap\n 157: invokeinterface #212, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 162: pop\n 163: iinc 16, 1\n 166: goto 112\n 169: aload 14\n 171: checkcast #109 // class java/util/List\n 174: nop\n 175: nop\n 176: aload 21\n 178: swap\n 179: invokeinterface #212, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 184: pop\n 185: goto 40\n 188: aload 5\n 190: checkcast #109 // class java/util/List\n 193: nop\n 194: areturn\n\n private final java.util.List<java.util.List<java.lang.Integer>> expandGrid(java.util.List<? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: aload_1\n 3: invokeinterface #112, 1 // InterfaceMethod java/util/List.size:()I\n 8: iconst_5\n 9: imul\n 10: istore 4\n 12: iload 4\n 14: anewarray #229 // class \"[Ljava/lang/Integer;\"\n 17: astore 5\n 19: iload_3\n 20: iload 4\n 22: if_icmpge 104\n 25: iload_3\n 26: istore 6\n 28: aload 5\n 30: iload 6\n 32: iconst_0\n 33: istore 7\n 35: aload_1\n 36: iconst_0\n 37: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 42: checkcast #109 // class java/util/List\n 45: invokeinterface #112, 1 // InterfaceMethod java/util/List.size:()I\n 50: iconst_5\n 51: imul\n 52: istore 8\n 54: iload 8\n 56: anewarray #69 // class java/lang/Integer\n 59: astore 9\n 61: istore 14\n 63: astore 13\n 65: iload 7\n 67: iload 8\n 69: if_icmpge 91\n 72: iload 7\n 74: istore 10\n 76: aload 9\n 78: iload 10\n 80: iconst_0\n 81: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 84: aastore\n 85: iinc 7, 1\n 88: goto 65\n 91: aload 13\n 93: iload 14\n 95: aload 9\n 97: aastore\n 98: iinc 3, 1\n 101: goto 19\n 104: aload 5\n 106: astore_2\n 107: iconst_0\n 108: istore_3\n 109: aload_1\n 110: checkcast #194 // class java/util/Collection\n 113: invokeinterface #230, 1 // InterfaceMethod java/util/Collection.size:()I\n 118: istore 4\n 120: iload_3\n 121: iload 4\n 123: if_icmpge 313\n 126: iconst_0\n 127: istore 5\n 129: aload_1\n 130: iconst_0\n 131: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 136: checkcast #194 // class java/util/Collection\n 139: invokeinterface #230, 1 // InterfaceMethod java/util/Collection.size:()I\n 144: istore 6\n 146: iload 5\n 148: iload 6\n 150: if_icmpge 307\n 153: iconst_0\n 154: istore 7\n 156: iload 7\n 158: iconst_5\n 159: if_icmpge 301\n 162: iconst_0\n 163: istore 8\n 165: iload 8\n 167: iconst_5\n 168: if_icmpge 295\n 171: iload_3\n 172: aload_1\n 173: invokeinterface #112, 1 // InterfaceMethod java/util/List.size:()I\n 178: iload 7\n 180: imul\n 181: iadd\n 182: istore 9\n 184: iload 5\n 186: aload_1\n 187: iconst_0\n 188: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 193: checkcast #109 // class java/util/List\n 196: invokeinterface #112, 1 // InterfaceMethod java/util/List.size:()I\n 201: iload 8\n 203: imul\n 204: iadd\n 205: istore 10\n 207: aload_2\n 208: iload 9\n 210: aaload\n 211: iload 10\n 213: aload_1\n 214: iload_3\n 215: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 220: checkcast #109 // class java/util/List\n 223: iload 5\n 225: invokeinterface #119, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 230: checkcast #142 // class java/lang/Number\n 233: invokevirtual #145 // Method java/lang/Number.intValue:()I\n 236: iload 7\n 238: iadd\n 239: iload 8\n 241: iadd\n 242: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 245: aastore\n 246: aload_2\n 247: iload 9\n 249: aaload\n 250: iload 10\n 252: aaload\n 253: invokevirtual #152 // Method java/lang/Integer.intValue:()I\n 256: bipush 9\n 258: if_icmple 289\n 261: aload_2\n 262: iload 9\n 264: aaload\n 265: astore 11\n 267: aload 11\n 269: iload 10\n 271: aload 11\n 273: iload 10\n 275: aaload\n 276: invokevirtual #152 // Method java/lang/Integer.intValue:()I\n 279: bipush 9\n 281: isub\n 282: invokestatic #73 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 285: aastore\n 286: goto 246\n 289: iinc 8, 1\n 292: goto 165\n 295: iinc 7, 1\n 298: goto 156\n 301: iinc 5, 1\n 304: goto 146\n 307: iinc 3, 1\n 310: goto 120\n 313: aload_2\n 314: checkcast #232 // class \"[Ljava/lang/Object;\"\n 317: astore_3\n 318: iconst_0\n 319: istore 4\n 321: aload_3\n 322: astore 5\n 324: new #185 // class java/util/ArrayList\n 327: dup\n 328: aload_3\n 329: arraylength\n 330: invokespecial #192 // Method java/util/ArrayList.\"<init>\":(I)V\n 333: checkcast #194 // class java/util/Collection\n 336: astore 6\n 338: iconst_0\n 339: istore 7\n 341: iconst_0\n 342: istore 8\n 344: aload 5\n 346: arraylength\n 347: istore 9\n 349: iload 8\n 351: iload 9\n 353: if_icmpge 397\n 356: aload 5\n 358: iload 8\n 360: aaload\n 361: astore 10\n 363: aload 6\n 365: aload 10\n 367: checkcast #229 // class \"[Ljava/lang/Integer;\"\n 370: astore 11\n 372: astore 13\n 374: iconst_0\n 375: istore 12\n 377: aload 11\n 379: invokestatic #237 // Method kotlin/collections/ArraysKt.toList:([Ljava/lang/Object;)Ljava/util/List;\n 382: aload 13\n 384: swap\n 385: invokeinterface #212, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 390: pop\n 391: iinc 8, 1\n 394: goto 349\n 397: aload 6\n 399: checkcast #109 // class java/util/List\n 402: nop\n 403: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #252 // String args\n 3: invokestatic #256 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc_w #258 // String input15.txt\n 9: iconst_0\n 10: anewarray #196 // class java/lang/String\n 13: invokestatic #264 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 16: getstatic #270 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 19: invokestatic #276 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 22: astore_1\n 23: getstatic #279 // Field INSTANCE:Lorg/aoc2021/Day15;\n 26: aload_1\n 27: invokestatic #103 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 30: aload_1\n 31: iconst_0\n 32: invokespecial #182 // Method solve:(Ljava/util/List;Z)I\n 35: istore_2\n 36: getstatic #285 // Field java/lang/System.out:Ljava/io/PrintStream;\n 39: iload_2\n 40: invokevirtual #290 // Method java/io/PrintStream.println:(I)V\n 43: getstatic #279 // Field INSTANCE:Lorg/aoc2021/Day15;\n 46: aload_1\n 47: iconst_1\n 48: invokespecial #182 // Method solve:(Ljava/util/List;Z)I\n 51: istore_3\n 52: getstatic #285 // Field java/lang/System.out:Ljava/io/PrintStream;\n 55: iload_3\n 56: invokevirtual #290 // Method java/io/PrintStream.println:(I)V\n 59: return\n\n private static final int solve$lambda$0(org.aoc2021.Day15$RiskPath, org.aoc2021.Day15$RiskPath);\n Code:\n 0: aload_0\n 1: invokevirtual #122 // Method org/aoc2021/Day15$RiskPath.getCurrentCost:()I\n 4: aload_1\n 5: invokevirtual #122 // Method org/aoc2021/Day15$RiskPath.getCurrentCost:()I\n 8: invokestatic #296 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 11: ireturn\n\n private static final int solve$lambda$1(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 #302, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 8: checkcast #142 // class java/lang/Number\n 11: invokevirtual #145 // Method java/lang/Number.intValue:()I\n 14: ireturn\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day15\n 3: dup\n 4: invokespecial #307 // Method \"<init>\":()V\n 7: putstatic #279 // Field INSTANCE:Lorg/aoc2021/Day15;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day15$RiskPath.class",
"javap": "Compiled from \"Day15.kt\"\npublic final class org.aoc2021.Day15$RiskPath {\n private final int currentCost;\n\n private final int row;\n\n private final int col;\n\n public org.aoc2021.Day15$RiskPath(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 currentCost:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field row:I\n 14: aload_0\n 15: iload_3\n 16: putfield #19 // Field col:I\n 19: return\n\n public final int getCurrentCost();\n Code:\n 0: aload_0\n 1: getfield #13 // Field currentCost:I\n 4: ireturn\n\n public final int getRow();\n Code:\n 0: aload_0\n 1: getfield #16 // Field row:I\n 4: ireturn\n\n public final int getCol();\n Code:\n 0: aload_0\n 1: getfield #19 // Field col:I\n 4: ireturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field currentCost:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field row:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #19 // Field col:I\n 4: ireturn\n\n public final org.aoc2021.Day15$RiskPath copy(int, int, int);\n Code:\n 0: new #2 // class org/aoc2021/Day15$RiskPath\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 org.aoc2021.Day15$RiskPath copy$default(org.aoc2021.Day15$RiskPath, 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 currentCost: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 row: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 col: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)Lorg/aoc2021/Day15$RiskPath;\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 RiskPath(currentCost=\n 9: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field currentCost:I\n 16: invokevirtual #51 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #53 // String , row=\n 21: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field row:I\n 28: invokevirtual #51 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #55 // String , col=\n 33: invokevirtual #48 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #19 // Field col: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 currentCost: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 row: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 col: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 org/aoc2021/Day15$RiskPath\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day15$RiskPath\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field currentCost:I\n 25: aload_2\n 26: getfield #13 // Field currentCost:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field row:I\n 38: aload_2\n 39: getfield #16 // Field row:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #19 // Field col:I\n 51: aload_2\n 52: getfield #19 // Field col:I\n 55: if_icmpeq 60\n 58: iconst_0\n 59: ireturn\n 60: iconst_1\n 61: ireturn\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day24.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
private fun <K, V> Map<K, V>.replaceKeyValue(k: K, v: V): Map<K, V> {
return this.entries.associate { (thisKey, thisValue) ->
if (thisKey == k) (k to v) else (thisKey to thisValue)
}
}
object Day24 {
data class Instruction(val operator: String, val a: String, val b: String? = null)
private fun solve(lines: List<String>, findMax: Boolean): String {
val program = parseProgram(lines)
val expressions = generateExpressions(program)
expressions.find { (_, variables) -> variables["z"] == LiteralValue(0) }?.let { (conditions, _) ->
if (conditions.any { !it.value }) {
throw IllegalStateException("unexpected condition: $conditions")
}
val result = Array(14) { 0 }
conditions.forEach { condition ->
val compare = if (condition.compare.a is Input) {
Compare(Add(condition.compare.a, LiteralValue(0)), condition.compare.b)
} else {
condition.compare
}
if (compare.a !is Add || compare.a.a !is Input || compare.a.b !is LiteralValue || compare.b !is Input) {
throw IllegalStateException("unexpected compare: $compare")
}
if (compare.a.b.value < 0) {
result[compare.a.a.index] = if (findMax) 9 else (1 - compare.a.b.value)
result[compare.b.index] = result[compare.a.a.index] + compare.a.b.value
} else {
result[compare.b.index] = if (findMax) 9 else (1 + compare.a.b.value)
result[compare.a.a.index] = result[compare.b.index] - compare.a.b.value
}
}
return result.map(Int::digitToChar).joinToString(separator = "")
}
throw IllegalArgumentException("no solution found")
}
sealed interface Expression {
fun simplify(): Expression
}
data class Input(val index: Int) : Expression {
override fun simplify() = this
override fun toString() = "input$index"
}
data class LiteralValue(val value: Int) : Expression {
override fun simplify() = this
override fun toString() = value.toString()
}
data class Add(val a: Expression, val b: Expression) : Expression {
override fun simplify(): Expression {
return if (a is LiteralValue && b is LiteralValue) {
LiteralValue(a.value + b.value)
} else if (a == LiteralValue(0)) {
b
} else if (b == LiteralValue(0)) {
a
} else if (a is Add && a.b is LiteralValue && b is LiteralValue) {
Add(a.a, LiteralValue(a.b.value + b.value)).simplify()
} else {
this
}
}
override fun toString() = "($a + $b)"
}
data class Multiply(val a: Expression, val b: Expression) : Expression {
override fun simplify(): Expression {
return if (a is LiteralValue && b is LiteralValue) {
LiteralValue(a.value * b.value)
} else if (a == LiteralValue(0) || b == LiteralValue(0)) {
LiteralValue(0)
} else if (a == LiteralValue(1)) {
b
} else if (b == LiteralValue(1)) {
a
} else if (a is Multiply && a.b is LiteralValue && b is LiteralValue) {
Multiply(a.a, LiteralValue(a.b.value * b.value)).simplify()
} else {
this
}
}
override fun toString() = "($a * $b)"
}
data class Divide(val a: Expression, val b: Expression) : Expression {
override fun simplify(): Expression {
return if (a is LiteralValue && b is LiteralValue) {
LiteralValue(a.value / b.value)
} else if (a == LiteralValue(0)) {
LiteralValue(0)
} else if (b == LiteralValue(1)) {
a
} else if (a is Multiply && a.b is LiteralValue && b is LiteralValue && (a.b.value % b.value == 0)) {
Multiply(a.a, LiteralValue(a.b.value / b.value)).simplify()
} else if (a is Add && a.a is Input && a.b is LiteralValue && b is LiteralValue && a.b.value < b.value - 9) {
LiteralValue(0)
} else if (a is Add && a.b is Add && a.b.a is Input && a.b.b is LiteralValue && b is LiteralValue && a.b.b.value >= 0 && a.b.b.value < b.value - 9) {
Divide(a.a, b).simplify()
} else {
this
}
}
override fun toString() = "($a / $b)"
}
data class Modulo(val a: Expression, val b: Expression): Expression {
override fun simplify(): Expression {
return if (a is LiteralValue && b is LiteralValue) {
LiteralValue(a.value % b.value)
} else if (a == LiteralValue(0)) {
LiteralValue(0)
} else if (a is Add && b is LiteralValue) {
Add(Modulo(a.a, b).simplify(), Modulo(a.b, b).simplify()).simplify()
} else if (a is Multiply && a.b is LiteralValue && b is LiteralValue && (a.b.value % b.value == 0)) {
LiteralValue(0)
} else if (a is Input && b is LiteralValue && b.value > 9) {
a
} else {
this
}
}
override fun toString() = "($a % $b)"
}
data class Compare(val a: Expression, val b: Expression, val invert: Boolean = false): Expression {
override fun simplify(): Expression {
return if (a is LiteralValue && b is LiteralValue) {
if (invert) {
LiteralValue(if (a.value == b.value) 0 else 1)
} else {
LiteralValue(if (a.value == b.value) 1 else 0)
}
} else if (a is Compare && b == LiteralValue(0)) {
Compare(a.a, a.b, invert = true).simplify()
} else if (isConditionImpossible(a, b)) {
LiteralValue(if (invert) 1 else 0)
} else {
this
}
}
override fun toString() = if (!invert) {
"($a == $b ? 1 : 0)"
} else {
"($a == $b ? 0 : 1)"
}
}
private fun isConditionImpossible(a: Expression, b: Expression): Boolean {
if (b !is Input) {
return false
}
if (a is LiteralValue && (a.value < 1 || a.value > 9)) {
return true
}
if (a is Add && a.a is Input && a.b is LiteralValue && a.b.value >= 9) {
return true
}
if (a is Add && a.a is Modulo && a.b is LiteralValue && a.b.value > 9) {
return true
}
return false
}
data class Condition(val compare: Compare, val value: Boolean)
private fun generateExpressions(
program: List<Instruction>,
initialState: Map<String, Expression> = listOf("w", "x", "y", "z").associateWith { LiteralValue(0) },
i: Int = 0,
initialInputIndex: Int = 0,
conditions: List<Condition> = listOf(),
): List<Pair<List<Condition>, Map<String, Expression>>> {
val variables = initialState.toMutableMap()
var inputIndex = initialInputIndex
for (j in i until program.size) {
val instruction = program[j]
when (instruction.operator) {
"inp" -> {
variables[instruction.a] = Input(inputIndex)
inputIndex++
}
"add" -> {
val aValue = variables[instruction.a]!!
val bValue = getExpressionValueOf(instruction.b!!, variables)
variables[instruction.a] = Add(aValue, bValue).simplify()
}
"mul" -> {
val aValue = variables[instruction.a]!!
val bValue = getExpressionValueOf(instruction.b!!, variables)
variables[instruction.a] = Multiply(aValue, bValue).simplify()
}
"div" -> {
val aValue = variables[instruction.a]!!
val bValue = getExpressionValueOf(instruction.b!!, variables)
variables[instruction.a] = Divide(aValue, bValue).simplify()
}
"mod" -> {
val aValue = variables[instruction.a]!!
val bValue = getExpressionValueOf(instruction.b!!, variables)
variables[instruction.a] = Modulo(aValue, bValue).simplify()
}
"eql" -> {
val aValue = variables[instruction.a]!!
val bValue = getExpressionValueOf(instruction.b!!, variables)
val compare = Compare(aValue, bValue).simplify()
if (compare is Compare) {
val oneBranch = variables.replaceKeyValue(instruction.a, LiteralValue(1))
val zeroBranch = variables.replaceKeyValue(instruction.a, LiteralValue(0))
return generateExpressions(program, oneBranch.toMap(), j + 1, inputIndex, conditions.plus(Condition(compare, true)))
.plus(generateExpressions(program, zeroBranch.toMap(), j + 1, inputIndex, conditions.plus(Condition(compare, false))))
}
variables[instruction.a] = compare
}
}
}
return listOf(conditions to variables.toMap())
}
private fun getExpressionValueOf(value: String, variables: Map<String, Expression>): Expression {
return variables[value] ?: LiteralValue(value.toInt())
}
private fun parseProgram(lines: List<String>): List<Instruction> {
return lines.map { line ->
val split = line.split(" ")
if (split[0] == "inp") {
Instruction(split[0], split[1])
} else {
Instruction(split[0], split[1], split[2])
}
}
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input24.txt"), Charsets.UTF_8)
val solution1 = solve(lines, true)
println(solution1)
val solution2 = solve(lines, false)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day24$Compare.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class org.aoc2021.Day24$Compare implements org.aoc2021.Day24$Expression {\n private final org.aoc2021.Day24$Expression a;\n\n private final org.aoc2021.Day24$Expression b;\n\n private final boolean invert;\n\n public org.aoc2021.Day24$Compare(org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression, boolean);\n Code:\n 0: aload_1\n 1: ldc #11 // String a\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #19 // String b\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokespecial #22 // Method java/lang/Object.\"<init>\":()V\n 16: aload_0\n 17: aload_1\n 18: putfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 21: aload_0\n 22: aload_2\n 23: putfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 26: aload_0\n 27: iload_3\n 28: putfield #31 // Field invert:Z\n 31: return\n\n public org.aoc2021.Day24$Compare(org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression, 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: aload_2\n 12: iload_3\n 13: invokespecial #36 // Method \"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;Z)V\n 16: return\n\n public final org.aoc2021.Day24$Expression getA();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final org.aoc2021.Day24$Expression getB();\n Code:\n 0: aload_0\n 1: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final boolean getInvert();\n Code:\n 0: aload_0\n 1: getfield #31 // Field invert:Z\n 4: ireturn\n\n public org.aoc2021.Day24$Expression simplify();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: instanceof #44 // class org/aoc2021/Day24$LiteralValue\n 7: ifeq 106\n 10: aload_0\n 11: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 14: instanceof #44 // class org/aoc2021/Day24$LiteralValue\n 17: ifeq 106\n 20: aload_0\n 21: getfield #31 // Field invert:Z\n 24: ifeq 65\n 27: new #44 // class org/aoc2021/Day24$LiteralValue\n 30: dup\n 31: aload_0\n 32: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 35: checkcast #44 // class org/aoc2021/Day24$LiteralValue\n 38: invokevirtual #48 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 41: aload_0\n 42: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 45: checkcast #44 // class org/aoc2021/Day24$LiteralValue\n 48: invokevirtual #48 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 51: if_icmpne 58\n 54: iconst_0\n 55: goto 59\n 58: iconst_1\n 59: invokespecial #51 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 62: goto 100\n 65: new #44 // class org/aoc2021/Day24$LiteralValue\n 68: dup\n 69: aload_0\n 70: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 73: checkcast #44 // class org/aoc2021/Day24$LiteralValue\n 76: invokevirtual #48 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 79: aload_0\n 80: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 83: checkcast #44 // class org/aoc2021/Day24$LiteralValue\n 86: invokevirtual #48 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 89: if_icmpne 96\n 92: iconst_1\n 93: goto 97\n 96: iconst_0\n 97: invokespecial #51 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 100: checkcast #6 // class org/aoc2021/Day24$Expression\n 103: goto 214\n 106: aload_0\n 107: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 110: instanceof #2 // class org/aoc2021/Day24$Compare\n 113: ifeq 168\n 116: aload_0\n 117: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 120: new #44 // class org/aoc2021/Day24$LiteralValue\n 123: dup\n 124: iconst_0\n 125: invokespecial #51 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 128: invokestatic #55 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 131: ifeq 168\n 134: new #2 // class org/aoc2021/Day24$Compare\n 137: dup\n 138: aload_0\n 139: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 142: checkcast #2 // class org/aoc2021/Day24$Compare\n 145: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 148: aload_0\n 149: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 152: checkcast #2 // class org/aoc2021/Day24$Compare\n 155: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 158: iconst_1\n 159: invokespecial #36 // Method \"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;Z)V\n 162: invokevirtual #57 // Method simplify:()Lorg/aoc2021/Day24$Expression;\n 165: goto 214\n 168: getstatic #63 // Field org/aoc2021/Day24.INSTANCE:Lorg/aoc2021/Day24;\n 171: aload_0\n 172: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 175: aload_0\n 176: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 179: invokestatic #67 // Method org/aoc2021/Day24.access$isConditionImpossible:(Lorg/aoc2021/Day24;Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)Z\n 182: ifeq 210\n 185: new #44 // class org/aoc2021/Day24$LiteralValue\n 188: dup\n 189: aload_0\n 190: getfield #31 // Field invert:Z\n 193: ifeq 200\n 196: iconst_1\n 197: goto 201\n 200: iconst_0\n 201: invokespecial #51 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 204: checkcast #6 // class org/aoc2021/Day24$Expression\n 207: goto 214\n 210: aload_0\n 211: checkcast #6 // class org/aoc2021/Day24$Expression\n 214: areturn\n\n public java.lang.String toString();\n Code:\n 0: aload_0\n 1: getfield #31 // Field invert:Z\n 4: ifne 49\n 7: new #71 // class java/lang/StringBuilder\n 10: dup\n 11: invokespecial #72 // Method java/lang/StringBuilder.\"<init>\":()V\n 14: bipush 40\n 16: invokevirtual #76 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 19: aload_0\n 20: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 23: invokevirtual #79 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 26: ldc #81 // String ==\n 28: invokevirtual #84 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 31: aload_0\n 32: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 35: invokevirtual #79 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 38: ldc #86 // String ? 1 : 0)\n 40: invokevirtual #84 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 43: invokevirtual #88 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 46: goto 88\n 49: new #71 // class java/lang/StringBuilder\n 52: dup\n 53: invokespecial #72 // Method java/lang/StringBuilder.\"<init>\":()V\n 56: bipush 40\n 58: invokevirtual #76 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 61: aload_0\n 62: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 65: invokevirtual #79 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 68: ldc #81 // String ==\n 70: invokevirtual #84 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 73: aload_0\n 74: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 77: invokevirtual #79 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 80: ldc #90 // String ? 0 : 1)\n 82: invokevirtual #84 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 85: invokevirtual #88 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 88: areturn\n\n public final org.aoc2021.Day24$Expression component1();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final org.aoc2021.Day24$Expression component2();\n Code:\n 0: aload_0\n 1: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final boolean component3();\n Code:\n 0: aload_0\n 1: getfield #31 // Field invert:Z\n 4: ireturn\n\n public final org.aoc2021.Day24$Compare copy(org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression, boolean);\n Code:\n 0: aload_1\n 1: ldc #11 // String a\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #19 // String b\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class org/aoc2021/Day24$Compare\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: iload_3\n 19: invokespecial #36 // Method \"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;Z)V\n 22: areturn\n\n public static org.aoc2021.Day24$Compare copy$default(org.aoc2021.Day24$Compare, org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression, 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 #25 // Field a:Lorg/aoc2021/Day24$Expression;\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 #27 // Field b:Lorg/aoc2021/Day24$Expression;\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 invert:Z\n 35: istore_3\n 36: aload_0\n 37: aload_1\n 38: aload_2\n 39: iload_3\n 40: invokevirtual #101 // Method copy:(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;Z)Lorg/aoc2021/Day24$Compare;\n 43: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: invokevirtual #104 // 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 #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 16: invokevirtual #104 // Method java/lang/Object.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 invert:Z\n 29: invokestatic #109 // 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 org/aoc2021/Day24$Compare\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day24$Compare\n 20: astore_2\n 21: aload_0\n 22: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 25: aload_2\n 26: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 29: invokestatic #55 // 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 b:Lorg/aoc2021/Day24$Expression;\n 41: aload_2\n 42: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 45: invokestatic #55 // 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 #31 // Field invert:Z\n 57: aload_2\n 58: getfield #31 // Field invert:Z\n 61: if_icmpeq 66\n 64: iconst_0\n 65: ireturn\n 66: iconst_1\n 67: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day24$Modulo.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class org.aoc2021.Day24$Modulo implements org.aoc2021.Day24$Expression {\n private final org.aoc2021.Day24$Expression a;\n\n private final org.aoc2021.Day24$Expression b;\n\n public org.aoc2021.Day24$Modulo(org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression);\n Code:\n 0: aload_1\n 1: ldc #11 // String a\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #19 // String b\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokespecial #22 // Method java/lang/Object.\"<init>\":()V\n 16: aload_0\n 17: aload_1\n 18: putfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 21: aload_0\n 22: aload_2\n 23: putfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 26: return\n\n public final org.aoc2021.Day24$Expression getA();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final org.aoc2021.Day24$Expression getB();\n Code:\n 0: aload_0\n 1: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public org.aoc2021.Day24$Expression simplify();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 7: ifeq 54\n 10: aload_0\n 11: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 14: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 17: ifeq 54\n 20: new #35 // class org/aoc2021/Day24$LiteralValue\n 23: dup\n 24: aload_0\n 25: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 28: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 31: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 34: aload_0\n 35: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 38: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 41: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 44: irem\n 45: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 48: checkcast #6 // class org/aoc2021/Day24$Expression\n 51: goto 293\n 54: aload_0\n 55: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 58: new #35 // class org/aoc2021/Day24$LiteralValue\n 61: dup\n 62: iconst_0\n 63: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 66: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 69: ifeq 86\n 72: new #35 // class org/aoc2021/Day24$LiteralValue\n 75: dup\n 76: iconst_0\n 77: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 80: checkcast #6 // class org/aoc2021/Day24$Expression\n 83: goto 293\n 86: aload_0\n 87: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 90: instanceof #48 // class org/aoc2021/Day24$Add\n 93: ifeq 167\n 96: aload_0\n 97: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 100: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 103: ifeq 167\n 106: new #48 // class org/aoc2021/Day24$Add\n 109: dup\n 110: new #2 // class org/aoc2021/Day24$Modulo\n 113: dup\n 114: aload_0\n 115: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 118: checkcast #48 // class org/aoc2021/Day24$Add\n 121: invokevirtual #50 // Method org/aoc2021/Day24$Add.getA:()Lorg/aoc2021/Day24$Expression;\n 124: aload_0\n 125: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 128: invokespecial #52 // Method \"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 131: invokevirtual #54 // Method simplify:()Lorg/aoc2021/Day24$Expression;\n 134: new #2 // class org/aoc2021/Day24$Modulo\n 137: dup\n 138: aload_0\n 139: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 142: checkcast #48 // class org/aoc2021/Day24$Add\n 145: invokevirtual #56 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 148: aload_0\n 149: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 152: invokespecial #52 // Method \"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 155: invokevirtual #54 // Method simplify:()Lorg/aoc2021/Day24$Expression;\n 158: invokespecial #57 // Method org/aoc2021/Day24$Add.\"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 161: invokevirtual #58 // Method org/aoc2021/Day24$Add.simplify:()Lorg/aoc2021/Day24$Expression;\n 164: goto 293\n 167: aload_0\n 168: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 171: instanceof #60 // class org/aoc2021/Day24$Multiply\n 174: ifeq 247\n 177: aload_0\n 178: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 181: checkcast #60 // class org/aoc2021/Day24$Multiply\n 184: invokevirtual #61 // Method org/aoc2021/Day24$Multiply.getB:()Lorg/aoc2021/Day24$Expression;\n 187: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 190: ifeq 247\n 193: aload_0\n 194: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 197: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 200: ifeq 247\n 203: aload_0\n 204: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 207: checkcast #60 // class org/aoc2021/Day24$Multiply\n 210: invokevirtual #61 // Method org/aoc2021/Day24$Multiply.getB:()Lorg/aoc2021/Day24$Expression;\n 213: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 216: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 219: aload_0\n 220: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 223: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 226: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 229: irem\n 230: ifne 247\n 233: new #35 // class org/aoc2021/Day24$LiteralValue\n 236: dup\n 237: iconst_0\n 238: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 241: checkcast #6 // class org/aoc2021/Day24$Expression\n 244: goto 293\n 247: aload_0\n 248: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 251: instanceof #63 // class org/aoc2021/Day24$Input\n 254: ifeq 289\n 257: aload_0\n 258: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 261: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 264: ifeq 289\n 267: aload_0\n 268: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 271: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 274: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 277: bipush 9\n 279: if_icmple 289\n 282: aload_0\n 283: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 286: goto 293\n 289: aload_0\n 290: checkcast #6 // class org/aoc2021/Day24$Expression\n 293: 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: bipush 40\n 9: invokevirtual #72 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 16: invokevirtual #75 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #77 // String %\n 21: invokevirtual #80 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 28: invokevirtual #75 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #72 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #82 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 39: areturn\n\n public final org.aoc2021.Day24$Expression component1();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final org.aoc2021.Day24$Expression component2();\n Code:\n 0: aload_0\n 1: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final org.aoc2021.Day24$Modulo copy(org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression);\n Code:\n 0: aload_1\n 1: ldc #11 // String a\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #19 // String b\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class org/aoc2021/Day24$Modulo\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: invokespecial #52 // Method \"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 21: areturn\n\n public static org.aoc2021.Day24$Modulo copy$default(org.aoc2021.Day24$Modulo, org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression, 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 #25 // Field a:Lorg/aoc2021/Day24$Expression;\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 b:Lorg/aoc2021/Day24$Expression;\n 21: astore_2\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokevirtual #90 // Method copy:(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)Lorg/aoc2021/Day24$Modulo;\n 28: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: invokevirtual #93 // 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 #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 16: invokevirtual #93 // 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 org/aoc2021/Day24$Modulo\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day24$Modulo\n 20: astore_2\n 21: aload_0\n 22: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 25: aload_2\n 26: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 29: invokestatic #46 // 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 b:Lorg/aoc2021/Day24$Expression;\n 41: aload_2\n 42: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 45: invokestatic #46 // 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": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day24$LiteralValue.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class org.aoc2021.Day24$LiteralValue implements org.aoc2021.Day24$Expression {\n private final int value;\n\n public org.aoc2021.Day24$LiteralValue(int);\n Code:\n 0: aload_0\n 1: invokespecial #11 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #15 // Field value:I\n 9: return\n\n public final int getValue();\n Code:\n 0: aload_0\n 1: getfield #15 // Field value:I\n 4: ireturn\n\n public org.aoc2021.Day24$LiteralValue simplify();\n Code:\n 0: aload_0\n 1: areturn\n\n public java.lang.String toString();\n Code:\n 0: aload_0\n 1: getfield #15 // Field value:I\n 4: invokestatic #30 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 7: areturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #15 // Field value:I\n 4: ireturn\n\n public final org.aoc2021.Day24$LiteralValue copy(int);\n Code:\n 0: new #2 // class org/aoc2021/Day24$LiteralValue\n 3: dup\n 4: iload_1\n 5: invokespecial #35 // Method \"<init>\":(I)V\n 8: areturn\n\n public static org.aoc2021.Day24$LiteralValue copy$default(org.aoc2021.Day24$LiteralValue, int, 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 #15 // Field value:I\n 10: istore_1\n 11: aload_0\n 12: iload_1\n 13: invokevirtual #39 // Method copy:(I)Lorg/aoc2021/Day24$LiteralValue;\n 16: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #15 // Field value:I\n 4: invokestatic #45 // Method java/lang/Integer.hashCode:(I)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 org/aoc2021/Day24$LiteralValue\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day24$LiteralValue\n 20: astore_2\n 21: aload_0\n 22: getfield #15 // Field value:I\n 25: aload_2\n 26: getfield #15 // Field value:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: iconst_1\n 35: ireturn\n\n public org.aoc2021.Day24$Expression simplify();\n Code:\n 0: aload_0\n 1: invokevirtual #53 // Method simplify:()Lorg/aoc2021/Day24$LiteralValue;\n 4: checkcast #6 // class org/aoc2021/Day24$Expression\n 7: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day24$Instruction.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class org.aoc2021.Day24$Instruction {\n private final java.lang.String operator;\n\n private final java.lang.String a;\n\n private final java.lang.String b;\n\n public org.aoc2021.Day24$Instruction(java.lang.String, java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #10 // String operator\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 a\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 operator:Ljava/lang/String;\n 21: aload_0\n 22: aload_2\n 23: putfield #26 // Field a:Ljava/lang/String;\n 26: aload_0\n 27: aload_3\n 28: putfield #29 // Field b:Ljava/lang/String;\n 31: return\n\n public org.aoc2021.Day24$Instruction(java.lang.String, java.lang.String, java.lang.String, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload 4\n 2: iconst_4\n 3: iand\n 4: ifeq 9\n 7: aconst_null\n 8: astore_3\n 9: aload_0\n 10: aload_1\n 11: aload_2\n 12: aload_3\n 13: invokespecial #34 // Method \"<init>\":(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V\n 16: return\n\n public final java.lang.String getOperator();\n Code:\n 0: aload_0\n 1: getfield #24 // Field operator:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.String getA();\n Code:\n 0: aload_0\n 1: getfield #26 // Field a:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.String getB();\n Code:\n 0: aload_0\n 1: getfield #29 // Field b:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.String component1();\n Code:\n 0: aload_0\n 1: getfield #24 // Field operator:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.String component2();\n Code:\n 0: aload_0\n 1: getfield #26 // Field a:Ljava/lang/String;\n 4: areturn\n\n public final java.lang.String component3();\n Code:\n 0: aload_0\n 1: getfield #29 // Field b:Ljava/lang/String;\n 4: areturn\n\n public final org.aoc2021.Day24$Instruction copy(java.lang.String, java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #10 // String operator\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 a\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class org/aoc2021/Day24$Instruction\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: aload_3\n 19: invokespecial #34 // Method \"<init>\":(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V\n 22: areturn\n\n public static org.aoc2021.Day24$Instruction copy$default(org.aoc2021.Day24$Instruction, java.lang.String, java.lang.String, java.lang.String, 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 operator: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 #26 // Field a:Ljava/lang/String;\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 #29 // Field b:Ljava/lang/String;\n 35: astore_3\n 36: aload_0\n 37: aload_1\n 38: aload_2\n 39: aload_3\n 40: invokevirtual #47 // Method copy:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lorg/aoc2021/Day24$Instruction;\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 Instruction(operator=\n 9: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #24 // Field operator:Ljava/lang/String;\n 16: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 19: ldc #59 // String , a=\n 21: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #26 // Field a:Ljava/lang/String;\n 28: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 31: ldc #61 // String , b=\n 33: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #29 // Field b:Ljava/lang/String;\n 40: invokevirtual #57 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #64 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #66 // 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 operator:Ljava/lang/String;\n 4: invokevirtual #72 // Method java/lang/String.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #26 // Field a:Ljava/lang/String;\n 16: invokevirtual #72 // 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 #29 // Field b:Ljava/lang/String;\n 29: ifnonnull 36\n 32: iconst_0\n 33: goto 43\n 36: aload_0\n 37: getfield #29 // Field b:Ljava/lang/String;\n 40: invokevirtual #72 // Method java/lang/String.hashCode:()I\n 43: iadd\n 44: istore_1\n 45: iload_1\n 46: 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 org/aoc2021/Day24$Instruction\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day24$Instruction\n 20: astore_2\n 21: aload_0\n 22: getfield #24 // Field operator:Ljava/lang/String;\n 25: aload_2\n 26: getfield #24 // Field operator:Ljava/lang/String;\n 29: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifne 37\n 35: iconst_0\n 36: ireturn\n 37: aload_0\n 38: getfield #26 // Field a:Ljava/lang/String;\n 41: aload_2\n 42: getfield #26 // Field a:Ljava/lang/String;\n 45: invokestatic #80 // 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 #29 // Field b:Ljava/lang/String;\n 57: aload_2\n 58: getfield #29 // Field b:Ljava/lang/String;\n 61: invokestatic #80 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 64: ifne 69\n 67: iconst_0\n 68: ireturn\n 69: iconst_1\n 70: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day24$Divide.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class org.aoc2021.Day24$Divide implements org.aoc2021.Day24$Expression {\n private final org.aoc2021.Day24$Expression a;\n\n private final org.aoc2021.Day24$Expression b;\n\n public org.aoc2021.Day24$Divide(org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression);\n Code:\n 0: aload_1\n 1: ldc #11 // String a\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #19 // String b\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokespecial #22 // Method java/lang/Object.\"<init>\":()V\n 16: aload_0\n 17: aload_1\n 18: putfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 21: aload_0\n 22: aload_2\n 23: putfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 26: return\n\n public final org.aoc2021.Day24$Expression getA();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final org.aoc2021.Day24$Expression getB();\n Code:\n 0: aload_0\n 1: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public org.aoc2021.Day24$Expression simplify();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 7: ifeq 54\n 10: aload_0\n 11: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 14: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 17: ifeq 54\n 20: new #35 // class org/aoc2021/Day24$LiteralValue\n 23: dup\n 24: aload_0\n 25: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 28: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 31: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 34: aload_0\n 35: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 38: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 41: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 44: idiv\n 45: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 48: checkcast #6 // class org/aoc2021/Day24$Expression\n 51: goto 509\n 54: aload_0\n 55: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 58: new #35 // class org/aoc2021/Day24$LiteralValue\n 61: dup\n 62: iconst_0\n 63: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 66: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 69: ifeq 86\n 72: new #35 // class org/aoc2021/Day24$LiteralValue\n 75: dup\n 76: iconst_0\n 77: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 80: checkcast #6 // class org/aoc2021/Day24$Expression\n 83: goto 509\n 86: aload_0\n 87: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 90: new #35 // class org/aoc2021/Day24$LiteralValue\n 93: dup\n 94: iconst_1\n 95: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 98: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 101: ifeq 111\n 104: aload_0\n 105: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 108: goto 509\n 111: aload_0\n 112: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 115: instanceof #48 // class org/aoc2021/Day24$Multiply\n 118: ifeq 237\n 121: aload_0\n 122: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 125: checkcast #48 // class org/aoc2021/Day24$Multiply\n 128: invokevirtual #50 // Method org/aoc2021/Day24$Multiply.getB:()Lorg/aoc2021/Day24$Expression;\n 131: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 134: ifeq 237\n 137: aload_0\n 138: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 141: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 144: ifeq 237\n 147: aload_0\n 148: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 151: checkcast #48 // class org/aoc2021/Day24$Multiply\n 154: invokevirtual #50 // Method org/aoc2021/Day24$Multiply.getB:()Lorg/aoc2021/Day24$Expression;\n 157: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 160: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 163: aload_0\n 164: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 167: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 170: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 173: irem\n 174: ifne 237\n 177: new #48 // class org/aoc2021/Day24$Multiply\n 180: dup\n 181: aload_0\n 182: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 185: checkcast #48 // class org/aoc2021/Day24$Multiply\n 188: invokevirtual #52 // Method org/aoc2021/Day24$Multiply.getA:()Lorg/aoc2021/Day24$Expression;\n 191: new #35 // class org/aoc2021/Day24$LiteralValue\n 194: dup\n 195: aload_0\n 196: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 199: checkcast #48 // class org/aoc2021/Day24$Multiply\n 202: invokevirtual #50 // Method org/aoc2021/Day24$Multiply.getB:()Lorg/aoc2021/Day24$Expression;\n 205: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 208: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 211: aload_0\n 212: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 215: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 218: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 221: idiv\n 222: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 225: checkcast #6 // class org/aoc2021/Day24$Expression\n 228: invokespecial #54 // Method org/aoc2021/Day24$Multiply.\"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 231: invokevirtual #56 // Method org/aoc2021/Day24$Multiply.simplify:()Lorg/aoc2021/Day24$Expression;\n 234: goto 509\n 237: aload_0\n 238: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 241: instanceof #58 // class org/aoc2021/Day24$Add\n 244: ifeq 335\n 247: aload_0\n 248: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 251: checkcast #58 // class org/aoc2021/Day24$Add\n 254: invokevirtual #59 // Method org/aoc2021/Day24$Add.getA:()Lorg/aoc2021/Day24$Expression;\n 257: instanceof #61 // class org/aoc2021/Day24$Input\n 260: ifeq 335\n 263: aload_0\n 264: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 267: checkcast #58 // class org/aoc2021/Day24$Add\n 270: invokevirtual #62 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 273: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 276: ifeq 335\n 279: aload_0\n 280: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 283: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 286: ifeq 335\n 289: aload_0\n 290: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 293: checkcast #58 // class org/aoc2021/Day24$Add\n 296: invokevirtual #62 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 299: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 302: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 305: aload_0\n 306: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 309: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 312: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 315: bipush 9\n 317: isub\n 318: if_icmpge 335\n 321: new #35 // class org/aoc2021/Day24$LiteralValue\n 324: dup\n 325: iconst_0\n 326: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 329: checkcast #6 // class org/aoc2021/Day24$Expression\n 332: goto 509\n 335: aload_0\n 336: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 339: instanceof #58 // class org/aoc2021/Day24$Add\n 342: ifeq 505\n 345: aload_0\n 346: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 349: checkcast #58 // class org/aoc2021/Day24$Add\n 352: invokevirtual #62 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 355: instanceof #58 // class org/aoc2021/Day24$Add\n 358: ifeq 505\n 361: aload_0\n 362: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 365: checkcast #58 // class org/aoc2021/Day24$Add\n 368: invokevirtual #62 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 371: checkcast #58 // class org/aoc2021/Day24$Add\n 374: invokevirtual #59 // Method org/aoc2021/Day24$Add.getA:()Lorg/aoc2021/Day24$Expression;\n 377: instanceof #61 // class org/aoc2021/Day24$Input\n 380: ifeq 505\n 383: aload_0\n 384: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 387: checkcast #58 // class org/aoc2021/Day24$Add\n 390: invokevirtual #62 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 393: checkcast #58 // class org/aoc2021/Day24$Add\n 396: invokevirtual #62 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 399: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 402: ifeq 505\n 405: aload_0\n 406: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 409: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 412: ifeq 505\n 415: aload_0\n 416: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 419: checkcast #58 // class org/aoc2021/Day24$Add\n 422: invokevirtual #62 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 425: checkcast #58 // class org/aoc2021/Day24$Add\n 428: invokevirtual #62 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 431: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 434: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 437: iflt 505\n 440: aload_0\n 441: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 444: checkcast #58 // class org/aoc2021/Day24$Add\n 447: invokevirtual #62 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 450: checkcast #58 // class org/aoc2021/Day24$Add\n 453: invokevirtual #62 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 456: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 459: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 462: aload_0\n 463: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 466: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 469: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 472: bipush 9\n 474: isub\n 475: if_icmpge 505\n 478: new #2 // class org/aoc2021/Day24$Divide\n 481: dup\n 482: aload_0\n 483: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 486: checkcast #58 // class org/aoc2021/Day24$Add\n 489: invokevirtual #59 // Method org/aoc2021/Day24$Add.getA:()Lorg/aoc2021/Day24$Expression;\n 492: aload_0\n 493: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 496: invokespecial #63 // Method \"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 499: invokevirtual #64 // Method simplify:()Lorg/aoc2021/Day24$Expression;\n 502: goto 509\n 505: aload_0\n 506: checkcast #6 // class org/aoc2021/Day24$Expression\n 509: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #68 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #69 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: bipush 40\n 9: invokevirtual #73 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 16: invokevirtual #76 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #78 // String /\n 21: invokevirtual #81 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 28: invokevirtual #76 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #73 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #83 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 39: areturn\n\n public final org.aoc2021.Day24$Expression component1();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final org.aoc2021.Day24$Expression component2();\n Code:\n 0: aload_0\n 1: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final org.aoc2021.Day24$Divide copy(org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression);\n Code:\n 0: aload_1\n 1: ldc #11 // String a\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #19 // String b\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class org/aoc2021/Day24$Divide\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: invokespecial #63 // Method \"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 21: areturn\n\n public static org.aoc2021.Day24$Divide copy$default(org.aoc2021.Day24$Divide, org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression, 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 #25 // Field a:Lorg/aoc2021/Day24$Expression;\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 b:Lorg/aoc2021/Day24$Expression;\n 21: astore_2\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokevirtual #91 // Method copy:(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)Lorg/aoc2021/Day24$Divide;\n 28: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: invokevirtual #94 // 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 #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 16: invokevirtual #94 // 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 org/aoc2021/Day24$Divide\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day24$Divide\n 20: astore_2\n 21: aload_0\n 22: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 25: aload_2\n 26: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 29: invokestatic #46 // 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 b:Lorg/aoc2021/Day24$Expression;\n 41: aload_2\n 42: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 45: invokestatic #46 // 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": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day24$Condition.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class org.aoc2021.Day24$Condition {\n private final org.aoc2021.Day24$Compare compare;\n\n private final boolean value;\n\n public org.aoc2021.Day24$Condition(org.aoc2021.Day24$Compare, boolean);\n Code:\n 0: aload_1\n 1: ldc #9 // String compare\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 compare:Lorg/aoc2021/Day24$Compare;\n 15: aload_0\n 16: iload_2\n 17: putfield #25 // Field value:Z\n 20: return\n\n public final org.aoc2021.Day24$Compare getCompare();\n Code:\n 0: aload_0\n 1: getfield #21 // Field compare:Lorg/aoc2021/Day24$Compare;\n 4: areturn\n\n public final boolean getValue();\n Code:\n 0: aload_0\n 1: getfield #25 // Field value:Z\n 4: ireturn\n\n public final org.aoc2021.Day24$Compare component1();\n Code:\n 0: aload_0\n 1: getfield #21 // Field compare:Lorg/aoc2021/Day24$Compare;\n 4: areturn\n\n public final boolean component2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field value:Z\n 4: ireturn\n\n public final org.aoc2021.Day24$Condition copy(org.aoc2021.Day24$Compare, boolean);\n Code:\n 0: aload_1\n 1: ldc #9 // String compare\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class org/aoc2021/Day24$Condition\n 9: dup\n 10: aload_1\n 11: iload_2\n 12: invokespecial #37 // Method \"<init>\":(Lorg/aoc2021/Day24$Compare;Z)V\n 15: areturn\n\n public static org.aoc2021.Day24$Condition copy$default(org.aoc2021.Day24$Condition, org.aoc2021.Day24$Compare, boolean, 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 #21 // Field compare:Lorg/aoc2021/Day24$Compare;\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 value:Z\n 21: istore_2\n 22: aload_0\n 23: aload_1\n 24: iload_2\n 25: invokevirtual #41 // Method copy:(Lorg/aoc2021/Day24$Compare;Z)Lorg/aoc2021/Day24$Condition;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #45 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #46 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #48 // String Condition(compare=\n 9: invokevirtual #52 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #21 // Field compare:Lorg/aoc2021/Day24$Compare;\n 16: invokevirtual #55 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #57 // String , value=\n 21: invokevirtual #52 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #25 // Field value:Z\n 28: invokevirtual #60 // Method java/lang/StringBuilder.append:(Z)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #63 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #65 // 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 #21 // Field compare:Lorg/aoc2021/Day24$Compare;\n 4: invokevirtual #71 // Method org/aoc2021/Day24$Compare.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 value:Z\n 16: invokestatic #76 // Method java/lang/Boolean.hashCode:(Z)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 org/aoc2021/Day24$Condition\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day24$Condition\n 20: astore_2\n 21: aload_0\n 22: getfield #21 // Field compare:Lorg/aoc2021/Day24$Compare;\n 25: aload_2\n 26: getfield #21 // Field compare:Lorg/aoc2021/Day24$Compare;\n 29: invokestatic #85 // 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 value:Z\n 41: aload_2\n 42: getfield #25 // Field value:Z\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: iconst_1\n 51: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day24$Expression.class",
"javap": "Compiled from \"Day24.kt\"\npublic interface org.aoc2021.Day24$Expression {\n public abstract org.aoc2021.Day24$Expression simplify();\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day24Kt.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class org.aoc2021.Day24Kt {\n private static final <K, V> java.util.Map<K, V> replaceKeyValue(java.util.Map<K, ? extends V>, K, V);\n Code:\n 0: aload_0\n 1: invokeinterface #13, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 6: checkcast #15 // class java/lang/Iterable\n 9: astore_3\n 10: iconst_0\n 11: istore 4\n 13: aload_3\n 14: bipush 10\n 16: invokestatic #21 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 19: invokestatic #27 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 22: bipush 16\n 24: invokestatic #33 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 27: istore 5\n 29: aload_3\n 30: astore 6\n 32: new #35 // class java/util/LinkedHashMap\n 35: dup\n 36: iload 5\n 38: invokespecial #39 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 41: checkcast #9 // class java/util/Map\n 44: astore 7\n 46: iconst_0\n 47: istore 8\n 49: aload 6\n 51: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 56: astore 9\n 58: aload 9\n 60: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 65: ifeq 156\n 68: aload 9\n 70: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 75: astore 10\n 77: aload 7\n 79: astore 11\n 81: aload 10\n 83: checkcast #55 // class java/util/Map$Entry\n 86: astore 12\n 88: iconst_0\n 89: istore 13\n 91: aload 12\n 93: invokeinterface #58, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 98: astore 14\n 100: aload 12\n 102: invokeinterface #61, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 107: astore 15\n 109: aload 14\n 111: aload_1\n 112: invokestatic #67 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 115: ifeq 126\n 118: aload_1\n 119: aload_2\n 120: invokestatic #73 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 123: goto 133\n 126: aload 14\n 128: aload 15\n 130: invokestatic #73 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 133: astore 12\n 135: aload 11\n 137: aload 12\n 139: invokevirtual #78 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 142: aload 12\n 144: invokevirtual #81 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 147: invokeinterface #85, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 152: pop\n 153: goto 58\n 156: aload 7\n 158: nop\n 159: areturn\n\n public static final java.util.Map access$replaceKeyValue(java.util.Map, java.lang.Object, java.lang.Object);\n Code:\n 0: aload_0\n 1: aload_1\n 2: aload_2\n 3: invokestatic #105 // Method replaceKeyValue:(Ljava/util/Map;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;\n 6: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day24$Input.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class org.aoc2021.Day24$Input implements org.aoc2021.Day24$Expression {\n private final int index;\n\n public org.aoc2021.Day24$Input(int);\n Code:\n 0: aload_0\n 1: invokespecial #11 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #15 // Field index:I\n 9: return\n\n public final int getIndex();\n Code:\n 0: aload_0\n 1: getfield #15 // Field index:I\n 4: ireturn\n\n public org.aoc2021.Day24$Input simplify();\n Code:\n 0: aload_0\n 1: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #26 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #27 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #29 // String input\n 9: invokevirtual #33 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #15 // Field index:I\n 16: invokevirtual #36 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: invokevirtual #38 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 22: areturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #15 // Field index:I\n 4: ireturn\n\n public final org.aoc2021.Day24$Input copy(int);\n Code:\n 0: new #2 // class org/aoc2021/Day24$Input\n 3: dup\n 4: iload_1\n 5: invokespecial #43 // Method \"<init>\":(I)V\n 8: areturn\n\n public static org.aoc2021.Day24$Input copy$default(org.aoc2021.Day24$Input, int, 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 #15 // Field index:I\n 10: istore_1\n 11: aload_0\n 12: iload_1\n 13: invokevirtual #47 // Method copy:(I)Lorg/aoc2021/Day24$Input;\n 16: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #15 // Field index:I\n 4: invokestatic #53 // Method java/lang/Integer.hashCode:(I)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 org/aoc2021/Day24$Input\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day24$Input\n 20: astore_2\n 21: aload_0\n 22: getfield #15 // Field index:I\n 25: aload_2\n 26: getfield #15 // Field index:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: iconst_1\n 35: ireturn\n\n public org.aoc2021.Day24$Expression simplify();\n Code:\n 0: aload_0\n 1: invokevirtual #61 // Method simplify:()Lorg/aoc2021/Day24$Input;\n 4: checkcast #6 // class org/aoc2021/Day24$Expression\n 7: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day24$Multiply.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class org.aoc2021.Day24$Multiply implements org.aoc2021.Day24$Expression {\n private final org.aoc2021.Day24$Expression a;\n\n private final org.aoc2021.Day24$Expression b;\n\n public org.aoc2021.Day24$Multiply(org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression);\n Code:\n 0: aload_1\n 1: ldc #11 // String a\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #19 // String b\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokespecial #22 // Method java/lang/Object.\"<init>\":()V\n 16: aload_0\n 17: aload_1\n 18: putfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 21: aload_0\n 22: aload_2\n 23: putfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 26: return\n\n public final org.aoc2021.Day24$Expression getA();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final org.aoc2021.Day24$Expression getB();\n Code:\n 0: aload_0\n 1: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public org.aoc2021.Day24$Expression simplify();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 7: ifeq 54\n 10: aload_0\n 11: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 14: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 17: ifeq 54\n 20: new #35 // class org/aoc2021/Day24$LiteralValue\n 23: dup\n 24: aload_0\n 25: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 28: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 31: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 34: aload_0\n 35: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 38: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 41: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 44: imul\n 45: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 48: checkcast #6 // class org/aoc2021/Day24$Expression\n 51: goto 254\n 54: aload_0\n 55: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 58: new #35 // class org/aoc2021/Day24$LiteralValue\n 61: dup\n 62: iconst_0\n 63: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 66: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 69: ifne 90\n 72: aload_0\n 73: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 76: new #35 // class org/aoc2021/Day24$LiteralValue\n 79: dup\n 80: iconst_0\n 81: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 84: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 87: ifeq 104\n 90: new #35 // class org/aoc2021/Day24$LiteralValue\n 93: dup\n 94: iconst_0\n 95: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 98: checkcast #6 // class org/aoc2021/Day24$Expression\n 101: goto 254\n 104: aload_0\n 105: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 108: new #35 // class org/aoc2021/Day24$LiteralValue\n 111: dup\n 112: iconst_1\n 113: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 116: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 119: ifeq 129\n 122: aload_0\n 123: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 126: goto 254\n 129: aload_0\n 130: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 133: new #35 // class org/aoc2021/Day24$LiteralValue\n 136: dup\n 137: iconst_1\n 138: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 141: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 144: ifeq 154\n 147: aload_0\n 148: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 151: goto 254\n 154: aload_0\n 155: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 158: instanceof #2 // class org/aoc2021/Day24$Multiply\n 161: ifeq 250\n 164: aload_0\n 165: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 168: checkcast #2 // class org/aoc2021/Day24$Multiply\n 171: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 174: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 177: ifeq 250\n 180: aload_0\n 181: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 184: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 187: ifeq 250\n 190: new #2 // class org/aoc2021/Day24$Multiply\n 193: dup\n 194: aload_0\n 195: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 198: checkcast #2 // class org/aoc2021/Day24$Multiply\n 201: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 204: new #35 // class org/aoc2021/Day24$LiteralValue\n 207: dup\n 208: aload_0\n 209: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 212: checkcast #2 // class org/aoc2021/Day24$Multiply\n 215: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 218: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 221: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 224: aload_0\n 225: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 228: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 231: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 234: imul\n 235: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 238: checkcast #6 // class org/aoc2021/Day24$Expression\n 241: invokespecial #48 // Method \"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 244: invokevirtual #50 // Method simplify:()Lorg/aoc2021/Day24$Expression;\n 247: goto 254\n 250: aload_0\n 251: checkcast #6 // class org/aoc2021/Day24$Expression\n 254: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #54 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #55 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: bipush 40\n 9: invokevirtual #59 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 16: invokevirtual #62 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #64 // String *\n 21: invokevirtual #67 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 28: invokevirtual #62 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #59 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #69 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 39: areturn\n\n public final org.aoc2021.Day24$Expression component1();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final org.aoc2021.Day24$Expression component2();\n Code:\n 0: aload_0\n 1: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final org.aoc2021.Day24$Multiply copy(org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression);\n Code:\n 0: aload_1\n 1: ldc #11 // String a\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #19 // String b\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class org/aoc2021/Day24$Multiply\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: invokespecial #48 // Method \"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 21: areturn\n\n public static org.aoc2021.Day24$Multiply copy$default(org.aoc2021.Day24$Multiply, org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression, 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 #25 // Field a:Lorg/aoc2021/Day24$Expression;\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 b:Lorg/aoc2021/Day24$Expression;\n 21: astore_2\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokevirtual #77 // Method copy:(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)Lorg/aoc2021/Day24$Multiply;\n 28: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: invokevirtual #80 // 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 #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 16: invokevirtual #80 // 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 org/aoc2021/Day24$Multiply\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day24$Multiply\n 20: astore_2\n 21: aload_0\n 22: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 25: aload_2\n 26: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 29: invokestatic #46 // 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 b:Lorg/aoc2021/Day24$Expression;\n 41: aload_2\n 42: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 45: invokestatic #46 // 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": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day24$Add.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class org.aoc2021.Day24$Add implements org.aoc2021.Day24$Expression {\n private final org.aoc2021.Day24$Expression a;\n\n private final org.aoc2021.Day24$Expression b;\n\n public org.aoc2021.Day24$Add(org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression);\n Code:\n 0: aload_1\n 1: ldc #11 // String a\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #19 // String b\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokespecial #22 // Method java/lang/Object.\"<init>\":()V\n 16: aload_0\n 17: aload_1\n 18: putfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 21: aload_0\n 22: aload_2\n 23: putfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 26: return\n\n public final org.aoc2021.Day24$Expression getA();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final org.aoc2021.Day24$Expression getB();\n Code:\n 0: aload_0\n 1: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public org.aoc2021.Day24$Expression simplify();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 7: ifeq 54\n 10: aload_0\n 11: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 14: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 17: ifeq 54\n 20: new #35 // class org/aoc2021/Day24$LiteralValue\n 23: dup\n 24: aload_0\n 25: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 28: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 31: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 34: aload_0\n 35: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 38: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 41: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 44: iadd\n 45: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 48: checkcast #6 // class org/aoc2021/Day24$Expression\n 51: goto 204\n 54: aload_0\n 55: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 58: new #35 // class org/aoc2021/Day24$LiteralValue\n 61: dup\n 62: iconst_0\n 63: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 66: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 69: ifeq 79\n 72: aload_0\n 73: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 76: goto 204\n 79: aload_0\n 80: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 83: new #35 // class org/aoc2021/Day24$LiteralValue\n 86: dup\n 87: iconst_0\n 88: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 91: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 94: ifeq 104\n 97: aload_0\n 98: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 101: goto 204\n 104: aload_0\n 105: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 108: instanceof #2 // class org/aoc2021/Day24$Add\n 111: ifeq 200\n 114: aload_0\n 115: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 118: checkcast #2 // class org/aoc2021/Day24$Add\n 121: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 124: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 127: ifeq 200\n 130: aload_0\n 131: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 134: instanceof #35 // class org/aoc2021/Day24$LiteralValue\n 137: ifeq 200\n 140: new #2 // class org/aoc2021/Day24$Add\n 143: dup\n 144: aload_0\n 145: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 148: checkcast #2 // class org/aoc2021/Day24$Add\n 151: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 154: new #35 // class org/aoc2021/Day24$LiteralValue\n 157: dup\n 158: aload_0\n 159: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 162: checkcast #2 // class org/aoc2021/Day24$Add\n 165: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 168: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 171: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 174: aload_0\n 175: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 178: checkcast #35 // class org/aoc2021/Day24$LiteralValue\n 181: invokevirtual #39 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 184: iadd\n 185: invokespecial #42 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 188: checkcast #6 // class org/aoc2021/Day24$Expression\n 191: invokespecial #48 // Method \"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 194: invokevirtual #50 // Method simplify:()Lorg/aoc2021/Day24$Expression;\n 197: goto 204\n 200: aload_0\n 201: checkcast #6 // class org/aoc2021/Day24$Expression\n 204: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #54 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #55 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: bipush 40\n 9: invokevirtual #59 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 16: invokevirtual #62 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #64 // String +\n 21: invokevirtual #67 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 28: invokevirtual #62 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #59 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #69 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 39: areturn\n\n public final org.aoc2021.Day24$Expression component1();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final org.aoc2021.Day24$Expression component2();\n Code:\n 0: aload_0\n 1: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 4: areturn\n\n public final org.aoc2021.Day24$Add copy(org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression);\n Code:\n 0: aload_1\n 1: ldc #11 // String a\n 3: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #19 // String b\n 9: invokestatic #17 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class org/aoc2021/Day24$Add\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: invokespecial #48 // Method \"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 21: areturn\n\n public static org.aoc2021.Day24$Add copy$default(org.aoc2021.Day24$Add, org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression, 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 #25 // Field a:Lorg/aoc2021/Day24$Expression;\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 b:Lorg/aoc2021/Day24$Expression;\n 21: astore_2\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokevirtual #77 // Method copy:(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)Lorg/aoc2021/Day24$Add;\n 28: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 4: invokevirtual #80 // 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 #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 16: invokevirtual #80 // 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 org/aoc2021/Day24$Add\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day24$Add\n 20: astore_2\n 21: aload_0\n 22: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 25: aload_2\n 26: getfield #25 // Field a:Lorg/aoc2021/Day24$Expression;\n 29: invokestatic #46 // 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 b:Lorg/aoc2021/Day24$Expression;\n 41: aload_2\n 42: getfield #27 // Field b:Lorg/aoc2021/Day24$Expression;\n 45: invokestatic #46 // 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": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day24.class",
"javap": "Compiled from \"Day24.kt\"\npublic final class org.aoc2021.Day24 {\n public static final org.aoc2021.Day24 INSTANCE;\n\n private org.aoc2021.Day24();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final java.lang.String solve(java.util.List<java.lang.String>, boolean);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #17 // Method parseProgram:(Ljava/util/List;)Ljava/util/List;\n 5: astore_3\n 6: aload_0\n 7: aload_3\n 8: aconst_null\n 9: iconst_0\n 10: iconst_0\n 11: aconst_null\n 12: bipush 30\n 14: aconst_null\n 15: invokestatic #21 // Method generateExpressions$default:(Lorg/aoc2021/Day24;Ljava/util/List;Ljava/util/Map;IILjava/util/List;ILjava/lang/Object;)Ljava/util/List;\n 18: astore 4\n 20: aload 4\n 22: checkcast #23 // class java/lang/Iterable\n 25: astore 6\n 27: aload 6\n 29: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 34: astore 7\n 36: aload 7\n 38: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 43: ifeq 103\n 46: aload 7\n 48: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 53: astore 8\n 55: aload 8\n 57: checkcast #39 // class kotlin/Pair\n 60: astore 9\n 62: iconst_0\n 63: istore 10\n 65: aload 9\n 67: invokevirtual #42 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 70: checkcast #44 // class java/util/Map\n 73: astore 11\n 75: aload 11\n 77: ldc #46 // String z\n 79: invokeinterface #50, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 84: new #52 // class org/aoc2021/Day24$LiteralValue\n 87: dup\n 88: iconst_0\n 89: invokespecial #55 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 92: invokestatic #61 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 95: ifeq 36\n 98: aload 8\n 100: goto 104\n 103: aconst_null\n 104: checkcast #39 // class kotlin/Pair\n 107: astore 5\n 109: aload 5\n 111: ifnull 857\n 114: aload 5\n 116: astore 6\n 118: iconst_0\n 119: istore 7\n 121: aload 6\n 123: invokevirtual #64 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 126: checkcast #66 // class java/util/List\n 129: astore 8\n 131: aload 8\n 133: checkcast #23 // class java/lang/Iterable\n 136: astore 9\n 138: iconst_0\n 139: istore 10\n 141: aload 9\n 143: instanceof #68 // class java/util/Collection\n 146: ifeq 166\n 149: aload 9\n 151: checkcast #68 // class java/util/Collection\n 154: invokeinterface #71, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 159: ifeq 166\n 162: iconst_0\n 163: goto 225\n 166: aload 9\n 168: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 173: astore 11\n 175: aload 11\n 177: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 182: ifeq 224\n 185: aload 11\n 187: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 192: astore 12\n 194: aload 12\n 196: checkcast #73 // class org/aoc2021/Day24$Condition\n 199: astore 13\n 201: iconst_0\n 202: istore 14\n 204: aload 13\n 206: invokevirtual #76 // Method org/aoc2021/Day24$Condition.getValue:()Z\n 209: ifne 216\n 212: iconst_1\n 213: goto 217\n 216: iconst_0\n 217: ifeq 175\n 220: iconst_1\n 221: goto 225\n 224: iconst_0\n 225: ifeq 256\n 228: new #78 // class java/lang/IllegalStateException\n 231: dup\n 232: new #80 // class java/lang/StringBuilder\n 235: dup\n 236: invokespecial #81 // Method java/lang/StringBuilder.\"<init>\":()V\n 239: ldc #83 // String unexpected condition:\n 241: invokevirtual #87 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 244: aload 8\n 246: invokevirtual #90 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 249: invokevirtual #94 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 252: invokespecial #97 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 255: athrow\n 256: iconst_0\n 257: istore 10\n 259: bipush 14\n 261: anewarray #99 // class java/lang/Integer\n 264: astore 11\n 266: iload 10\n 268: bipush 14\n 270: if_icmpge 292\n 273: iload 10\n 275: istore 12\n 277: aload 11\n 279: iload 12\n 281: iconst_0\n 282: invokestatic #103 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 285: aastore\n 286: iinc 10, 1\n 289: goto 266\n 292: aload 11\n 294: astore 9\n 296: aload 8\n 298: checkcast #23 // class java/lang/Iterable\n 301: astore 10\n 303: iconst_0\n 304: istore 11\n 306: aload 10\n 308: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 313: astore 12\n 315: aload 12\n 317: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 322: ifeq 739\n 325: aload 12\n 327: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 332: astore 13\n 334: aload 13\n 336: checkcast #73 // class org/aoc2021/Day24$Condition\n 339: astore 14\n 341: iconst_0\n 342: istore 15\n 344: aload 14\n 346: invokevirtual #107 // Method org/aoc2021/Day24$Condition.getCompare:()Lorg/aoc2021/Day24$Compare;\n 349: invokevirtual #113 // Method org/aoc2021/Day24$Compare.getA:()Lorg/aoc2021/Day24$Expression;\n 352: instanceof #115 // class org/aoc2021/Day24$Input\n 355: ifeq 408\n 358: new #109 // class org/aoc2021/Day24$Compare\n 361: dup\n 362: new #117 // class org/aoc2021/Day24$Add\n 365: dup\n 366: aload 14\n 368: invokevirtual #107 // Method org/aoc2021/Day24$Condition.getCompare:()Lorg/aoc2021/Day24$Compare;\n 371: invokevirtual #113 // Method org/aoc2021/Day24$Compare.getA:()Lorg/aoc2021/Day24$Expression;\n 374: new #52 // class org/aoc2021/Day24$LiteralValue\n 377: dup\n 378: iconst_0\n 379: invokespecial #55 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 382: checkcast #119 // class org/aoc2021/Day24$Expression\n 385: invokespecial #122 // Method org/aoc2021/Day24$Add.\"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 388: checkcast #119 // class org/aoc2021/Day24$Expression\n 391: aload 14\n 393: invokevirtual #107 // Method org/aoc2021/Day24$Condition.getCompare:()Lorg/aoc2021/Day24$Compare;\n 396: invokevirtual #125 // Method org/aoc2021/Day24$Compare.getB:()Lorg/aoc2021/Day24$Expression;\n 399: iconst_0\n 400: iconst_4\n 401: aconst_null\n 402: invokespecial #128 // Method org/aoc2021/Day24$Compare.\"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 405: goto 413\n 408: aload 14\n 410: invokevirtual #107 // Method org/aoc2021/Day24$Condition.getCompare:()Lorg/aoc2021/Day24$Compare;\n 413: astore 16\n 415: aload 16\n 417: invokevirtual #113 // Method org/aoc2021/Day24$Compare.getA:()Lorg/aoc2021/Day24$Expression;\n 420: instanceof #117 // class org/aoc2021/Day24$Add\n 423: ifeq 471\n 426: aload 16\n 428: invokevirtual #113 // Method org/aoc2021/Day24$Compare.getA:()Lorg/aoc2021/Day24$Expression;\n 431: checkcast #117 // class org/aoc2021/Day24$Add\n 434: invokevirtual #129 // Method org/aoc2021/Day24$Add.getA:()Lorg/aoc2021/Day24$Expression;\n 437: instanceof #115 // class org/aoc2021/Day24$Input\n 440: ifeq 471\n 443: aload 16\n 445: invokevirtual #113 // Method org/aoc2021/Day24$Compare.getA:()Lorg/aoc2021/Day24$Expression;\n 448: checkcast #117 // class org/aoc2021/Day24$Add\n 451: invokevirtual #130 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 454: instanceof #52 // class org/aoc2021/Day24$LiteralValue\n 457: ifeq 471\n 460: aload 16\n 462: invokevirtual #125 // Method org/aoc2021/Day24$Compare.getB:()Lorg/aoc2021/Day24$Expression;\n 465: instanceof #115 // class org/aoc2021/Day24$Input\n 468: ifne 499\n 471: new #78 // class java/lang/IllegalStateException\n 474: dup\n 475: new #80 // class java/lang/StringBuilder\n 478: dup\n 479: invokespecial #81 // Method java/lang/StringBuilder.\"<init>\":()V\n 482: ldc #132 // String unexpected compare:\n 484: invokevirtual #87 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 487: aload 16\n 489: invokevirtual #90 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 492: invokevirtual #94 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 495: invokespecial #97 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 498: athrow\n 499: aload 16\n 501: invokevirtual #113 // Method org/aoc2021/Day24$Compare.getA:()Lorg/aoc2021/Day24$Expression;\n 504: checkcast #117 // class org/aoc2021/Day24$Add\n 507: invokevirtual #130 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 510: checkcast #52 // class org/aoc2021/Day24$LiteralValue\n 513: invokevirtual #135 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 516: ifge 631\n 519: aload 9\n 521: aload 16\n 523: invokevirtual #113 // Method org/aoc2021/Day24$Compare.getA:()Lorg/aoc2021/Day24$Expression;\n 526: checkcast #117 // class org/aoc2021/Day24$Add\n 529: invokevirtual #129 // Method org/aoc2021/Day24$Add.getA:()Lorg/aoc2021/Day24$Expression;\n 532: checkcast #115 // class org/aoc2021/Day24$Input\n 535: invokevirtual #138 // Method org/aoc2021/Day24$Input.getIndex:()I\n 538: iload_2\n 539: ifeq 547\n 542: bipush 9\n 544: goto 566\n 547: iconst_1\n 548: aload 16\n 550: invokevirtual #113 // Method org/aoc2021/Day24$Compare.getA:()Lorg/aoc2021/Day24$Expression;\n 553: checkcast #117 // class org/aoc2021/Day24$Add\n 556: invokevirtual #130 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 559: checkcast #52 // class org/aoc2021/Day24$LiteralValue\n 562: invokevirtual #135 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 565: isub\n 566: invokestatic #103 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 569: aastore\n 570: aload 9\n 572: aload 16\n 574: invokevirtual #125 // Method org/aoc2021/Day24$Compare.getB:()Lorg/aoc2021/Day24$Expression;\n 577: checkcast #115 // class org/aoc2021/Day24$Input\n 580: invokevirtual #138 // Method org/aoc2021/Day24$Input.getIndex:()I\n 583: aload 9\n 585: aload 16\n 587: invokevirtual #113 // Method org/aoc2021/Day24$Compare.getA:()Lorg/aoc2021/Day24$Expression;\n 590: checkcast #117 // class org/aoc2021/Day24$Add\n 593: invokevirtual #129 // Method org/aoc2021/Day24$Add.getA:()Lorg/aoc2021/Day24$Expression;\n 596: checkcast #115 // class org/aoc2021/Day24$Input\n 599: invokevirtual #138 // Method org/aoc2021/Day24$Input.getIndex:()I\n 602: aaload\n 603: invokevirtual #141 // Method java/lang/Integer.intValue:()I\n 606: aload 16\n 608: invokevirtual #113 // Method org/aoc2021/Day24$Compare.getA:()Lorg/aoc2021/Day24$Expression;\n 611: checkcast #117 // class org/aoc2021/Day24$Add\n 614: invokevirtual #130 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 617: checkcast #52 // class org/aoc2021/Day24$LiteralValue\n 620: invokevirtual #135 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 623: iadd\n 624: invokestatic #103 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 627: aastore\n 628: goto 734\n 631: aload 9\n 633: aload 16\n 635: invokevirtual #125 // Method org/aoc2021/Day24$Compare.getB:()Lorg/aoc2021/Day24$Expression;\n 638: checkcast #115 // class org/aoc2021/Day24$Input\n 641: invokevirtual #138 // Method org/aoc2021/Day24$Input.getIndex:()I\n 644: iload_2\n 645: ifeq 653\n 648: bipush 9\n 650: goto 672\n 653: iconst_1\n 654: aload 16\n 656: invokevirtual #113 // Method org/aoc2021/Day24$Compare.getA:()Lorg/aoc2021/Day24$Expression;\n 659: checkcast #117 // class org/aoc2021/Day24$Add\n 662: invokevirtual #130 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 665: checkcast #52 // class org/aoc2021/Day24$LiteralValue\n 668: invokevirtual #135 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 671: iadd\n 672: invokestatic #103 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 675: aastore\n 676: aload 9\n 678: aload 16\n 680: invokevirtual #113 // Method org/aoc2021/Day24$Compare.getA:()Lorg/aoc2021/Day24$Expression;\n 683: checkcast #117 // class org/aoc2021/Day24$Add\n 686: invokevirtual #129 // Method org/aoc2021/Day24$Add.getA:()Lorg/aoc2021/Day24$Expression;\n 689: checkcast #115 // class org/aoc2021/Day24$Input\n 692: invokevirtual #138 // Method org/aoc2021/Day24$Input.getIndex:()I\n 695: aload 9\n 697: aload 16\n 699: invokevirtual #125 // Method org/aoc2021/Day24$Compare.getB:()Lorg/aoc2021/Day24$Expression;\n 702: checkcast #115 // class org/aoc2021/Day24$Input\n 705: invokevirtual #138 // Method org/aoc2021/Day24$Input.getIndex:()I\n 708: aaload\n 709: invokevirtual #141 // Method java/lang/Integer.intValue:()I\n 712: aload 16\n 714: invokevirtual #113 // Method org/aoc2021/Day24$Compare.getA:()Lorg/aoc2021/Day24$Expression;\n 717: checkcast #117 // class org/aoc2021/Day24$Add\n 720: invokevirtual #130 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 723: checkcast #52 // class org/aoc2021/Day24$LiteralValue\n 726: invokevirtual #135 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 729: isub\n 730: invokestatic #103 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 733: aastore\n 734: nop\n 735: nop\n 736: goto 315\n 739: nop\n 740: aload 9\n 742: astore 10\n 744: iconst_0\n 745: istore 11\n 747: aload 10\n 749: astore 12\n 751: new #143 // class java/util/ArrayList\n 754: dup\n 755: aload 10\n 757: arraylength\n 758: invokespecial #144 // Method java/util/ArrayList.\"<init>\":(I)V\n 761: checkcast #68 // class java/util/Collection\n 764: astore 13\n 766: iconst_0\n 767: istore 14\n 769: iconst_0\n 770: istore 15\n 772: aload 12\n 774: arraylength\n 775: istore 16\n 777: iload 15\n 779: iload 16\n 781: if_icmpge 831\n 784: aload 12\n 786: iload 15\n 788: aaload\n 789: astore 17\n 791: aload 13\n 793: aload 17\n 795: checkcast #146 // class java/lang/Number\n 798: invokevirtual #147 // Method java/lang/Number.intValue:()I\n 801: istore 18\n 803: astore 19\n 805: iconst_0\n 806: istore 20\n 808: iload 18\n 810: invokestatic #153 // Method kotlin/text/CharsKt.digitToChar:(I)C\n 813: invokestatic #158 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 816: aload 19\n 818: swap\n 819: invokeinterface #162, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 824: pop\n 825: iinc 15, 1\n 828: goto 777\n 831: aload 13\n 833: checkcast #66 // class java/util/List\n 836: nop\n 837: checkcast #23 // class java/lang/Iterable\n 840: ldc #164 // String\n 842: checkcast #166 // class java/lang/CharSequence\n 845: aconst_null\n 846: aconst_null\n 847: iconst_0\n 848: aconst_null\n 849: aconst_null\n 850: bipush 62\n 852: aconst_null\n 853: invokestatic #172 // 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 856: areturn\n 857: new #174 // class java/lang/IllegalArgumentException\n 860: dup\n 861: ldc #176 // String no solution found\n 863: invokespecial #177 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 866: athrow\n\n private final boolean isConditionImpossible(org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression);\n Code:\n 0: aload_2\n 1: instanceof #115 // class org/aoc2021/Day24$Input\n 4: ifne 9\n 7: iconst_0\n 8: ireturn\n 9: aload_1\n 10: instanceof #52 // class org/aoc2021/Day24$LiteralValue\n 13: ifeq 41\n 16: aload_1\n 17: checkcast #52 // class org/aoc2021/Day24$LiteralValue\n 20: invokevirtual #135 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 23: iconst_1\n 24: if_icmplt 39\n 27: aload_1\n 28: checkcast #52 // class org/aoc2021/Day24$LiteralValue\n 31: invokevirtual #135 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 34: bipush 9\n 36: if_icmple 41\n 39: iconst_1\n 40: ireturn\n 41: aload_1\n 42: instanceof #117 // class org/aoc2021/Day24$Add\n 45: ifeq 94\n 48: aload_1\n 49: checkcast #117 // class org/aoc2021/Day24$Add\n 52: invokevirtual #129 // Method org/aoc2021/Day24$Add.getA:()Lorg/aoc2021/Day24$Expression;\n 55: instanceof #115 // class org/aoc2021/Day24$Input\n 58: ifeq 94\n 61: aload_1\n 62: checkcast #117 // class org/aoc2021/Day24$Add\n 65: invokevirtual #130 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 68: instanceof #52 // class org/aoc2021/Day24$LiteralValue\n 71: ifeq 94\n 74: aload_1\n 75: checkcast #117 // class org/aoc2021/Day24$Add\n 78: invokevirtual #130 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 81: checkcast #52 // class org/aoc2021/Day24$LiteralValue\n 84: invokevirtual #135 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 87: bipush 9\n 89: if_icmplt 94\n 92: iconst_1\n 93: ireturn\n 94: aload_1\n 95: instanceof #117 // class org/aoc2021/Day24$Add\n 98: ifeq 147\n 101: aload_1\n 102: checkcast #117 // class org/aoc2021/Day24$Add\n 105: invokevirtual #129 // Method org/aoc2021/Day24$Add.getA:()Lorg/aoc2021/Day24$Expression;\n 108: instanceof #220 // class org/aoc2021/Day24$Modulo\n 111: ifeq 147\n 114: aload_1\n 115: checkcast #117 // class org/aoc2021/Day24$Add\n 118: invokevirtual #130 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 121: instanceof #52 // class org/aoc2021/Day24$LiteralValue\n 124: ifeq 147\n 127: aload_1\n 128: checkcast #117 // class org/aoc2021/Day24$Add\n 131: invokevirtual #130 // Method org/aoc2021/Day24$Add.getB:()Lorg/aoc2021/Day24$Expression;\n 134: checkcast #52 // class org/aoc2021/Day24$LiteralValue\n 137: invokevirtual #135 // Method org/aoc2021/Day24$LiteralValue.getValue:()I\n 140: bipush 9\n 142: if_icmple 147\n 145: iconst_1\n 146: ireturn\n 147: iconst_0\n 148: ireturn\n\n private final java.util.List<kotlin.Pair<java.util.List<org.aoc2021.Day24$Condition>, java.util.Map<java.lang.String, org.aoc2021.Day24$Expression>>> generateExpressions(java.util.List<org.aoc2021.Day24$Instruction>, java.util.Map<java.lang.String, ? extends org.aoc2021.Day24$Expression>, int, int, java.util.List<org.aoc2021.Day24$Condition>);\n Code:\n 0: aload_2\n 1: invokestatic #232 // Method kotlin/collections/MapsKt.toMutableMap:(Ljava/util/Map;)Ljava/util/Map;\n 4: astore 6\n 6: iload 4\n 8: istore 7\n 10: iload_3\n 11: istore 8\n 13: aload_1\n 14: invokeinterface #235, 1 // InterfaceMethod java/util/List.size:()I\n 19: istore 9\n 21: iload 8\n 23: iload 9\n 25: if_icmpge 701\n 28: aload_1\n 29: iload 8\n 31: invokeinterface #238, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 36: checkcast #240 // class org/aoc2021/Day24$Instruction\n 39: astore 10\n 41: aload 10\n 43: invokevirtual #243 // Method org/aoc2021/Day24$Instruction.getOperator:()Ljava/lang/String;\n 46: astore 11\n 48: aload 11\n 50: invokevirtual #248 // Method java/lang/String.hashCode:()I\n 53: lookupswitch { // 6\n 96417: 112\n 99473: 125\n 100672: 138\n 104427: 180\n 108290: 152\n 108484: 166\n default: 695\n }\n 112: aload 11\n 114: ldc #249 // String add\n 116: invokevirtual #252 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 119: ifne 219\n 122: goto 695\n 125: aload 11\n 127: ldc #254 // String div\n 129: invokevirtual #252 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 132: ifne 355\n 135: goto 695\n 138: aload 11\n 140: ldc_w #256 // String eql\n 143: invokevirtual #252 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 146: ifne 491\n 149: goto 695\n 152: aload 11\n 154: ldc_w #258 // String mod\n 157: invokevirtual #252 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 160: ifne 423\n 163: goto 695\n 166: aload 11\n 168: ldc_w #260 // String mul\n 171: invokevirtual #252 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 174: ifne 287\n 177: goto 695\n 180: aload 11\n 182: ldc_w #262 // String inp\n 185: invokevirtual #252 // Method java/lang/String.equals:(Ljava/lang/Object;)Z\n 188: ifeq 695\n 191: aload 6\n 193: aload 10\n 195: invokevirtual #264 // Method org/aoc2021/Day24$Instruction.getA:()Ljava/lang/String;\n 198: new #115 // class org/aoc2021/Day24$Input\n 201: dup\n 202: iload 7\n 204: invokespecial #265 // Method org/aoc2021/Day24$Input.\"<init>\":(I)V\n 207: invokeinterface #269, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 212: pop\n 213: iinc 7, 1\n 216: goto 695\n 219: aload 6\n 221: aload 10\n 223: invokevirtual #264 // Method org/aoc2021/Day24$Instruction.getA:()Ljava/lang/String;\n 226: invokeinterface #50, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 231: dup\n 232: invokestatic #273 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 235: checkcast #119 // class org/aoc2021/Day24$Expression\n 238: astore 12\n 240: aload_0\n 241: aload 10\n 243: invokevirtual #275 // Method org/aoc2021/Day24$Instruction.getB:()Ljava/lang/String;\n 246: dup\n 247: invokestatic #273 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 250: aload 6\n 252: invokespecial #279 // Method getExpressionValueOf:(Ljava/lang/String;Ljava/util/Map;)Lorg/aoc2021/Day24$Expression;\n 255: astore 13\n 257: aload 6\n 259: aload 10\n 261: invokevirtual #264 // Method org/aoc2021/Day24$Instruction.getA:()Ljava/lang/String;\n 264: new #117 // class org/aoc2021/Day24$Add\n 267: dup\n 268: aload 12\n 270: aload 13\n 272: invokespecial #122 // Method org/aoc2021/Day24$Add.\"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 275: invokevirtual #282 // Method org/aoc2021/Day24$Add.simplify:()Lorg/aoc2021/Day24$Expression;\n 278: invokeinterface #269, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 283: pop\n 284: goto 695\n 287: aload 6\n 289: aload 10\n 291: invokevirtual #264 // Method org/aoc2021/Day24$Instruction.getA:()Ljava/lang/String;\n 294: invokeinterface #50, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 299: dup\n 300: invokestatic #273 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 303: checkcast #119 // class org/aoc2021/Day24$Expression\n 306: astore 12\n 308: aload_0\n 309: aload 10\n 311: invokevirtual #275 // Method org/aoc2021/Day24$Instruction.getB:()Ljava/lang/String;\n 314: dup\n 315: invokestatic #273 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 318: aload 6\n 320: invokespecial #279 // Method getExpressionValueOf:(Ljava/lang/String;Ljava/util/Map;)Lorg/aoc2021/Day24$Expression;\n 323: astore 13\n 325: aload 6\n 327: aload 10\n 329: invokevirtual #264 // Method org/aoc2021/Day24$Instruction.getA:()Ljava/lang/String;\n 332: new #284 // class org/aoc2021/Day24$Multiply\n 335: dup\n 336: aload 12\n 338: aload 13\n 340: invokespecial #285 // Method org/aoc2021/Day24$Multiply.\"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 343: invokevirtual #286 // Method org/aoc2021/Day24$Multiply.simplify:()Lorg/aoc2021/Day24$Expression;\n 346: invokeinterface #269, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 351: pop\n 352: goto 695\n 355: aload 6\n 357: aload 10\n 359: invokevirtual #264 // Method org/aoc2021/Day24$Instruction.getA:()Ljava/lang/String;\n 362: invokeinterface #50, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 367: dup\n 368: invokestatic #273 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 371: checkcast #119 // class org/aoc2021/Day24$Expression\n 374: astore 12\n 376: aload_0\n 377: aload 10\n 379: invokevirtual #275 // Method org/aoc2021/Day24$Instruction.getB:()Ljava/lang/String;\n 382: dup\n 383: invokestatic #273 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 386: aload 6\n 388: invokespecial #279 // Method getExpressionValueOf:(Ljava/lang/String;Ljava/util/Map;)Lorg/aoc2021/Day24$Expression;\n 391: astore 13\n 393: aload 6\n 395: aload 10\n 397: invokevirtual #264 // Method org/aoc2021/Day24$Instruction.getA:()Ljava/lang/String;\n 400: new #288 // class org/aoc2021/Day24$Divide\n 403: dup\n 404: aload 12\n 406: aload 13\n 408: invokespecial #289 // Method org/aoc2021/Day24$Divide.\"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 411: invokevirtual #290 // Method org/aoc2021/Day24$Divide.simplify:()Lorg/aoc2021/Day24$Expression;\n 414: invokeinterface #269, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 419: pop\n 420: goto 695\n 423: aload 6\n 425: aload 10\n 427: invokevirtual #264 // Method org/aoc2021/Day24$Instruction.getA:()Ljava/lang/String;\n 430: invokeinterface #50, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 435: dup\n 436: invokestatic #273 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 439: checkcast #119 // class org/aoc2021/Day24$Expression\n 442: astore 12\n 444: aload_0\n 445: aload 10\n 447: invokevirtual #275 // Method org/aoc2021/Day24$Instruction.getB:()Ljava/lang/String;\n 450: dup\n 451: invokestatic #273 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 454: aload 6\n 456: invokespecial #279 // Method getExpressionValueOf:(Ljava/lang/String;Ljava/util/Map;)Lorg/aoc2021/Day24$Expression;\n 459: astore 13\n 461: aload 6\n 463: aload 10\n 465: invokevirtual #264 // Method org/aoc2021/Day24$Instruction.getA:()Ljava/lang/String;\n 468: new #220 // class org/aoc2021/Day24$Modulo\n 471: dup\n 472: aload 12\n 474: aload 13\n 476: invokespecial #291 // Method org/aoc2021/Day24$Modulo.\"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)V\n 479: invokevirtual #292 // Method org/aoc2021/Day24$Modulo.simplify:()Lorg/aoc2021/Day24$Expression;\n 482: invokeinterface #269, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 487: pop\n 488: goto 695\n 491: aload 6\n 493: aload 10\n 495: invokevirtual #264 // Method org/aoc2021/Day24$Instruction.getA:()Ljava/lang/String;\n 498: invokeinterface #50, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 503: dup\n 504: invokestatic #273 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 507: checkcast #119 // class org/aoc2021/Day24$Expression\n 510: astore 12\n 512: aload_0\n 513: aload 10\n 515: invokevirtual #275 // Method org/aoc2021/Day24$Instruction.getB:()Ljava/lang/String;\n 518: dup\n 519: invokestatic #273 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 522: aload 6\n 524: invokespecial #279 // Method getExpressionValueOf:(Ljava/lang/String;Ljava/util/Map;)Lorg/aoc2021/Day24$Expression;\n 527: astore 13\n 529: new #109 // class org/aoc2021/Day24$Compare\n 532: dup\n 533: aload 12\n 535: aload 13\n 537: iconst_0\n 538: iconst_4\n 539: aconst_null\n 540: invokespecial #128 // Method org/aoc2021/Day24$Compare.\"<init>\":(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;ZILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 543: invokevirtual #293 // Method org/aoc2021/Day24$Compare.simplify:()Lorg/aoc2021/Day24$Expression;\n 546: astore 14\n 548: aload 14\n 550: instanceof #109 // class org/aoc2021/Day24$Compare\n 553: ifeq 680\n 556: aload 6\n 558: aload 10\n 560: invokevirtual #264 // Method org/aoc2021/Day24$Instruction.getA:()Ljava/lang/String;\n 563: new #52 // class org/aoc2021/Day24$LiteralValue\n 566: dup\n 567: iconst_1\n 568: invokespecial #55 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 571: invokestatic #299 // Method org/aoc2021/Day24Kt.access$replaceKeyValue:(Ljava/util/Map;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;\n 574: astore 15\n 576: aload 6\n 578: aload 10\n 580: invokevirtual #264 // Method org/aoc2021/Day24$Instruction.getA:()Ljava/lang/String;\n 583: new #52 // class org/aoc2021/Day24$LiteralValue\n 586: dup\n 587: iconst_0\n 588: invokespecial #55 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 591: invokestatic #299 // Method org/aoc2021/Day24Kt.access$replaceKeyValue:(Ljava/util/Map;Ljava/lang/Object;Ljava/lang/Object;)Ljava/util/Map;\n 594: astore 16\n 596: aload_0\n 597: aload_1\n 598: aload 15\n 600: invokestatic #302 // Method kotlin/collections/MapsKt.toMap:(Ljava/util/Map;)Ljava/util/Map;\n 603: iload 8\n 605: iconst_1\n 606: iadd\n 607: iload 7\n 609: aload 5\n 611: checkcast #68 // class java/util/Collection\n 614: new #73 // class org/aoc2021/Day24$Condition\n 617: dup\n 618: aload 14\n 620: checkcast #109 // class org/aoc2021/Day24$Compare\n 623: iconst_1\n 624: invokespecial #305 // Method org/aoc2021/Day24$Condition.\"<init>\":(Lorg/aoc2021/Day24$Compare;Z)V\n 627: invokestatic #309 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 630: invokespecial #311 // Method generateExpressions:(Ljava/util/List;Ljava/util/Map;IILjava/util/List;)Ljava/util/List;\n 633: checkcast #68 // class java/util/Collection\n 636: aload_0\n 637: aload_1\n 638: aload 16\n 640: invokestatic #302 // Method kotlin/collections/MapsKt.toMap:(Ljava/util/Map;)Ljava/util/Map;\n 643: iload 8\n 645: iconst_1\n 646: iadd\n 647: iload 7\n 649: aload 5\n 651: checkcast #68 // class java/util/Collection\n 654: new #73 // class org/aoc2021/Day24$Condition\n 657: dup\n 658: aload 14\n 660: checkcast #109 // class org/aoc2021/Day24$Compare\n 663: iconst_0\n 664: invokespecial #305 // Method org/aoc2021/Day24$Condition.\"<init>\":(Lorg/aoc2021/Day24$Compare;Z)V\n 667: invokestatic #309 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 670: invokespecial #311 // Method generateExpressions:(Ljava/util/List;Ljava/util/Map;IILjava/util/List;)Ljava/util/List;\n 673: checkcast #23 // class java/lang/Iterable\n 676: invokestatic #314 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 679: areturn\n 680: aload 6\n 682: aload 10\n 684: invokevirtual #264 // Method org/aoc2021/Day24$Instruction.getA:()Ljava/lang/String;\n 687: aload 14\n 689: invokeinterface #269, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 694: pop\n 695: iinc 8, 1\n 698: goto 21\n 701: aload 5\n 703: aload 6\n 705: invokestatic #302 // Method kotlin/collections/MapsKt.toMap:(Ljava/util/Map;)Ljava/util/Map;\n 708: invokestatic #320 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 711: invokestatic #324 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 714: areturn\n\n static java.util.List generateExpressions$default(org.aoc2021.Day24, java.util.List, java.util.Map, int, int, java.util.List, int, java.lang.Object);\n Code:\n 0: iload 6\n 2: iconst_2\n 3: iand\n 4: ifeq 165\n 7: iconst_4\n 8: anewarray #245 // class java/lang/String\n 11: astore 8\n 13: aload 8\n 15: iconst_0\n 16: ldc_w #337 // String w\n 19: aastore\n 20: aload 8\n 22: iconst_1\n 23: ldc_w #339 // String x\n 26: aastore\n 27: aload 8\n 29: iconst_2\n 30: ldc_w #341 // String y\n 33: aastore\n 34: aload 8\n 36: iconst_3\n 37: ldc #46 // String z\n 39: aastore\n 40: aload 8\n 42: invokestatic #344 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 45: checkcast #23 // class java/lang/Iterable\n 48: astore 8\n 50: iconst_0\n 51: istore 9\n 53: new #346 // class java/util/LinkedHashMap\n 56: dup\n 57: aload 8\n 59: bipush 10\n 61: invokestatic #350 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 64: invokestatic #354 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 67: bipush 16\n 69: invokestatic #360 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 72: invokespecial #361 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 75: astore 10\n 77: aload 8\n 79: astore 11\n 81: iconst_0\n 82: istore 12\n 84: aload 11\n 86: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 91: astore 13\n 93: aload 13\n 95: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 100: ifeq 158\n 103: aload 13\n 105: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 110: astore 14\n 112: aload 10\n 114: checkcast #44 // class java/util/Map\n 117: aload 14\n 119: aload 14\n 121: checkcast #245 // class java/lang/String\n 124: astore 15\n 126: astore 18\n 128: astore 17\n 130: iconst_0\n 131: istore 16\n 133: new #52 // class org/aoc2021/Day24$LiteralValue\n 136: dup\n 137: iconst_0\n 138: invokespecial #55 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 141: astore 19\n 143: aload 17\n 145: aload 18\n 147: aload 19\n 149: invokeinterface #269, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 154: pop\n 155: goto 93\n 158: aload 10\n 160: checkcast #44 // class java/util/Map\n 163: nop\n 164: astore_2\n 165: iload 6\n 167: iconst_4\n 168: iand\n 169: ifeq 174\n 172: iconst_0\n 173: istore_3\n 174: iload 6\n 176: bipush 8\n 178: iand\n 179: ifeq 185\n 182: iconst_0\n 183: istore 4\n 185: iload 6\n 187: bipush 16\n 189: iand\n 190: ifeq 198\n 193: invokestatic #365 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 196: astore 5\n 198: aload_0\n 199: aload_1\n 200: aload_2\n 201: iload_3\n 202: iload 4\n 204: aload 5\n 206: invokespecial #311 // Method generateExpressions:(Ljava/util/List;Ljava/util/Map;IILjava/util/List;)Ljava/util/List;\n 209: areturn\n\n private final org.aoc2021.Day24$Expression getExpressionValueOf(java.lang.String, java.util.Map<java.lang.String, ? extends org.aoc2021.Day24$Expression>);\n Code:\n 0: aload_2\n 1: aload_1\n 2: invokeinterface #50, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #119 // class org/aoc2021/Day24$Expression\n 10: dup\n 11: ifnonnull 29\n 14: pop\n 15: new #52 // class org/aoc2021/Day24$LiteralValue\n 18: dup\n 19: aload_1\n 20: invokestatic #379 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 23: invokespecial #55 // Method org/aoc2021/Day24$LiteralValue.\"<init>\":(I)V\n 26: checkcast #119 // class org/aoc2021/Day24$Expression\n 29: areturn\n\n private final java.util.List<org.aoc2021.Day24$Instruction> parseProgram(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #23 // 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 #143 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #350 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #144 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #68 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 208\n 50: aload 7\n 52: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #245 // class java/lang/String\n 66: astore 9\n 68: astore 13\n 70: iconst_0\n 71: istore 10\n 73: aload 9\n 75: checkcast #166 // class java/lang/CharSequence\n 78: iconst_1\n 79: anewarray #245 // class java/lang/String\n 82: astore 11\n 84: aload 11\n 86: iconst_0\n 87: ldc_w #383 // 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 #389 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 101: astore 12\n 103: aload 12\n 105: iconst_0\n 106: invokeinterface #238, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 111: ldc_w #262 // String inp\n 114: invokestatic #61 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 117: ifeq 155\n 120: new #240 // class org/aoc2021/Day24$Instruction\n 123: dup\n 124: aload 12\n 126: iconst_0\n 127: invokeinterface #238, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 132: checkcast #245 // class java/lang/String\n 135: aload 12\n 137: iconst_1\n 138: invokeinterface #238, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 143: checkcast #245 // class java/lang/String\n 146: aconst_null\n 147: iconst_4\n 148: aconst_null\n 149: invokespecial #392 // Method org/aoc2021/Day24$Instruction.\"<init>\":(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 152: goto 195\n 155: new #240 // class org/aoc2021/Day24$Instruction\n 158: dup\n 159: aload 12\n 161: iconst_0\n 162: invokeinterface #238, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 167: checkcast #245 // class java/lang/String\n 170: aload 12\n 172: iconst_1\n 173: invokeinterface #238, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 178: checkcast #245 // class java/lang/String\n 181: aload 12\n 183: iconst_2\n 184: invokeinterface #238, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 189: checkcast #245 // class java/lang/String\n 192: invokespecial #395 // Method org/aoc2021/Day24$Instruction.\"<init>\":(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V\n 195: nop\n 196: aload 13\n 198: swap\n 199: invokeinterface #162, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 204: pop\n 205: goto 40\n 208: aload 5\n 210: checkcast #66 // class java/util/List\n 213: nop\n 214: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc_w #406 // String args\n 4: invokestatic #410 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: ldc_w #412 // String input24.txt\n 10: iconst_0\n 11: anewarray #245 // class java/lang/String\n 14: invokestatic #418 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 17: getstatic #424 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 20: invokestatic #430 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 23: astore_1\n 24: getstatic #433 // Field INSTANCE:Lorg/aoc2021/Day24;\n 27: aload_1\n 28: invokestatic #273 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 31: aload_1\n 32: iconst_1\n 33: invokespecial #435 // Method solve:(Ljava/util/List;Z)Ljava/lang/String;\n 36: astore_2\n 37: getstatic #441 // Field java/lang/System.out:Ljava/io/PrintStream;\n 40: aload_2\n 41: invokevirtual #446 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 44: getstatic #433 // Field INSTANCE:Lorg/aoc2021/Day24;\n 47: aload_1\n 48: iconst_0\n 49: invokespecial #435 // Method solve:(Ljava/util/List;Z)Ljava/lang/String;\n 52: astore_3\n 53: getstatic #441 // Field java/lang/System.out:Ljava/io/PrintStream;\n 56: aload_3\n 57: invokevirtual #446 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 60: return\n\n public static final boolean access$isConditionImpossible(org.aoc2021.Day24, org.aoc2021.Day24$Expression, org.aoc2021.Day24$Expression);\n Code:\n 0: aload_0\n 1: aload_1\n 2: aload_2\n 3: invokespecial #452 // Method isConditionImpossible:(Lorg/aoc2021/Day24$Expression;Lorg/aoc2021/Day24$Expression;)Z\n 6: ireturn\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day24\n 3: dup\n 4: invokespecial #455 // Method \"<init>\":()V\n 7: putstatic #433 // Field INSTANCE:Lorg/aoc2021/Day24;\n 10: return\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day23.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
object Day23 {
private const val hallwayLength = 11
private val amphipodChars = setOf('A', 'B', 'C', 'D')
private val roomIndices = setOf(2, 4, 6, 8)
private val secondRow = listOf(Amphipod.DESERT, Amphipod.COPPER, Amphipod.BRONZE, Amphipod.AMBER)
private val thirdRow = listOf(Amphipod.DESERT, Amphipod.BRONZE, Amphipod.AMBER, Amphipod.COPPER)
enum class Amphipod(val energyPerStep: Int) {
AMBER(1),
BRONZE(10),
COPPER(100),
DESERT(1000),
}
private val winState = Amphipod.values().toList()
sealed interface HallwayPosition
data class Space(val occupant: Amphipod?) : HallwayPosition
data class Room(val occupants: List<Amphipod?>) : HallwayPosition {
fun withNewOccupant(occupant: Amphipod): Room {
if (occupants.all { it == null }) {
return Room(occupants.drop(1).plus(occupant))
}
val firstNullIndex = firstOpenIndex()
return Room(
occupants.take(firstNullIndex).plus(occupant).plus(occupants.drop(firstNullIndex + 1))
)
}
fun withoutTopOccupant(): Room {
val firstNonNullIndex = firstOccupiedIndex()
return Room(
occupants.take(firstNonNullIndex).plus(null).plus(occupants.drop(firstNonNullIndex + 1))
)
}
fun firstOpenIndex(): Int {
return occupants.indexOfLast { it == null }
}
fun firstOccupiedIndex(): Int {
return occupants.indexOfFirst { it != null }
}
}
data class State(val distance: Int, val hallway: List<HallwayPosition>)
private fun solve(lines: List<String>, expandMiddle: Boolean): Int {
val hallway = parseInput(lines, expandMiddle)
val pq = PriorityQueue<State> { a, b ->
a.distance.compareTo(b.distance)
}
pq.add(State(0, hallway))
val stateToMinDistance = mutableMapOf<List<HallwayPosition>, Int>()
while (!pq.isEmpty()) {
val state = pq.remove()
if (state.distance >= (stateToMinDistance[state.hallway] ?: Integer.MAX_VALUE)) {
continue
}
stateToMinDistance[state.hallway] = state.distance
if (isWinningState(state.hallway)) {
return state.distance
}
generatePossibleMoves(state.hallway).forEach { (moveDistance, moveState) ->
val newDistance = state.distance + moveDistance
if (newDistance < (stateToMinDistance[moveState] ?: Integer.MAX_VALUE)) {
pq.add(State(newDistance, moveState))
}
}
}
throw IllegalArgumentException("no winning solution found")
}
private fun isWinningState(state: List<HallwayPosition>): Boolean {
return state.filterIsInstance<Room>().zip(winState).all { (room, targetAmphipod) ->
room.occupants.all { it == targetAmphipod }
}
}
private fun generatePossibleMoves(hallway: List<HallwayPosition>): List<Pair<Int, List<HallwayPosition>>> {
val moves = mutableListOf<Pair<Int, List<HallwayPosition>>>()
hallway.forEachIndexed { i, position ->
when (position) {
is Space -> moves.addAll(generateSpaceMoves(hallway, i, position))
is Room -> moves.addAll(generateRoomMoves(hallway, i, position))
}
}
return moves.toList()
}
private fun generateSpaceMoves(
hallway: List<HallwayPosition>,
i: Int,
space: Space,
): List<Pair<Int, List<HallwayPosition>>> {
if (space.occupant == null) {
return listOf()
}
val targetIndex = 2 * winState.indexOf(space.occupant) + 2
val targetRoom = hallway[targetIndex] as Room
if (canMoveToRoom(hallway, i, targetIndex)) {
val distance = space.occupant.energyPerStep * (abs(i - targetIndex) + 1 + targetRoom.firstOpenIndex())
val newState = hallway.map { position ->
if (position === space) {
Space(null)
} else if (position === targetRoom) {
targetRoom.withNewOccupant(space.occupant)
} else {
position
}
}
return listOf(distance to newState)
}
return listOf()
}
private fun generateRoomMoves(
hallway: List<HallwayPosition>,
i: Int,
room: Room,
): List<Pair<Int, List<HallwayPosition>>> {
val targetAmphipod = winState[(i - 2) / 2]
if (room.occupants.all { it == null || it == targetAmphipod }) {
return listOf()
}
val firstOccupiedIndex = room.firstOccupiedIndex()
val first = room.occupants[firstOccupiedIndex]!!
if (first != targetAmphipod) {
val firstTargetIndex = 2 * winState.indexOf(first) + 2
val firstTargetRoom = hallway[firstTargetIndex] as Room
if (canMoveToRoom(hallway, i, firstTargetIndex)) {
val steps = abs(i - firstTargetIndex) + 2 + firstOccupiedIndex + firstTargetRoom.firstOpenIndex()
val distance = first.energyPerStep * steps
val newState = hallway.map { position ->
if (position === room) {
room.withoutTopOccupant()
} else if (position === firstTargetRoom) {
firstTargetRoom.withNewOccupant(first)
} else {
position
}
}
return listOf(distance to newState)
}
}
val moves = mutableListOf<Pair<Int, List<HallwayPosition>>>()
for (j in hallway.indices) {
val space = hallway[j]
if (space !is Space) {
continue
}
if (canMoveToSpace(hallway, i, j)) {
val distance = first.energyPerStep * (abs(i - j) + 1 + room.firstOccupiedIndex())
val newState = hallway.map { position ->
if (position === room) {
room.withoutTopOccupant()
} else if (position === space) {
Space(first)
} else {
position
}
}
moves.add(distance to newState)
}
}
return moves.toList()
}
private fun canMoveToSpace(
hallway: List<HallwayPosition>,
i: Int,
targetIndex: Int,
): Boolean {
val space = hallway[targetIndex] as Space
if (space.occupant != null) {
return false
}
return canMoveToPosition(hallway, i, targetIndex)
}
private fun canMoveToRoom(
hallway: List<HallwayPosition>,
i: Int,
targetIndex: Int,
): Boolean {
val targetAmphipod = winState[(targetIndex - 2) / 2]
val targetRoom = hallway[targetIndex] as Room
if (!targetRoom.occupants.all { it == null || it == targetAmphipod }) {
return false
}
return canMoveToPosition(hallway, i, targetIndex)
}
private fun canMoveToPosition(
hallway: List<HallwayPosition>,
i: Int,
targetIndex: Int,
): Boolean {
val start = min(i, targetIndex)
val end = max(i, targetIndex)
return ((start + 1) until end).all { j ->
val position = hallway[j]
position !is Space || position.occupant == null
}
}
private fun parseInput(lines: List<String>, expandMiddle: Boolean): List<HallwayPosition> {
val frontOccupants = lines[2].filter(amphipodChars::contains).toCharArray()
val backOccupants = lines[3].filter(amphipodChars::contains).toCharArray()
val roomOccupants = frontOccupants.zip(backOccupants)
var occupantsIndex = 0
val result = mutableListOf<HallwayPosition>()
for (i in 0 until hallwayLength) {
if (roomIndices.contains(i)) {
val (frontOccupant, backOccupant) = roomOccupants[occupantsIndex]
val room = if (expandMiddle) {
Room(listOf(
charToAmphipod(frontOccupant),
secondRow[(i - 2) / 2],
thirdRow[(i - 2) / 2],
charToAmphipod(backOccupant),
))
} else {
Room(listOf(charToAmphipod(frontOccupant), charToAmphipod(backOccupant)))
}
result.add(room)
occupantsIndex++
} else {
result.add(Space(occupant = null))
}
}
return result.toList()
}
private fun charToAmphipod(c: Char): Amphipod = when (c) {
'A' -> Amphipod.AMBER
'B' -> Amphipod.BRONZE
'C' -> Amphipod.COPPER
'D' -> Amphipod.DESERT
else -> throw IllegalArgumentException("$c")
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input23.txt"), Charsets.UTF_8)
val solution1 = solve(lines, false)
println(solution1)
val solution2 = solve(lines, true)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day23$Room.class",
"javap": "Compiled from \"Day23.kt\"\npublic final class org.aoc2021.Day23$Room implements org.aoc2021.Day23$HallwayPosition {\n private final java.util.List<org.aoc2021.Day23$Amphipod> occupants;\n\n public org.aoc2021.Day23$Room(java.util.List<? extends org.aoc2021.Day23$Amphipod>);\n Code:\n 0: aload_1\n 1: ldc #12 // String occupants\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #21 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: aload_1\n 12: putfield #24 // Field occupants:Ljava/util/List;\n 15: return\n\n public final java.util.List<org.aoc2021.Day23$Amphipod> getOccupants();\n Code:\n 0: aload_0\n 1: getfield #24 // Field occupants:Ljava/util/List;\n 4: areturn\n\n public final org.aoc2021.Day23$Room withNewOccupant(org.aoc2021.Day23$Amphipod);\n Code:\n 0: aload_1\n 1: ldc #33 // String occupant\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: getfield #24 // Field occupants:Ljava/util/List;\n 10: checkcast #35 // class java/lang/Iterable\n 13: astore_2\n 14: iconst_0\n 15: istore_3\n 16: aload_2\n 17: instanceof #37 // class java/util/Collection\n 20: ifeq 39\n 23: aload_2\n 24: checkcast #37 // class java/util/Collection\n 27: invokeinterface #41, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 32: ifeq 39\n 35: iconst_1\n 36: goto 94\n 39: aload_2\n 40: invokeinterface #45, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 4\n 47: aload 4\n 49: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 93\n 57: aload 4\n 59: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 5\n 66: aload 5\n 68: checkcast #56 // class org/aoc2021/Day23$Amphipod\n 71: astore 6\n 73: iconst_0\n 74: istore 7\n 76: aload 6\n 78: ifnonnull 85\n 81: iconst_1\n 82: goto 86\n 85: iconst_0\n 86: ifne 47\n 89: iconst_0\n 90: goto 94\n 93: iconst_1\n 94: ifeq 123\n 97: new #2 // class org/aoc2021/Day23$Room\n 100: dup\n 101: aload_0\n 102: getfield #24 // Field occupants:Ljava/util/List;\n 105: checkcast #35 // class java/lang/Iterable\n 108: iconst_1\n 109: invokestatic #62 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 112: checkcast #37 // class java/util/Collection\n 115: aload_1\n 116: invokestatic #66 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 119: invokespecial #68 // Method \"<init>\":(Ljava/util/List;)V\n 122: areturn\n 123: aload_0\n 124: invokevirtual #72 // Method firstOpenIndex:()I\n 127: istore_2\n 128: new #2 // class org/aoc2021/Day23$Room\n 131: dup\n 132: aload_0\n 133: getfield #24 // Field occupants:Ljava/util/List;\n 136: checkcast #35 // class java/lang/Iterable\n 139: iload_2\n 140: invokestatic #75 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 143: checkcast #37 // class java/util/Collection\n 146: aload_1\n 147: invokestatic #66 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 150: checkcast #37 // class java/util/Collection\n 153: aload_0\n 154: getfield #24 // Field occupants:Ljava/util/List;\n 157: checkcast #35 // class java/lang/Iterable\n 160: iload_2\n 161: iconst_1\n 162: iadd\n 163: invokestatic #62 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 166: checkcast #35 // class java/lang/Iterable\n 169: invokestatic #78 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 172: invokespecial #68 // Method \"<init>\":(Ljava/util/List;)V\n 175: areturn\n\n public final org.aoc2021.Day23$Room withoutTopOccupant();\n Code:\n 0: aload_0\n 1: invokevirtual #93 // Method firstOccupiedIndex:()I\n 4: istore_1\n 5: new #2 // class org/aoc2021/Day23$Room\n 8: dup\n 9: aload_0\n 10: getfield #24 // Field occupants:Ljava/util/List;\n 13: checkcast #35 // class java/lang/Iterable\n 16: iload_1\n 17: invokestatic #75 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 20: checkcast #37 // class java/util/Collection\n 23: aconst_null\n 24: invokestatic #66 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 27: checkcast #37 // class java/util/Collection\n 30: aload_0\n 31: getfield #24 // Field occupants:Ljava/util/List;\n 34: checkcast #35 // class java/lang/Iterable\n 37: iload_1\n 38: iconst_1\n 39: iadd\n 40: invokestatic #62 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 43: checkcast #35 // class java/lang/Iterable\n 46: invokestatic #78 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 49: invokespecial #68 // Method \"<init>\":(Ljava/util/List;)V\n 52: areturn\n\n public final int firstOpenIndex();\n Code:\n 0: aload_0\n 1: getfield #24 // Field occupants:Ljava/util/List;\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: aload_1\n 8: aload_1\n 9: invokeinterface #99, 1 // InterfaceMethod java/util/List.size:()I\n 14: invokeinterface #103, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 19: astore_3\n 20: aload_3\n 21: invokeinterface #108, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 26: ifeq 65\n 29: aload_3\n 30: invokeinterface #111, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 35: checkcast #56 // class org/aoc2021/Day23$Amphipod\n 38: astore 4\n 40: iconst_0\n 41: istore 5\n 43: aload 4\n 45: ifnonnull 52\n 48: iconst_1\n 49: goto 53\n 52: iconst_0\n 53: ifeq 20\n 56: aload_3\n 57: invokeinterface #114, 1 // InterfaceMethod java/util/ListIterator.nextIndex:()I\n 62: goto 66\n 65: iconst_m1\n 66: ireturn\n\n public final int firstOccupiedIndex();\n Code:\n 0: aload_0\n 1: getfield #24 // Field occupants:Ljava/util/List;\n 4: astore_1\n 5: iconst_0\n 6: istore_2\n 7: iconst_0\n 8: istore_3\n 9: aload_1\n 10: invokeinterface #120, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 15: astore 4\n 17: aload 4\n 19: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 24: ifeq 69\n 27: aload 4\n 29: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 34: astore 5\n 36: aload 5\n 38: checkcast #56 // class org/aoc2021/Day23$Amphipod\n 41: astore 6\n 43: iconst_0\n 44: istore 7\n 46: aload 6\n 48: ifnull 55\n 51: iconst_1\n 52: goto 56\n 55: iconst_0\n 56: ifeq 63\n 59: iload_3\n 60: goto 70\n 63: iinc 3, 1\n 66: goto 17\n 69: iconst_m1\n 70: ireturn\n\n public final java.util.List<org.aoc2021.Day23$Amphipod> component1();\n Code:\n 0: aload_0\n 1: getfield #24 // Field occupants:Ljava/util/List;\n 4: areturn\n\n public final org.aoc2021.Day23$Room copy(java.util.List<? extends org.aoc2021.Day23$Amphipod>);\n Code:\n 0: aload_1\n 1: ldc #12 // String occupants\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class org/aoc2021/Day23$Room\n 9: dup\n 10: aload_1\n 11: invokespecial #68 // Method \"<init>\":(Ljava/util/List;)V\n 14: areturn\n\n public static org.aoc2021.Day23$Room copy$default(org.aoc2021.Day23$Room, 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 #24 // Field occupants:Ljava/util/List;\n 10: astore_1\n 11: aload_0\n 12: aload_1\n 13: invokevirtual #133 // Method copy:(Ljava/util/List;)Lorg/aoc2021/Day23$Room;\n 16: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #137 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #138 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #140 // String Room(occupants=\n 9: invokevirtual #144 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #24 // Field occupants:Ljava/util/List;\n 16: invokevirtual #147 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: bipush 41\n 21: invokevirtual #150 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 24: invokevirtual #152 // 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 #24 // Field occupants:Ljava/util/List;\n 4: invokevirtual #155 // 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 org/aoc2021/Day23$Room\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day23$Room\n 20: astore_2\n 21: aload_0\n 22: getfield #24 // Field occupants:Ljava/util/List;\n 25: aload_2\n 26: getfield #24 // Field occupants:Ljava/util/List;\n 29: invokestatic #162 // 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": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day23$Amphipod.class",
"javap": "Compiled from \"Day23.kt\"\npublic final class org.aoc2021.Day23$Amphipod extends java.lang.Enum<org.aoc2021.Day23$Amphipod> {\n private final int energyPerStep;\n\n public static final org.aoc2021.Day23$Amphipod AMBER;\n\n public static final org.aoc2021.Day23$Amphipod BRONZE;\n\n public static final org.aoc2021.Day23$Amphipod COPPER;\n\n public static final org.aoc2021.Day23$Amphipod DESERT;\n\n private static final org.aoc2021.Day23$Amphipod[] $VALUES;\n\n private static final kotlin.enums.EnumEntries $ENTRIES;\n\n private org.aoc2021.Day23$Amphipod(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 energyPerStep:I\n 11: return\n\n public final int getEnergyPerStep();\n Code:\n 0: aload_0\n 1: getfield #15 // Field energyPerStep:I\n 4: ireturn\n\n public static org.aoc2021.Day23$Amphipod[] values();\n Code:\n 0: getstatic #28 // Field $VALUES:[Lorg/aoc2021/Day23$Amphipod;\n 3: invokevirtual #34 // Method java/lang/Object.clone:()Ljava/lang/Object;\n 6: checkcast #35 // class \"[Lorg/aoc2021/Day23$Amphipod;\"\n 9: areturn\n\n public static org.aoc2021.Day23$Amphipod valueOf(java.lang.String);\n Code:\n 0: ldc #2 // class org/aoc2021/Day23$Amphipod\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 org/aoc2021/Day23$Amphipod\n 9: areturn\n\n public static kotlin.enums.EnumEntries<org.aoc2021.Day23$Amphipod> getEntries();\n Code:\n 0: getstatic #49 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 3: areturn\n\n private static final org.aoc2021.Day23$Amphipod[] $values();\n Code:\n 0: iconst_4\n 1: anewarray #2 // class org/aoc2021/Day23$Amphipod\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: getstatic #53 // Field AMBER:Lorg/aoc2021/Day23$Amphipod;\n 10: aastore\n 11: aload_0\n 12: iconst_1\n 13: getstatic #56 // Field BRONZE:Lorg/aoc2021/Day23$Amphipod;\n 16: aastore\n 17: aload_0\n 18: iconst_2\n 19: getstatic #59 // Field COPPER:Lorg/aoc2021/Day23$Amphipod;\n 22: aastore\n 23: aload_0\n 24: iconst_3\n 25: getstatic #62 // Field DESERT:Lorg/aoc2021/Day23$Amphipod;\n 28: aastore\n 29: aload_0\n 30: areturn\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day23$Amphipod\n 3: dup\n 4: ldc #65 // String AMBER\n 6: iconst_0\n 7: iconst_1\n 8: invokespecial #67 // Method \"<init>\":(Ljava/lang/String;II)V\n 11: putstatic #53 // Field AMBER:Lorg/aoc2021/Day23$Amphipod;\n 14: new #2 // class org/aoc2021/Day23$Amphipod\n 17: dup\n 18: ldc #68 // String BRONZE\n 20: iconst_1\n 21: bipush 10\n 23: invokespecial #67 // Method \"<init>\":(Ljava/lang/String;II)V\n 26: putstatic #56 // Field BRONZE:Lorg/aoc2021/Day23$Amphipod;\n 29: new #2 // class org/aoc2021/Day23$Amphipod\n 32: dup\n 33: ldc #69 // String COPPER\n 35: iconst_2\n 36: bipush 100\n 38: invokespecial #67 // Method \"<init>\":(Ljava/lang/String;II)V\n 41: putstatic #59 // Field COPPER:Lorg/aoc2021/Day23$Amphipod;\n 44: new #2 // class org/aoc2021/Day23$Amphipod\n 47: dup\n 48: ldc #70 // String DESERT\n 50: iconst_3\n 51: sipush 1000\n 54: invokespecial #67 // Method \"<init>\":(Ljava/lang/String;II)V\n 57: putstatic #62 // Field DESERT:Lorg/aoc2021/Day23$Amphipod;\n 60: invokestatic #72 // Method $values:()[Lorg/aoc2021/Day23$Amphipod;\n 63: putstatic #28 // Field $VALUES:[Lorg/aoc2021/Day23$Amphipod;\n 66: getstatic #28 // Field $VALUES:[Lorg/aoc2021/Day23$Amphipod;\n 69: checkcast #74 // class \"[Ljava/lang/Enum;\"\n 72: invokestatic #80 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;\n 75: putstatic #49 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 78: return\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day23$HallwayPosition.class",
"javap": "Compiled from \"Day23.kt\"\npublic interface org.aoc2021.Day23$HallwayPosition {\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day23.class",
"javap": "Compiled from \"Day23.kt\"\npublic final class org.aoc2021.Day23 {\n public static final org.aoc2021.Day23 INSTANCE;\n\n private static final int hallwayLength;\n\n private static final java.util.Set<java.lang.Character> amphipodChars;\n\n private static final java.util.Set<java.lang.Integer> roomIndices;\n\n private static final java.util.List<org.aoc2021.Day23$Amphipod> secondRow;\n\n private static final java.util.List<org.aoc2021.Day23$Amphipod> thirdRow;\n\n private static final java.util.List<org.aoc2021.Day23$Amphipod> winState;\n\n private org.aoc2021.Day23();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int solve(java.util.List<java.lang.String>, boolean);\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: invokespecial #17 // Method parseInput:(Ljava/util/List;Z)Ljava/util/List;\n 6: astore_3\n 7: new #19 // class java/util/PriorityQueue\n 10: dup\n 11: invokedynamic #39, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;\n 16: invokedynamic #50, 0 // InvokeDynamic #1:compare:(Lkotlin/jvm/functions/Function2;)Ljava/util/Comparator;\n 21: invokespecial #53 // Method java/util/PriorityQueue.\"<init>\":(Ljava/util/Comparator;)V\n 24: astore 4\n 26: aload 4\n 28: new #55 // class org/aoc2021/Day23$State\n 31: dup\n 32: iconst_0\n 33: aload_3\n 34: invokespecial #58 // Method org/aoc2021/Day23$State.\"<init>\":(ILjava/util/List;)V\n 37: invokevirtual #62 // Method java/util/PriorityQueue.add:(Ljava/lang/Object;)Z\n 40: pop\n 41: new #64 // class java/util/LinkedHashMap\n 44: dup\n 45: invokespecial #65 // Method java/util/LinkedHashMap.\"<init>\":()V\n 48: checkcast #67 // class java/util/Map\n 51: astore 5\n 53: aload 4\n 55: invokevirtual #71 // Method java/util/PriorityQueue.isEmpty:()Z\n 58: ifne 293\n 61: aload 4\n 63: invokevirtual #75 // Method java/util/PriorityQueue.remove:()Ljava/lang/Object;\n 66: checkcast #55 // class org/aoc2021/Day23$State\n 69: astore 6\n 71: aload 6\n 73: invokevirtual #79 // Method org/aoc2021/Day23$State.getDistance:()I\n 76: aload 5\n 78: aload 6\n 80: invokevirtual #83 // Method org/aoc2021/Day23$State.getHallway:()Ljava/util/List;\n 83: invokeinterface #87, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 88: checkcast #89 // class java/lang/Integer\n 91: dup\n 92: ifnull 101\n 95: invokevirtual #92 // Method java/lang/Integer.intValue:()I\n 98: goto 104\n 101: pop\n 102: ldc #93 // int 2147483647\n 104: if_icmplt 110\n 107: goto 53\n 110: aload 5\n 112: aload 6\n 114: invokevirtual #83 // Method org/aoc2021/Day23$State.getHallway:()Ljava/util/List;\n 117: aload 6\n 119: invokevirtual #79 // Method org/aoc2021/Day23$State.getDistance:()I\n 122: invokestatic #97 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 125: invokeinterface #100, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 130: pop\n 131: aload_0\n 132: aload 6\n 134: invokevirtual #83 // Method org/aoc2021/Day23$State.getHallway:()Ljava/util/List;\n 137: invokespecial #104 // Method isWinningState:(Ljava/util/List;)Z\n 140: ifeq 149\n 143: aload 6\n 145: invokevirtual #79 // Method org/aoc2021/Day23$State.getDistance:()I\n 148: ireturn\n 149: aload_0\n 150: aload 6\n 152: invokevirtual #83 // Method org/aoc2021/Day23$State.getHallway:()Ljava/util/List;\n 155: invokespecial #108 // Method generatePossibleMoves:(Ljava/util/List;)Ljava/util/List;\n 158: checkcast #110 // class java/lang/Iterable\n 161: astore 7\n 163: iconst_0\n 164: istore 8\n 166: aload 7\n 168: invokeinterface #114, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 173: astore 9\n 175: aload 9\n 177: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 182: ifeq 289\n 185: aload 9\n 187: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 192: astore 10\n 194: aload 10\n 196: checkcast #124 // class kotlin/Pair\n 199: astore 11\n 201: iconst_0\n 202: istore 12\n 204: aload 11\n 206: invokevirtual #127 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 209: checkcast #129 // class java/lang/Number\n 212: invokevirtual #130 // Method java/lang/Number.intValue:()I\n 215: istore 13\n 217: aload 11\n 219: invokevirtual #133 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 222: checkcast #135 // class java/util/List\n 225: astore 14\n 227: aload 6\n 229: invokevirtual #79 // Method org/aoc2021/Day23$State.getDistance:()I\n 232: iload 13\n 234: iadd\n 235: istore 15\n 237: iload 15\n 239: aload 5\n 241: aload 14\n 243: invokeinterface #87, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 248: checkcast #89 // class java/lang/Integer\n 251: dup\n 252: ifnull 261\n 255: invokevirtual #92 // Method java/lang/Integer.intValue:()I\n 258: goto 264\n 261: pop\n 262: ldc #93 // int 2147483647\n 264: if_icmpge 284\n 267: aload 4\n 269: new #55 // class org/aoc2021/Day23$State\n 272: dup\n 273: iload 15\n 275: aload 14\n 277: invokespecial #58 // Method org/aoc2021/Day23$State.\"<init>\":(ILjava/util/List;)V\n 280: invokevirtual #62 // Method java/util/PriorityQueue.add:(Ljava/lang/Object;)Z\n 283: pop\n 284: nop\n 285: nop\n 286: goto 175\n 289: nop\n 290: goto 53\n 293: new #137 // class java/lang/IllegalArgumentException\n 296: dup\n 297: ldc #139 // String no winning solution found\n 299: invokespecial #142 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 302: athrow\n\n private final boolean isWinningState(java.util.List<? extends org.aoc2021.Day23$HallwayPosition>);\n Code:\n 0: aload_1\n 1: checkcast #110 // 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 #166 // class java/util/ArrayList\n 13: dup\n 14: invokespecial #167 // Method java/util/ArrayList.\"<init>\":()V\n 17: checkcast #169 // class java/util/Collection\n 20: astore 5\n 22: iconst_0\n 23: istore 6\n 25: aload 4\n 27: invokeinterface #114, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 7\n 34: aload 7\n 36: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 74\n 44: aload 7\n 46: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: astore 8\n 53: aload 8\n 55: instanceof #171 // class org/aoc2021/Day23$Room\n 58: ifeq 34\n 61: aload 5\n 63: aload 8\n 65: invokeinterface #172, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 70: pop\n 71: goto 34\n 74: aload 5\n 76: checkcast #135 // class java/util/List\n 79: nop\n 80: checkcast #110 // class java/lang/Iterable\n 83: getstatic #175 // Field winState:Ljava/util/List;\n 86: checkcast #110 // class java/lang/Iterable\n 89: invokestatic #181 // Method kotlin/collections/CollectionsKt.zip:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;\n 92: checkcast #110 // class java/lang/Iterable\n 95: astore_2\n 96: iconst_0\n 97: istore_3\n 98: aload_2\n 99: instanceof #169 // class java/util/Collection\n 102: ifeq 121\n 105: aload_2\n 106: checkcast #169 // class java/util/Collection\n 109: invokeinterface #182, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 114: ifeq 121\n 117: iconst_1\n 118: goto 283\n 121: aload_2\n 122: invokeinterface #114, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 127: astore 4\n 129: aload 4\n 131: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 136: ifeq 282\n 139: aload 4\n 141: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 146: astore 5\n 148: aload 5\n 150: checkcast #124 // class kotlin/Pair\n 153: astore 6\n 155: iconst_0\n 156: istore 7\n 158: aload 6\n 160: invokevirtual #127 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 163: checkcast #171 // class org/aoc2021/Day23$Room\n 166: astore 8\n 168: aload 6\n 170: invokevirtual #133 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 173: checkcast #184 // class org/aoc2021/Day23$Amphipod\n 176: astore 9\n 178: aload 8\n 180: invokevirtual #187 // Method org/aoc2021/Day23$Room.getOccupants:()Ljava/util/List;\n 183: checkcast #110 // class java/lang/Iterable\n 186: astore 10\n 188: iconst_0\n 189: istore 11\n 191: aload 10\n 193: instanceof #169 // class java/util/Collection\n 196: ifeq 216\n 199: aload 10\n 201: checkcast #169 // class java/util/Collection\n 204: invokeinterface #182, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 209: ifeq 216\n 212: iconst_1\n 213: goto 274\n 216: aload 10\n 218: invokeinterface #114, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 223: astore 12\n 225: aload 12\n 227: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 232: ifeq 273\n 235: aload 12\n 237: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 242: astore 13\n 244: aload 13\n 246: checkcast #184 // class org/aoc2021/Day23$Amphipod\n 249: astore 14\n 251: iconst_0\n 252: istore 15\n 254: aload 14\n 256: aload 9\n 258: if_acmpne 265\n 261: iconst_1\n 262: goto 266\n 265: iconst_0\n 266: ifne 225\n 269: iconst_0\n 270: goto 274\n 273: iconst_1\n 274: nop\n 275: ifne 129\n 278: iconst_0\n 279: goto 283\n 282: iconst_1\n 283: ireturn\n\n private final java.util.List<kotlin.Pair<java.lang.Integer, java.util.List<org.aoc2021.Day23$HallwayPosition>>> generatePossibleMoves(java.util.List<? extends org.aoc2021.Day23$HallwayPosition>);\n Code:\n 0: new #166 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #167 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #135 // class java/util/List\n 10: astore_2\n 11: aload_1\n 12: checkcast #110 // 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 #114, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 28: astore 6\n 30: aload 6\n 32: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 37: ifeq 164\n 40: aload 6\n 42: invokeinterface #122, 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 #207 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 64: iload 8\n 66: aload 7\n 68: checkcast #209 // class org/aoc2021/Day23$HallwayPosition\n 71: astore 9\n 73: istore 10\n 75: iconst_0\n 76: istore 11\n 78: aload 9\n 80: astore 12\n 82: aload 12\n 84: instanceof #211 // class org/aoc2021/Day23$Space\n 87: ifeq 116\n 90: aload_2\n 91: getstatic #214 // Field INSTANCE:Lorg/aoc2021/Day23;\n 94: aload_1\n 95: iload 10\n 97: aload 9\n 99: checkcast #211 // class org/aoc2021/Day23$Space\n 102: invokespecial #218 // Method generateSpaceMoves:(Ljava/util/List;ILorg/aoc2021/Day23$Space;)Ljava/util/List;\n 105: checkcast #169 // class java/util/Collection\n 108: invokeinterface #222, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 113: goto 158\n 116: aload 12\n 118: instanceof #171 // class org/aoc2021/Day23$Room\n 121: ifeq 150\n 124: aload_2\n 125: getstatic #214 // Field INSTANCE:Lorg/aoc2021/Day23;\n 128: aload_1\n 129: iload 10\n 131: aload 9\n 133: checkcast #171 // class org/aoc2021/Day23$Room\n 136: invokespecial #226 // Method generateRoomMoves:(Ljava/util/List;ILorg/aoc2021/Day23$Room;)Ljava/util/List;\n 139: checkcast #169 // class java/util/Collection\n 142: invokeinterface #222, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 147: goto 158\n 150: new #228 // class kotlin/NoWhenBranchMatchedException\n 153: dup\n 154: invokespecial #229 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 157: athrow\n 158: pop\n 159: nop\n 160: nop\n 161: goto 30\n 164: nop\n 165: aload_2\n 166: checkcast #110 // class java/lang/Iterable\n 169: invokestatic #233 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 172: areturn\n\n private final java.util.List<kotlin.Pair<java.lang.Integer, java.util.List<org.aoc2021.Day23$HallwayPosition>>> generateSpaceMoves(java.util.List<? extends org.aoc2021.Day23$HallwayPosition>, int, org.aoc2021.Day23$Space);\n Code:\n 0: aload_3\n 1: invokevirtual #247 // Method org/aoc2021/Day23$Space.getOccupant:()Lorg/aoc2021/Day23$Amphipod;\n 4: ifnonnull 11\n 7: invokestatic #250 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 10: areturn\n 11: iconst_2\n 12: getstatic #175 // Field winState:Ljava/util/List;\n 15: aload_3\n 16: invokevirtual #247 // Method org/aoc2021/Day23$Space.getOccupant:()Lorg/aoc2021/Day23$Amphipod;\n 19: invokeinterface #254, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 24: imul\n 25: iconst_2\n 26: iadd\n 27: istore 4\n 29: aload_1\n 30: iload 4\n 32: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 37: dup\n 38: ldc_w #259 // String null cannot be cast to non-null type org.aoc2021.Day23.Room\n 41: invokestatic #265 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V\n 44: checkcast #171 // class org/aoc2021/Day23$Room\n 47: astore 5\n 49: aload_0\n 50: aload_1\n 51: iload_2\n 52: iload 4\n 54: invokespecial #269 // Method canMoveToRoom:(Ljava/util/List;II)Z\n 57: ifeq 241\n 60: aload_3\n 61: invokevirtual #247 // Method org/aoc2021/Day23$Space.getOccupant:()Lorg/aoc2021/Day23$Amphipod;\n 64: invokevirtual #272 // Method org/aoc2021/Day23$Amphipod.getEnergyPerStep:()I\n 67: iload_2\n 68: iload 4\n 70: isub\n 71: invokestatic #278 // Method java/lang/Math.abs:(I)I\n 74: iconst_1\n 75: iadd\n 76: aload 5\n 78: invokevirtual #281 // Method org/aoc2021/Day23$Room.firstOpenIndex:()I\n 81: iadd\n 82: imul\n 83: istore 6\n 85: aload_1\n 86: checkcast #110 // class java/lang/Iterable\n 89: astore 8\n 91: iconst_0\n 92: istore 9\n 94: aload 8\n 96: astore 10\n 98: new #166 // class java/util/ArrayList\n 101: dup\n 102: aload 8\n 104: bipush 10\n 106: invokestatic #285 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 109: invokespecial #288 // Method java/util/ArrayList.\"<init>\":(I)V\n 112: checkcast #169 // class java/util/Collection\n 115: astore 11\n 117: iconst_0\n 118: istore 12\n 120: aload 10\n 122: invokeinterface #114, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 127: astore 13\n 129: aload 13\n 131: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 136: ifeq 219\n 139: aload 13\n 141: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 146: astore 14\n 148: aload 11\n 150: aload 14\n 152: checkcast #209 // class org/aoc2021/Day23$HallwayPosition\n 155: astore 15\n 157: astore 17\n 159: iconst_0\n 160: istore 16\n 162: aload 15\n 164: aload_3\n 165: if_acmpne 182\n 168: new #211 // class org/aoc2021/Day23$Space\n 171: dup\n 172: aconst_null\n 173: invokespecial #291 // Method org/aoc2021/Day23$Space.\"<init>\":(Lorg/aoc2021/Day23$Amphipod;)V\n 176: checkcast #209 // class org/aoc2021/Day23$HallwayPosition\n 179: goto 206\n 182: aload 15\n 184: aload 5\n 186: if_acmpne 204\n 189: aload 5\n 191: aload_3\n 192: invokevirtual #247 // Method org/aoc2021/Day23$Space.getOccupant:()Lorg/aoc2021/Day23$Amphipod;\n 195: invokevirtual #295 // Method org/aoc2021/Day23$Room.withNewOccupant:(Lorg/aoc2021/Day23$Amphipod;)Lorg/aoc2021/Day23$Room;\n 198: checkcast #209 // class org/aoc2021/Day23$HallwayPosition\n 201: goto 206\n 204: aload 15\n 206: nop\n 207: aload 17\n 209: swap\n 210: invokeinterface #172, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 215: pop\n 216: goto 129\n 219: aload 11\n 221: checkcast #135 // class java/util/List\n 224: nop\n 225: astore 7\n 227: iload 6\n 229: invokestatic #97 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 232: aload 7\n 234: invokestatic #301 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 237: invokestatic #305 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 240: areturn\n 241: invokestatic #250 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 244: areturn\n\n private final java.util.List<kotlin.Pair<java.lang.Integer, java.util.List<org.aoc2021.Day23$HallwayPosition>>> generateRoomMoves(java.util.List<? extends org.aoc2021.Day23$HallwayPosition>, int, org.aoc2021.Day23$Room);\n Code:\n 0: getstatic #175 // Field winState:Ljava/util/List;\n 3: iload_2\n 4: iconst_2\n 5: isub\n 6: iconst_2\n 7: idiv\n 8: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 13: checkcast #184 // class org/aoc2021/Day23$Amphipod\n 16: astore 4\n 18: aload_3\n 19: invokevirtual #187 // Method org/aoc2021/Day23$Room.getOccupants:()Ljava/util/List;\n 22: checkcast #110 // class java/lang/Iterable\n 25: astore 5\n 27: iconst_0\n 28: istore 6\n 30: aload 5\n 32: instanceof #169 // class java/util/Collection\n 35: ifeq 55\n 38: aload 5\n 40: checkcast #169 // class java/util/Collection\n 43: invokeinterface #182, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 48: ifeq 55\n 51: iconst_1\n 52: goto 118\n 55: aload 5\n 57: invokeinterface #114, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 62: astore 7\n 64: aload 7\n 66: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 71: ifeq 117\n 74: aload 7\n 76: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 81: astore 8\n 83: aload 8\n 85: checkcast #184 // class org/aoc2021/Day23$Amphipod\n 88: astore 9\n 90: iconst_0\n 91: istore 10\n 93: aload 9\n 95: ifnull 105\n 98: aload 9\n 100: aload 4\n 102: if_acmpne 109\n 105: iconst_1\n 106: goto 110\n 109: iconst_0\n 110: ifne 64\n 113: iconst_0\n 114: goto 118\n 117: iconst_1\n 118: ifeq 125\n 121: invokestatic #250 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 124: areturn\n 125: aload_3\n 126: invokevirtual #321 // Method org/aoc2021/Day23$Room.firstOccupiedIndex:()I\n 129: istore 5\n 131: aload_3\n 132: invokevirtual #187 // Method org/aoc2021/Day23$Room.getOccupants:()Ljava/util/List;\n 135: iload 5\n 137: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 142: dup\n 143: invokestatic #324 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 146: checkcast #184 // class org/aoc2021/Day23$Amphipod\n 149: astore 6\n 151: aload 6\n 153: aload 4\n 155: if_acmpeq 385\n 158: iconst_2\n 159: getstatic #175 // Field winState:Ljava/util/List;\n 162: aload 6\n 164: invokeinterface #254, 2 // InterfaceMethod java/util/List.indexOf:(Ljava/lang/Object;)I\n 169: imul\n 170: iconst_2\n 171: iadd\n 172: istore 7\n 174: aload_1\n 175: iload 7\n 177: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 182: dup\n 183: ldc_w #259 // String null cannot be cast to non-null type org.aoc2021.Day23.Room\n 186: invokestatic #265 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V\n 189: checkcast #171 // class org/aoc2021/Day23$Room\n 192: astore 8\n 194: aload_0\n 195: aload_1\n 196: iload_2\n 197: iload 7\n 199: invokespecial #269 // Method canMoveToRoom:(Ljava/util/List;II)Z\n 202: ifeq 385\n 205: iload_2\n 206: iload 7\n 208: isub\n 209: invokestatic #278 // Method java/lang/Math.abs:(I)I\n 212: iconst_2\n 213: iadd\n 214: iload 5\n 216: iadd\n 217: aload 8\n 219: invokevirtual #281 // Method org/aoc2021/Day23$Room.firstOpenIndex:()I\n 222: iadd\n 223: istore 9\n 225: aload 6\n 227: invokevirtual #272 // Method org/aoc2021/Day23$Amphipod.getEnergyPerStep:()I\n 230: iload 9\n 232: imul\n 233: istore 10\n 235: aload_1\n 236: checkcast #110 // class java/lang/Iterable\n 239: astore 12\n 241: iconst_0\n 242: istore 13\n 244: aload 12\n 246: astore 14\n 248: new #166 // class java/util/ArrayList\n 251: dup\n 252: aload 12\n 254: bipush 10\n 256: invokestatic #285 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 259: invokespecial #288 // Method java/util/ArrayList.\"<init>\":(I)V\n 262: checkcast #169 // class java/util/Collection\n 265: astore 15\n 267: iconst_0\n 268: istore 16\n 270: aload 14\n 272: invokeinterface #114, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 277: astore 17\n 279: aload 17\n 281: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 286: ifeq 363\n 289: aload 17\n 291: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 296: astore 18\n 298: aload 15\n 300: aload 18\n 302: checkcast #209 // class org/aoc2021/Day23$HallwayPosition\n 305: astore 19\n 307: astore 22\n 309: iconst_0\n 310: istore 20\n 312: aload 19\n 314: aload_3\n 315: if_acmpne 328\n 318: aload_3\n 319: invokevirtual #328 // Method org/aoc2021/Day23$Room.withoutTopOccupant:()Lorg/aoc2021/Day23$Room;\n 322: checkcast #209 // class org/aoc2021/Day23$HallwayPosition\n 325: goto 350\n 328: aload 19\n 330: aload 8\n 332: if_acmpne 348\n 335: aload 8\n 337: aload 6\n 339: invokevirtual #295 // Method org/aoc2021/Day23$Room.withNewOccupant:(Lorg/aoc2021/Day23$Amphipod;)Lorg/aoc2021/Day23$Room;\n 342: checkcast #209 // class org/aoc2021/Day23$HallwayPosition\n 345: goto 350\n 348: aload 19\n 350: nop\n 351: aload 22\n 353: swap\n 354: invokeinterface #172, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 359: pop\n 360: goto 279\n 363: aload 15\n 365: checkcast #135 // class java/util/List\n 368: nop\n 369: astore 11\n 371: iload 10\n 373: invokestatic #97 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 376: aload 11\n 378: invokestatic #301 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 381: invokestatic #305 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 384: areturn\n 385: new #166 // class java/util/ArrayList\n 388: dup\n 389: invokespecial #167 // Method java/util/ArrayList.\"<init>\":()V\n 392: checkcast #135 // class java/util/List\n 395: astore 7\n 397: iconst_0\n 398: istore 8\n 400: aload_1\n 401: checkcast #169 // class java/util/Collection\n 404: invokeinterface #331, 1 // InterfaceMethod java/util/Collection.size:()I\n 409: istore 9\n 411: iload 8\n 413: iload 9\n 415: if_icmpge 637\n 418: aload_1\n 419: iload 8\n 421: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 426: checkcast #209 // class org/aoc2021/Day23$HallwayPosition\n 429: astore 10\n 431: aload 10\n 433: instanceof #211 // class org/aoc2021/Day23$Space\n 436: ifne 442\n 439: goto 631\n 442: aload_0\n 443: aload_1\n 444: iload_2\n 445: iload 8\n 447: invokespecial #334 // Method canMoveToSpace:(Ljava/util/List;II)Z\n 450: ifeq 631\n 453: aload 6\n 455: invokevirtual #272 // Method org/aoc2021/Day23$Amphipod.getEnergyPerStep:()I\n 458: iload_2\n 459: iload 8\n 461: isub\n 462: invokestatic #278 // Method java/lang/Math.abs:(I)I\n 465: iconst_1\n 466: iadd\n 467: aload_3\n 468: invokevirtual #321 // Method org/aoc2021/Day23$Room.firstOccupiedIndex:()I\n 471: iadd\n 472: imul\n 473: istore 11\n 475: aload_1\n 476: checkcast #110 // class java/lang/Iterable\n 479: astore 13\n 481: iconst_0\n 482: istore 14\n 484: aload 13\n 486: astore 15\n 488: new #166 // class java/util/ArrayList\n 491: dup\n 492: aload 13\n 494: bipush 10\n 496: invokestatic #285 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 499: invokespecial #288 // Method java/util/ArrayList.\"<init>\":(I)V\n 502: checkcast #169 // class java/util/Collection\n 505: astore 16\n 507: iconst_0\n 508: istore 17\n 510: aload 15\n 512: invokeinterface #114, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 517: astore 18\n 519: aload 18\n 521: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 526: ifeq 605\n 529: aload 18\n 531: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 536: astore 19\n 538: aload 16\n 540: aload 19\n 542: checkcast #209 // class org/aoc2021/Day23$HallwayPosition\n 545: astore 20\n 547: astore 22\n 549: iconst_0\n 550: istore 21\n 552: aload 20\n 554: aload_3\n 555: if_acmpne 568\n 558: aload_3\n 559: invokevirtual #328 // Method org/aoc2021/Day23$Room.withoutTopOccupant:()Lorg/aoc2021/Day23$Room;\n 562: checkcast #209 // class org/aoc2021/Day23$HallwayPosition\n 565: goto 592\n 568: aload 20\n 570: aload 10\n 572: if_acmpne 590\n 575: new #211 // class org/aoc2021/Day23$Space\n 578: dup\n 579: aload 6\n 581: invokespecial #291 // Method org/aoc2021/Day23$Space.\"<init>\":(Lorg/aoc2021/Day23$Amphipod;)V\n 584: checkcast #209 // class org/aoc2021/Day23$HallwayPosition\n 587: goto 592\n 590: aload 20\n 592: nop\n 593: aload 22\n 595: swap\n 596: invokeinterface #172, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 601: pop\n 602: goto 519\n 605: aload 16\n 607: checkcast #135 // class java/util/List\n 610: nop\n 611: astore 12\n 613: aload 7\n 615: iload 11\n 617: invokestatic #97 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 620: aload 12\n 622: invokestatic #301 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 625: invokeinterface #335, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 630: pop\n 631: iinc 8, 1\n 634: goto 411\n 637: aload 7\n 639: checkcast #110 // class java/lang/Iterable\n 642: invokestatic #233 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 645: areturn\n\n private final boolean canMoveToSpace(java.util.List<? extends org.aoc2021.Day23$HallwayPosition>, int, int);\n Code:\n 0: aload_1\n 1: iload_3\n 2: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: dup\n 8: ldc_w #346 // String null cannot be cast to non-null type org.aoc2021.Day23.Space\n 11: invokestatic #265 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: checkcast #211 // class org/aoc2021/Day23$Space\n 17: astore 4\n 19: aload 4\n 21: invokevirtual #247 // Method org/aoc2021/Day23$Space.getOccupant:()Lorg/aoc2021/Day23$Amphipod;\n 24: ifnull 29\n 27: iconst_0\n 28: ireturn\n 29: aload_0\n 30: aload_1\n 31: iload_2\n 32: iload_3\n 33: invokespecial #349 // Method canMoveToPosition:(Ljava/util/List;II)Z\n 36: ireturn\n\n private final boolean canMoveToRoom(java.util.List<? extends org.aoc2021.Day23$HallwayPosition>, int, int);\n Code:\n 0: getstatic #175 // Field winState:Ljava/util/List;\n 3: iload_3\n 4: iconst_2\n 5: isub\n 6: iconst_2\n 7: idiv\n 8: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 13: checkcast #184 // class org/aoc2021/Day23$Amphipod\n 16: astore 4\n 18: aload_1\n 19: iload_3\n 20: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 25: dup\n 26: ldc_w #259 // String null cannot be cast to non-null type org.aoc2021.Day23.Room\n 29: invokestatic #265 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;Ljava/lang/String;)V\n 32: checkcast #171 // class org/aoc2021/Day23$Room\n 35: astore 5\n 37: aload 5\n 39: invokevirtual #187 // Method org/aoc2021/Day23$Room.getOccupants:()Ljava/util/List;\n 42: checkcast #110 // class java/lang/Iterable\n 45: astore 6\n 47: iconst_0\n 48: istore 7\n 50: aload 6\n 52: instanceof #169 // class java/util/Collection\n 55: ifeq 75\n 58: aload 6\n 60: checkcast #169 // class java/util/Collection\n 63: invokeinterface #182, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 68: ifeq 75\n 71: iconst_1\n 72: goto 138\n 75: aload 6\n 77: invokeinterface #114, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 82: astore 8\n 84: aload 8\n 86: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 91: ifeq 137\n 94: aload 8\n 96: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 101: astore 9\n 103: aload 9\n 105: checkcast #184 // class org/aoc2021/Day23$Amphipod\n 108: astore 10\n 110: iconst_0\n 111: istore 11\n 113: aload 10\n 115: ifnull 125\n 118: aload 10\n 120: aload 4\n 122: if_acmpne 129\n 125: iconst_1\n 126: goto 130\n 129: iconst_0\n 130: ifne 84\n 133: iconst_0\n 134: goto 138\n 137: iconst_1\n 138: ifne 143\n 141: iconst_0\n 142: ireturn\n 143: aload_0\n 144: aload_1\n 145: iload_2\n 146: iload_3\n 147: invokespecial #349 // Method canMoveToPosition:(Ljava/util/List;II)Z\n 150: ireturn\n\n private final boolean canMoveToPosition(java.util.List<? extends org.aoc2021.Day23$HallwayPosition>, int, int);\n Code:\n 0: iload_2\n 1: iload_3\n 2: invokestatic #354 // Method java/lang/Math.min:(II)I\n 5: istore 4\n 7: iload_2\n 8: iload_3\n 9: invokestatic #357 // Method java/lang/Math.max:(II)I\n 12: istore 5\n 14: iload 4\n 16: iconst_1\n 17: iadd\n 18: iload 5\n 20: invokestatic #363 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 23: checkcast #110 // class java/lang/Iterable\n 26: astore 6\n 28: iconst_0\n 29: istore 7\n 31: aload 6\n 33: instanceof #169 // class java/util/Collection\n 36: ifeq 56\n 39: aload 6\n 41: checkcast #169 // class java/util/Collection\n 44: invokeinterface #182, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 49: ifeq 56\n 52: iconst_1\n 53: goto 137\n 56: aload 6\n 58: invokeinterface #114, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 63: astore 8\n 65: aload 8\n 67: invokeinterface #119, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 72: ifeq 136\n 75: aload 8\n 77: checkcast #365 // class kotlin/collections/IntIterator\n 80: invokevirtual #368 // Method kotlin/collections/IntIterator.nextInt:()I\n 83: istore 9\n 85: iload 9\n 87: istore 10\n 89: iconst_0\n 90: istore 11\n 92: aload_1\n 93: iload 10\n 95: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 100: checkcast #209 // class org/aoc2021/Day23$HallwayPosition\n 103: astore 12\n 105: aload 12\n 107: instanceof #211 // class org/aoc2021/Day23$Space\n 110: ifeq 124\n 113: aload 12\n 115: checkcast #211 // class org/aoc2021/Day23$Space\n 118: invokevirtual #247 // Method org/aoc2021/Day23$Space.getOccupant:()Lorg/aoc2021/Day23$Amphipod;\n 121: ifnonnull 128\n 124: iconst_1\n 125: goto 129\n 128: iconst_0\n 129: ifne 65\n 132: iconst_0\n 133: goto 137\n 136: iconst_1\n 137: ireturn\n\n private final java.util.List<org.aoc2021.Day23$HallwayPosition> parseInput(java.util.List<java.lang.String>, boolean);\n Code:\n 0: aload_1\n 1: iconst_2\n 2: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #374 // class java/lang/String\n 10: astore 4\n 12: getstatic #378 // Field amphipodChars:Ljava/util/Set;\n 15: astore 5\n 17: iconst_0\n 18: istore 6\n 20: aload 4\n 22: checkcast #380 // class java/lang/CharSequence\n 25: astore 7\n 27: new #382 // class java/lang/StringBuilder\n 30: dup\n 31: invokespecial #383 // Method java/lang/StringBuilder.\"<init>\":()V\n 34: checkcast #385 // class java/lang/Appendable\n 37: astore 8\n 39: iconst_0\n 40: istore 9\n 42: iconst_0\n 43: istore 10\n 45: aload 7\n 47: invokeinterface #388, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 52: istore 11\n 54: iload 10\n 56: iload 11\n 58: if_icmpge 110\n 61: aload 7\n 63: iload 10\n 65: invokeinterface #392, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 70: istore 12\n 72: iload 12\n 74: istore 13\n 76: iconst_0\n 77: istore 14\n 79: aload 5\n 81: iload 13\n 83: invokestatic #397 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 86: invokeinterface #402, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 91: ifeq 104\n 94: aload 8\n 96: iload 12\n 98: invokeinterface #406, 2 // InterfaceMethod java/lang/Appendable.append:(C)Ljava/lang/Appendable;\n 103: pop\n 104: iinc 10, 1\n 107: goto 54\n 110: aload 8\n 112: checkcast #382 // class java/lang/StringBuilder\n 115: invokevirtual #410 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 118: invokevirtual #414 // Method java/lang/String.toCharArray:()[C\n 121: dup\n 122: ldc_w #416 // String toCharArray(...)\n 125: invokestatic #419 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 128: astore_3\n 129: aload_1\n 130: iconst_3\n 131: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 136: checkcast #374 // class java/lang/String\n 139: astore 5\n 141: getstatic #378 // Field amphipodChars:Ljava/util/Set;\n 144: astore 6\n 146: iconst_0\n 147: istore 7\n 149: aload 5\n 151: checkcast #380 // class java/lang/CharSequence\n 154: astore 8\n 156: new #382 // class java/lang/StringBuilder\n 159: dup\n 160: invokespecial #383 // Method java/lang/StringBuilder.\"<init>\":()V\n 163: checkcast #385 // class java/lang/Appendable\n 166: astore 9\n 168: iconst_0\n 169: istore 10\n 171: iconst_0\n 172: istore 11\n 174: aload 8\n 176: invokeinterface #388, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 181: istore 12\n 183: iload 11\n 185: iload 12\n 187: if_icmpge 239\n 190: aload 8\n 192: iload 11\n 194: invokeinterface #392, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 199: istore 13\n 201: iload 13\n 203: istore 14\n 205: iconst_0\n 206: istore 15\n 208: aload 6\n 210: iload 14\n 212: invokestatic #397 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 215: invokeinterface #402, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 220: ifeq 233\n 223: aload 9\n 225: iload 13\n 227: invokeinterface #406, 2 // InterfaceMethod java/lang/Appendable.append:(C)Ljava/lang/Appendable;\n 232: pop\n 233: iinc 11, 1\n 236: goto 183\n 239: aload 9\n 241: checkcast #382 // class java/lang/StringBuilder\n 244: invokevirtual #410 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 247: invokevirtual #414 // Method java/lang/String.toCharArray:()[C\n 250: dup\n 251: ldc_w #416 // String toCharArray(...)\n 254: invokestatic #419 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 257: astore 4\n 259: aload_3\n 260: aload 4\n 262: invokestatic #424 // Method kotlin/collections/ArraysKt.zip:([C[C)Ljava/util/List;\n 265: astore 5\n 267: iconst_0\n 268: istore 6\n 270: new #166 // class java/util/ArrayList\n 273: dup\n 274: invokespecial #167 // Method java/util/ArrayList.\"<init>\":()V\n 277: checkcast #135 // class java/util/List\n 280: astore 7\n 282: iconst_0\n 283: istore 8\n 285: iload 8\n 287: bipush 11\n 289: if_icmpge 510\n 292: getstatic #427 // Field roomIndices:Ljava/util/Set;\n 295: iload 8\n 297: invokestatic #97 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 300: invokeinterface #402, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 305: ifeq 488\n 308: aload 5\n 310: iload 6\n 312: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 317: checkcast #124 // class kotlin/Pair\n 320: astore 9\n 322: aload 9\n 324: invokevirtual #127 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 327: checkcast #394 // class java/lang/Character\n 330: invokevirtual #431 // Method java/lang/Character.charValue:()C\n 333: istore 10\n 335: aload 9\n 337: invokevirtual #133 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 340: checkcast #394 // class java/lang/Character\n 343: invokevirtual #431 // Method java/lang/Character.charValue:()C\n 346: istore 11\n 348: iload_2\n 349: ifeq 429\n 352: new #171 // class org/aoc2021/Day23$Room\n 355: dup\n 356: iconst_4\n 357: anewarray #184 // class org/aoc2021/Day23$Amphipod\n 360: astore 13\n 362: aload 13\n 364: iconst_0\n 365: aload_0\n 366: iload 10\n 368: invokespecial #435 // Method charToAmphipod:(C)Lorg/aoc2021/Day23$Amphipod;\n 371: aastore\n 372: aload 13\n 374: iconst_1\n 375: getstatic #438 // Field secondRow:Ljava/util/List;\n 378: iload 8\n 380: iconst_2\n 381: isub\n 382: iconst_2\n 383: idiv\n 384: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 389: aastore\n 390: aload 13\n 392: iconst_2\n 393: getstatic #441 // Field thirdRow:Ljava/util/List;\n 396: iload 8\n 398: iconst_2\n 399: isub\n 400: iconst_2\n 401: idiv\n 402: invokeinterface #257, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 407: aastore\n 408: aload 13\n 410: iconst_3\n 411: aload_0\n 412: iload 11\n 414: invokespecial #435 // Method charToAmphipod:(C)Lorg/aoc2021/Day23$Amphipod;\n 417: aastore\n 418: aload 13\n 420: invokestatic #444 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 423: invokespecial #447 // Method org/aoc2021/Day23$Room.\"<init>\":(Ljava/util/List;)V\n 426: goto 467\n 429: new #171 // class org/aoc2021/Day23$Room\n 432: dup\n 433: iconst_2\n 434: anewarray #184 // class org/aoc2021/Day23$Amphipod\n 437: astore 13\n 439: aload 13\n 441: iconst_0\n 442: aload_0\n 443: iload 10\n 445: invokespecial #435 // Method charToAmphipod:(C)Lorg/aoc2021/Day23$Amphipod;\n 448: aastore\n 449: aload 13\n 451: iconst_1\n 452: aload_0\n 453: iload 11\n 455: invokespecial #435 // Method charToAmphipod:(C)Lorg/aoc2021/Day23$Amphipod;\n 458: aastore\n 459: aload 13\n 461: invokestatic #444 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 464: invokespecial #447 // Method org/aoc2021/Day23$Room.\"<init>\":(Ljava/util/List;)V\n 467: astore 12\n 469: aload 7\n 471: aload 12\n 473: invokeinterface #335, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 478: pop\n 479: iload 6\n 481: iinc 6, 1\n 484: pop\n 485: goto 504\n 488: aload 7\n 490: new #211 // class org/aoc2021/Day23$Space\n 493: dup\n 494: aconst_null\n 495: invokespecial #291 // Method org/aoc2021/Day23$Space.\"<init>\":(Lorg/aoc2021/Day23$Amphipod;)V\n 498: invokeinterface #335, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 503: pop\n 504: iinc 8, 1\n 507: goto 285\n 510: aload 7\n 512: checkcast #110 // class java/lang/Iterable\n 515: invokestatic #233 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 518: areturn\n\n private final org.aoc2021.Day23$Amphipod charToAmphipod(char);\n Code:\n 0: iload_1\n 1: tableswitch { // 65 to 68\n 65: 32\n 66: 38\n 67: 44\n 68: 50\n default: 56\n }\n 32: getstatic #473 // Field org/aoc2021/Day23$Amphipod.AMBER:Lorg/aoc2021/Day23$Amphipod;\n 35: goto 68\n 38: getstatic #476 // Field org/aoc2021/Day23$Amphipod.BRONZE:Lorg/aoc2021/Day23$Amphipod;\n 41: goto 68\n 44: getstatic #479 // Field org/aoc2021/Day23$Amphipod.COPPER:Lorg/aoc2021/Day23$Amphipod;\n 47: goto 68\n 50: getstatic #482 // Field org/aoc2021/Day23$Amphipod.DESERT:Lorg/aoc2021/Day23$Amphipod;\n 53: goto 68\n 56: new #137 // class java/lang/IllegalArgumentException\n 59: dup\n 60: iload_1\n 61: invokestatic #485 // Method java/lang/String.valueOf:(C)Ljava/lang/String;\n 64: invokespecial #142 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 67: athrow\n 68: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc_w #492 // String args\n 4: invokestatic #495 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: ldc_w #497 // String input23.txt\n 10: iconst_0\n 11: anewarray #374 // class java/lang/String\n 14: invokestatic #503 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 17: getstatic #509 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 20: invokestatic #515 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 23: astore_1\n 24: getstatic #214 // Field INSTANCE:Lorg/aoc2021/Day23;\n 27: aload_1\n 28: invokestatic #324 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 31: aload_1\n 32: iconst_0\n 33: invokespecial #517 // Method solve:(Ljava/util/List;Z)I\n 36: istore_2\n 37: getstatic #523 // Field java/lang/System.out:Ljava/io/PrintStream;\n 40: iload_2\n 41: invokevirtual #528 // Method java/io/PrintStream.println:(I)V\n 44: getstatic #214 // Field INSTANCE:Lorg/aoc2021/Day23;\n 47: aload_1\n 48: iconst_1\n 49: invokespecial #517 // Method solve:(Ljava/util/List;Z)I\n 52: istore_3\n 53: getstatic #523 // Field java/lang/System.out:Ljava/io/PrintStream;\n 56: iload_3\n 57: invokevirtual #528 // Method java/io/PrintStream.println:(I)V\n 60: return\n\n private static final int solve$lambda$0(org.aoc2021.Day23$State, org.aoc2021.Day23$State);\n Code:\n 0: aload_0\n 1: invokevirtual #79 // Method org/aoc2021/Day23$State.getDistance:()I\n 4: aload_1\n 5: invokevirtual #79 // Method org/aoc2021/Day23$State.getDistance:()I\n 8: invokestatic #533 // Method kotlin/jvm/internal/Intrinsics.compare:(II)I\n 11: ireturn\n\n private static final int solve$lambda$1(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 #539, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 8: checkcast #129 // class java/lang/Number\n 11: invokevirtual #130 // Method java/lang/Number.intValue:()I\n 14: ireturn\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day23\n 3: dup\n 4: invokespecial #544 // Method \"<init>\":()V\n 7: putstatic #214 // Field INSTANCE:Lorg/aoc2021/Day23;\n 10: iconst_4\n 11: anewarray #394 // class java/lang/Character\n 14: astore_0\n 15: aload_0\n 16: iconst_0\n 17: bipush 65\n 19: invokestatic #397 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 22: aastore\n 23: aload_0\n 24: iconst_1\n 25: bipush 66\n 27: invokestatic #397 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 30: aastore\n 31: aload_0\n 32: iconst_2\n 33: bipush 67\n 35: invokestatic #397 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 38: aastore\n 39: aload_0\n 40: iconst_3\n 41: bipush 68\n 43: invokestatic #397 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 46: aastore\n 47: aload_0\n 48: invokestatic #550 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 51: putstatic #378 // Field amphipodChars:Ljava/util/Set;\n 54: iconst_4\n 55: anewarray #89 // class java/lang/Integer\n 58: astore_0\n 59: aload_0\n 60: iconst_0\n 61: iconst_2\n 62: invokestatic #97 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 65: aastore\n 66: aload_0\n 67: iconst_1\n 68: iconst_4\n 69: invokestatic #97 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 72: aastore\n 73: aload_0\n 74: iconst_2\n 75: bipush 6\n 77: invokestatic #97 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 80: aastore\n 81: aload_0\n 82: iconst_3\n 83: bipush 8\n 85: invokestatic #97 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 88: aastore\n 89: aload_0\n 90: invokestatic #550 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 93: putstatic #427 // Field roomIndices:Ljava/util/Set;\n 96: iconst_4\n 97: anewarray #184 // class org/aoc2021/Day23$Amphipod\n 100: astore_0\n 101: aload_0\n 102: iconst_0\n 103: getstatic #482 // Field org/aoc2021/Day23$Amphipod.DESERT:Lorg/aoc2021/Day23$Amphipod;\n 106: aastore\n 107: aload_0\n 108: iconst_1\n 109: getstatic #479 // Field org/aoc2021/Day23$Amphipod.COPPER:Lorg/aoc2021/Day23$Amphipod;\n 112: aastore\n 113: aload_0\n 114: iconst_2\n 115: getstatic #476 // Field org/aoc2021/Day23$Amphipod.BRONZE:Lorg/aoc2021/Day23$Amphipod;\n 118: aastore\n 119: aload_0\n 120: iconst_3\n 121: getstatic #473 // Field org/aoc2021/Day23$Amphipod.AMBER:Lorg/aoc2021/Day23$Amphipod;\n 124: aastore\n 125: aload_0\n 126: invokestatic #444 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 129: putstatic #438 // Field secondRow:Ljava/util/List;\n 132: iconst_4\n 133: anewarray #184 // class org/aoc2021/Day23$Amphipod\n 136: astore_0\n 137: aload_0\n 138: iconst_0\n 139: getstatic #482 // Field org/aoc2021/Day23$Amphipod.DESERT:Lorg/aoc2021/Day23$Amphipod;\n 142: aastore\n 143: aload_0\n 144: iconst_1\n 145: getstatic #476 // Field org/aoc2021/Day23$Amphipod.BRONZE:Lorg/aoc2021/Day23$Amphipod;\n 148: aastore\n 149: aload_0\n 150: iconst_2\n 151: getstatic #473 // Field org/aoc2021/Day23$Amphipod.AMBER:Lorg/aoc2021/Day23$Amphipod;\n 154: aastore\n 155: aload_0\n 156: iconst_3\n 157: getstatic #479 // Field org/aoc2021/Day23$Amphipod.COPPER:Lorg/aoc2021/Day23$Amphipod;\n 160: aastore\n 161: aload_0\n 162: invokestatic #444 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 165: putstatic #441 // Field thirdRow:Ljava/util/List;\n 168: invokestatic #554 // Method org/aoc2021/Day23$Amphipod.values:()[Lorg/aoc2021/Day23$Amphipod;\n 171: invokestatic #556 // Method kotlin/collections/ArraysKt.toList:([Ljava/lang/Object;)Ljava/util/List;\n 174: putstatic #175 // Field winState:Ljava/util/List;\n 177: return\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day23$Space.class",
"javap": "Compiled from \"Day23.kt\"\npublic final class org.aoc2021.Day23$Space implements org.aoc2021.Day23$HallwayPosition {\n private final org.aoc2021.Day23$Amphipod occupant;\n\n public org.aoc2021.Day23$Space(org.aoc2021.Day23$Amphipod);\n Code:\n 0: aload_0\n 1: invokespecial #12 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: aload_1\n 6: putfield #16 // Field occupant:Lorg/aoc2021/Day23$Amphipod;\n 9: return\n\n public final org.aoc2021.Day23$Amphipod getOccupant();\n Code:\n 0: aload_0\n 1: getfield #16 // Field occupant:Lorg/aoc2021/Day23$Amphipod;\n 4: areturn\n\n public final org.aoc2021.Day23$Amphipod component1();\n Code:\n 0: aload_0\n 1: getfield #16 // Field occupant:Lorg/aoc2021/Day23$Amphipod;\n 4: areturn\n\n public final org.aoc2021.Day23$Space copy(org.aoc2021.Day23$Amphipod);\n Code:\n 0: new #2 // class org/aoc2021/Day23$Space\n 3: dup\n 4: aload_1\n 5: invokespecial #26 // Method \"<init>\":(Lorg/aoc2021/Day23$Amphipod;)V\n 8: areturn\n\n public static org.aoc2021.Day23$Space copy$default(org.aoc2021.Day23$Space, org.aoc2021.Day23$Amphipod, 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 #16 // Field occupant:Lorg/aoc2021/Day23$Amphipod;\n 10: astore_1\n 11: aload_0\n 12: aload_1\n 13: invokevirtual #30 // Method copy:(Lorg/aoc2021/Day23$Amphipod;)Lorg/aoc2021/Day23$Space;\n 16: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #34 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #35 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #37 // String Space(occupant=\n 9: invokevirtual #41 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #16 // Field occupant:Lorg/aoc2021/Day23$Amphipod;\n 16: invokevirtual #44 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: bipush 41\n 21: invokevirtual #47 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 24: invokevirtual #49 // 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 #16 // Field occupant:Lorg/aoc2021/Day23$Amphipod;\n 4: ifnonnull 11\n 7: iconst_0\n 8: goto 18\n 11: aload_0\n 12: getfield #16 // Field occupant:Lorg/aoc2021/Day23$Amphipod;\n 15: invokevirtual #55 // Method org/aoc2021/Day23$Amphipod.hashCode:()I\n 18: 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 org/aoc2021/Day23$Space\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day23$Space\n 20: astore_2\n 21: aload_0\n 22: getfield #16 // Field occupant:Lorg/aoc2021/Day23$Amphipod;\n 25: aload_2\n 26: getfield #16 // Field occupant:Lorg/aoc2021/Day23$Amphipod;\n 29: if_acmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: iconst_1\n 35: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day23$State.class",
"javap": "Compiled from \"Day23.kt\"\npublic final class org.aoc2021.Day23$State {\n private final int distance;\n\n private final java.util.List<org.aoc2021.Day23$HallwayPosition> hallway;\n\n public org.aoc2021.Day23$State(int, java.util.List<? extends org.aoc2021.Day23$HallwayPosition>);\n Code:\n 0: aload_2\n 1: ldc #10 // String hallway\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: iload_1\n 12: putfield #23 // Field distance:I\n 15: aload_0\n 16: aload_2\n 17: putfield #26 // Field hallway:Ljava/util/List;\n 20: return\n\n public final int getDistance();\n Code:\n 0: aload_0\n 1: getfield #23 // Field distance:I\n 4: ireturn\n\n public final java.util.List<org.aoc2021.Day23$HallwayPosition> getHallway();\n Code:\n 0: aload_0\n 1: getfield #26 // Field hallway:Ljava/util/List;\n 4: areturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #23 // Field distance:I\n 4: ireturn\n\n public final java.util.List<org.aoc2021.Day23$HallwayPosition> component2();\n Code:\n 0: aload_0\n 1: getfield #26 // Field hallway:Ljava/util/List;\n 4: areturn\n\n public final org.aoc2021.Day23$State copy(int, java.util.List<? extends org.aoc2021.Day23$HallwayPosition>);\n Code:\n 0: aload_2\n 1: ldc #10 // String hallway\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class org/aoc2021/Day23$State\n 9: dup\n 10: iload_1\n 11: aload_2\n 12: invokespecial #40 // Method \"<init>\":(ILjava/util/List;)V\n 15: areturn\n\n public static org.aoc2021.Day23$State copy$default(org.aoc2021.Day23$State, int, java.util.List, 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 distance: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 #26 // Field hallway:Ljava/util/List;\n 21: astore_2\n 22: aload_0\n 23: iload_1\n 24: aload_2\n 25: invokevirtual #44 // Method copy:(ILjava/util/List;)Lorg/aoc2021/Day23$State;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #48 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #49 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #51 // String State(distance=\n 9: invokevirtual #55 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #23 // Field distance:I\n 16: invokevirtual #58 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #60 // String , hallway=\n 21: invokevirtual #55 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #26 // Field hallway:Ljava/util/List;\n 28: invokevirtual #63 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #66 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #68 // 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 distance:I\n 4: invokestatic #74 // 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 #26 // Field hallway:Ljava/util/List;\n 16: invokevirtual #76 // 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 org/aoc2021/Day23$State\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day23$State\n 20: astore_2\n 21: aload_0\n 22: getfield #23 // Field distance:I\n 25: aload_2\n 26: getfield #23 // Field distance:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #26 // Field hallway:Ljava/util/List;\n 38: aload_2\n 39: getfield #26 // Field hallway:Ljava/util/List;\n 42: invokestatic #84 // 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": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day9.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
object Day9 {
data class Point(val x: Int, val y: Int)
private fun solvePart1(lines: List<String>): Int {
val heights = lines.map { line ->
line.map(Char::digitToInt)
}
val lowPoints = findLowPoints(heights)
return lowPoints.sumOf { p ->
1 + heights[p.x][p.y]
}
}
private fun solvePart2(lines: List<String>): Int {
val heights = lines.map { line ->
line.map(Char::digitToInt)
}
val lowPoints = findLowPoints(heights)
val basinMarkers = findBasins(heights, lowPoints)
return basinMarkers.flatten()
.filter { it != 0 }
.groupBy { it }
.map { (_, values) -> values.size }
.sortedDescending()
.take(3)
.reduce { a, b -> a * b }
}
private fun findLowPoints(heights: List<List<Int>>): List<Point> {
val lowPoints = mutableListOf<Point>()
for (i in heights.indices) {
for (j in heights[0].indices) {
if (
(i == 0 || heights[i][j] < heights[i-1][j]) &&
(i == heights.size - 1 || heights[i][j] < heights[i+1][j]) &&
(j == 0 || heights[i][j] < heights[i][j-1]) &&
(j == heights[0].size - 1 || heights[i][j] < heights[i][j+1])
) {
lowPoints.add(Point(i, j))
}
}
}
return lowPoints.toList()
}
private fun findBasins(heights: List<List<Int>>, lowPoints: List<Point>): Array<Array<Int>> {
val basinMarkers = Array(heights.size) { Array(heights[0].size) { 0 } }
lowPoints.forEachIndexed { index, p ->
val marker = index + 1
fill(p, marker, heights, basinMarkers)
}
return basinMarkers
}
private fun fill(p: Point, marker: Int, heights: List<List<Int>>, basinMarkers: Array<Array<Int>>) {
val (x, y) = p
basinMarkers[x][y] = marker
listOf(
-1 to 0,
1 to 0,
0 to -1,
0 to 1,
).forEach { (dx, dy) ->
val i = x + dx
val j = y + dy
if (
i >= 0 && i < heights.size &&
j >= 0 && j < heights[0].size &&
heights[i][j] != 9 && basinMarkers[i][j] == 0
) {
fill(Point(i, j), marker, heights, basinMarkers)
}
}
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input9.txt"), Charsets.UTF_8)
val solution1 = solvePart1(lines)
println(solution1)
val solution2 = solvePart2(lines)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day9$Point.class",
"javap": "Compiled from \"Day9.kt\"\npublic final class org.aoc2021.Day9$Point {\n private final int x;\n\n private final int y;\n\n public org.aoc2021.Day9$Point(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 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 org.aoc2021.Day9$Point copy(int, int);\n Code:\n 0: new #2 // class org/aoc2021/Day9$Point\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: invokespecial #28 // Method \"<init>\":(II)V\n 9: areturn\n\n public static org.aoc2021.Day9$Point copy$default(org.aoc2021.Day9$Point, 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 #32 // Method copy:(II)Lorg/aoc2021/Day9$Point;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #36 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #37 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #39 // String Point(x=\n 9: invokevirtual #43 // 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 #46 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #48 // String , y=\n 21: invokevirtual #43 // 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 #46 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #51 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #53 // 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 #59 // 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 #59 // 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 org/aoc2021/Day9$Point\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day9$Point\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": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day9.class",
"javap": "Compiled from \"Day9.kt\"\npublic final class org.aoc2021.Day9 {\n public static final org.aoc2021.Day9 INSTANCE;\n\n private org.aoc2021.Day9();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int solvePart1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #15 // 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 #17 // class java/util/ArrayList\n 14: dup\n 15: aload_3\n 16: bipush 10\n 18: invokestatic #23 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 21: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 24: checkcast #28 // class java/util/Collection\n 27: astore 6\n 29: iconst_0\n 30: istore 7\n 32: aload 5\n 34: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 8\n 41: aload 8\n 43: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 189\n 51: aload 8\n 53: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 9\n 60: aload 6\n 62: aload 9\n 64: checkcast #44 // class java/lang/String\n 67: astore 10\n 69: astore 22\n 71: iconst_0\n 72: istore 11\n 74: aload 10\n 76: checkcast #46 // class java/lang/CharSequence\n 79: astore 12\n 81: iconst_0\n 82: istore 13\n 84: aload 12\n 86: astore 14\n 88: new #17 // class java/util/ArrayList\n 91: dup\n 92: aload 12\n 94: invokeinterface #50, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 99: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 102: checkcast #28 // class java/util/Collection\n 105: astore 15\n 107: iconst_0\n 108: istore 16\n 110: iconst_0\n 111: istore 17\n 113: iload 17\n 115: aload 14\n 117: invokeinterface #50, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 122: if_icmpge 170\n 125: aload 14\n 127: iload 17\n 129: invokeinterface #54, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 134: istore 18\n 136: aload 15\n 138: iload 18\n 140: istore 19\n 142: astore 20\n 144: iconst_0\n 145: istore 21\n 147: iload 19\n 149: invokestatic #60 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 152: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 155: aload 20\n 157: swap\n 158: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 163: pop\n 164: iinc 17, 1\n 167: goto 113\n 170: aload 15\n 172: checkcast #72 // class java/util/List\n 175: nop\n 176: nop\n 177: aload 22\n 179: swap\n 180: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 185: pop\n 186: goto 41\n 189: aload 6\n 191: checkcast #72 // class java/util/List\n 194: nop\n 195: astore_2\n 196: aload_0\n 197: aload_2\n 198: invokespecial #76 // Method findLowPoints:(Ljava/util/List;)Ljava/util/List;\n 201: astore_3\n 202: aload_3\n 203: checkcast #15 // class java/lang/Iterable\n 206: astore 4\n 208: iconst_0\n 209: istore 5\n 211: aload 4\n 213: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 218: astore 6\n 220: aload 6\n 222: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 227: ifeq 297\n 230: aload 6\n 232: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 237: astore 7\n 239: iload 5\n 241: aload 7\n 243: checkcast #78 // class org/aoc2021/Day9$Point\n 246: astore 8\n 248: istore 22\n 250: iconst_0\n 251: istore 9\n 253: iconst_1\n 254: aload_2\n 255: aload 8\n 257: invokevirtual #81 // Method org/aoc2021/Day9$Point.getX:()I\n 260: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 265: checkcast #72 // class java/util/List\n 268: aload 8\n 270: invokevirtual #88 // Method org/aoc2021/Day9$Point.getY:()I\n 273: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 278: checkcast #90 // class java/lang/Number\n 281: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 284: iadd\n 285: istore 23\n 287: iload 22\n 289: iload 23\n 291: iadd\n 292: istore 5\n 294: goto 220\n 297: iload 5\n 299: ireturn\n\n private final int solvePart2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #15 // 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 #17 // class java/util/ArrayList\n 14: dup\n 15: aload_3\n 16: bipush 10\n 18: invokestatic #23 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 21: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 24: checkcast #28 // class java/util/Collection\n 27: astore 6\n 29: iconst_0\n 30: istore 7\n 32: aload 5\n 34: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 39: astore 8\n 41: aload 8\n 43: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 48: ifeq 189\n 51: aload 8\n 53: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 58: astore 9\n 60: aload 6\n 62: aload 9\n 64: checkcast #44 // class java/lang/String\n 67: astore 10\n 69: astore 22\n 71: iconst_0\n 72: istore 11\n 74: aload 10\n 76: checkcast #46 // class java/lang/CharSequence\n 79: astore 12\n 81: iconst_0\n 82: istore 13\n 84: aload 12\n 86: astore 14\n 88: new #17 // class java/util/ArrayList\n 91: dup\n 92: aload 12\n 94: invokeinterface #50, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 99: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 102: checkcast #28 // class java/util/Collection\n 105: astore 15\n 107: iconst_0\n 108: istore 16\n 110: iconst_0\n 111: istore 17\n 113: iload 17\n 115: aload 14\n 117: invokeinterface #50, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 122: if_icmpge 170\n 125: aload 14\n 127: iload 17\n 129: invokeinterface #54, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 134: istore 18\n 136: aload 15\n 138: iload 18\n 140: istore 19\n 142: astore 20\n 144: iconst_0\n 145: istore 21\n 147: iload 19\n 149: invokestatic #60 // Method kotlin/text/CharsKt.digitToInt:(C)I\n 152: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 155: aload 20\n 157: swap\n 158: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 163: pop\n 164: iinc 17, 1\n 167: goto 113\n 170: aload 15\n 172: checkcast #72 // class java/util/List\n 175: nop\n 176: nop\n 177: aload 22\n 179: swap\n 180: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 185: pop\n 186: goto 41\n 189: aload 6\n 191: checkcast #72 // class java/util/List\n 194: nop\n 195: astore_2\n 196: aload_0\n 197: aload_2\n 198: invokespecial #76 // Method findLowPoints:(Ljava/util/List;)Ljava/util/List;\n 201: astore_3\n 202: aload_0\n 203: aload_2\n 204: aload_3\n 205: invokespecial #122 // Method findBasins:(Ljava/util/List;Ljava/util/List;)[[Ljava/lang/Integer;\n 208: astore 4\n 210: aload 4\n 212: invokestatic #128 // Method kotlin/collections/ArraysKt.flatten:([[Ljava/lang/Object;)Ljava/util/List;\n 215: checkcast #15 // class java/lang/Iterable\n 218: astore 5\n 220: nop\n 221: iconst_0\n 222: istore 6\n 224: aload 5\n 226: astore 7\n 228: new #17 // class java/util/ArrayList\n 231: dup\n 232: invokespecial #129 // Method java/util/ArrayList.\"<init>\":()V\n 235: checkcast #28 // class java/util/Collection\n 238: astore 8\n 240: iconst_0\n 241: istore 9\n 243: aload 7\n 245: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 250: astore 10\n 252: aload 10\n 254: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 259: ifeq 310\n 262: aload 10\n 264: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 269: astore 11\n 271: aload 11\n 273: checkcast #90 // class java/lang/Number\n 276: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 279: istore 12\n 281: iconst_0\n 282: istore 13\n 284: iload 12\n 286: ifeq 293\n 289: iconst_1\n 290: goto 294\n 293: iconst_0\n 294: ifeq 252\n 297: aload 8\n 299: aload 11\n 301: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 306: pop\n 307: goto 252\n 310: aload 8\n 312: checkcast #72 // class java/util/List\n 315: nop\n 316: checkcast #15 // class java/lang/Iterable\n 319: astore 5\n 321: nop\n 322: iconst_0\n 323: istore 6\n 325: aload 5\n 327: astore 7\n 329: new #131 // class java/util/LinkedHashMap\n 332: dup\n 333: invokespecial #132 // Method java/util/LinkedHashMap.\"<init>\":()V\n 336: checkcast #134 // class java/util/Map\n 339: astore 8\n 341: iconst_0\n 342: istore 9\n 344: aload 7\n 346: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 351: astore 10\n 353: aload 10\n 355: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 360: ifeq 468\n 363: aload 10\n 365: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 370: astore 11\n 372: aload 11\n 374: checkcast #90 // class java/lang/Number\n 377: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 380: istore 12\n 382: iconst_0\n 383: istore 13\n 385: iload 12\n 387: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 390: astore 14\n 392: aload 8\n 394: astore 15\n 396: iconst_0\n 397: istore 16\n 399: aload 15\n 401: aload 14\n 403: invokeinterface #137, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 408: astore 17\n 410: aload 17\n 412: ifnonnull 447\n 415: iconst_0\n 416: istore 18\n 418: new #17 // class java/util/ArrayList\n 421: dup\n 422: invokespecial #129 // Method java/util/ArrayList.\"<init>\":()V\n 425: checkcast #72 // class java/util/List\n 428: astore 18\n 430: aload 15\n 432: aload 14\n 434: aload 18\n 436: invokeinterface #141, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 441: pop\n 442: aload 18\n 444: goto 449\n 447: aload 17\n 449: nop\n 450: checkcast #72 // class java/util/List\n 453: astore 12\n 455: aload 12\n 457: aload 11\n 459: invokeinterface #142, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 464: pop\n 465: goto 353\n 468: aload 8\n 470: nop\n 471: astore 5\n 473: nop\n 474: iconst_0\n 475: istore 6\n 477: aload 5\n 479: astore 7\n 481: new #17 // class java/util/ArrayList\n 484: dup\n 485: aload 5\n 487: invokeinterface #145, 1 // InterfaceMethod java/util/Map.size:()I\n 492: invokespecial #26 // Method java/util/ArrayList.\"<init>\":(I)V\n 495: checkcast #28 // class java/util/Collection\n 498: astore 8\n 500: iconst_0\n 501: istore 9\n 503: aload 7\n 505: invokeinterface #149, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 510: invokeinterface #152, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 515: astore 10\n 517: aload 10\n 519: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 524: ifeq 584\n 527: aload 10\n 529: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 534: checkcast #154 // class java/util/Map$Entry\n 537: astore 11\n 539: aload 8\n 541: aload 11\n 543: astore 12\n 545: astore 22\n 547: iconst_0\n 548: istore 13\n 550: aload 12\n 552: invokeinterface #157, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 557: checkcast #72 // class java/util/List\n 560: astore 14\n 562: aload 14\n 564: invokeinterface #158, 1 // InterfaceMethod java/util/List.size:()I\n 569: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 572: aload 22\n 574: swap\n 575: invokeinterface #70, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 580: pop\n 581: goto 517\n 584: aload 8\n 586: checkcast #72 // class java/util/List\n 589: nop\n 590: checkcast #15 // class java/lang/Iterable\n 593: invokestatic #162 // Method kotlin/collections/CollectionsKt.sortedDescending:(Ljava/lang/Iterable;)Ljava/util/List;\n 596: checkcast #15 // class java/lang/Iterable\n 599: iconst_3\n 600: invokestatic #166 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;\n 603: checkcast #15 // class java/lang/Iterable\n 606: astore 5\n 608: nop\n 609: iconst_0\n 610: istore 6\n 612: aload 5\n 614: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 619: astore 7\n 621: aload 7\n 623: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 628: ifne 641\n 631: new #168 // class java/lang/UnsupportedOperationException\n 634: dup\n 635: ldc #170 // String Empty collection can\\'t be reduced.\n 637: invokespecial #173 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 640: athrow\n 641: aload 7\n 643: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 648: astore 8\n 650: aload 7\n 652: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 657: ifeq 701\n 660: aload 8\n 662: aload 7\n 664: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 669: checkcast #90 // class java/lang/Number\n 672: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 675: istore 9\n 677: checkcast #90 // class java/lang/Number\n 680: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 683: istore 10\n 685: iconst_0\n 686: istore 11\n 688: iload 10\n 690: iload 9\n 692: imul\n 693: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 696: astore 8\n 698: goto 650\n 701: aload 8\n 703: checkcast #90 // class java/lang/Number\n 706: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 709: ireturn\n\n private final java.util.List<org.aoc2021.Day9$Point> findLowPoints(java.util.List<? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: new #17 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #129 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #72 // class java/util/List\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_1\n 14: checkcast #28 // class java/util/Collection\n 17: invokeinterface #211, 1 // InterfaceMethod java/util/Collection.size:()I\n 22: istore 4\n 24: iload_3\n 25: iload 4\n 27: if_icmpge 333\n 30: iconst_0\n 31: istore 5\n 33: aload_1\n 34: iconst_0\n 35: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 40: checkcast #28 // class java/util/Collection\n 43: invokeinterface #211, 1 // InterfaceMethod java/util/Collection.size:()I\n 48: istore 6\n 50: iload 5\n 52: iload 6\n 54: if_icmpge 327\n 57: iload_3\n 58: ifeq 112\n 61: aload_1\n 62: iload_3\n 63: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 68: checkcast #72 // class java/util/List\n 71: iload 5\n 73: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 78: checkcast #90 // class java/lang/Number\n 81: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 84: aload_1\n 85: iload_3\n 86: iconst_1\n 87: isub\n 88: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 93: checkcast #72 // class java/util/List\n 96: iload 5\n 98: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 103: checkcast #90 // class java/lang/Number\n 106: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 109: if_icmpge 321\n 112: iload_3\n 113: aload_1\n 114: invokeinterface #158, 1 // InterfaceMethod java/util/List.size:()I\n 119: iconst_1\n 120: isub\n 121: if_icmpeq 175\n 124: aload_1\n 125: iload_3\n 126: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 131: checkcast #72 // class java/util/List\n 134: iload 5\n 136: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 141: checkcast #90 // class java/lang/Number\n 144: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 147: aload_1\n 148: iload_3\n 149: iconst_1\n 150: iadd\n 151: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 156: checkcast #72 // class java/util/List\n 159: iload 5\n 161: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 166: checkcast #90 // class java/lang/Number\n 169: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 172: if_icmpge 321\n 175: iload 5\n 177: ifeq 231\n 180: aload_1\n 181: iload_3\n 182: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 187: checkcast #72 // class java/util/List\n 190: iload 5\n 192: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 197: checkcast #90 // class java/lang/Number\n 200: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 203: aload_1\n 204: iload_3\n 205: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 210: checkcast #72 // class java/util/List\n 213: iload 5\n 215: iconst_1\n 216: isub\n 217: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 222: checkcast #90 // class java/lang/Number\n 225: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 228: if_icmpge 321\n 231: iload 5\n 233: aload_1\n 234: iconst_0\n 235: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 240: checkcast #72 // class java/util/List\n 243: invokeinterface #158, 1 // InterfaceMethod java/util/List.size:()I\n 248: iconst_1\n 249: isub\n 250: if_icmpeq 304\n 253: aload_1\n 254: iload_3\n 255: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 260: checkcast #72 // class java/util/List\n 263: iload 5\n 265: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 270: checkcast #90 // class java/lang/Number\n 273: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 276: aload_1\n 277: iload_3\n 278: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 283: checkcast #72 // class java/util/List\n 286: iload 5\n 288: iconst_1\n 289: iadd\n 290: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 295: checkcast #90 // class java/lang/Number\n 298: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 301: if_icmpge 321\n 304: aload_2\n 305: new #78 // class org/aoc2021/Day9$Point\n 308: dup\n 309: iload_3\n 310: iload 5\n 312: invokespecial #214 // Method org/aoc2021/Day9$Point.\"<init>\":(II)V\n 315: invokeinterface #142, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 320: pop\n 321: iinc 5, 1\n 324: goto 50\n 327: iinc 3, 1\n 330: goto 24\n 333: aload_2\n 334: checkcast #15 // class java/lang/Iterable\n 337: invokestatic #217 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 340: areturn\n\n private final java.lang.Integer[][] findBasins(java.util.List<? extends java.util.List<java.lang.Integer>>, java.util.List<org.aoc2021.Day9$Point>);\n Code:\n 0: iconst_0\n 1: istore 4\n 3: aload_1\n 4: invokeinterface #158, 1 // InterfaceMethod java/util/List.size:()I\n 9: istore 5\n 11: iload 5\n 13: anewarray #222 // class \"[Ljava/lang/Integer;\"\n 16: astore 6\n 18: iload 4\n 20: iload 5\n 22: if_icmpge 103\n 25: iload 4\n 27: istore 7\n 29: aload 6\n 31: iload 7\n 33: iconst_0\n 34: istore 8\n 36: aload_1\n 37: iconst_0\n 38: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 43: checkcast #72 // class java/util/List\n 46: invokeinterface #158, 1 // InterfaceMethod java/util/List.size:()I\n 51: istore 9\n 53: iload 9\n 55: anewarray #62 // class java/lang/Integer\n 58: astore 10\n 60: istore 15\n 62: astore 14\n 64: iload 8\n 66: iload 9\n 68: if_icmpge 90\n 71: iload 8\n 73: istore 11\n 75: aload 10\n 77: iload 11\n 79: iconst_0\n 80: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 83: aastore\n 84: iinc 8, 1\n 87: goto 64\n 90: aload 14\n 92: iload 15\n 94: aload 10\n 96: aastore\n 97: iinc 4, 1\n 100: goto 18\n 103: aload 6\n 105: astore_3\n 106: aload_2\n 107: checkcast #15 // class java/lang/Iterable\n 110: astore 4\n 112: iconst_0\n 113: istore 5\n 115: iconst_0\n 116: istore 6\n 118: aload 4\n 120: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 125: astore 7\n 127: aload 7\n 129: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 134: ifeq 198\n 137: aload 7\n 139: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 144: astore 8\n 146: iload 6\n 148: iinc 6, 1\n 151: istore 9\n 153: iload 9\n 155: ifge 161\n 158: invokestatic #225 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 161: iload 9\n 163: aload 8\n 165: checkcast #78 // class org/aoc2021/Day9$Point\n 168: astore 10\n 170: istore 11\n 172: iconst_0\n 173: istore 12\n 175: iload 11\n 177: iconst_1\n 178: iadd\n 179: istore 13\n 181: getstatic #228 // Field INSTANCE:Lorg/aoc2021/Day9;\n 184: aload 10\n 186: iload 13\n 188: aload_1\n 189: aload_3\n 190: invokespecial #232 // Method fill:(Lorg/aoc2021/Day9$Point;ILjava/util/List;[[Ljava/lang/Integer;)V\n 193: nop\n 194: nop\n 195: goto 127\n 198: nop\n 199: aload_3\n 200: areturn\n\n private final void fill(org.aoc2021.Day9$Point, int, java.util.List<? extends java.util.List<java.lang.Integer>>, java.lang.Integer[][]);\n Code:\n 0: aload_1\n 1: invokevirtual #243 // Method org/aoc2021/Day9$Point.component1:()I\n 4: istore 5\n 6: aload_1\n 7: invokevirtual #246 // Method org/aoc2021/Day9$Point.component2:()I\n 10: istore 6\n 12: aload 4\n 14: iload 5\n 16: aaload\n 17: iload 6\n 19: iload_2\n 20: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 23: aastore\n 24: iconst_4\n 25: anewarray #248 // class kotlin/Pair\n 28: astore 7\n 30: aload 7\n 32: iconst_0\n 33: iconst_m1\n 34: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 37: iconst_0\n 38: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 41: invokestatic #254 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 44: aastore\n 45: aload 7\n 47: iconst_1\n 48: iconst_1\n 49: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 52: iconst_0\n 53: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 56: invokestatic #254 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 59: aastore\n 60: aload 7\n 62: iconst_2\n 63: iconst_0\n 64: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 67: iconst_m1\n 68: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 71: invokestatic #254 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 74: aastore\n 75: aload 7\n 77: iconst_3\n 78: iconst_0\n 79: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 82: iconst_1\n 83: invokestatic #66 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 86: invokestatic #254 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 89: aastore\n 90: aload 7\n 92: invokestatic #258 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 95: checkcast #15 // class java/lang/Iterable\n 98: astore 7\n 100: nop\n 101: iconst_0\n 102: istore 8\n 104: aload 7\n 106: invokeinterface #32, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 111: astore 9\n 113: aload 9\n 115: invokeinterface #38, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 120: ifeq 292\n 123: aload 9\n 125: invokeinterface #42, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 130: astore 10\n 132: aload 10\n 134: checkcast #248 // class kotlin/Pair\n 137: astore 11\n 139: iconst_0\n 140: istore 12\n 142: aload 11\n 144: invokevirtual #260 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 147: checkcast #90 // class java/lang/Number\n 150: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 153: istore 13\n 155: aload 11\n 157: invokevirtual #262 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 160: checkcast #90 // class java/lang/Number\n 163: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 166: istore 14\n 168: iload 5\n 170: iload 13\n 172: iadd\n 173: istore 15\n 175: iload 6\n 177: iload 14\n 179: iadd\n 180: istore 16\n 182: iload 15\n 184: iflt 287\n 187: iload 15\n 189: aload_3\n 190: invokeinterface #158, 1 // InterfaceMethod java/util/List.size:()I\n 195: if_icmpge 287\n 198: iload 16\n 200: iflt 287\n 203: iload 16\n 205: aload_3\n 206: iconst_0\n 207: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 212: checkcast #72 // class java/util/List\n 215: invokeinterface #158, 1 // InterfaceMethod java/util/List.size:()I\n 220: if_icmpge 287\n 223: aload_3\n 224: iload 15\n 226: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 231: checkcast #72 // class java/util/List\n 234: iload 16\n 236: invokeinterface #85, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 241: checkcast #90 // class java/lang/Number\n 244: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 247: bipush 9\n 249: if_icmpeq 287\n 252: aload 4\n 254: iload 15\n 256: aaload\n 257: iload 16\n 259: aaload\n 260: invokevirtual #263 // Method java/lang/Integer.intValue:()I\n 263: ifne 287\n 266: getstatic #228 // Field INSTANCE:Lorg/aoc2021/Day9;\n 269: new #78 // class org/aoc2021/Day9$Point\n 272: dup\n 273: iload 15\n 275: iload 16\n 277: invokespecial #214 // Method org/aoc2021/Day9$Point.\"<init>\":(II)V\n 280: iload_2\n 281: aload_3\n 282: aload 4\n 284: invokespecial #232 // Method fill:(Lorg/aoc2021/Day9$Point;ILjava/util/List;[[Ljava/lang/Integer;)V\n 287: nop\n 288: nop\n 289: goto 113\n 292: nop\n 293: return\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc_w #277 // String args\n 4: invokestatic #283 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: ldc_w #285 // String input9.txt\n 10: iconst_0\n 11: anewarray #44 // class java/lang/String\n 14: invokestatic #291 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 17: getstatic #297 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 20: invokestatic #303 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 23: astore_1\n 24: getstatic #228 // Field INSTANCE:Lorg/aoc2021/Day9;\n 27: aload_1\n 28: invokestatic #307 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 31: aload_1\n 32: invokespecial #309 // Method solvePart1:(Ljava/util/List;)I\n 35: istore_2\n 36: getstatic #315 // Field java/lang/System.out:Ljava/io/PrintStream;\n 39: iload_2\n 40: invokevirtual #320 // Method java/io/PrintStream.println:(I)V\n 43: getstatic #228 // Field INSTANCE:Lorg/aoc2021/Day9;\n 46: aload_1\n 47: invokespecial #322 // Method solvePart2:(Ljava/util/List;)I\n 50: istore_3\n 51: getstatic #315 // Field java/lang/System.out:Ljava/io/PrintStream;\n 54: iload_3\n 55: invokevirtual #320 // Method java/io/PrintStream.println:(I)V\n 58: return\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day9\n 3: dup\n 4: invokespecial #327 // Method \"<init>\":()V\n 7: putstatic #228 // Field INSTANCE:Lorg/aoc2021/Day9;\n 10: return\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day22.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
import kotlin.math.max
import kotlin.math.min
private fun IntRange.size(): Int {
return if (this.last >= this.first) {
this.last - this.first + 1
} else {
0
}
}
object Day22 {
data class Cube(val x: IntRange, val y: IntRange, val z: IntRange) {
fun volume(): Long {
return x.size().toLong() * y.size() * z.size()
}
fun intersect(other: Cube): Cube {
if (x.first > other.x.last ||
x.last < other.x.first ||
y.first > other.y.last ||
y.last < other.y.first ||
z.first > other.z.last ||
z.last < other.z.first) {
return Cube(IntRange.EMPTY, IntRange.EMPTY, IntRange.EMPTY)
}
val minX = max(x.first, other.x.first)
val maxX = min(x.last, other.x.last)
val minY = max(y.first, other.y.first)
val maxY = min(y.last, other.y.last)
val minZ = max(z.first, other.z.first)
val maxZ = min(z.last, other.z.last)
return Cube(minX..maxX, minY..maxY, minZ..maxZ)
}
}
data class Step(val on: Boolean, val cube: Cube)
private fun solve(lines: List<String>, shouldBound: Boolean): Long {
val steps = parseSteps(lines).let { if (shouldBound) boundCubes(it) else it }
val cubes = steps.map(Step::cube)
var totalVolume = 0L
steps.forEachIndexed { i, step ->
val flippedVolume = computeFlippedVolume(steps.subList(0, i), step)
if (step.on) {
totalVolume += flippedVolume
totalVolume += computeNonIntersectingVolume(cubes.subList(0, i), step.cube)
} else {
totalVolume -= flippedVolume
}
}
return totalVolume
}
private fun parseSteps(lines: List<String>): List<Step> {
return lines.map { line ->
val (onString, rest) = line.split(" ")
val (xRange, yRange, zRange) = rest.split(",").map { rangeString ->
rangeString.substring(2).split("..").let { it[0].toInt()..it[1].toInt() }
}
Step(onString == "on", Cube(xRange, yRange, zRange))
}
}
private fun boundCubes(steps: List<Step>): List<Step> {
return steps.map { step ->
val (x, y, z) = step.cube
Step(step.on, Cube(
max(x.first, -50)..min(x.last, 50),
max(y.first, -50)..min(y.last, 50),
max(z.first, -50)..min(z.last, 50),
))
}
}
private fun computeFlippedVolume(previousSteps: List<Step>, step: Step): Long {
val overlappingSteps = previousSteps.filter { it.cube.intersect(step.cube).volume() > 0 }
var totalFlippedVolume = 0L
overlappingSteps.indices.filter { j -> overlappingSteps[j].on != step.on }.forEach { j ->
val otherStep = overlappingSteps[j]
val laterCubes = overlappingSteps.subList(j + 1, overlappingSteps.size).map(Step::cube)
val offOnIntersect = step.cube.intersect(otherStep.cube)
totalFlippedVolume += computeNonIntersectingVolume(laterCubes, offOnIntersect)
}
return totalFlippedVolume
}
private fun computeNonIntersectingVolume(previousCubes: List<Cube>, cube: Cube): Long {
val overlappingCubes = previousCubes.filter { it.intersect(cube).volume() > 0 }
var newVolume = cube.volume()
var sign = -1
for (cubeCount in 1..overlappingCubes.size) {
val cubeCombinations = combinations(overlappingCubes, cubeCount)
cubeCombinations.forEach { cubeCombination ->
newVolume += sign * cubeCombination.fold(cube) { a, b -> a.intersect(b) }.volume()
}
sign *= -1
}
return newVolume
}
private fun <T> combinations(list: List<T>, count: Int): List<List<T>> {
if (count == 1) {
return list.map { listOf(it) }
}
return list.flatMapIndexed { i, elem ->
val subCombinations = combinations(list.subList(i + 1, list.size), count - 1)
subCombinations.map { listOf(elem).plus(it) }
}
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input22.txt"), Charsets.UTF_8)
val solution1 = solve(lines, true)
println(solution1)
val solution2 = solve(lines, false)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day22Kt.class",
"javap": "Compiled from \"Day22.kt\"\npublic final class org.aoc2021.Day22Kt {\n private static final int size(kotlin.ranges.IntRange);\n Code:\n 0: aload_0\n 1: invokevirtual #12 // Method kotlin/ranges/IntRange.getLast:()I\n 4: aload_0\n 5: invokevirtual #15 // Method kotlin/ranges/IntRange.getFirst:()I\n 8: if_icmplt 25\n 11: aload_0\n 12: invokevirtual #12 // Method kotlin/ranges/IntRange.getLast:()I\n 15: aload_0\n 16: invokevirtual #15 // Method kotlin/ranges/IntRange.getFirst:()I\n 19: isub\n 20: iconst_1\n 21: iadd\n 22: goto 26\n 25: iconst_0\n 26: ireturn\n\n public static final int access$size(kotlin.ranges.IntRange);\n Code:\n 0: aload_0\n 1: invokestatic #20 // Method size:(Lkotlin/ranges/IntRange;)I\n 4: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day22$Step.class",
"javap": "Compiled from \"Day22.kt\"\npublic final class org.aoc2021.Day22$Step {\n private final boolean on;\n\n private final org.aoc2021.Day22$Cube cube;\n\n public org.aoc2021.Day22$Step(boolean, org.aoc2021.Day22$Cube);\n Code:\n 0: aload_2\n 1: ldc #9 // String cube\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 on:Z\n 15: aload_0\n 16: aload_2\n 17: putfield #25 // Field cube:Lorg/aoc2021/Day22$Cube;\n 20: return\n\n public final boolean getOn();\n Code:\n 0: aload_0\n 1: getfield #22 // Field on:Z\n 4: ireturn\n\n public final org.aoc2021.Day22$Cube getCube();\n Code:\n 0: aload_0\n 1: getfield #25 // Field cube:Lorg/aoc2021/Day22$Cube;\n 4: areturn\n\n public final boolean component1();\n Code:\n 0: aload_0\n 1: getfield #22 // Field on:Z\n 4: ireturn\n\n public final org.aoc2021.Day22$Cube component2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field cube:Lorg/aoc2021/Day22$Cube;\n 4: areturn\n\n public final org.aoc2021.Day22$Step copy(boolean, org.aoc2021.Day22$Cube);\n Code:\n 0: aload_2\n 1: ldc #9 // String cube\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class org/aoc2021/Day22$Step\n 9: dup\n 10: iload_1\n 11: aload_2\n 12: invokespecial #37 // Method \"<init>\":(ZLorg/aoc2021/Day22$Cube;)V\n 15: areturn\n\n public static org.aoc2021.Day22$Step copy$default(org.aoc2021.Day22$Step, boolean, org.aoc2021.Day22$Cube, 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 on:Z\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 cube:Lorg/aoc2021/Day22$Cube;\n 21: astore_2\n 22: aload_0\n 23: iload_1\n 24: aload_2\n 25: invokevirtual #41 // Method copy:(ZLorg/aoc2021/Day22$Cube;)Lorg/aoc2021/Day22$Step;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #45 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #46 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #48 // String Step(on=\n 9: invokevirtual #52 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #22 // Field on:Z\n 16: invokevirtual #55 // Method java/lang/StringBuilder.append:(Z)Ljava/lang/StringBuilder;\n 19: ldc #57 // String , cube=\n 21: invokevirtual #52 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #25 // Field cube:Lorg/aoc2021/Day22$Cube;\n 28: invokevirtual #60 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #63 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #65 // 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 on:Z\n 4: invokestatic #72 // Method java/lang/Boolean.hashCode:(Z)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 cube:Lorg/aoc2021/Day22$Cube;\n 16: invokevirtual #76 // Method org/aoc2021/Day22$Cube.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 org/aoc2021/Day22$Step\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day22$Step\n 20: astore_2\n 21: aload_0\n 22: getfield #22 // Field on:Z\n 25: aload_2\n 26: getfield #22 // Field on:Z\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #25 // Field cube:Lorg/aoc2021/Day22$Cube;\n 38: aload_2\n 39: getfield #25 // Field cube:Lorg/aoc2021/Day22$Cube;\n 42: invokestatic #85 // 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": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day22$Cube.class",
"javap": "Compiled from \"Day22.kt\"\npublic final class org.aoc2021.Day22$Cube {\n private final kotlin.ranges.IntRange x;\n\n private final kotlin.ranges.IntRange y;\n\n private final kotlin.ranges.IntRange z;\n\n public org.aoc2021.Day22$Cube(kotlin.ranges.IntRange, kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_1\n 1: ldc #9 // String x\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #17 // String y\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_3\n 13: ldc #19 // String z\n 15: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload_0\n 19: invokespecial #22 // Method java/lang/Object.\"<init>\":()V\n 22: aload_0\n 23: aload_1\n 24: putfield #25 // Field x:Lkotlin/ranges/IntRange;\n 27: aload_0\n 28: aload_2\n 29: putfield #27 // Field y:Lkotlin/ranges/IntRange;\n 32: aload_0\n 33: aload_3\n 34: putfield #29 // Field z:Lkotlin/ranges/IntRange;\n 37: return\n\n public final kotlin.ranges.IntRange getX();\n Code:\n 0: aload_0\n 1: getfield #25 // Field x:Lkotlin/ranges/IntRange;\n 4: areturn\n\n public final kotlin.ranges.IntRange getY();\n Code:\n 0: aload_0\n 1: getfield #27 // Field y:Lkotlin/ranges/IntRange;\n 4: areturn\n\n public final kotlin.ranges.IntRange getZ();\n Code:\n 0: aload_0\n 1: getfield #29 // Field z:Lkotlin/ranges/IntRange;\n 4: areturn\n\n public final long volume();\n Code:\n 0: aload_0\n 1: getfield #25 // Field x:Lkotlin/ranges/IntRange;\n 4: invokestatic #43 // Method org/aoc2021/Day22Kt.access$size:(Lkotlin/ranges/IntRange;)I\n 7: i2l\n 8: aload_0\n 9: getfield #27 // Field y:Lkotlin/ranges/IntRange;\n 12: invokestatic #43 // Method org/aoc2021/Day22Kt.access$size:(Lkotlin/ranges/IntRange;)I\n 15: i2l\n 16: lmul\n 17: aload_0\n 18: getfield #29 // Field z:Lkotlin/ranges/IntRange;\n 21: invokestatic #43 // Method org/aoc2021/Day22Kt.access$size:(Lkotlin/ranges/IntRange;)I\n 24: i2l\n 25: lmul\n 26: lreturn\n\n public final org.aoc2021.Day22$Cube intersect(org.aoc2021.Day22$Cube);\n Code:\n 0: aload_1\n 1: ldc #47 // String other\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 x:Lkotlin/ranges/IntRange;\n 10: invokevirtual #53 // Method kotlin/ranges/IntRange.getFirst:()I\n 13: aload_1\n 14: getfield #25 // Field x:Lkotlin/ranges/IntRange;\n 17: invokevirtual #56 // Method kotlin/ranges/IntRange.getLast:()I\n 20: if_icmpgt 108\n 23: aload_0\n 24: getfield #25 // Field x:Lkotlin/ranges/IntRange;\n 27: invokevirtual #56 // Method kotlin/ranges/IntRange.getLast:()I\n 30: aload_1\n 31: getfield #25 // Field x:Lkotlin/ranges/IntRange;\n 34: invokevirtual #53 // Method kotlin/ranges/IntRange.getFirst:()I\n 37: if_icmplt 108\n 40: aload_0\n 41: getfield #27 // Field y:Lkotlin/ranges/IntRange;\n 44: invokevirtual #53 // Method kotlin/ranges/IntRange.getFirst:()I\n 47: aload_1\n 48: getfield #27 // Field y:Lkotlin/ranges/IntRange;\n 51: invokevirtual #56 // Method kotlin/ranges/IntRange.getLast:()I\n 54: if_icmpgt 108\n 57: aload_0\n 58: getfield #27 // Field y:Lkotlin/ranges/IntRange;\n 61: invokevirtual #56 // Method kotlin/ranges/IntRange.getLast:()I\n 64: aload_1\n 65: getfield #27 // Field y:Lkotlin/ranges/IntRange;\n 68: invokevirtual #53 // Method kotlin/ranges/IntRange.getFirst:()I\n 71: if_icmplt 108\n 74: aload_0\n 75: getfield #29 // Field z:Lkotlin/ranges/IntRange;\n 78: invokevirtual #53 // Method kotlin/ranges/IntRange.getFirst:()I\n 81: aload_1\n 82: getfield #29 // Field z:Lkotlin/ranges/IntRange;\n 85: invokevirtual #56 // Method kotlin/ranges/IntRange.getLast:()I\n 88: if_icmpgt 108\n 91: aload_0\n 92: getfield #29 // Field z:Lkotlin/ranges/IntRange;\n 95: invokevirtual #56 // Method kotlin/ranges/IntRange.getLast:()I\n 98: aload_1\n 99: getfield #29 // Field z:Lkotlin/ranges/IntRange;\n 102: invokevirtual #53 // Method kotlin/ranges/IntRange.getFirst:()I\n 105: if_icmpge 134\n 108: new #2 // class org/aoc2021/Day22$Cube\n 111: dup\n 112: getstatic #60 // Field kotlin/ranges/IntRange.Companion:Lkotlin/ranges/IntRange$Companion;\n 115: invokevirtual #65 // Method kotlin/ranges/IntRange$Companion.getEMPTY:()Lkotlin/ranges/IntRange;\n 118: getstatic #60 // Field kotlin/ranges/IntRange.Companion:Lkotlin/ranges/IntRange$Companion;\n 121: invokevirtual #65 // Method kotlin/ranges/IntRange$Companion.getEMPTY:()Lkotlin/ranges/IntRange;\n 124: getstatic #60 // Field kotlin/ranges/IntRange.Companion:Lkotlin/ranges/IntRange$Companion;\n 127: invokevirtual #65 // Method kotlin/ranges/IntRange$Companion.getEMPTY:()Lkotlin/ranges/IntRange;\n 130: invokespecial #67 // Method \"<init>\":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V\n 133: areturn\n 134: aload_0\n 135: getfield #25 // Field x:Lkotlin/ranges/IntRange;\n 138: invokevirtual #53 // Method kotlin/ranges/IntRange.getFirst:()I\n 141: aload_1\n 142: getfield #25 // Field x:Lkotlin/ranges/IntRange;\n 145: invokevirtual #53 // Method kotlin/ranges/IntRange.getFirst:()I\n 148: invokestatic #73 // Method java/lang/Math.max:(II)I\n 151: istore_2\n 152: aload_0\n 153: getfield #25 // Field x:Lkotlin/ranges/IntRange;\n 156: invokevirtual #56 // Method kotlin/ranges/IntRange.getLast:()I\n 159: aload_1\n 160: getfield #25 // Field x:Lkotlin/ranges/IntRange;\n 163: invokevirtual #56 // Method kotlin/ranges/IntRange.getLast:()I\n 166: invokestatic #76 // Method java/lang/Math.min:(II)I\n 169: istore_3\n 170: aload_0\n 171: getfield #27 // Field y:Lkotlin/ranges/IntRange;\n 174: invokevirtual #53 // Method kotlin/ranges/IntRange.getFirst:()I\n 177: aload_1\n 178: getfield #27 // Field y:Lkotlin/ranges/IntRange;\n 181: invokevirtual #53 // Method kotlin/ranges/IntRange.getFirst:()I\n 184: invokestatic #73 // Method java/lang/Math.max:(II)I\n 187: istore 4\n 189: aload_0\n 190: getfield #27 // Field y:Lkotlin/ranges/IntRange;\n 193: invokevirtual #56 // Method kotlin/ranges/IntRange.getLast:()I\n 196: aload_1\n 197: getfield #27 // Field y:Lkotlin/ranges/IntRange;\n 200: invokevirtual #56 // Method kotlin/ranges/IntRange.getLast:()I\n 203: invokestatic #76 // Method java/lang/Math.min:(II)I\n 206: istore 5\n 208: aload_0\n 209: getfield #29 // Field z:Lkotlin/ranges/IntRange;\n 212: invokevirtual #53 // Method kotlin/ranges/IntRange.getFirst:()I\n 215: aload_1\n 216: getfield #29 // Field z:Lkotlin/ranges/IntRange;\n 219: invokevirtual #53 // Method kotlin/ranges/IntRange.getFirst:()I\n 222: invokestatic #73 // Method java/lang/Math.max:(II)I\n 225: istore 6\n 227: aload_0\n 228: getfield #29 // Field z:Lkotlin/ranges/IntRange;\n 231: invokevirtual #56 // Method kotlin/ranges/IntRange.getLast:()I\n 234: aload_1\n 235: getfield #29 // Field z:Lkotlin/ranges/IntRange;\n 238: invokevirtual #56 // Method kotlin/ranges/IntRange.getLast:()I\n 241: invokestatic #76 // Method java/lang/Math.min:(II)I\n 244: istore 7\n 246: new #2 // class org/aoc2021/Day22$Cube\n 249: dup\n 250: new #49 // class kotlin/ranges/IntRange\n 253: dup\n 254: iload_2\n 255: iload_3\n 256: invokespecial #79 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 259: new #49 // class kotlin/ranges/IntRange\n 262: dup\n 263: iload 4\n 265: iload 5\n 267: invokespecial #79 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 270: new #49 // class kotlin/ranges/IntRange\n 273: dup\n 274: iload 6\n 276: iload 7\n 278: invokespecial #79 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 281: invokespecial #67 // Method \"<init>\":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V\n 284: areturn\n\n public final kotlin.ranges.IntRange component1();\n Code:\n 0: aload_0\n 1: getfield #25 // Field x:Lkotlin/ranges/IntRange;\n 4: areturn\n\n public final kotlin.ranges.IntRange component2();\n Code:\n 0: aload_0\n 1: getfield #27 // Field y:Lkotlin/ranges/IntRange;\n 4: areturn\n\n public final kotlin.ranges.IntRange component3();\n Code:\n 0: aload_0\n 1: getfield #29 // Field z:Lkotlin/ranges/IntRange;\n 4: areturn\n\n public final org.aoc2021.Day22$Cube copy(kotlin.ranges.IntRange, kotlin.ranges.IntRange, kotlin.ranges.IntRange);\n Code:\n 0: aload_1\n 1: ldc #9 // String x\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #17 // String y\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_3\n 13: ldc #19 // String z\n 15: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: new #2 // class org/aoc2021/Day22$Cube\n 21: dup\n 22: aload_1\n 23: aload_2\n 24: aload_3\n 25: invokespecial #67 // Method \"<init>\":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V\n 28: areturn\n\n public static org.aoc2021.Day22$Cube copy$default(org.aoc2021.Day22$Cube, kotlin.ranges.IntRange, kotlin.ranges.IntRange, kotlin.ranges.IntRange, 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 x:Lkotlin/ranges/IntRange;\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 #27 // Field y:Lkotlin/ranges/IntRange;\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 #29 // Field z:Lkotlin/ranges/IntRange;\n 35: astore_3\n 36: aload_0\n 37: aload_1\n 38: aload_2\n 39: aload_3\n 40: invokevirtual #95 // Method copy:(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)Lorg/aoc2021/Day22$Cube;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #99 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #100 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #102 // String Cube(x=\n 9: invokevirtual #106 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #25 // Field x:Lkotlin/ranges/IntRange;\n 16: invokevirtual #109 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #111 // String , y=\n 21: invokevirtual #106 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #27 // Field y:Lkotlin/ranges/IntRange;\n 28: invokevirtual #109 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: ldc #113 // String , z=\n 33: invokevirtual #106 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #29 // Field z:Lkotlin/ranges/IntRange;\n 40: invokevirtual #109 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #116 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #118 // 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 x:Lkotlin/ranges/IntRange;\n 4: invokevirtual #121 // Method kotlin/ranges/IntRange.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 y:Lkotlin/ranges/IntRange;\n 16: invokevirtual #121 // Method kotlin/ranges/IntRange.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 #29 // Field z:Lkotlin/ranges/IntRange;\n 29: invokevirtual #121 // Method kotlin/ranges/IntRange.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 org/aoc2021/Day22$Cube\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day22$Cube\n 20: astore_2\n 21: aload_0\n 22: getfield #25 // Field x:Lkotlin/ranges/IntRange;\n 25: aload_2\n 26: getfield #25 // Field x:Lkotlin/ranges/IntRange;\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 #27 // Field y:Lkotlin/ranges/IntRange;\n 41: aload_2\n 42: getfield #27 // Field y:Lkotlin/ranges/IntRange;\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 #29 // Field z:Lkotlin/ranges/IntRange;\n 57: aload_2\n 58: getfield #29 // Field z:Lkotlin/ranges/IntRange;\n 61: invokestatic #129 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 64: ifne 69\n 67: iconst_0\n 68: ireturn\n 69: iconst_1\n 70: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day22.class",
"javap": "Compiled from \"Day22.kt\"\npublic final class org.aoc2021.Day22 {\n public static final org.aoc2021.Day22 INSTANCE;\n\n private org.aoc2021.Day22();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final long solve(java.util.List<java.lang.String>, boolean);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #17 // Method parseSteps:(Ljava/util/List;)Ljava/util/List;\n 5: astore 5\n 7: iconst_0\n 8: istore 6\n 10: iload_2\n 11: ifeq 25\n 14: getstatic #20 // Field INSTANCE:Lorg/aoc2021/Day22;\n 17: aload 5\n 19: invokespecial #23 // Method boundCubes:(Ljava/util/List;)Ljava/util/List;\n 22: goto 27\n 25: aload 5\n 27: nop\n 28: astore_3\n 29: aload_3\n 30: checkcast #25 // class java/lang/Iterable\n 33: astore 5\n 35: iconst_0\n 36: istore 6\n 38: aload 5\n 40: astore 7\n 42: new #27 // class java/util/ArrayList\n 45: dup\n 46: aload 5\n 48: bipush 10\n 50: invokestatic #33 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 53: invokespecial #36 // Method java/util/ArrayList.\"<init>\":(I)V\n 56: checkcast #38 // class java/util/Collection\n 59: astore 8\n 61: iconst_0\n 62: istore 9\n 64: aload 7\n 66: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 71: astore 10\n 73: aload 10\n 75: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 80: ifeq 123\n 83: aload 10\n 85: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 90: astore 11\n 92: aload 8\n 94: aload 11\n 96: checkcast #54 // class org/aoc2021/Day22$Step\n 99: astore 12\n 101: astore 17\n 103: iconst_0\n 104: istore 13\n 106: aload 12\n 108: invokevirtual #58 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;\n 111: aload 17\n 113: swap\n 114: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 119: pop\n 120: goto 73\n 123: aload 8\n 125: checkcast #64 // class java/util/List\n 128: nop\n 129: astore 4\n 131: lconst_0\n 132: lstore 18\n 134: aload_3\n 135: checkcast #25 // class java/lang/Iterable\n 138: astore 6\n 140: iconst_0\n 141: istore 7\n 143: iconst_0\n 144: istore 8\n 146: aload 6\n 148: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 153: astore 9\n 155: aload 9\n 157: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 162: ifeq 278\n 165: aload 9\n 167: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 172: astore 10\n 174: iload 8\n 176: iinc 8, 1\n 179: istore 11\n 181: iload 11\n 183: ifge 189\n 186: invokestatic #67 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 189: iload 11\n 191: aload 10\n 193: checkcast #54 // class org/aoc2021/Day22$Step\n 196: astore 12\n 198: istore 13\n 200: iconst_0\n 201: istore 14\n 203: getstatic #20 // Field INSTANCE:Lorg/aoc2021/Day22;\n 206: aload_3\n 207: iconst_0\n 208: iload 13\n 210: invokeinterface #71, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 215: aload 12\n 217: invokespecial #75 // Method computeFlippedVolume:(Ljava/util/List;Lorg/aoc2021/Day22$Step;)J\n 220: lstore 15\n 222: aload 12\n 224: invokevirtual #78 // Method org/aoc2021/Day22$Step.getOn:()Z\n 227: ifeq 266\n 230: lload 18\n 232: lload 15\n 234: ladd\n 235: lstore 18\n 237: lload 18\n 239: getstatic #20 // Field INSTANCE:Lorg/aoc2021/Day22;\n 242: aload 4\n 244: iconst_0\n 245: iload 13\n 247: invokeinterface #71, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 252: aload 12\n 254: invokevirtual #58 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;\n 257: invokespecial #82 // Method computeNonIntersectingVolume:(Ljava/util/List;Lorg/aoc2021/Day22$Cube;)J\n 260: ladd\n 261: lstore 18\n 263: goto 273\n 266: lload 18\n 268: lload 15\n 270: lsub\n 271: lstore 18\n 273: nop\n 274: nop\n 275: goto 155\n 278: nop\n 279: lload 18\n 281: lreturn\n\n private final java.util.List<org.aoc2021.Day22$Step> parseSteps(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #25 // 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 #27 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #33 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #36 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #38 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 408\n 50: aload 7\n 52: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #116 // class java/lang/String\n 66: astore 9\n 68: astore 28\n 70: iconst_0\n 71: istore 10\n 73: aload 9\n 75: checkcast #118 // class java/lang/CharSequence\n 78: iconst_1\n 79: anewarray #116 // class java/lang/String\n 82: astore 11\n 84: aload 11\n 86: iconst_0\n 87: ldc #120 // String\n 89: aastore\n 90: aload 11\n 92: iconst_0\n 93: iconst_0\n 94: bipush 6\n 96: aconst_null\n 97: invokestatic #126 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 100: astore 12\n 102: aload 12\n 104: iconst_0\n 105: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 110: checkcast #116 // class java/lang/String\n 113: astore 11\n 115: aload 12\n 117: iconst_1\n 118: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 123: checkcast #116 // class java/lang/String\n 126: astore 13\n 128: aload 13\n 130: checkcast #118 // class java/lang/CharSequence\n 133: iconst_1\n 134: anewarray #116 // class java/lang/String\n 137: astore 14\n 139: aload 14\n 141: iconst_0\n 142: ldc #132 // String ,\n 144: aastore\n 145: aload 14\n 147: iconst_0\n 148: iconst_0\n 149: bipush 6\n 151: aconst_null\n 152: invokestatic #126 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 155: checkcast #25 // class java/lang/Iterable\n 158: astore 14\n 160: iconst_0\n 161: istore 15\n 163: aload 14\n 165: astore 16\n 167: new #27 // class java/util/ArrayList\n 170: dup\n 171: aload 14\n 173: bipush 10\n 175: invokestatic #33 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 178: invokespecial #36 // Method java/util/ArrayList.\"<init>\":(I)V\n 181: checkcast #38 // class java/util/Collection\n 184: astore 17\n 186: iconst_0\n 187: istore 18\n 189: aload 16\n 191: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 196: astore 19\n 198: aload 19\n 200: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 205: ifeq 322\n 208: aload 19\n 210: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 215: astore 20\n 217: aload 17\n 219: aload 20\n 221: checkcast #116 // class java/lang/String\n 224: astore 21\n 226: astore 22\n 228: iconst_0\n 229: istore 23\n 231: aload 21\n 233: iconst_2\n 234: invokevirtual #136 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 237: dup\n 238: ldc #138 // String substring(...)\n 240: invokestatic #144 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 243: checkcast #118 // class java/lang/CharSequence\n 246: iconst_1\n 247: anewarray #116 // class java/lang/String\n 250: astore 24\n 252: aload 24\n 254: iconst_0\n 255: ldc #146 // String ..\n 257: aastore\n 258: aload 24\n 260: iconst_0\n 261: iconst_0\n 262: bipush 6\n 264: aconst_null\n 265: invokestatic #126 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 268: astore 25\n 270: iconst_0\n 271: istore 26\n 273: new #148 // class kotlin/ranges/IntRange\n 276: dup\n 277: aload 25\n 279: iconst_0\n 280: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 285: checkcast #116 // class java/lang/String\n 288: invokestatic #154 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 291: aload 25\n 293: iconst_1\n 294: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 299: checkcast #116 // class java/lang/String\n 302: invokestatic #154 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 305: invokespecial #157 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 308: nop\n 309: nop\n 310: aload 22\n 312: swap\n 313: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 318: pop\n 319: goto 198\n 322: aload 17\n 324: checkcast #64 // class java/util/List\n 327: nop\n 328: astore 27\n 330: aload 27\n 332: iconst_0\n 333: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 338: checkcast #148 // class kotlin/ranges/IntRange\n 341: astore 14\n 343: aload 27\n 345: iconst_1\n 346: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 351: checkcast #148 // class kotlin/ranges/IntRange\n 354: astore 15\n 356: aload 27\n 358: iconst_2\n 359: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 364: checkcast #148 // class kotlin/ranges/IntRange\n 367: astore 16\n 369: new #54 // class org/aoc2021/Day22$Step\n 372: dup\n 373: aload 11\n 375: ldc #159 // String on\n 377: invokestatic #163 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 380: new #165 // class org/aoc2021/Day22$Cube\n 383: dup\n 384: aload 14\n 386: aload 15\n 388: aload 16\n 390: invokespecial #168 // Method org/aoc2021/Day22$Cube.\"<init>\":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V\n 393: invokespecial #171 // Method org/aoc2021/Day22$Step.\"<init>\":(ZLorg/aoc2021/Day22$Cube;)V\n 396: aload 28\n 398: swap\n 399: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 404: pop\n 405: goto 40\n 408: aload 5\n 410: checkcast #64 // class java/util/List\n 413: nop\n 414: areturn\n\n private final java.util.List<org.aoc2021.Day22$Step> boundCubes(java.util.List<org.aoc2021.Day22$Step>);\n Code:\n 0: aload_1\n 1: checkcast #25 // 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 #27 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #33 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #36 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #38 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 214\n 50: aload 7\n 52: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #54 // class org/aoc2021/Day22$Step\n 66: astore 9\n 68: astore 15\n 70: iconst_0\n 71: istore 10\n 73: aload 9\n 75: invokevirtual #58 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;\n 78: astore 11\n 80: aload 11\n 82: invokevirtual #188 // Method org/aoc2021/Day22$Cube.component1:()Lkotlin/ranges/IntRange;\n 85: astore 12\n 87: aload 11\n 89: invokevirtual #191 // Method org/aoc2021/Day22$Cube.component2:()Lkotlin/ranges/IntRange;\n 92: astore 13\n 94: aload 11\n 96: invokevirtual #194 // Method org/aoc2021/Day22$Cube.component3:()Lkotlin/ranges/IntRange;\n 99: astore 14\n 101: new #54 // class org/aoc2021/Day22$Step\n 104: dup\n 105: aload 9\n 107: invokevirtual #78 // Method org/aoc2021/Day22$Step.getOn:()Z\n 110: new #165 // class org/aoc2021/Day22$Cube\n 113: dup\n 114: new #148 // class kotlin/ranges/IntRange\n 117: dup\n 118: aload 12\n 120: invokevirtual #198 // Method kotlin/ranges/IntRange.getFirst:()I\n 123: bipush -50\n 125: invokestatic #204 // Method java/lang/Math.max:(II)I\n 128: aload 12\n 130: invokevirtual #207 // Method kotlin/ranges/IntRange.getLast:()I\n 133: bipush 50\n 135: invokestatic #210 // Method java/lang/Math.min:(II)I\n 138: invokespecial #157 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 141: new #148 // class kotlin/ranges/IntRange\n 144: dup\n 145: aload 13\n 147: invokevirtual #198 // Method kotlin/ranges/IntRange.getFirst:()I\n 150: bipush -50\n 152: invokestatic #204 // Method java/lang/Math.max:(II)I\n 155: aload 13\n 157: invokevirtual #207 // Method kotlin/ranges/IntRange.getLast:()I\n 160: bipush 50\n 162: invokestatic #210 // Method java/lang/Math.min:(II)I\n 165: invokespecial #157 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 168: new #148 // class kotlin/ranges/IntRange\n 171: dup\n 172: aload 14\n 174: invokevirtual #198 // Method kotlin/ranges/IntRange.getFirst:()I\n 177: bipush -50\n 179: invokestatic #204 // Method java/lang/Math.max:(II)I\n 182: aload 14\n 184: invokevirtual #207 // Method kotlin/ranges/IntRange.getLast:()I\n 187: bipush 50\n 189: invokestatic #210 // Method java/lang/Math.min:(II)I\n 192: invokespecial #157 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 195: invokespecial #168 // Method org/aoc2021/Day22$Cube.\"<init>\":(Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;Lkotlin/ranges/IntRange;)V\n 198: invokespecial #171 // Method org/aoc2021/Day22$Step.\"<init>\":(ZLorg/aoc2021/Day22$Cube;)V\n 201: nop\n 202: aload 15\n 204: swap\n 205: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 210: pop\n 211: goto 40\n 214: aload 5\n 216: checkcast #64 // class java/util/List\n 219: nop\n 220: areturn\n\n private final long computeFlippedVolume(java.util.List<org.aoc2021.Day22$Step>, org.aoc2021.Day22$Step);\n Code:\n 0: aload_1\n 1: checkcast #25 // 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 #27 // class java/util/ArrayList\n 16: dup\n 17: invokespecial #216 // Method java/util/ArrayList.\"<init>\":()V\n 20: checkcast #38 // class java/util/Collection\n 23: astore 7\n 25: iconst_0\n 26: istore 8\n 28: aload 6\n 30: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 35: astore 9\n 37: aload 9\n 39: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 44: ifeq 107\n 47: aload 9\n 49: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 54: astore 10\n 56: aload 10\n 58: checkcast #54 // class org/aoc2021/Day22$Step\n 61: astore 11\n 63: iconst_0\n 64: istore 12\n 66: aload 11\n 68: invokevirtual #58 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;\n 71: aload_2\n 72: invokevirtual #58 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;\n 75: invokevirtual #220 // Method org/aoc2021/Day22$Cube.intersect:(Lorg/aoc2021/Day22$Cube;)Lorg/aoc2021/Day22$Cube;\n 78: invokevirtual #224 // Method org/aoc2021/Day22$Cube.volume:()J\n 81: lconst_0\n 82: lcmp\n 83: ifle 90\n 86: iconst_1\n 87: goto 91\n 90: iconst_0\n 91: ifeq 37\n 94: aload 7\n 96: aload 10\n 98: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 103: pop\n 104: goto 37\n 107: aload 7\n 109: checkcast #64 // class java/util/List\n 112: nop\n 113: astore_3\n 114: lconst_0\n 115: lstore 23\n 117: aload_3\n 118: checkcast #38 // class java/util/Collection\n 121: invokestatic #228 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 124: checkcast #25 // class java/lang/Iterable\n 127: astore 5\n 129: iconst_0\n 130: istore 6\n 132: aload 5\n 134: astore 7\n 136: new #27 // class java/util/ArrayList\n 139: dup\n 140: invokespecial #216 // Method java/util/ArrayList.\"<init>\":()V\n 143: checkcast #38 // class java/util/Collection\n 146: astore 8\n 148: iconst_0\n 149: istore 9\n 151: aload 7\n 153: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 158: astore 10\n 160: aload 10\n 162: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 167: ifeq 234\n 170: aload 10\n 172: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 177: astore 11\n 179: aload 11\n 181: checkcast #230 // class java/lang/Number\n 184: invokevirtual #233 // Method java/lang/Number.intValue:()I\n 187: istore 12\n 189: iconst_0\n 190: istore 13\n 192: aload_3\n 193: iload 12\n 195: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 200: checkcast #54 // class org/aoc2021/Day22$Step\n 203: invokevirtual #78 // Method org/aoc2021/Day22$Step.getOn:()Z\n 206: aload_2\n 207: invokevirtual #78 // Method org/aoc2021/Day22$Step.getOn:()Z\n 210: if_icmpeq 217\n 213: iconst_1\n 214: goto 218\n 217: iconst_0\n 218: ifeq 160\n 221: aload 8\n 223: aload 11\n 225: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 230: pop\n 231: goto 160\n 234: aload 8\n 236: checkcast #64 // class java/util/List\n 239: nop\n 240: checkcast #25 // class java/lang/Iterable\n 243: astore 5\n 245: nop\n 246: iconst_0\n 247: istore 6\n 249: aload 5\n 251: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 256: astore 7\n 258: aload 7\n 260: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 265: ifeq 454\n 268: aload 7\n 270: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 275: astore 8\n 277: aload 8\n 279: checkcast #230 // class java/lang/Number\n 282: invokevirtual #233 // Method java/lang/Number.intValue:()I\n 285: istore 9\n 287: iconst_0\n 288: istore 10\n 290: aload_3\n 291: iload 9\n 293: invokeinterface #130, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 298: checkcast #54 // class org/aoc2021/Day22$Step\n 301: astore 11\n 303: aload_3\n 304: iload 9\n 306: iconst_1\n 307: iadd\n 308: aload_3\n 309: invokeinterface #236, 1 // InterfaceMethod java/util/List.size:()I\n 314: invokeinterface #71, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 319: checkcast #25 // class java/lang/Iterable\n 322: astore 12\n 324: iconst_0\n 325: istore 13\n 327: aload 12\n 329: astore 14\n 331: new #27 // class java/util/ArrayList\n 334: dup\n 335: aload 12\n 337: bipush 10\n 339: invokestatic #33 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 342: invokespecial #36 // Method java/util/ArrayList.\"<init>\":(I)V\n 345: checkcast #38 // class java/util/Collection\n 348: astore 15\n 350: iconst_0\n 351: istore 16\n 353: aload 14\n 355: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 360: astore 17\n 362: aload 17\n 364: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 369: ifeq 412\n 372: aload 17\n 374: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 379: astore 18\n 381: aload 15\n 383: aload 18\n 385: checkcast #54 // class org/aoc2021/Day22$Step\n 388: astore 19\n 390: astore 20\n 392: iconst_0\n 393: istore 21\n 395: aload 19\n 397: invokevirtual #58 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;\n 400: aload 20\n 402: swap\n 403: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 408: pop\n 409: goto 362\n 412: aload 15\n 414: checkcast #64 // class java/util/List\n 417: nop\n 418: astore 22\n 420: aload_2\n 421: invokevirtual #58 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;\n 424: aload 11\n 426: invokevirtual #58 // Method org/aoc2021/Day22$Step.getCube:()Lorg/aoc2021/Day22$Cube;\n 429: invokevirtual #220 // Method org/aoc2021/Day22$Cube.intersect:(Lorg/aoc2021/Day22$Cube;)Lorg/aoc2021/Day22$Cube;\n 432: astore 12\n 434: lload 23\n 436: getstatic #20 // Field INSTANCE:Lorg/aoc2021/Day22;\n 439: aload 22\n 441: aload 12\n 443: invokespecial #82 // Method computeNonIntersectingVolume:(Ljava/util/List;Lorg/aoc2021/Day22$Cube;)J\n 446: ladd\n 447: lstore 23\n 449: nop\n 450: nop\n 451: goto 258\n 454: nop\n 455: lload 23\n 457: lreturn\n\n private final long computeNonIntersectingVolume(java.util.List<org.aoc2021.Day22$Cube>, org.aoc2021.Day22$Cube);\n Code:\n 0: aload_1\n 1: checkcast #25 // 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 #27 // class java/util/ArrayList\n 16: dup\n 17: invokespecial #216 // Method java/util/ArrayList.\"<init>\":()V\n 20: checkcast #38 // class java/util/Collection\n 23: astore 7\n 25: iconst_0\n 26: istore 8\n 28: aload 6\n 30: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 35: astore 9\n 37: aload 9\n 39: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 44: ifeq 101\n 47: aload 9\n 49: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 54: astore 10\n 56: aload 10\n 58: checkcast #165 // class org/aoc2021/Day22$Cube\n 61: astore 11\n 63: iconst_0\n 64: istore 12\n 66: aload 11\n 68: aload_2\n 69: invokevirtual #220 // Method org/aoc2021/Day22$Cube.intersect:(Lorg/aoc2021/Day22$Cube;)Lorg/aoc2021/Day22$Cube;\n 72: invokevirtual #224 // Method org/aoc2021/Day22$Cube.volume:()J\n 75: lconst_0\n 76: lcmp\n 77: ifle 84\n 80: iconst_1\n 81: goto 85\n 84: iconst_0\n 85: ifeq 37\n 88: aload 7\n 90: aload 10\n 92: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 97: pop\n 98: goto 37\n 101: aload 7\n 103: checkcast #64 // class java/util/List\n 106: nop\n 107: astore_3\n 108: lconst_0\n 109: lstore 28\n 111: aload_2\n 112: invokevirtual #224 // Method org/aoc2021/Day22$Cube.volume:()J\n 115: lstore 28\n 117: iconst_0\n 118: istore 5\n 120: iconst_m1\n 121: istore 5\n 123: iconst_1\n 124: istore 6\n 126: aload_3\n 127: invokeinterface #236, 1 // InterfaceMethod java/util/List.size:()I\n 132: istore 7\n 134: iload 6\n 136: iload 7\n 138: if_icmpgt 316\n 141: aload_0\n 142: aload_3\n 143: iload 6\n 145: invokespecial #261 // Method combinations:(Ljava/util/List;I)Ljava/util/List;\n 148: astore 8\n 150: aload 8\n 152: checkcast #25 // class java/lang/Iterable\n 155: astore 9\n 157: iconst_0\n 158: istore 10\n 160: aload 9\n 162: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 167: astore 11\n 169: aload 11\n 171: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 176: ifeq 296\n 179: aload 11\n 181: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 186: astore 12\n 188: aload 12\n 190: checkcast #64 // class java/util/List\n 193: astore 13\n 195: iconst_0\n 196: istore 14\n 198: lload 28\n 200: iload 5\n 202: i2l\n 203: aload 13\n 205: checkcast #25 // class java/lang/Iterable\n 208: astore 15\n 210: lstore 16\n 212: lstore 18\n 214: iconst_0\n 215: istore 20\n 217: aload_2\n 218: astore 21\n 220: aload 15\n 222: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 227: astore 22\n 229: aload 22\n 231: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 236: ifeq 274\n 239: aload 22\n 241: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 246: astore 23\n 248: aload 21\n 250: aload 23\n 252: checkcast #165 // class org/aoc2021/Day22$Cube\n 255: astore 24\n 257: astore 25\n 259: iconst_0\n 260: istore 26\n 262: aload 25\n 264: aload 24\n 266: invokevirtual #220 // Method org/aoc2021/Day22$Cube.intersect:(Lorg/aoc2021/Day22$Cube;)Lorg/aoc2021/Day22$Cube;\n 269: astore 21\n 271: goto 229\n 274: aload 21\n 276: astore 27\n 278: lload 18\n 280: lload 16\n 282: aload 27\n 284: invokevirtual #224 // Method org/aoc2021/Day22$Cube.volume:()J\n 287: lmul\n 288: ladd\n 289: lstore 28\n 291: nop\n 292: nop\n 293: goto 169\n 296: nop\n 297: iload 5\n 299: iconst_m1\n 300: imul\n 301: istore 5\n 303: iload 6\n 305: iload 7\n 307: if_icmpeq 316\n 310: iinc 6, 1\n 313: goto 141\n 316: lload 28\n 318: lreturn\n\n private final <T> java.util.List<java.util.List<T>> combinations(java.util.List<? extends T>, int);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: if_icmpne 100\n 5: aload_1\n 6: checkcast #25 // class java/lang/Iterable\n 9: astore_3\n 10: iconst_0\n 11: istore 4\n 13: aload_3\n 14: astore 5\n 16: new #27 // class java/util/ArrayList\n 19: dup\n 20: aload_3\n 21: bipush 10\n 23: invokestatic #33 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #36 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #38 // class java/util/Collection\n 32: astore 6\n 34: iconst_0\n 35: istore 7\n 37: aload 5\n 39: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 8\n 46: aload 8\n 48: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 93\n 56: aload 8\n 58: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 9\n 65: aload 6\n 67: aload 9\n 69: astore 10\n 71: astore 24\n 73: iconst_0\n 74: istore 11\n 76: aload 10\n 78: invokestatic #282 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 81: aload 24\n 83: swap\n 84: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 89: pop\n 90: goto 46\n 93: aload 6\n 95: checkcast #64 // class java/util/List\n 98: nop\n 99: areturn\n 100: aload_1\n 101: checkcast #25 // class java/lang/Iterable\n 104: astore 4\n 106: new #27 // class java/util/ArrayList\n 109: dup\n 110: invokespecial #216 // Method java/util/ArrayList.\"<init>\":()V\n 113: checkcast #38 // class java/util/Collection\n 116: astore 5\n 118: iconst_0\n 119: istore 6\n 121: aload 4\n 123: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 128: astore 7\n 130: aload 7\n 132: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 137: ifeq 328\n 140: aload 7\n 142: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 147: astore 8\n 149: iload 6\n 151: iinc 6, 1\n 154: istore 9\n 156: iload 9\n 158: ifge 164\n 161: invokestatic #67 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 164: iload 9\n 166: aload 8\n 168: astore 10\n 170: istore 11\n 172: iconst_0\n 173: istore 12\n 175: getstatic #20 // Field INSTANCE:Lorg/aoc2021/Day22;\n 178: aload_1\n 179: iload 11\n 181: iconst_1\n 182: iadd\n 183: aload_1\n 184: invokeinterface #236, 1 // InterfaceMethod java/util/List.size:()I\n 189: invokeinterface #71, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 194: iload_2\n 195: iconst_1\n 196: isub\n 197: invokespecial #261 // Method combinations:(Ljava/util/List;I)Ljava/util/List;\n 200: astore 13\n 202: aload 13\n 204: checkcast #25 // class java/lang/Iterable\n 207: astore 14\n 209: iconst_0\n 210: istore 15\n 212: aload 14\n 214: astore 16\n 216: new #27 // class java/util/ArrayList\n 219: dup\n 220: aload 14\n 222: bipush 10\n 224: invokestatic #33 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 227: invokespecial #36 // Method java/util/ArrayList.\"<init>\":(I)V\n 230: checkcast #38 // class java/util/Collection\n 233: astore 17\n 235: iconst_0\n 236: istore 18\n 238: aload 16\n 240: invokeinterface #42, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 245: astore 19\n 247: aload 19\n 249: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 254: ifeq 308\n 257: aload 19\n 259: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 264: astore 20\n 266: aload 17\n 268: aload 20\n 270: checkcast #64 // class java/util/List\n 273: astore 21\n 275: astore 22\n 277: iconst_0\n 278: istore 23\n 280: aload 10\n 282: invokestatic #282 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 285: checkcast #38 // class java/util/Collection\n 288: aload 21\n 290: checkcast #25 // class java/lang/Iterable\n 293: invokestatic #286 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 296: aload 22\n 298: swap\n 299: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 304: pop\n 305: goto 247\n 308: aload 17\n 310: checkcast #64 // class java/util/List\n 313: nop\n 314: checkcast #25 // class java/lang/Iterable\n 317: nop\n 318: aload 5\n 320: swap\n 321: invokestatic #290 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 324: pop\n 325: goto 130\n 328: aload 5\n 330: checkcast #64 // class java/util/List\n 333: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc_w #303 // String args\n 4: invokestatic #306 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: ldc_w #308 // String input22.txt\n 10: iconst_0\n 11: anewarray #116 // class java/lang/String\n 14: invokestatic #314 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 17: getstatic #320 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 20: invokestatic #326 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 23: astore_1\n 24: getstatic #20 // Field INSTANCE:Lorg/aoc2021/Day22;\n 27: aload_1\n 28: invokestatic #330 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 31: aload_1\n 32: iconst_1\n 33: invokespecial #332 // Method solve:(Ljava/util/List;Z)J\n 36: lstore_2\n 37: getstatic #338 // Field java/lang/System.out:Ljava/io/PrintStream;\n 40: lload_2\n 41: invokevirtual #344 // Method java/io/PrintStream.println:(J)V\n 44: getstatic #20 // Field INSTANCE:Lorg/aoc2021/Day22;\n 47: aload_1\n 48: iconst_0\n 49: invokespecial #332 // Method solve:(Ljava/util/List;Z)J\n 52: lstore 4\n 54: getstatic #338 // Field java/lang/System.out:Ljava/io/PrintStream;\n 57: lload 4\n 59: invokevirtual #344 // Method java/io/PrintStream.println:(J)V\n 62: return\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day22\n 3: dup\n 4: invokespecial #349 // Method \"<init>\":()V\n 7: putstatic #20 // Field INSTANCE:Lorg/aoc2021/Day22;\n 10: return\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day5.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
import kotlin.math.sign
object Day5 {
data class Vent(val x1: Int, val y1: Int, val x2: Int, val y2: Int)
private fun solvePart1(filename: String): Int {
val vents = Files.readAllLines(Path.of(filename), Charsets.UTF_8)
.map(Day5::parseLine)
val counts = emptyCountsGrid(vents)
vents.forEach { vent ->
if (vent.x1 == vent.x2) {
val start = min(vent.y1, vent.y2)
val end = max(vent.y1, vent.y2)
for (j in start..end) {
counts[vent.x1][j]++
}
}
if (vent.y1 == vent.y2) {
val start = min(vent.x1, vent.x2)
val end = max(vent.x1, vent.x2)
for (i in start..end) {
counts[i][vent.y1]++
}
}
}
return counts.sumOf { column ->
column.count { it >= 2 }
}
}
private fun solvePart2(filename: String): Int {
val vents = Files.readAllLines(Path.of(filename), Charsets.UTF_8)
.map(Day5::parseLine)
val counts = emptyCountsGrid(vents)
vents.forEach { vent ->
val dx = (vent.x2 - vent.x1).sign
val dy = (vent.y2 - vent.y1).sign
val length = max(abs(vent.x2 - vent.x1), abs(vent.y2 - vent.y1))
for (i in 0..length) {
counts[vent.x1 + dx * i][vent.y1 + dy * i]++
}
}
return counts.sumOf { column ->
column.count { it >= 2 }
}
}
private fun emptyCountsGrid(vents: List<Vent>): Array<Array<Int>> {
val maxX = vents.maxOf { max(it.x1, it.x2) } + 1
val maxY = vents.maxOf { max(it.y1, it.y2) } + 1
return Array(maxX) { Array(maxY) { 0 } }
}
private fun parseLine(line: String): Vent {
val (p1, p2) = line.split(" -> ")
val (x1, y1) = p1.split(",").map(String::toInt)
val (x2, y2) = p2.split(",").map(String::toInt)
return Vent(x1, y1, x2, y2)
}
@JvmStatic
fun main(args: Array<String>) {
val filename = "input5.txt"
val solution1 = solvePart1(filename)
println(solution1)
val solution2 = solvePart2(filename)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day5$Vent.class",
"javap": "Compiled from \"Day5.kt\"\npublic final class org.aoc2021.Day5$Vent {\n private final int x1;\n\n private final int y1;\n\n private final int x2;\n\n private final int y2;\n\n public org.aoc2021.Day5$Vent(int, 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 x1:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field y1:I\n 14: aload_0\n 15: iload_3\n 16: putfield #19 // Field x2:I\n 19: aload_0\n 20: iload 4\n 22: putfield #22 // Field y2:I\n 25: return\n\n public final int getX1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x1:I\n 4: ireturn\n\n public final int getY1();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y1:I\n 4: ireturn\n\n public final int getX2();\n Code:\n 0: aload_0\n 1: getfield #19 // Field x2:I\n 4: ireturn\n\n public final int getY2();\n Code:\n 0: aload_0\n 1: getfield #22 // Field y2:I\n 4: ireturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field x1:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field y1:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #19 // Field x2:I\n 4: ireturn\n\n public final int component4();\n Code:\n 0: aload_0\n 1: getfield #22 // Field y2:I\n 4: ireturn\n\n public final org.aoc2021.Day5$Vent copy(int, int, int, int);\n Code:\n 0: new #2 // class org/aoc2021/Day5$Vent\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: iload_3\n 7: iload 4\n 9: invokespecial #38 // Method \"<init>\":(IIII)V\n 12: areturn\n\n public static org.aoc2021.Day5$Vent copy$default(org.aoc2021.Day5$Vent, int, int, int, 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 #13 // Field x1: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 #16 // Field y1: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 #19 // Field x2: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 #22 // Field y2:I\n 48: istore 4\n 50: aload_0\n 51: iload_1\n 52: iload_2\n 53: iload_3\n 54: iload 4\n 56: invokevirtual #42 // Method copy:(IIII)Lorg/aoc2021/Day5$Vent;\n 59: 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 Vent(x1=\n 9: invokevirtual #53 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field x1:I\n 16: invokevirtual #56 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #58 // String , y1=\n 21: invokevirtual #53 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field y1:I\n 28: invokevirtual #56 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #60 // String , x2=\n 33: invokevirtual #53 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #19 // Field x2:I\n 40: invokevirtual #56 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 43: ldc #62 // String , y2=\n 45: invokevirtual #53 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: aload_0\n 49: getfield #22 // Field y2:I\n 52: invokevirtual #56 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 55: bipush 41\n 57: invokevirtual #65 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 60: invokevirtual #67 // 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 #13 // Field x1:I\n 4: invokestatic #73 // 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 y1:I\n 16: invokestatic #73 // 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 x2:I\n 29: invokestatic #73 // 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 #22 // Field y2:I\n 42: invokestatic #73 // Method java/lang/Integer.hashCode:(I)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 org/aoc2021/Day5$Vent\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day5$Vent\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field x1:I\n 25: aload_2\n 26: getfield #13 // Field x1:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field y1:I\n 38: aload_2\n 39: getfield #16 // Field y1:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #19 // Field x2:I\n 51: aload_2\n 52: getfield #19 // Field x2:I\n 55: if_icmpeq 60\n 58: iconst_0\n 59: ireturn\n 60: aload_0\n 61: getfield #22 // Field y2:I\n 64: aload_2\n 65: getfield #22 // Field y2:I\n 68: if_icmpeq 73\n 71: iconst_0\n 72: ireturn\n 73: iconst_1\n 74: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day5.class",
"javap": "Compiled from \"Day5.kt\"\npublic final class org.aoc2021.Day5 {\n public static final org.aoc2021.Day5 INSTANCE;\n\n private org.aoc2021.Day5();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int solvePart1(java.lang.String);\n Code:\n 0: aload_1\n 1: iconst_0\n 2: anewarray #14 // class java/lang/String\n 5: invokestatic #20 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 8: getstatic #26 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 11: invokestatic #32 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 14: dup\n 15: ldc #34 // String readAllLines(...)\n 17: invokestatic #40 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 20: checkcast #42 // class java/lang/Iterable\n 23: astore_3\n 24: getstatic #45 // Field INSTANCE:Lorg/aoc2021/Day5;\n 27: astore 4\n 29: iconst_0\n 30: istore 5\n 32: aload_3\n 33: astore 6\n 35: new #47 // class java/util/ArrayList\n 38: dup\n 39: aload_3\n 40: bipush 10\n 42: invokestatic #53 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 45: invokespecial #56 // Method java/util/ArrayList.\"<init>\":(I)V\n 48: checkcast #58 // class java/util/Collection\n 51: astore 7\n 53: iconst_0\n 54: istore 8\n 56: aload 6\n 58: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 63: astore 9\n 65: aload 9\n 67: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 72: ifeq 117\n 75: aload 9\n 77: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 82: astore 10\n 84: aload 7\n 86: aload 10\n 88: checkcast #14 // class java/lang/String\n 91: astore 11\n 93: astore 19\n 95: iconst_0\n 96: istore 12\n 98: aload 4\n 100: aload 11\n 102: invokespecial #76 // Method parseLine:(Ljava/lang/String;)Lorg/aoc2021/Day5$Vent;\n 105: aload 19\n 107: swap\n 108: invokeinterface #80, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 113: pop\n 114: goto 65\n 117: aload 7\n 119: checkcast #82 // class java/util/List\n 122: nop\n 123: astore_2\n 124: aload_0\n 125: aload_2\n 126: invokespecial #86 // Method emptyCountsGrid:(Ljava/util/List;)[[Ljava/lang/Integer;\n 129: astore_3\n 130: aload_2\n 131: checkcast #42 // class java/lang/Iterable\n 134: astore 4\n 136: iconst_0\n 137: istore 5\n 139: aload 4\n 141: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 146: astore 6\n 148: aload 6\n 150: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 155: ifeq 386\n 158: aload 6\n 160: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 165: astore 7\n 167: aload 7\n 169: checkcast #88 // class org/aoc2021/Day5$Vent\n 172: astore 8\n 174: iconst_0\n 175: istore 9\n 177: aload 8\n 179: invokevirtual #92 // Method org/aoc2021/Day5$Vent.getX1:()I\n 182: aload 8\n 184: invokevirtual #95 // Method org/aoc2021/Day5$Vent.getX2:()I\n 187: if_icmpne 279\n 190: aload 8\n 192: invokevirtual #98 // Method org/aoc2021/Day5$Vent.getY1:()I\n 195: aload 8\n 197: invokevirtual #101 // Method org/aoc2021/Day5$Vent.getY2:()I\n 200: invokestatic #107 // Method java/lang/Math.min:(II)I\n 203: istore 10\n 205: aload 8\n 207: invokevirtual #98 // Method org/aoc2021/Day5$Vent.getY1:()I\n 210: aload 8\n 212: invokevirtual #101 // Method org/aoc2021/Day5$Vent.getY2:()I\n 215: invokestatic #110 // Method java/lang/Math.max:(II)I\n 218: istore 11\n 220: iload 10\n 222: istore 12\n 224: iload 12\n 226: iload 11\n 228: if_icmpgt 279\n 231: aload_3\n 232: aload 8\n 234: invokevirtual #92 // Method org/aoc2021/Day5$Vent.getX1:()I\n 237: aaload\n 238: astore 13\n 240: iload 12\n 242: istore 14\n 244: aload 13\n 246: iload 14\n 248: aaload\n 249: invokevirtual #115 // Method java/lang/Integer.intValue:()I\n 252: istore 15\n 254: aload 13\n 256: iload 14\n 258: iload 15\n 260: iconst_1\n 261: iadd\n 262: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 265: aastore\n 266: iload 12\n 268: iload 11\n 270: if_icmpeq 279\n 273: iinc 12, 1\n 276: goto 231\n 279: aload 8\n 281: invokevirtual #98 // Method org/aoc2021/Day5$Vent.getY1:()I\n 284: aload 8\n 286: invokevirtual #101 // Method org/aoc2021/Day5$Vent.getY2:()I\n 289: if_icmpne 381\n 292: aload 8\n 294: invokevirtual #92 // Method org/aoc2021/Day5$Vent.getX1:()I\n 297: aload 8\n 299: invokevirtual #95 // Method org/aoc2021/Day5$Vent.getX2:()I\n 302: invokestatic #107 // Method java/lang/Math.min:(II)I\n 305: istore 10\n 307: aload 8\n 309: invokevirtual #92 // Method org/aoc2021/Day5$Vent.getX1:()I\n 312: aload 8\n 314: invokevirtual #95 // Method org/aoc2021/Day5$Vent.getX2:()I\n 317: invokestatic #110 // Method java/lang/Math.max:(II)I\n 320: istore 11\n 322: iload 10\n 324: istore 12\n 326: iload 12\n 328: iload 11\n 330: if_icmpgt 381\n 333: aload_3\n 334: iload 12\n 336: aaload\n 337: astore 13\n 339: aload 8\n 341: invokevirtual #98 // Method org/aoc2021/Day5$Vent.getY1:()I\n 344: istore 14\n 346: aload 13\n 348: iload 14\n 350: aaload\n 351: invokevirtual #115 // Method java/lang/Integer.intValue:()I\n 354: istore 15\n 356: aload 13\n 358: iload 14\n 360: iload 15\n 362: iconst_1\n 363: iadd\n 364: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 367: aastore\n 368: iload 12\n 370: iload 11\n 372: if_icmpeq 381\n 375: iinc 12, 1\n 378: goto 333\n 381: nop\n 382: nop\n 383: goto 148\n 386: nop\n 387: aload_3\n 388: checkcast #121 // class \"[Ljava/lang/Object;\"\n 391: astore 4\n 393: iconst_0\n 394: istore 5\n 396: iconst_0\n 397: istore 6\n 399: aload 4\n 401: arraylength\n 402: istore 7\n 404: iload 6\n 406: iload 7\n 408: if_icmpge 518\n 411: aload 4\n 413: iload 6\n 415: aaload\n 416: astore 8\n 418: iload 5\n 420: aload 8\n 422: checkcast #123 // class \"[Ljava/lang/Integer;\"\n 425: astore 9\n 427: istore 19\n 429: iconst_0\n 430: istore 10\n 432: aload 9\n 434: astore 11\n 436: iconst_0\n 437: istore 12\n 439: iconst_0\n 440: istore 13\n 442: iconst_0\n 443: istore 14\n 445: aload 11\n 447: arraylength\n 448: istore 15\n 450: iload 14\n 452: iload 15\n 454: if_icmpge 500\n 457: aload 11\n 459: iload 14\n 461: aaload\n 462: astore 16\n 464: aload 16\n 466: checkcast #125 // class java/lang/Number\n 469: invokevirtual #126 // Method java/lang/Number.intValue:()I\n 472: istore 17\n 474: iconst_0\n 475: istore 18\n 477: iload 17\n 479: iconst_2\n 480: if_icmplt 487\n 483: iconst_1\n 484: goto 488\n 487: iconst_0\n 488: ifeq 494\n 491: iinc 13, 1\n 494: iinc 14, 1\n 497: goto 450\n 500: iload 13\n 502: nop\n 503: istore 20\n 505: iload 19\n 507: iload 20\n 509: iadd\n 510: istore 5\n 512: iinc 6, 1\n 515: goto 404\n 518: iload 5\n 520: ireturn\n\n private final int solvePart2(java.lang.String);\n Code:\n 0: aload_1\n 1: iconst_0\n 2: anewarray #14 // class java/lang/String\n 5: invokestatic #20 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 8: getstatic #26 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 11: invokestatic #32 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 14: dup\n 15: ldc #34 // String readAllLines(...)\n 17: invokestatic #40 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 20: checkcast #42 // class java/lang/Iterable\n 23: astore_3\n 24: getstatic #45 // Field INSTANCE:Lorg/aoc2021/Day5;\n 27: astore 4\n 29: iconst_0\n 30: istore 5\n 32: aload_3\n 33: astore 6\n 35: new #47 // class java/util/ArrayList\n 38: dup\n 39: aload_3\n 40: bipush 10\n 42: invokestatic #53 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 45: invokespecial #56 // Method java/util/ArrayList.\"<init>\":(I)V\n 48: checkcast #58 // class java/util/Collection\n 51: astore 7\n 53: iconst_0\n 54: istore 8\n 56: aload 6\n 58: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 63: astore 9\n 65: aload 9\n 67: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 72: ifeq 117\n 75: aload 9\n 77: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 82: astore 10\n 84: aload 7\n 86: aload 10\n 88: checkcast #14 // class java/lang/String\n 91: astore 11\n 93: astore 19\n 95: iconst_0\n 96: istore 12\n 98: aload 4\n 100: aload 11\n 102: invokespecial #76 // Method parseLine:(Ljava/lang/String;)Lorg/aoc2021/Day5$Vent;\n 105: aload 19\n 107: swap\n 108: invokeinterface #80, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 113: pop\n 114: goto 65\n 117: aload 7\n 119: checkcast #82 // class java/util/List\n 122: nop\n 123: astore_2\n 124: aload_0\n 125: aload_2\n 126: invokespecial #86 // Method emptyCountsGrid:(Ljava/util/List;)[[Ljava/lang/Integer;\n 129: astore_3\n 130: aload_2\n 131: checkcast #42 // class java/lang/Iterable\n 134: astore 4\n 136: iconst_0\n 137: istore 5\n 139: aload 4\n 141: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 146: astore 6\n 148: aload 6\n 150: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 155: ifeq 321\n 158: aload 6\n 160: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 165: astore 7\n 167: aload 7\n 169: checkcast #88 // class org/aoc2021/Day5$Vent\n 172: astore 8\n 174: iconst_0\n 175: istore 9\n 177: aload 8\n 179: invokevirtual #95 // Method org/aoc2021/Day5$Vent.getX2:()I\n 182: aload 8\n 184: invokevirtual #92 // Method org/aoc2021/Day5$Vent.getX1:()I\n 187: isub\n 188: invokestatic #169 // Method kotlin/math/MathKt.getSign:(I)I\n 191: istore 10\n 193: aload 8\n 195: invokevirtual #101 // Method org/aoc2021/Day5$Vent.getY2:()I\n 198: aload 8\n 200: invokevirtual #98 // Method org/aoc2021/Day5$Vent.getY1:()I\n 203: isub\n 204: invokestatic #169 // Method kotlin/math/MathKt.getSign:(I)I\n 207: istore 11\n 209: nop\n 210: aload 8\n 212: invokevirtual #95 // Method org/aoc2021/Day5$Vent.getX2:()I\n 215: aload 8\n 217: invokevirtual #92 // Method org/aoc2021/Day5$Vent.getX1:()I\n 220: isub\n 221: invokestatic #172 // Method java/lang/Math.abs:(I)I\n 224: aload 8\n 226: invokevirtual #101 // Method org/aoc2021/Day5$Vent.getY2:()I\n 229: aload 8\n 231: invokevirtual #98 // Method org/aoc2021/Day5$Vent.getY1:()I\n 234: isub\n 235: invokestatic #172 // Method java/lang/Math.abs:(I)I\n 238: invokestatic #110 // Method java/lang/Math.max:(II)I\n 241: istore 12\n 243: iconst_0\n 244: istore 13\n 246: iload 13\n 248: iload 12\n 250: if_icmpgt 316\n 253: aload_3\n 254: aload 8\n 256: invokevirtual #92 // Method org/aoc2021/Day5$Vent.getX1:()I\n 259: iload 10\n 261: iload 13\n 263: imul\n 264: iadd\n 265: aaload\n 266: astore 14\n 268: aload 8\n 270: invokevirtual #98 // Method org/aoc2021/Day5$Vent.getY1:()I\n 273: iload 11\n 275: iload 13\n 277: imul\n 278: iadd\n 279: istore 15\n 281: aload 14\n 283: iload 15\n 285: aaload\n 286: invokevirtual #115 // Method java/lang/Integer.intValue:()I\n 289: istore 16\n 291: aload 14\n 293: iload 15\n 295: iload 16\n 297: iconst_1\n 298: iadd\n 299: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 302: aastore\n 303: iload 13\n 305: iload 12\n 307: if_icmpeq 316\n 310: iinc 13, 1\n 313: goto 253\n 316: nop\n 317: nop\n 318: goto 148\n 321: nop\n 322: aload_3\n 323: checkcast #121 // class \"[Ljava/lang/Object;\"\n 326: astore 4\n 328: iconst_0\n 329: istore 5\n 331: iconst_0\n 332: istore 6\n 334: aload 4\n 336: arraylength\n 337: istore 7\n 339: iload 6\n 341: iload 7\n 343: if_icmpge 453\n 346: aload 4\n 348: iload 6\n 350: aaload\n 351: astore 8\n 353: iload 5\n 355: aload 8\n 357: checkcast #123 // class \"[Ljava/lang/Integer;\"\n 360: astore 9\n 362: istore 19\n 364: iconst_0\n 365: istore 10\n 367: aload 9\n 369: astore 11\n 371: iconst_0\n 372: istore 12\n 374: iconst_0\n 375: istore 13\n 377: iconst_0\n 378: istore 14\n 380: aload 11\n 382: arraylength\n 383: istore 15\n 385: iload 14\n 387: iload 15\n 389: if_icmpge 435\n 392: aload 11\n 394: iload 14\n 396: aaload\n 397: astore 16\n 399: aload 16\n 401: checkcast #125 // class java/lang/Number\n 404: invokevirtual #126 // Method java/lang/Number.intValue:()I\n 407: istore 17\n 409: iconst_0\n 410: istore 18\n 412: iload 17\n 414: iconst_2\n 415: if_icmplt 422\n 418: iconst_1\n 419: goto 423\n 422: iconst_0\n 423: ifeq 429\n 426: iinc 13, 1\n 429: iinc 14, 1\n 432: goto 385\n 435: iload 13\n 437: nop\n 438: istore 20\n 440: iload 19\n 442: iload 20\n 444: iadd\n 445: istore 5\n 447: iinc 6, 1\n 450: goto 339\n 453: iload 5\n 455: ireturn\n\n private final java.lang.Integer[][] emptyCountsGrid(java.util.List<org.aoc2021.Day5$Vent>);\n Code:\n 0: aload_1\n 1: checkcast #42 // class java/lang/Iterable\n 4: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 9: astore 4\n 11: aload 4\n 13: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 18: ifne 29\n 21: new #182 // class java/util/NoSuchElementException\n 24: dup\n 25: invokespecial #183 // Method java/util/NoSuchElementException.\"<init>\":()V\n 28: athrow\n 29: aload 4\n 31: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 36: checkcast #88 // class org/aoc2021/Day5$Vent\n 39: astore 5\n 41: iconst_0\n 42: istore 6\n 44: aload 5\n 46: invokevirtual #92 // Method org/aoc2021/Day5$Vent.getX1:()I\n 49: aload 5\n 51: invokevirtual #95 // Method org/aoc2021/Day5$Vent.getX2:()I\n 54: invokestatic #110 // Method java/lang/Math.max:(II)I\n 57: nop\n 58: istore 5\n 60: aload 4\n 62: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 67: ifeq 115\n 70: aload 4\n 72: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 77: checkcast #88 // class org/aoc2021/Day5$Vent\n 80: astore 6\n 82: iconst_0\n 83: istore 7\n 85: aload 6\n 87: invokevirtual #92 // Method org/aoc2021/Day5$Vent.getX1:()I\n 90: aload 6\n 92: invokevirtual #95 // Method org/aoc2021/Day5$Vent.getX2:()I\n 95: invokestatic #110 // Method java/lang/Math.max:(II)I\n 98: nop\n 99: istore 6\n 101: iload 5\n 103: iload 6\n 105: if_icmpge 60\n 108: iload 6\n 110: istore 5\n 112: goto 60\n 115: iload 5\n 117: iconst_1\n 118: iadd\n 119: istore_2\n 120: aload_1\n 121: checkcast #42 // class java/lang/Iterable\n 124: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 129: astore 5\n 131: aload 5\n 133: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 138: ifne 149\n 141: new #182 // class java/util/NoSuchElementException\n 144: dup\n 145: invokespecial #183 // Method java/util/NoSuchElementException.\"<init>\":()V\n 148: athrow\n 149: aload 5\n 151: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 156: checkcast #88 // class org/aoc2021/Day5$Vent\n 159: astore 6\n 161: iconst_0\n 162: istore 7\n 164: aload 6\n 166: invokevirtual #98 // Method org/aoc2021/Day5$Vent.getY1:()I\n 169: aload 6\n 171: invokevirtual #101 // Method org/aoc2021/Day5$Vent.getY2:()I\n 174: invokestatic #110 // Method java/lang/Math.max:(II)I\n 177: nop\n 178: istore 6\n 180: aload 5\n 182: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 187: ifeq 235\n 190: aload 5\n 192: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 197: checkcast #88 // class org/aoc2021/Day5$Vent\n 200: astore 7\n 202: iconst_0\n 203: istore 8\n 205: aload 7\n 207: invokevirtual #98 // Method org/aoc2021/Day5$Vent.getY1:()I\n 210: aload 7\n 212: invokevirtual #101 // Method org/aoc2021/Day5$Vent.getY2:()I\n 215: invokestatic #110 // Method java/lang/Math.max:(II)I\n 218: nop\n 219: istore 7\n 221: iload 6\n 223: iload 7\n 225: if_icmpge 180\n 228: iload 7\n 230: istore 6\n 232: goto 180\n 235: iload 6\n 237: iconst_1\n 238: iadd\n 239: istore_3\n 240: iconst_0\n 241: istore 4\n 243: iload_2\n 244: anewarray #123 // class \"[Ljava/lang/Integer;\"\n 247: astore 5\n 249: iload 4\n 251: iload_2\n 252: if_icmpge 314\n 255: iload 4\n 257: istore 6\n 259: aload 5\n 261: iload 6\n 263: iconst_0\n 264: istore 7\n 266: iload_3\n 267: anewarray #112 // class java/lang/Integer\n 270: astore 8\n 272: istore 11\n 274: astore 10\n 276: iload 7\n 278: iload_3\n 279: if_icmpge 301\n 282: iload 7\n 284: istore 9\n 286: aload 8\n 288: iload 9\n 290: iconst_0\n 291: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 294: aastore\n 295: iinc 7, 1\n 298: goto 276\n 301: aload 10\n 303: iload 11\n 305: aload 8\n 307: aastore\n 308: iinc 4, 1\n 311: goto 249\n 314: aload 5\n 316: areturn\n\n private final org.aoc2021.Day5$Vent parseLine(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #189 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #14 // class java/lang/String\n 8: astore_3\n 9: aload_3\n 10: iconst_0\n 11: ldc #191 // 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 #197 // 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 #201, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 31: checkcast #14 // class java/lang/String\n 34: astore_3\n 35: aload_2\n 36: iconst_1\n 37: invokeinterface #201, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 42: checkcast #14 // class java/lang/String\n 45: astore 4\n 47: aload_3\n 48: checkcast #189 // class java/lang/CharSequence\n 51: iconst_1\n 52: anewarray #14 // class java/lang/String\n 55: astore 6\n 57: aload 6\n 59: iconst_0\n 60: ldc #203 // String ,\n 62: aastore\n 63: aload 6\n 65: iconst_0\n 66: iconst_0\n 67: bipush 6\n 69: aconst_null\n 70: invokestatic #197 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 73: checkcast #42 // class java/lang/Iterable\n 76: astore 6\n 78: iconst_0\n 79: istore 7\n 81: aload 6\n 83: astore 8\n 85: new #47 // class java/util/ArrayList\n 88: dup\n 89: aload 6\n 91: bipush 10\n 93: invokestatic #53 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 96: invokespecial #56 // Method java/util/ArrayList.\"<init>\":(I)V\n 99: checkcast #58 // class java/util/Collection\n 102: astore 9\n 104: iconst_0\n 105: istore 10\n 107: aload 8\n 109: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 114: astore 11\n 116: aload 11\n 118: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 123: ifeq 170\n 126: aload 11\n 128: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 133: astore 12\n 135: aload 9\n 137: aload 12\n 139: checkcast #14 // class java/lang/String\n 142: astore 13\n 144: astore 18\n 146: iconst_0\n 147: istore 14\n 149: aload 13\n 151: invokestatic #206 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 154: nop\n 155: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 158: aload 18\n 160: swap\n 161: invokeinterface #80, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 166: pop\n 167: goto 116\n 170: aload 9\n 172: checkcast #82 // class java/util/List\n 175: nop\n 176: astore 5\n 178: aload 5\n 180: iconst_0\n 181: invokeinterface #201, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 186: checkcast #125 // class java/lang/Number\n 189: invokevirtual #126 // Method java/lang/Number.intValue:()I\n 192: istore 6\n 194: aload 5\n 196: iconst_1\n 197: invokeinterface #201, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 202: checkcast #125 // class java/lang/Number\n 205: invokevirtual #126 // Method java/lang/Number.intValue:()I\n 208: istore 7\n 210: aload 4\n 212: checkcast #189 // class java/lang/CharSequence\n 215: iconst_1\n 216: anewarray #14 // class java/lang/String\n 219: astore 9\n 221: aload 9\n 223: iconst_0\n 224: ldc #203 // String ,\n 226: aastore\n 227: aload 9\n 229: iconst_0\n 230: iconst_0\n 231: bipush 6\n 233: aconst_null\n 234: invokestatic #197 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 237: checkcast #42 // class java/lang/Iterable\n 240: astore 9\n 242: iconst_0\n 243: istore 10\n 245: aload 9\n 247: astore 11\n 249: new #47 // class java/util/ArrayList\n 252: dup\n 253: aload 9\n 255: bipush 10\n 257: invokestatic #53 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 260: invokespecial #56 // Method java/util/ArrayList.\"<init>\":(I)V\n 263: checkcast #58 // class java/util/Collection\n 266: astore 12\n 268: iconst_0\n 269: istore 13\n 271: aload 11\n 273: invokeinterface #62, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 278: astore 14\n 280: aload 14\n 282: invokeinterface #68, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 287: ifeq 334\n 290: aload 14\n 292: invokeinterface #72, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 297: astore 15\n 299: aload 12\n 301: aload 15\n 303: checkcast #14 // class java/lang/String\n 306: astore 16\n 308: astore 18\n 310: iconst_0\n 311: istore 17\n 313: aload 16\n 315: invokestatic #206 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 318: nop\n 319: invokestatic #119 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 322: aload 18\n 324: swap\n 325: invokeinterface #80, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 330: pop\n 331: goto 280\n 334: aload 12\n 336: checkcast #82 // class java/util/List\n 339: nop\n 340: astore 8\n 342: aload 8\n 344: iconst_0\n 345: invokeinterface #201, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 350: checkcast #125 // class java/lang/Number\n 353: invokevirtual #126 // Method java/lang/Number.intValue:()I\n 356: istore 9\n 358: aload 8\n 360: iconst_1\n 361: invokeinterface #201, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 366: checkcast #125 // class java/lang/Number\n 369: invokevirtual #126 // Method java/lang/Number.intValue:()I\n 372: istore 10\n 374: new #88 // class org/aoc2021/Day5$Vent\n 377: dup\n 378: iload 6\n 380: iload 7\n 382: iload 9\n 384: iload 10\n 386: invokespecial #209 // Method org/aoc2021/Day5$Vent.\"<init>\":(IIII)V\n 389: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #224 // String args\n 3: invokestatic #227 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #229 // String input5.txt\n 8: astore_1\n 9: getstatic #45 // Field INSTANCE:Lorg/aoc2021/Day5;\n 12: aload_1\n 13: invokespecial #231 // Method solvePart1:(Ljava/lang/String;)I\n 16: istore_2\n 17: getstatic #237 // Field java/lang/System.out:Ljava/io/PrintStream;\n 20: iload_2\n 21: invokevirtual #242 // Method java/io/PrintStream.println:(I)V\n 24: getstatic #45 // Field INSTANCE:Lorg/aoc2021/Day5;\n 27: aload_1\n 28: invokespecial #244 // Method solvePart2:(Ljava/lang/String;)I\n 31: istore_3\n 32: getstatic #237 // Field java/lang/System.out:Ljava/io/PrintStream;\n 35: iload_3\n 36: invokevirtual #242 // Method java/io/PrintStream.println:(I)V\n 39: return\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day5\n 3: dup\n 4: invokespecial #249 // Method \"<init>\":()V\n 7: putstatic #45 // Field INSTANCE:Lorg/aoc2021/Day5;\n 10: return\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day16.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
object Day16 {
interface Packet {
val version: Int
val typeId: Int
fun sumSubPacketVersions(): Int
fun evaluate(): Long
}
data class LiteralValuePacket(
override val version: Int,
override val typeId: Int,
val value: Long,
) : Packet {
override fun sumSubPacketVersions() = 0
override fun evaluate() = value
}
data class OperatorPacket(
override val version: Int,
override val typeId: Int,
val subPackets: List<Packet>,
) : Packet {
override fun sumSubPacketVersions() = subPackets.sumOf { p ->
p.version + p.sumSubPacketVersions()
}
override fun evaluate() = when (typeId) {
0 -> subPackets.sumOf(Packet::evaluate)
1 -> subPackets.fold(1L) { p, packet -> p * packet.evaluate() }
2 -> subPackets.minOf(Packet::evaluate)
3 -> subPackets.maxOf(Packet::evaluate)
5 -> if (subPackets[0].evaluate() > subPackets[1].evaluate()) 1L else 0L
6 -> if (subPackets[0].evaluate() < subPackets[1].evaluate()) 1L else 0L
7 -> if (subPackets[0].evaluate() == subPackets[1].evaluate()) 1L else 0L
else -> throw IllegalArgumentException("$typeId")
}
}
private fun solvePart1(lines: List<String>): Int {
val binary = hexToBinary(lines[0])
val outerPacket = parsePacket(binary).first
return outerPacket.version + outerPacket.sumSubPacketVersions()
}
private fun solvePart2(lines: List<String>): Long {
val binary = hexToBinary(lines[0])
val outerPacket = parsePacket(binary).first
return outerPacket.evaluate()
}
private fun hexToBinary(line: String): String {
return line.map { c ->
val binary = c.toString().toInt(16).toString(2)
if (binary.length == 4) {
binary
} else {
"0".repeat(4 - (binary.length % 4)) + binary
}
}.joinToString(separator = "")
}
private fun parsePacket(binary: String, i: Int = 0): Pair<Packet, Int> {
val version = binary.substring(i..i+2).toInt(2)
val typeId = binary.substring(i+3..i+5).toInt(2)
if (typeId == 4) {
return parseLiteralValuePacket(binary, i, version, typeId)
}
return parseOperatorPacket(binary, i, version, typeId)
}
private fun parseLiteralValuePacket(binary: String, i: Int, version: Int, typeId: Int): Pair<LiteralValuePacket, Int> {
var currentIndex = i + 6
var currentValue = 0L
while (true) {
currentValue = 16 * currentValue + binary.substring(currentIndex+1..currentIndex+4).toInt(2)
if (binary[currentIndex] == '0') {
break
}
currentIndex += 5
}
val packet = LiteralValuePacket(version, typeId, currentValue)
return packet to (currentIndex + 5)
}
private fun parseOperatorPacket(binary: String, i: Int, version: Int, typeId: Int): Pair<OperatorPacket, Int> {
if (binary[i + 6] == '0') {
val totalSubPacketLength = binary.substring(i+7..i+21).toInt(2)
val subPackets = mutableListOf<Packet>()
var currentIndex = i + 22
while (currentIndex - (i + 22) != totalSubPacketLength) {
val (packet, nextPacketIndex) = parsePacket(binary, currentIndex)
subPackets.add(packet)
currentIndex = nextPacketIndex
}
return OperatorPacket(version, typeId, subPackets.toList()) to currentIndex
} else {
val numSubPackets = binary.substring(i+7..i+17).toInt(2)
val subPackets = mutableListOf<Packet>()
var currentIndex = i + 18
(1..numSubPackets).forEach { _ ->
val (packet, nextPacketIndex) = parsePacket(binary, currentIndex)
subPackets.add(packet)
currentIndex = nextPacketIndex
}
return OperatorPacket(version, typeId, subPackets.toList()) to currentIndex
}
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input16.txt"), Charsets.UTF_8)
val solution1 = solvePart1(lines)
println(solution1)
val solution2 = solvePart2(lines)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day16$Packet.class",
"javap": "Compiled from \"Day16.kt\"\npublic interface org.aoc2021.Day16$Packet {\n public abstract int getVersion();\n\n public abstract int getTypeId();\n\n public abstract int sumSubPacketVersions();\n\n public abstract long evaluate();\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day16$OperatorPacket.class",
"javap": "Compiled from \"Day16.kt\"\npublic final class org.aoc2021.Day16$OperatorPacket implements org.aoc2021.Day16$Packet {\n private final int version;\n\n private final int typeId;\n\n private final java.util.List<org.aoc2021.Day16$Packet> subPackets;\n\n public org.aoc2021.Day16$OperatorPacket(int, int, java.util.List<? extends org.aoc2021.Day16$Packet>);\n Code:\n 0: aload_3\n 1: ldc #12 // String subPackets\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokespecial #21 // Method java/lang/Object.\"<init>\":()V\n 10: aload_0\n 11: iload_1\n 12: putfield #25 // Field version:I\n 15: aload_0\n 16: iload_2\n 17: putfield #28 // Field typeId:I\n 20: aload_0\n 21: aload_3\n 22: putfield #31 // Field subPackets:Ljava/util/List;\n 25: 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 int getTypeId();\n Code:\n 0: aload_0\n 1: getfield #28 // Field typeId:I\n 4: ireturn\n\n public final java.util.List<org.aoc2021.Day16$Packet> getSubPackets();\n Code:\n 0: aload_0\n 1: getfield #31 // Field subPackets:Ljava/util/List;\n 4: areturn\n\n public int sumSubPacketVersions();\n Code:\n 0: aload_0\n 1: getfield #31 // Field subPackets:Ljava/util/List;\n 4: checkcast #42 // class java/lang/Iterable\n 7: astore_1\n 8: iconst_0\n 9: istore_2\n 10: aload_1\n 11: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 16: astore_3\n 17: aload_3\n 18: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 23: ifeq 73\n 26: aload_3\n 27: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 32: astore 4\n 34: iload_2\n 35: aload 4\n 37: checkcast #6 // class org/aoc2021/Day16$Packet\n 40: astore 5\n 42: istore 7\n 44: iconst_0\n 45: istore 6\n 47: aload 5\n 49: invokeinterface #58, 1 // InterfaceMethod org/aoc2021/Day16$Packet.getVersion:()I\n 54: aload 5\n 56: invokeinterface #60, 1 // InterfaceMethod org/aoc2021/Day16$Packet.sumSubPacketVersions:()I\n 61: iadd\n 62: istore 8\n 64: iload 7\n 66: iload 8\n 68: iadd\n 69: istore_2\n 70: goto 17\n 73: iload_2\n 74: ireturn\n\n public long evaluate();\n Code:\n 0: aload_0\n 1: invokevirtual #67 // Method getTypeId:()I\n 4: tableswitch { // 0 to 7\n 0: 52\n 1: 124\n 2: 201\n 3: 306\n 4: 555\n 5: 411\n 6: 459\n 7: 507\n default: 555\n }\n 52: aload_0\n 53: getfield #31 // Field subPackets:Ljava/util/List;\n 56: checkcast #42 // class java/lang/Iterable\n 59: astore_1\n 60: lconst_0\n 61: lstore_2\n 62: aload_1\n 63: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 68: astore 6\n 70: aload 6\n 72: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 77: ifeq 120\n 80: aload 6\n 82: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 87: astore 8\n 89: lload_2\n 90: aload 8\n 92: checkcast #6 // class org/aoc2021/Day16$Packet\n 95: astore 9\n 97: lstore 14\n 99: iconst_0\n 100: istore 10\n 102: aload 9\n 104: invokeinterface #69, 1 // InterfaceMethod org/aoc2021/Day16$Packet.evaluate:()J\n 109: lstore 16\n 111: lload 14\n 113: lload 16\n 115: ladd\n 116: lstore_2\n 117: goto 70\n 120: lload_2\n 121: goto 570\n 124: aload_0\n 125: getfield #31 // Field subPackets:Ljava/util/List;\n 128: checkcast #42 // class java/lang/Iterable\n 131: astore_1\n 132: lconst_1\n 133: lstore_2\n 134: iconst_0\n 135: istore 4\n 137: lload_2\n 138: lstore 6\n 140: aload_1\n 141: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 146: astore 8\n 148: aload 8\n 150: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 155: ifeq 196\n 158: aload 8\n 160: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 165: astore 9\n 167: lload 6\n 169: aload 9\n 171: checkcast #6 // class org/aoc2021/Day16$Packet\n 174: astore 10\n 176: lstore 11\n 178: iconst_0\n 179: istore 13\n 181: lload 11\n 183: aload 10\n 185: invokeinterface #69, 1 // InterfaceMethod org/aoc2021/Day16$Packet.evaluate:()J\n 190: lmul\n 191: lstore 6\n 193: goto 148\n 196: lload 6\n 198: goto 570\n 201: aload_0\n 202: getfield #31 // Field subPackets:Ljava/util/List;\n 205: checkcast #42 // class java/lang/Iterable\n 208: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 213: astore_2\n 214: aload_2\n 215: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 220: ifne 231\n 223: new #71 // class java/util/NoSuchElementException\n 226: dup\n 227: invokespecial #72 // Method java/util/NoSuchElementException.\"<init>\":()V\n 230: athrow\n 231: aload_2\n 232: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 237: checkcast #6 // class org/aoc2021/Day16$Packet\n 240: astore 4\n 242: iconst_0\n 243: istore 6\n 245: aload 4\n 247: invokeinterface #69, 1 // InterfaceMethod org/aoc2021/Day16$Packet.evaluate:()J\n 252: lstore 4\n 254: aload_2\n 255: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 260: ifeq 301\n 263: aload_2\n 264: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 269: checkcast #6 // class org/aoc2021/Day16$Packet\n 272: astore 6\n 274: iconst_0\n 275: istore 8\n 277: aload 6\n 279: invokeinterface #69, 1 // InterfaceMethod org/aoc2021/Day16$Packet.evaluate:()J\n 284: lstore 6\n 286: lload 4\n 288: lload 6\n 290: lcmp\n 291: ifle 254\n 294: lload 6\n 296: lstore 4\n 298: goto 254\n 301: lload 4\n 303: goto 570\n 306: aload_0\n 307: getfield #31 // Field subPackets:Ljava/util/List;\n 310: checkcast #42 // class java/lang/Iterable\n 313: invokeinterface #46, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 318: astore_2\n 319: aload_2\n 320: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 325: ifne 336\n 328: new #71 // class java/util/NoSuchElementException\n 331: dup\n 332: invokespecial #72 // Method java/util/NoSuchElementException.\"<init>\":()V\n 335: athrow\n 336: aload_2\n 337: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 342: checkcast #6 // class org/aoc2021/Day16$Packet\n 345: astore 4\n 347: iconst_0\n 348: istore 6\n 350: aload 4\n 352: invokeinterface #69, 1 // InterfaceMethod org/aoc2021/Day16$Packet.evaluate:()J\n 357: lstore 4\n 359: aload_2\n 360: invokeinterface #52, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 365: ifeq 406\n 368: aload_2\n 369: invokeinterface #56, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 374: checkcast #6 // class org/aoc2021/Day16$Packet\n 377: astore 6\n 379: iconst_0\n 380: istore 8\n 382: aload 6\n 384: invokeinterface #69, 1 // InterfaceMethod org/aoc2021/Day16$Packet.evaluate:()J\n 389: lstore 6\n 391: lload 4\n 393: lload 6\n 395: lcmp\n 396: ifge 359\n 399: lload 6\n 401: lstore 4\n 403: goto 359\n 406: lload 4\n 408: goto 570\n 411: aload_0\n 412: getfield #31 // Field subPackets:Ljava/util/List;\n 415: iconst_0\n 416: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 421: checkcast #6 // class org/aoc2021/Day16$Packet\n 424: invokeinterface #69, 1 // InterfaceMethod org/aoc2021/Day16$Packet.evaluate:()J\n 429: aload_0\n 430: getfield #31 // Field subPackets:Ljava/util/List;\n 433: iconst_1\n 434: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 439: checkcast #6 // class org/aoc2021/Day16$Packet\n 442: invokeinterface #69, 1 // InterfaceMethod org/aoc2021/Day16$Packet.evaluate:()J\n 447: lcmp\n 448: ifle 455\n 451: lconst_1\n 452: goto 570\n 455: lconst_0\n 456: goto 570\n 459: aload_0\n 460: getfield #31 // Field subPackets:Ljava/util/List;\n 463: iconst_0\n 464: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 469: checkcast #6 // class org/aoc2021/Day16$Packet\n 472: invokeinterface #69, 1 // InterfaceMethod org/aoc2021/Day16$Packet.evaluate:()J\n 477: aload_0\n 478: getfield #31 // Field subPackets:Ljava/util/List;\n 481: iconst_1\n 482: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 487: checkcast #6 // class org/aoc2021/Day16$Packet\n 490: invokeinterface #69, 1 // InterfaceMethod org/aoc2021/Day16$Packet.evaluate:()J\n 495: lcmp\n 496: ifge 503\n 499: lconst_1\n 500: goto 570\n 503: lconst_0\n 504: goto 570\n 507: aload_0\n 508: getfield #31 // Field subPackets:Ljava/util/List;\n 511: iconst_0\n 512: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 517: checkcast #6 // class org/aoc2021/Day16$Packet\n 520: invokeinterface #69, 1 // InterfaceMethod org/aoc2021/Day16$Packet.evaluate:()J\n 525: aload_0\n 526: getfield #31 // Field subPackets:Ljava/util/List;\n 529: iconst_1\n 530: invokeinterface #78, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 535: checkcast #6 // class org/aoc2021/Day16$Packet\n 538: invokeinterface #69, 1 // InterfaceMethod org/aoc2021/Day16$Packet.evaluate:()J\n 543: lcmp\n 544: ifne 551\n 547: lconst_1\n 548: goto 570\n 551: lconst_0\n 552: goto 570\n 555: new #80 // class java/lang/IllegalArgumentException\n 558: dup\n 559: aload_0\n 560: invokevirtual #67 // Method getTypeId:()I\n 563: invokestatic #86 // Method java/lang/String.valueOf:(I)Ljava/lang/String;\n 566: invokespecial #89 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 569: athrow\n 570: 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 int component2();\n Code:\n 0: aload_0\n 1: getfield #28 // Field typeId:I\n 4: ireturn\n\n public final java.util.List<org.aoc2021.Day16$Packet> component3();\n Code:\n 0: aload_0\n 1: getfield #31 // Field subPackets:Ljava/util/List;\n 4: areturn\n\n public final org.aoc2021.Day16$OperatorPacket copy(int, int, java.util.List<? extends org.aoc2021.Day16$Packet>);\n Code:\n 0: aload_3\n 1: ldc #12 // String subPackets\n 3: invokestatic #18 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class org/aoc2021/Day16$OperatorPacket\n 9: dup\n 10: iload_1\n 11: iload_2\n 12: aload_3\n 13: invokespecial #111 // Method \"<init>\":(IILjava/util/List;)V\n 16: areturn\n\n public static org.aoc2021.Day16$OperatorPacket copy$default(org.aoc2021.Day16$OperatorPacket, int, 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 #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 typeId: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 subPackets:Ljava/util/List;\n 35: astore_3\n 36: aload_0\n 37: iload_1\n 38: iload_2\n 39: aload_3\n 40: invokevirtual #115 // Method copy:(IILjava/util/List;)Lorg/aoc2021/Day16$OperatorPacket;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #119 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #120 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #122 // String OperatorPacket(version=\n 9: invokevirtual #126 // 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 #129 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #131 // String , typeId=\n 21: invokevirtual #126 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #28 // Field typeId:I\n 28: invokevirtual #129 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #133 // String , subPackets=\n 33: invokevirtual #126 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #31 // Field subPackets:Ljava/util/List;\n 40: invokevirtual #136 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #139 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #141 // 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 #147 // 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 typeId:I\n 16: invokestatic #147 // 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 subPackets:Ljava/util/List;\n 29: invokevirtual #149 // 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 org/aoc2021/Day16$OperatorPacket\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day16$OperatorPacket\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 typeId:I\n 38: aload_2\n 39: getfield #28 // Field typeId:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #31 // Field subPackets:Ljava/util/List;\n 51: aload_2\n 52: getfield #31 // Field subPackets:Ljava/util/List;\n 55: invokestatic #157 // 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": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day16.class",
"javap": "Compiled from \"Day16.kt\"\npublic final class org.aoc2021.Day16 {\n public static final org.aoc2021.Day16 INSTANCE;\n\n private org.aoc2021.Day16();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int solvePart1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: iconst_0\n 3: invokeinterface #19, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 8: checkcast #21 // class java/lang/String\n 11: invokespecial #25 // Method hexToBinary:(Ljava/lang/String;)Ljava/lang/String;\n 14: astore_2\n 15: aload_0\n 16: aload_2\n 17: iconst_0\n 18: iconst_2\n 19: aconst_null\n 20: invokestatic #29 // Method parsePacket$default:(Lorg/aoc2021/Day16;Ljava/lang/String;IILjava/lang/Object;)Lkotlin/Pair;\n 23: invokevirtual #35 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 26: checkcast #37 // class org/aoc2021/Day16$Packet\n 29: astore_3\n 30: aload_3\n 31: invokeinterface #41, 1 // InterfaceMethod org/aoc2021/Day16$Packet.getVersion:()I\n 36: aload_3\n 37: invokeinterface #44, 1 // InterfaceMethod org/aoc2021/Day16$Packet.sumSubPacketVersions:()I\n 42: iadd\n 43: ireturn\n\n private final long solvePart2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: iconst_0\n 3: invokeinterface #19, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 8: checkcast #21 // class java/lang/String\n 11: invokespecial #25 // Method hexToBinary:(Ljava/lang/String;)Ljava/lang/String;\n 14: astore_2\n 15: aload_0\n 16: aload_2\n 17: iconst_0\n 18: iconst_2\n 19: aconst_null\n 20: invokestatic #29 // Method parsePacket$default:(Lorg/aoc2021/Day16;Ljava/lang/String;IILjava/lang/Object;)Lkotlin/Pair;\n 23: invokevirtual #35 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 26: checkcast #37 // class org/aoc2021/Day16$Packet\n 29: astore_3\n 30: aload_3\n 31: invokeinterface #57, 1 // InterfaceMethod org/aoc2021/Day16$Packet.evaluate:()J\n 36: lreturn\n\n private final java.lang.String hexToBinary(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #59 // 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 #61 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: invokeinterface #64, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 20: invokespecial #67 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #69 // 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 #64, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 43: if_icmpge 161\n 46: aload 4\n 48: iload 7\n 50: invokeinterface #73, 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 12\n 65: iconst_0\n 66: istore 10\n 68: iload 9\n 70: invokestatic #77 // Method java/lang/String.valueOf:(C)Ljava/lang/String;\n 73: bipush 16\n 75: invokestatic #83 // Method kotlin/text/CharsKt.checkRadix:(I)I\n 78: invokestatic #89 // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I\n 81: iconst_2\n 82: invokestatic #83 // Method kotlin/text/CharsKt.checkRadix:(I)I\n 85: invokestatic #93 // Method java/lang/Integer.toString:(II)Ljava/lang/String;\n 88: dup\n 89: ldc #95 // String toString(...)\n 91: invokestatic #101 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 94: astore 11\n 96: aload 11\n 98: invokevirtual #102 // Method java/lang/String.length:()I\n 101: iconst_4\n 102: if_icmpne 110\n 105: aload 11\n 107: goto 145\n 110: new #104 // class java/lang/StringBuilder\n 113: dup\n 114: invokespecial #105 // Method java/lang/StringBuilder.\"<init>\":()V\n 117: ldc #107 // String 0\n 119: checkcast #59 // class java/lang/CharSequence\n 122: iconst_4\n 123: aload 11\n 125: invokevirtual #102 // Method java/lang/String.length:()I\n 128: iconst_4\n 129: irem\n 130: isub\n 131: invokestatic #113 // Method kotlin/text/StringsKt.repeat:(Ljava/lang/CharSequence;I)Ljava/lang/String;\n 134: invokevirtual #117 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 137: aload 11\n 139: invokevirtual #117 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 142: invokevirtual #120 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 145: nop\n 146: aload 12\n 148: swap\n 149: invokeinterface #124, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 154: pop\n 155: iinc 7, 1\n 158: goto 34\n 161: aload 5\n 163: checkcast #15 // class java/util/List\n 166: nop\n 167: checkcast #126 // class java/lang/Iterable\n 170: ldc #128 // String\n 172: checkcast #59 // class java/lang/CharSequence\n 175: aconst_null\n 176: aconst_null\n 177: iconst_0\n 178: aconst_null\n 179: aconst_null\n 180: bipush 62\n 182: aconst_null\n 183: invokestatic #134 // 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 186: areturn\n\n private final kotlin.Pair<org.aoc2021.Day16$Packet, java.lang.Integer> parsePacket(java.lang.String, int);\n Code:\n 0: aload_1\n 1: new #152 // class kotlin/ranges/IntRange\n 4: dup\n 5: iload_2\n 6: iload_2\n 7: iconst_2\n 8: iadd\n 9: invokespecial #155 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 12: invokestatic #159 // Method kotlin/text/StringsKt.substring:(Ljava/lang/String;Lkotlin/ranges/IntRange;)Ljava/lang/String;\n 15: iconst_2\n 16: invokestatic #83 // Method kotlin/text/CharsKt.checkRadix:(I)I\n 19: invokestatic #89 // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I\n 22: istore_3\n 23: aload_1\n 24: new #152 // class kotlin/ranges/IntRange\n 27: dup\n 28: iload_2\n 29: iconst_3\n 30: iadd\n 31: iload_2\n 32: iconst_5\n 33: iadd\n 34: invokespecial #155 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 37: invokestatic #159 // Method kotlin/text/StringsKt.substring:(Ljava/lang/String;Lkotlin/ranges/IntRange;)Ljava/lang/String;\n 40: iconst_2\n 41: invokestatic #83 // Method kotlin/text/CharsKt.checkRadix:(I)I\n 44: invokestatic #89 // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I\n 47: istore 4\n 49: iload 4\n 51: iconst_4\n 52: if_icmpne 65\n 55: aload_0\n 56: aload_1\n 57: iload_2\n 58: iload_3\n 59: iload 4\n 61: invokespecial #163 // Method parseLiteralValuePacket:(Ljava/lang/String;III)Lkotlin/Pair;\n 64: areturn\n 65: aload_0\n 66: aload_1\n 67: iload_2\n 68: iload_3\n 69: iload 4\n 71: invokespecial #166 // Method parseOperatorPacket:(Ljava/lang/String;III)Lkotlin/Pair;\n 74: areturn\n\n static kotlin.Pair parsePacket$default(org.aoc2021.Day16, java.lang.String, int, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_2\n 2: iand\n 3: ifeq 8\n 6: iconst_0\n 7: istore_2\n 8: aload_0\n 9: aload_1\n 10: iload_2\n 11: invokespecial #171 // Method parsePacket:(Ljava/lang/String;I)Lkotlin/Pair;\n 14: areturn\n\n private final kotlin.Pair<org.aoc2021.Day16$LiteralValuePacket, java.lang.Integer> parseLiteralValuePacket(java.lang.String, int, int, int);\n Code:\n 0: iload_2\n 1: bipush 6\n 3: iadd\n 4: istore 5\n 6: lconst_0\n 7: lstore 6\n 9: nop\n 10: bipush 16\n 12: i2l\n 13: lload 6\n 15: lmul\n 16: aload_1\n 17: new #152 // class kotlin/ranges/IntRange\n 20: dup\n 21: iload 5\n 23: iconst_1\n 24: iadd\n 25: iload 5\n 27: iconst_4\n 28: iadd\n 29: invokespecial #155 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 32: invokestatic #159 // Method kotlin/text/StringsKt.substring:(Ljava/lang/String;Lkotlin/ranges/IntRange;)Ljava/lang/String;\n 35: iconst_2\n 36: invokestatic #83 // Method kotlin/text/CharsKt.checkRadix:(I)I\n 39: invokestatic #89 // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I\n 42: i2l\n 43: ladd\n 44: lstore 6\n 46: aload_1\n 47: iload 5\n 49: invokevirtual #173 // Method java/lang/String.charAt:(I)C\n 52: bipush 48\n 54: if_icmpne 60\n 57: goto 66\n 60: iinc 5, 5\n 63: goto 9\n 66: new #175 // class org/aoc2021/Day16$LiteralValuePacket\n 69: dup\n 70: iload_3\n 71: iload 4\n 73: lload 6\n 75: invokespecial #178 // Method org/aoc2021/Day16$LiteralValuePacket.\"<init>\":(IIJ)V\n 78: astore 8\n 80: aload 8\n 82: iload 5\n 84: iconst_5\n 85: iadd\n 86: invokestatic #181 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 89: invokestatic #187 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 92: areturn\n\n private final kotlin.Pair<org.aoc2021.Day16$OperatorPacket, java.lang.Integer> parseOperatorPacket(java.lang.String, int, int, int);\n Code:\n 0: aload_1\n 1: iload_2\n 2: bipush 6\n 4: iadd\n 5: invokevirtual #173 // Method java/lang/String.charAt:(I)C\n 8: bipush 48\n 10: if_icmpne 147\n 13: aload_1\n 14: new #152 // class kotlin/ranges/IntRange\n 17: dup\n 18: iload_2\n 19: bipush 7\n 21: iadd\n 22: iload_2\n 23: bipush 21\n 25: iadd\n 26: invokespecial #155 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 29: invokestatic #159 // Method kotlin/text/StringsKt.substring:(Ljava/lang/String;Lkotlin/ranges/IntRange;)Ljava/lang/String;\n 32: iconst_2\n 33: invokestatic #83 // Method kotlin/text/CharsKt.checkRadix:(I)I\n 36: invokestatic #89 // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I\n 39: istore 5\n 41: new #61 // class java/util/ArrayList\n 44: dup\n 45: invokespecial #194 // Method java/util/ArrayList.\"<init>\":()V\n 48: checkcast #15 // class java/util/List\n 51: astore 6\n 53: iload_2\n 54: bipush 22\n 56: iadd\n 57: istore 7\n 59: iload 7\n 61: iload_2\n 62: bipush 22\n 64: iadd\n 65: isub\n 66: iload 5\n 68: if_icmpeq 120\n 71: aload_0\n 72: aload_1\n 73: iload 7\n 75: invokespecial #171 // Method parsePacket:(Ljava/lang/String;I)Lkotlin/Pair;\n 78: astore 8\n 80: aload 8\n 82: invokevirtual #197 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 85: checkcast #37 // class org/aoc2021/Day16$Packet\n 88: astore 9\n 90: aload 8\n 92: invokevirtual #200 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 95: checkcast #202 // class java/lang/Number\n 98: invokevirtual #205 // Method java/lang/Number.intValue:()I\n 101: istore 10\n 103: aload 6\n 105: aload 9\n 107: invokeinterface #206, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 112: pop\n 113: iload 10\n 115: istore 7\n 117: goto 59\n 120: new #208 // class org/aoc2021/Day16$OperatorPacket\n 123: dup\n 124: iload_3\n 125: iload 4\n 127: aload 6\n 129: checkcast #126 // class java/lang/Iterable\n 132: invokestatic #212 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 135: invokespecial #215 // Method org/aoc2021/Day16$OperatorPacket.\"<init>\":(IILjava/util/List;)V\n 138: iload 7\n 140: invokestatic #181 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 143: invokestatic #187 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 146: areturn\n 147: aload_1\n 148: new #152 // class kotlin/ranges/IntRange\n 151: dup\n 152: iload_2\n 153: bipush 7\n 155: iadd\n 156: iload_2\n 157: bipush 17\n 159: iadd\n 160: invokespecial #155 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 163: invokestatic #159 // Method kotlin/text/StringsKt.substring:(Ljava/lang/String;Lkotlin/ranges/IntRange;)Ljava/lang/String;\n 166: iconst_2\n 167: invokestatic #83 // Method kotlin/text/CharsKt.checkRadix:(I)I\n 170: invokestatic #89 // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I\n 173: istore 5\n 175: new #61 // class java/util/ArrayList\n 178: dup\n 179: invokespecial #194 // Method java/util/ArrayList.\"<init>\":()V\n 182: checkcast #15 // class java/util/List\n 185: astore 6\n 187: iconst_0\n 188: istore 7\n 190: iload_2\n 191: bipush 18\n 193: iadd\n 194: istore 7\n 196: new #152 // class kotlin/ranges/IntRange\n 199: dup\n 200: iconst_1\n 201: iload 5\n 203: invokespecial #155 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 206: checkcast #126 // class java/lang/Iterable\n 209: astore 8\n 211: iconst_0\n 212: istore 9\n 214: aload 8\n 216: invokeinterface #219, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 221: astore 10\n 223: aload 10\n 225: invokeinterface #225, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 230: ifeq 299\n 233: aload 10\n 235: checkcast #227 // class kotlin/collections/IntIterator\n 238: invokevirtual #230 // Method kotlin/collections/IntIterator.nextInt:()I\n 241: istore 11\n 243: iconst_0\n 244: istore 12\n 246: getstatic #233 // Field INSTANCE:Lorg/aoc2021/Day16;\n 249: aload_1\n 250: iload 7\n 252: invokespecial #171 // Method parsePacket:(Ljava/lang/String;I)Lkotlin/Pair;\n 255: astore 13\n 257: aload 13\n 259: invokevirtual #197 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 262: checkcast #37 // class org/aoc2021/Day16$Packet\n 265: astore 14\n 267: aload 13\n 269: invokevirtual #200 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 272: checkcast #202 // class java/lang/Number\n 275: invokevirtual #205 // Method java/lang/Number.intValue:()I\n 278: istore 15\n 280: aload 6\n 282: aload 14\n 284: invokeinterface #206, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 289: pop\n 290: iload 15\n 292: istore 7\n 294: nop\n 295: nop\n 296: goto 223\n 299: nop\n 300: new #208 // class org/aoc2021/Day16$OperatorPacket\n 303: dup\n 304: iload_3\n 305: iload 4\n 307: aload 6\n 309: checkcast #126 // class java/lang/Iterable\n 312: invokestatic #212 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 315: invokespecial #215 // Method org/aoc2021/Day16$OperatorPacket.\"<init>\":(IILjava/util/List;)V\n 318: iload 7\n 320: invokestatic #181 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 323: invokestatic #187 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 326: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #248 // String args\n 3: invokestatic #251 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #253 // String input16.txt\n 8: iconst_0\n 9: anewarray #21 // class java/lang/String\n 12: invokestatic #259 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 15: getstatic #265 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 18: invokestatic #271 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 21: astore_1\n 22: getstatic #233 // Field INSTANCE:Lorg/aoc2021/Day16;\n 25: aload_1\n 26: invokestatic #275 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 29: aload_1\n 30: invokespecial #277 // Method solvePart1:(Ljava/util/List;)I\n 33: istore_2\n 34: getstatic #283 // Field java/lang/System.out:Ljava/io/PrintStream;\n 37: iload_2\n 38: invokevirtual #288 // Method java/io/PrintStream.println:(I)V\n 41: getstatic #233 // Field INSTANCE:Lorg/aoc2021/Day16;\n 44: aload_1\n 45: invokespecial #290 // Method solvePart2:(Ljava/util/List;)J\n 48: lstore_3\n 49: getstatic #283 // Field java/lang/System.out:Ljava/io/PrintStream;\n 52: lload_3\n 53: invokevirtual #293 // Method java/io/PrintStream.println:(J)V\n 56: return\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day16\n 3: dup\n 4: invokespecial #298 // Method \"<init>\":()V\n 7: putstatic #233 // Field INSTANCE:Lorg/aoc2021/Day16;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day16$LiteralValuePacket.class",
"javap": "Compiled from \"Day16.kt\"\npublic final class org.aoc2021.Day16$LiteralValuePacket implements org.aoc2021.Day16$Packet {\n private final int version;\n\n private final int typeId;\n\n private final long value;\n\n public org.aoc2021.Day16$LiteralValuePacket(int, int, long);\n Code:\n 0: aload_0\n 1: invokespecial #11 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #15 // Field version:I\n 9: aload_0\n 10: iload_2\n 11: putfield #18 // Field typeId:I\n 14: aload_0\n 15: lload_3\n 16: putfield #22 // Field value:J\n 19: return\n\n public int getVersion();\n Code:\n 0: aload_0\n 1: getfield #15 // Field version:I\n 4: ireturn\n\n public int getTypeId();\n Code:\n 0: aload_0\n 1: getfield #18 // Field typeId:I\n 4: ireturn\n\n public final long getValue();\n Code:\n 0: aload_0\n 1: getfield #22 // Field value:J\n 4: lreturn\n\n public int sumSubPacketVersions();\n Code:\n 0: iconst_0\n 1: ireturn\n\n public long evaluate();\n Code:\n 0: aload_0\n 1: getfield #22 // Field value:J\n 4: lreturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #15 // Field version:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #18 // Field typeId:I\n 4: ireturn\n\n public final long component3();\n Code:\n 0: aload_0\n 1: getfield #22 // Field value:J\n 4: lreturn\n\n public final org.aoc2021.Day16$LiteralValuePacket copy(int, int, long);\n Code:\n 0: new #2 // class org/aoc2021/Day16$LiteralValuePacket\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: lload_3\n 7: invokespecial #39 // Method \"<init>\":(IIJ)V\n 10: areturn\n\n public static org.aoc2021.Day16$LiteralValuePacket copy$default(org.aoc2021.Day16$LiteralValuePacket, int, int, long, 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 #15 // Field version: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 #18 // Field typeId: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 #22 // Field value:J\n 35: lstore_3\n 36: aload_0\n 37: iload_1\n 38: iload_2\n 39: lload_3\n 40: invokevirtual #43 // Method copy:(IIJ)Lorg/aoc2021/Day16$LiteralValuePacket;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #47 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #48 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #50 // String LiteralValuePacket(version=\n 9: invokevirtual #54 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #15 // Field version:I\n 16: invokevirtual #57 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #59 // String , typeId=\n 21: invokevirtual #54 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #18 // Field typeId:I\n 28: invokevirtual #57 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #61 // String , value=\n 33: invokevirtual #54 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #22 // Field value:J\n 40: invokevirtual #64 // Method java/lang/StringBuilder.append:(J)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #67 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #69 // 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 #15 // Field version:I\n 4: invokestatic #75 // 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 typeId:I\n 16: invokestatic #75 // 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 #22 // Field value:J\n 29: invokestatic #80 // Method java/lang/Long.hashCode:(J)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 org/aoc2021/Day16$LiteralValuePacket\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day16$LiteralValuePacket\n 20: astore_2\n 21: aload_0\n 22: getfield #15 // Field version:I\n 25: aload_2\n 26: getfield #15 // Field version:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #18 // Field typeId:I\n 38: aload_2\n 39: getfield #18 // Field typeId:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #22 // Field value:J\n 51: aload_2\n 52: getfield #22 // Field value:J\n 55: lcmp\n 56: ifeq 61\n 59: iconst_0\n 60: ireturn\n 61: iconst_1\n 62: ireturn\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day3.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
object Day3 {
private fun solvePart1(filename: String): Int {
val lines = Files.readAllLines(Path.of(filename), Charsets.UTF_8)
val numBits = lines[0].length
val oneCounts = Array(numBits) { 0 }
lines.forEach { line ->
line.forEachIndexed { i, bit ->
if (bit == '1') {
oneCounts[i]++
}
}
}
val majorityLine = if (lines.size % 2 == 0) {
lines.size / 2
} else {
lines.size / 2 + 1
}
val gammaString = oneCounts.map { if (it >= majorityLine) '1' else '0' }
.joinToString(separator = "")
val epsilonString = gammaString.map { if (it == '1') '0' else '1' }
.joinToString(separator = "")
return gammaString.toInt(2) * epsilonString.toInt(2)
}
private fun solvePart2(filename: String): Int {
val lines = Files.readAllLines(Path.of(filename), Charsets.UTF_8)
val oxygenRating = findRating(lines, false)
val co2Rating = findRating(lines, true)
return oxygenRating * co2Rating
}
private tailrec fun findRating(lines: List<String>, invert: Boolean, i: Int = 0): Int {
if (lines.size == 1) {
return lines[0].toInt(2)
}
val (leadingOnes, leadingZeroes) = lines.partition { it[i] == '1' }
val mostCommonBit = if (leadingOnes.size >= leadingZeroes.size) '1' else '0'
val remainingLines = lines.filter { line ->
val matches = (line[i] == mostCommonBit)
if (invert) !matches else matches
}
return findRating(remainingLines, invert, i + 1)
}
@JvmStatic
fun main(args: Array<String>) {
val filename = "input3.txt"
val solution1 = solvePart1(filename)
println(solution1)
val solution2 = solvePart2(filename)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day3.class",
"javap": "Compiled from \"Day3.kt\"\npublic final class org.aoc2021.Day3 {\n public static final org.aoc2021.Day3 INSTANCE;\n\n private org.aoc2021.Day3();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int solvePart1(java.lang.String);\n Code:\n 0: aload_1\n 1: iconst_0\n 2: anewarray #14 // class java/lang/String\n 5: invokestatic #20 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 8: getstatic #26 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 11: invokestatic #32 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 14: astore_2\n 15: aload_2\n 16: iconst_0\n 17: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 22: checkcast #14 // class java/lang/String\n 25: invokevirtual #42 // Method java/lang/String.length:()I\n 28: istore_3\n 29: iconst_0\n 30: istore 5\n 32: iload_3\n 33: anewarray #44 // class java/lang/Integer\n 36: astore 6\n 38: iload 5\n 40: iload_3\n 41: if_icmpge 63\n 44: iload 5\n 46: istore 7\n 48: aload 6\n 50: iload 7\n 52: iconst_0\n 53: invokestatic #48 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 56: aastore\n 57: iinc 5, 1\n 60: goto 38\n 63: aload 6\n 65: astore 4\n 67: aload_2\n 68: invokestatic #54 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 71: aload_2\n 72: checkcast #56 // class java/lang/Iterable\n 75: astore 5\n 77: iconst_0\n 78: istore 6\n 80: aload 5\n 82: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 87: astore 7\n 89: aload 7\n 91: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 96: ifeq 219\n 99: aload 7\n 101: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 106: astore 8\n 108: aload 8\n 110: checkcast #14 // class java/lang/String\n 113: astore 9\n 115: iconst_0\n 116: istore 10\n 118: aload 9\n 120: invokestatic #54 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 123: aload 9\n 125: checkcast #72 // class java/lang/CharSequence\n 128: astore 11\n 130: iconst_0\n 131: istore 12\n 133: iconst_0\n 134: istore 13\n 136: iconst_0\n 137: istore 14\n 139: iload 14\n 141: aload 11\n 143: invokeinterface #73, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 148: if_icmpge 213\n 151: aload 11\n 153: iload 14\n 155: invokeinterface #77, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 160: istore 15\n 162: iload 13\n 164: iinc 13, 1\n 167: iload 15\n 169: istore 16\n 171: istore 17\n 173: iconst_0\n 174: istore 18\n 176: iload 16\n 178: bipush 49\n 180: if_icmpne 205\n 183: aload 4\n 185: iload 17\n 187: aaload\n 188: invokevirtual #80 // Method java/lang/Integer.intValue:()I\n 191: istore 19\n 193: aload 4\n 195: iload 17\n 197: iload 19\n 199: iconst_1\n 200: iadd\n 201: invokestatic #48 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 204: aastore\n 205: nop\n 206: nop\n 207: iinc 14, 1\n 210: goto 139\n 213: nop\n 214: nop\n 215: nop\n 216: goto 89\n 219: nop\n 220: aload_2\n 221: invokeinterface #83, 1 // InterfaceMethod java/util/List.size:()I\n 226: iconst_2\n 227: irem\n 228: ifne 242\n 231: aload_2\n 232: invokeinterface #83, 1 // InterfaceMethod java/util/List.size:()I\n 237: iconst_2\n 238: idiv\n 239: goto 252\n 242: aload_2\n 243: invokeinterface #83, 1 // InterfaceMethod java/util/List.size:()I\n 248: iconst_2\n 249: idiv\n 250: iconst_1\n 251: iadd\n 252: istore 5\n 254: aload 4\n 256: astore 7\n 258: iconst_0\n 259: istore 8\n 261: aload 7\n 263: astore 9\n 265: new #85 // class java/util/ArrayList\n 268: dup\n 269: aload 7\n 271: arraylength\n 272: invokespecial #88 // Method java/util/ArrayList.\"<init>\":(I)V\n 275: checkcast #90 // class java/util/Collection\n 278: astore 10\n 280: iconst_0\n 281: istore 11\n 283: iconst_0\n 284: istore 12\n 286: aload 9\n 288: arraylength\n 289: istore 13\n 291: iload 12\n 293: iload 13\n 295: if_icmpge 354\n 298: aload 9\n 300: iload 12\n 302: aaload\n 303: astore 14\n 305: aload 10\n 307: aload 14\n 309: checkcast #92 // class java/lang/Number\n 312: invokevirtual #93 // Method java/lang/Number.intValue:()I\n 315: istore 15\n 317: astore 20\n 319: iconst_0\n 320: istore 16\n 322: iload 15\n 324: iload 5\n 326: if_icmplt 334\n 329: bipush 49\n 331: goto 336\n 334: bipush 48\n 336: invokestatic #98 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 339: aload 20\n 341: swap\n 342: invokeinterface #102, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 347: pop\n 348: iinc 12, 1\n 351: goto 291\n 354: aload 10\n 356: checkcast #34 // class java/util/List\n 359: nop\n 360: checkcast #56 // class java/lang/Iterable\n 363: ldc #104 // String\n 365: checkcast #72 // class java/lang/CharSequence\n 368: aconst_null\n 369: aconst_null\n 370: iconst_0\n 371: aconst_null\n 372: aconst_null\n 373: bipush 62\n 375: aconst_null\n 376: invokestatic #110 // 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 379: astore 6\n 381: aload 6\n 383: checkcast #72 // class java/lang/CharSequence\n 386: astore 8\n 388: iconst_0\n 389: istore 9\n 391: aload 8\n 393: astore 10\n 395: new #85 // class java/util/ArrayList\n 398: dup\n 399: aload 8\n 401: invokeinterface #73, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 406: invokespecial #88 // Method java/util/ArrayList.\"<init>\":(I)V\n 409: checkcast #90 // class java/util/Collection\n 412: astore 11\n 414: iconst_0\n 415: istore 12\n 417: iconst_0\n 418: istore 13\n 420: iload 13\n 422: aload 10\n 424: invokeinterface #73, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 429: if_icmpge 486\n 432: aload 10\n 434: iload 13\n 436: invokeinterface #77, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 441: istore 14\n 443: aload 11\n 445: iload 14\n 447: istore 15\n 449: astore 20\n 451: iconst_0\n 452: istore 16\n 454: iload 15\n 456: bipush 49\n 458: if_icmpne 466\n 461: bipush 48\n 463: goto 468\n 466: bipush 49\n 468: invokestatic #98 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 471: aload 20\n 473: swap\n 474: invokeinterface #102, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 479: pop\n 480: iinc 13, 1\n 483: goto 420\n 486: aload 11\n 488: checkcast #34 // class java/util/List\n 491: nop\n 492: checkcast #56 // class java/lang/Iterable\n 495: ldc #104 // String\n 497: checkcast #72 // class java/lang/CharSequence\n 500: aconst_null\n 501: aconst_null\n 502: iconst_0\n 503: aconst_null\n 504: aconst_null\n 505: bipush 62\n 507: aconst_null\n 508: invokestatic #110 // 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 511: astore 7\n 513: aload 6\n 515: iconst_2\n 516: invokestatic #116 // Method kotlin/text/CharsKt.checkRadix:(I)I\n 519: invokestatic #120 // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I\n 522: aload 7\n 524: iconst_2\n 525: invokestatic #116 // Method kotlin/text/CharsKt.checkRadix:(I)I\n 528: invokestatic #120 // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I\n 531: imul\n 532: ireturn\n\n private final int solvePart2(java.lang.String);\n Code:\n 0: aload_1\n 1: iconst_0\n 2: anewarray #14 // class java/lang/String\n 5: invokestatic #20 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 8: getstatic #26 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 11: invokestatic #32 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 14: astore_2\n 15: aload_0\n 16: aload_2\n 17: invokestatic #54 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 20: aload_2\n 21: iconst_0\n 22: iconst_0\n 23: iconst_4\n 24: aconst_null\n 25: invokestatic #164 // Method findRating$default:(Lorg/aoc2021/Day3;Ljava/util/List;ZIILjava/lang/Object;)I\n 28: istore_3\n 29: aload_0\n 30: aload_2\n 31: iconst_1\n 32: iconst_0\n 33: iconst_4\n 34: aconst_null\n 35: invokestatic #164 // Method findRating$default:(Lorg/aoc2021/Day3;Ljava/util/List;ZIILjava/lang/Object;)I\n 38: istore 4\n 40: iload_3\n 41: iload 4\n 43: imul\n 44: ireturn\n\n private final int findRating(java.util.List<java.lang.String>, boolean, int);\n Code:\n 0: aload_0\n 1: astore 4\n 3: aload_1\n 4: invokeinterface #83, 1 // InterfaceMethod java/util/List.size:()I\n 9: iconst_1\n 10: if_icmpne 31\n 13: aload_1\n 14: iconst_0\n 15: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 20: checkcast #14 // class java/lang/String\n 23: iconst_2\n 24: invokestatic #116 // Method kotlin/text/CharsKt.checkRadix:(I)I\n 27: invokestatic #120 // Method java/lang/Integer.parseInt:(Ljava/lang/String;I)I\n 30: ireturn\n 31: aload_1\n 32: checkcast #56 // class java/lang/Iterable\n 35: astore 6\n 37: iconst_0\n 38: istore 7\n 40: new #85 // class java/util/ArrayList\n 43: dup\n 44: invokespecial #170 // Method java/util/ArrayList.\"<init>\":()V\n 47: astore 8\n 49: new #85 // class java/util/ArrayList\n 52: dup\n 53: invokespecial #170 // Method java/util/ArrayList.\"<init>\":()V\n 56: astore 9\n 58: aload 6\n 60: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 65: astore 10\n 67: aload 10\n 69: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 74: ifeq 136\n 77: aload 10\n 79: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 84: astore 11\n 86: aload 11\n 88: checkcast #14 // class java/lang/String\n 91: astore 12\n 93: iconst_0\n 94: istore 13\n 96: aload 12\n 98: iload_3\n 99: invokevirtual #171 // Method java/lang/String.charAt:(I)C\n 102: bipush 49\n 104: if_icmpne 111\n 107: iconst_1\n 108: goto 112\n 111: iconst_0\n 112: ifeq 125\n 115: aload 8\n 117: aload 11\n 119: invokevirtual #172 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 122: goto 132\n 125: aload 9\n 127: aload 11\n 129: invokevirtual #172 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 132: pop\n 133: goto 67\n 136: new #174 // class kotlin/Pair\n 139: dup\n 140: aload 8\n 142: aload 9\n 144: invokespecial #177 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 147: astore 5\n 149: aload 5\n 151: invokevirtual #180 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 154: checkcast #34 // class java/util/List\n 157: astore 6\n 159: aload 5\n 161: invokevirtual #183 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 164: checkcast #34 // class java/util/List\n 167: astore 7\n 169: aload 6\n 171: invokeinterface #83, 1 // InterfaceMethod java/util/List.size:()I\n 176: aload 7\n 178: invokeinterface #83, 1 // InterfaceMethod java/util/List.size:()I\n 183: if_icmplt 191\n 186: bipush 49\n 188: goto 193\n 191: bipush 48\n 193: istore 8\n 195: aload_1\n 196: checkcast #56 // class java/lang/Iterable\n 199: astore 10\n 201: iconst_0\n 202: istore 11\n 204: aload 10\n 206: astore 12\n 208: new #85 // class java/util/ArrayList\n 211: dup\n 212: invokespecial #170 // Method java/util/ArrayList.\"<init>\":()V\n 215: checkcast #90 // class java/util/Collection\n 218: astore 13\n 220: iconst_0\n 221: istore 14\n 223: aload 12\n 225: invokeinterface #60, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 230: astore 15\n 232: aload 15\n 234: invokeinterface #66, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 239: ifeq 314\n 242: aload 15\n 244: invokeinterface #70, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 249: astore 16\n 251: aload 16\n 253: checkcast #14 // class java/lang/String\n 256: astore 17\n 258: iconst_0\n 259: istore 18\n 261: aload 17\n 263: iload_3\n 264: invokevirtual #171 // Method java/lang/String.charAt:(I)C\n 267: iload 8\n 269: if_icmpne 276\n 272: iconst_1\n 273: goto 277\n 276: iconst_0\n 277: istore 19\n 279: iload_2\n 280: ifeq 296\n 283: iload 19\n 285: ifne 292\n 288: iconst_1\n 289: goto 298\n 292: iconst_0\n 293: goto 298\n 296: iload 19\n 298: ifeq 232\n 301: aload 13\n 303: aload 16\n 305: invokeinterface #102, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 310: pop\n 311: goto 232\n 314: aload 13\n 316: checkcast #34 // class java/util/List\n 319: nop\n 320: astore 9\n 322: aload 4\n 324: astore 10\n 326: iload_2\n 327: istore 11\n 329: iload_3\n 330: iconst_1\n 331: iadd\n 332: istore 12\n 334: aload 10\n 336: astore 4\n 338: aload 9\n 340: astore_1\n 341: iload 11\n 343: istore_2\n 344: iload 12\n 346: istore_3\n 347: goto 3\n\n static int findRating$default(org.aoc2021.Day3, java.util.List, boolean, int, int, java.lang.Object);\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 #204 // Method findRating:(Ljava/util/List;ZI)I\n 16: ireturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #210 // String args\n 3: invokestatic #214 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #216 // String input3.txt\n 8: astore_1\n 9: getstatic #219 // Field INSTANCE:Lorg/aoc2021/Day3;\n 12: aload_1\n 13: invokespecial #221 // Method solvePart1:(Ljava/lang/String;)I\n 16: istore_2\n 17: getstatic #227 // Field java/lang/System.out:Ljava/io/PrintStream;\n 20: iload_2\n 21: invokevirtual #232 // Method java/io/PrintStream.println:(I)V\n 24: getstatic #219 // Field INSTANCE:Lorg/aoc2021/Day3;\n 27: aload_1\n 28: invokespecial #234 // Method solvePart2:(Ljava/lang/String;)I\n 31: istore_3\n 32: getstatic #227 // Field java/lang/System.out:Ljava/io/PrintStream;\n 35: iload_3\n 36: invokevirtual #232 // Method java/io/PrintStream.println:(I)V\n 39: return\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day3\n 3: dup\n 4: invokespecial #239 // Method \"<init>\":()V\n 7: putstatic #219 // Field INSTANCE:Lorg/aoc2021/Day3;\n 10: return\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day13.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
object Day13 {
data class Point(val x: Int, val y: Int)
data class Fold(val direction: String, val coordinate: Int)
private fun solvePart1(lines: List<String>): Int {
val (points, folds) = parseLines(lines)
val (cols, rows) = determineGridSize(folds)
val grid = generateGrid(points, rows, cols)
val folded = applyFold(grid, folds[0])
return folded.sumOf { column -> column.count { it } }
}
private fun solvePart2(lines: List<String>) {
val (points, folds) = parseLines(lines)
val (cols, rows) = determineGridSize(folds)
val grid = generateGrid(points, rows, cols)
val folded = folds.fold(grid) { newGrid, fold -> applyFold(newGrid, fold) }
printGrid(folded)
}
private fun parseLines(lines: List<String>): Pair<List<Point>, List<Fold>> {
val points = mutableListOf<Point>()
val folds = mutableListOf<Fold>()
lines.filter(String::isNotBlank).forEach { line ->
if (line.startsWith("fold along ")) {
val (direction, coordinate) = line.substringAfter("fold along ")
.split("=")
.let { it[0] to it[1].toInt() }
folds.add(Fold(direction, coordinate))
} else {
val (x, y) = line.split(",").map(String::toInt)
points.add(Point(x, y))
}
}
return points.toList() to folds.toList()
}
private fun generateGrid(points: List<Point>, rows: Int, cols: Int): Array<Array<Boolean>> {
val grid = Array(cols) { Array(rows) { false } }
points.forEach { (x, y) -> grid[x][y] = true }
return grid
}
private fun determineGridSize(folds: List<Fold>): Pair<Int, Int> {
val firstHorizontalFold = folds.first { it.direction == "x" }
val firstVerticalFold = folds.first { it.direction == "y" }
return (2 * firstHorizontalFold.coordinate + 1) to (2 * firstVerticalFold.coordinate + 1)
}
private fun applyFold(grid: Array<Array<Boolean>>, fold: Fold) = when (fold.direction) {
"x" -> applyHorizontalFold(grid, fold.coordinate)
"y" -> applyVerticalFold(grid, fold.coordinate)
else -> throw IllegalArgumentException(fold.direction)
}
private fun applyHorizontalFold(grid: Array<Array<Boolean>>, x: Int): Array<Array<Boolean>> {
if (x != (grid.size - 1) / 2) throw IllegalArgumentException("$x ${grid.size}")
val newGrid = Array(x) { Array(grid[0].size) { false } }
for (i in 0 until x) {
for (j in grid[0].indices) {
newGrid[i][j] = grid[i][j]
}
}
for (i in x+1 until grid.size) {
for (j in grid[0].indices) {
if (grid[i][j]) {
newGrid[grid.size - 1 - i][j] = true
}
}
}
return newGrid
}
private fun applyVerticalFold(grid: Array<Array<Boolean>>, y: Int): Array<Array<Boolean>> {
if (y != (grid[0].size - 1) / 2) throw IllegalArgumentException("$y ${grid[0].size}")
val newGrid = Array(grid.size) { Array(y) { false } }
for (i in grid.indices) {
for (j in 0 until y) {
newGrid[i][j] = grid[i][j]
}
}
for (i in grid.indices) {
for (j in y+1 until grid[0].size) {
if (grid[i][j]) {
newGrid[i][grid[0].size - 1 - j] = true
}
}
}
return newGrid
}
private fun printGrid(grid: Array<Array<Boolean>>) {
for (j in grid[0].indices) {
for (i in grid.indices) {
print(if (grid[i][j]) "#" else " ")
}
println()
}
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input13.txt"), Charsets.UTF_8)
val solution1 = solvePart1(lines)
println(solution1)
solvePart2(lines)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day13.class",
"javap": "Compiled from \"Day13.kt\"\npublic final class org.aoc2021.Day13 {\n public static final org.aoc2021.Day13 INSTANCE;\n\n private org.aoc2021.Day13();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int solvePart1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #17 // Method parseLines:(Ljava/util/List;)Lkotlin/Pair;\n 5: astore_2\n 6: aload_2\n 7: invokevirtual #23 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 10: checkcast #25 // class java/util/List\n 13: astore_3\n 14: aload_2\n 15: invokevirtual #28 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 18: checkcast #25 // class java/util/List\n 21: astore 4\n 23: aload_0\n 24: aload 4\n 26: invokespecial #31 // Method determineGridSize:(Ljava/util/List;)Lkotlin/Pair;\n 29: astore 5\n 31: aload 5\n 33: invokevirtual #23 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 36: checkcast #33 // class java/lang/Number\n 39: invokevirtual #37 // Method java/lang/Number.intValue:()I\n 42: istore 6\n 44: aload 5\n 46: invokevirtual #28 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 49: checkcast #33 // class java/lang/Number\n 52: invokevirtual #37 // Method java/lang/Number.intValue:()I\n 55: istore 7\n 57: aload_0\n 58: aload_3\n 59: iload 7\n 61: iload 6\n 63: invokespecial #41 // Method generateGrid:(Ljava/util/List;II)[[Ljava/lang/Boolean;\n 66: astore 8\n 68: aload_0\n 69: aload 8\n 71: aload 4\n 73: iconst_0\n 74: invokeinterface #45, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 79: checkcast #47 // class org/aoc2021/Day13$Fold\n 82: invokespecial #51 // Method applyFold:([[Ljava/lang/Boolean;Lorg/aoc2021/Day13$Fold;)[[Ljava/lang/Boolean;\n 85: astore 9\n 87: aload 9\n 89: checkcast #53 // class \"[Ljava/lang/Object;\"\n 92: astore 10\n 94: iconst_0\n 95: istore 11\n 97: iconst_0\n 98: istore 12\n 100: aload 10\n 102: arraylength\n 103: istore 13\n 105: iload 12\n 107: iload 13\n 109: if_icmpge 207\n 112: aload 10\n 114: iload 12\n 116: aaload\n 117: astore 14\n 119: iload 11\n 121: aload 14\n 123: checkcast #55 // class \"[Ljava/lang/Boolean;\"\n 126: astore 15\n 128: istore 25\n 130: iconst_0\n 131: istore 16\n 133: aload 15\n 135: astore 17\n 137: iconst_0\n 138: istore 18\n 140: iconst_0\n 141: istore 19\n 143: iconst_0\n 144: istore 20\n 146: aload 17\n 148: arraylength\n 149: istore 21\n 151: iload 20\n 153: iload 21\n 155: if_icmpge 189\n 158: aload 17\n 160: iload 20\n 162: aaload\n 163: astore 22\n 165: aload 22\n 167: invokevirtual #61 // Method java/lang/Boolean.booleanValue:()Z\n 170: istore 23\n 172: iconst_0\n 173: istore 24\n 175: iload 23\n 177: ifeq 183\n 180: iinc 19, 1\n 183: iinc 20, 1\n 186: goto 151\n 189: iload 19\n 191: nop\n 192: istore 26\n 194: iload 25\n 196: iload 26\n 198: iadd\n 199: istore 11\n 201: iinc 12, 1\n 204: goto 105\n 207: iload 11\n 209: ireturn\n\n private final void solvePart2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #17 // Method parseLines:(Ljava/util/List;)Lkotlin/Pair;\n 5: astore_2\n 6: aload_2\n 7: invokevirtual #23 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 10: checkcast #25 // class java/util/List\n 13: astore_3\n 14: aload_2\n 15: invokevirtual #28 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 18: checkcast #25 // class java/util/List\n 21: astore 4\n 23: aload_0\n 24: aload 4\n 26: invokespecial #31 // Method determineGridSize:(Ljava/util/List;)Lkotlin/Pair;\n 29: astore 5\n 31: aload 5\n 33: invokevirtual #23 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 36: checkcast #33 // class java/lang/Number\n 39: invokevirtual #37 // Method java/lang/Number.intValue:()I\n 42: istore 6\n 44: aload 5\n 46: invokevirtual #28 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 49: checkcast #33 // class java/lang/Number\n 52: invokevirtual #37 // Method java/lang/Number.intValue:()I\n 55: istore 7\n 57: aload_0\n 58: aload_3\n 59: iload 7\n 61: iload 6\n 63: invokespecial #41 // Method generateGrid:(Ljava/util/List;II)[[Ljava/lang/Boolean;\n 66: astore 8\n 68: aload 4\n 70: checkcast #87 // class java/lang/Iterable\n 73: astore 10\n 75: iconst_0\n 76: istore 11\n 78: aload 8\n 80: astore 12\n 82: aload 10\n 84: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 89: astore 13\n 91: aload 13\n 93: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 98: ifeq 142\n 101: aload 13\n 103: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 108: astore 14\n 110: aload 12\n 112: aload 14\n 114: checkcast #47 // class org/aoc2021/Day13$Fold\n 117: astore 15\n 119: checkcast #82 // class \"[[Ljava/lang/Boolean;\"\n 122: astore 16\n 124: iconst_0\n 125: istore 17\n 127: getstatic #102 // Field INSTANCE:Lorg/aoc2021/Day13;\n 130: aload 16\n 132: aload 15\n 134: invokespecial #51 // Method applyFold:([[Ljava/lang/Boolean;Lorg/aoc2021/Day13$Fold;)[[Ljava/lang/Boolean;\n 137: astore 12\n 139: goto 91\n 142: aload 12\n 144: checkcast #82 // class \"[[Ljava/lang/Boolean;\"\n 147: astore 9\n 149: aload_0\n 150: aload 9\n 152: invokespecial #106 // Method printGrid:([[Ljava/lang/Boolean;)V\n 155: return\n\n private final kotlin.Pair<java.util.List<org.aoc2021.Day13$Point>, java.util.List<org.aoc2021.Day13$Fold>> parseLines(java.util.List<java.lang.String>);\n Code:\n 0: new #117 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #118 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #25 // class java/util/List\n 10: astore_2\n 11: new #117 // class java/util/ArrayList\n 14: dup\n 15: invokespecial #118 // Method java/util/ArrayList.\"<init>\":()V\n 18: checkcast #25 // class java/util/List\n 21: astore_3\n 22: aload_1\n 23: checkcast #87 // class java/lang/Iterable\n 26: astore 4\n 28: iconst_0\n 29: istore 5\n 31: aload 4\n 33: astore 6\n 35: new #117 // class java/util/ArrayList\n 38: dup\n 39: invokespecial #118 // Method java/util/ArrayList.\"<init>\":()V\n 42: checkcast #120 // class java/util/Collection\n 45: astore 7\n 47: iconst_0\n 48: istore 8\n 50: aload 6\n 52: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 57: astore 9\n 59: aload 9\n 61: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 66: ifeq 121\n 69: aload 9\n 71: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 76: astore 10\n 78: aload 10\n 80: checkcast #122 // class java/lang/String\n 83: astore 11\n 85: iconst_0\n 86: istore 12\n 88: aload 11\n 90: checkcast #124 // class java/lang/CharSequence\n 93: invokestatic #130 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 96: ifne 103\n 99: iconst_1\n 100: goto 104\n 103: iconst_0\n 104: nop\n 105: ifeq 59\n 108: aload 7\n 110: aload 10\n 112: invokeinterface #134, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 117: pop\n 118: goto 59\n 121: aload 7\n 123: checkcast #25 // class java/util/List\n 126: nop\n 127: checkcast #87 // class java/lang/Iterable\n 130: astore 4\n 132: nop\n 133: iconst_0\n 134: istore 5\n 136: aload 4\n 138: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 143: astore 6\n 145: aload 6\n 147: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 152: ifeq 488\n 155: aload 6\n 157: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 162: astore 7\n 164: aload 7\n 166: checkcast #122 // class java/lang/String\n 169: astore 8\n 171: iconst_0\n 172: istore 9\n 174: aload 8\n 176: ldc #136 // String fold along\n 178: iconst_0\n 179: iconst_2\n 180: aconst_null\n 181: invokestatic #140 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 184: ifeq 301\n 187: aload 8\n 189: ldc #136 // String fold along\n 191: aconst_null\n 192: iconst_2\n 193: aconst_null\n 194: invokestatic #144 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 197: checkcast #124 // class java/lang/CharSequence\n 200: iconst_1\n 201: anewarray #122 // class java/lang/String\n 204: astore 10\n 206: aload 10\n 208: iconst_0\n 209: ldc #146 // String =\n 211: aastore\n 212: aload 10\n 214: iconst_0\n 215: iconst_0\n 216: bipush 6\n 218: aconst_null\n 219: invokestatic #150 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 222: astore 11\n 224: iconst_0\n 225: istore 12\n 227: aload 11\n 229: iconst_0\n 230: invokeinterface #45, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 235: aload 11\n 237: iconst_1\n 238: invokeinterface #45, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 243: checkcast #122 // class java/lang/String\n 246: invokestatic #156 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 249: invokestatic #160 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 252: invokestatic #166 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 255: nop\n 256: astore 13\n 258: aload 13\n 260: invokevirtual #23 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 263: checkcast #122 // class java/lang/String\n 266: astore 10\n 268: aload 13\n 270: invokevirtual #28 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 273: checkcast #33 // class java/lang/Number\n 276: invokevirtual #37 // Method java/lang/Number.intValue:()I\n 279: istore 11\n 281: aload_3\n 282: new #47 // class org/aoc2021/Day13$Fold\n 285: dup\n 286: aload 10\n 288: iload 11\n 290: invokespecial #169 // Method org/aoc2021/Day13$Fold.\"<init>\":(Ljava/lang/String;I)V\n 293: invokeinterface #170, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 298: goto 482\n 301: aload 8\n 303: checkcast #124 // class java/lang/CharSequence\n 306: iconst_1\n 307: anewarray #122 // class java/lang/String\n 310: astore 10\n 312: aload 10\n 314: iconst_0\n 315: ldc #172 // String ,\n 317: aastore\n 318: aload 10\n 320: iconst_0\n 321: iconst_0\n 322: bipush 6\n 324: aconst_null\n 325: invokestatic #150 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 328: checkcast #87 // class java/lang/Iterable\n 331: astore 10\n 333: iconst_0\n 334: istore 11\n 336: aload 10\n 338: astore 12\n 340: new #117 // class java/util/ArrayList\n 343: dup\n 344: aload 10\n 346: bipush 10\n 348: invokestatic #178 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 351: invokespecial #181 // Method java/util/ArrayList.\"<init>\":(I)V\n 354: checkcast #120 // class java/util/Collection\n 357: astore 14\n 359: iconst_0\n 360: istore 15\n 362: aload 12\n 364: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 369: astore 16\n 371: aload 16\n 373: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 378: ifeq 425\n 381: aload 16\n 383: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 388: astore 17\n 390: aload 14\n 392: aload 17\n 394: checkcast #122 // class java/lang/String\n 397: astore 18\n 399: astore 19\n 401: iconst_0\n 402: istore 20\n 404: aload 18\n 406: invokestatic #156 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 409: nop\n 410: invokestatic #160 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 413: aload 19\n 415: swap\n 416: invokeinterface #134, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 421: pop\n 422: goto 371\n 425: aload 14\n 427: checkcast #25 // class java/util/List\n 430: nop\n 431: astore 13\n 433: aload 13\n 435: iconst_0\n 436: invokeinterface #45, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 441: checkcast #33 // class java/lang/Number\n 444: invokevirtual #37 // Method java/lang/Number.intValue:()I\n 447: istore 10\n 449: aload 13\n 451: iconst_1\n 452: invokeinterface #45, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 457: checkcast #33 // class java/lang/Number\n 460: invokevirtual #37 // Method java/lang/Number.intValue:()I\n 463: istore 11\n 465: aload_2\n 466: new #183 // class org/aoc2021/Day13$Point\n 469: dup\n 470: iload 10\n 472: iload 11\n 474: invokespecial #186 // Method org/aoc2021/Day13$Point.\"<init>\":(II)V\n 477: invokeinterface #170, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 482: pop\n 483: nop\n 484: nop\n 485: goto 145\n 488: nop\n 489: aload_2\n 490: checkcast #87 // class java/lang/Iterable\n 493: invokestatic #190 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 496: aload_3\n 497: checkcast #87 // class java/lang/Iterable\n 500: invokestatic #190 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 503: invokestatic #166 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 506: areturn\n\n private final java.lang.Boolean[][] generateGrid(java.util.List<org.aoc2021.Day13$Point>, int, int);\n Code:\n 0: iconst_0\n 1: istore 5\n 3: iload_3\n 4: anewarray #55 // class \"[Ljava/lang/Boolean;\"\n 7: astore 6\n 9: iload 5\n 11: iload_3\n 12: if_icmpge 74\n 15: iload 5\n 17: istore 7\n 19: aload 6\n 21: iload 7\n 23: iconst_0\n 24: istore 8\n 26: iload_2\n 27: anewarray #57 // class java/lang/Boolean\n 30: astore 9\n 32: istore 14\n 34: astore 13\n 36: iload 8\n 38: iload_2\n 39: if_icmpge 61\n 42: iload 8\n 44: istore 10\n 46: aload 9\n 48: iload 10\n 50: iconst_0\n 51: invokestatic #219 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 54: aastore\n 55: iinc 8, 1\n 58: goto 36\n 61: aload 13\n 63: iload 14\n 65: aload 9\n 67: aastore\n 68: iinc 5, 1\n 71: goto 9\n 74: aload 6\n 76: astore 4\n 78: aload_1\n 79: checkcast #87 // class java/lang/Iterable\n 82: astore 5\n 84: iconst_0\n 85: istore 6\n 87: aload 5\n 89: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 94: astore 7\n 96: aload 7\n 98: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 103: ifeq 155\n 106: aload 7\n 108: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 113: astore 8\n 115: aload 8\n 117: checkcast #183 // class org/aoc2021/Day13$Point\n 120: astore 9\n 122: iconst_0\n 123: istore 10\n 125: aload 9\n 127: invokevirtual #221 // Method org/aoc2021/Day13$Point.component1:()I\n 130: istore 11\n 132: aload 9\n 134: invokevirtual #223 // Method org/aoc2021/Day13$Point.component2:()I\n 137: istore 12\n 139: aload 4\n 141: iload 11\n 143: aaload\n 144: iload 12\n 146: iconst_1\n 147: invokestatic #219 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 150: aastore\n 151: nop\n 152: goto 96\n 155: nop\n 156: aload 4\n 158: areturn\n\n private final kotlin.Pair<java.lang.Integer, java.lang.Integer> determineGridSize(java.util.List<org.aoc2021.Day13$Fold>);\n Code:\n 0: aload_1\n 1: checkcast #87 // class java/lang/Iterable\n 4: astore_3\n 5: iconst_0\n 6: istore 4\n 8: aload_3\n 9: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 14: astore 5\n 16: aload 5\n 18: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 23: ifeq 63\n 26: aload 5\n 28: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 33: astore 6\n 35: aload 6\n 37: checkcast #47 // class org/aoc2021/Day13$Fold\n 40: astore 7\n 42: iconst_0\n 43: istore 8\n 45: aload 7\n 47: invokevirtual #229 // Method org/aoc2021/Day13$Fold.getDirection:()Ljava/lang/String;\n 50: ldc #230 // String x\n 52: invokestatic #236 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 55: ifeq 16\n 58: aload 6\n 60: goto 73\n 63: new #238 // class java/util/NoSuchElementException\n 66: dup\n 67: ldc #240 // String Collection contains no element matching the predicate.\n 69: invokespecial #243 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 72: athrow\n 73: checkcast #47 // class org/aoc2021/Day13$Fold\n 76: astore_2\n 77: aload_1\n 78: checkcast #87 // class java/lang/Iterable\n 81: astore 4\n 83: iconst_0\n 84: istore 5\n 86: aload 4\n 88: invokeinterface #91, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 93: astore 6\n 95: aload 6\n 97: invokeinterface #96, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 102: ifeq 142\n 105: aload 6\n 107: invokeinterface #99, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 112: astore 7\n 114: aload 7\n 116: checkcast #47 // class org/aoc2021/Day13$Fold\n 119: astore 8\n 121: iconst_0\n 122: istore 9\n 124: aload 8\n 126: invokevirtual #229 // Method org/aoc2021/Day13$Fold.getDirection:()Ljava/lang/String;\n 129: ldc #244 // String y\n 131: invokestatic #236 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 134: ifeq 95\n 137: aload 7\n 139: goto 152\n 142: new #238 // class java/util/NoSuchElementException\n 145: dup\n 146: ldc #240 // String Collection contains no element matching the predicate.\n 148: invokespecial #243 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 151: athrow\n 152: checkcast #47 // class org/aoc2021/Day13$Fold\n 155: astore_3\n 156: iconst_2\n 157: aload_2\n 158: invokevirtual #247 // Method org/aoc2021/Day13$Fold.getCoordinate:()I\n 161: imul\n 162: iconst_1\n 163: iadd\n 164: invokestatic #160 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 167: iconst_2\n 168: aload_3\n 169: invokevirtual #247 // Method org/aoc2021/Day13$Fold.getCoordinate:()I\n 172: imul\n 173: iconst_1\n 174: iadd\n 175: invokestatic #160 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 178: invokestatic #166 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 181: areturn\n\n private final java.lang.Boolean[][] applyFold(java.lang.Boolean[][], org.aoc2021.Day13$Fold);\n Code:\n 0: aload_2\n 1: invokevirtual #229 // Method org/aoc2021/Day13$Fold.getDirection:()Ljava/lang/String;\n 4: astore_3\n 5: aload_3\n 6: ldc #230 // String x\n 8: invokestatic #236 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 11: ifeq 26\n 14: aload_0\n 15: aload_1\n 16: aload_2\n 17: invokevirtual #247 // Method org/aoc2021/Day13$Fold.getCoordinate:()I\n 20: invokespecial #257 // Method applyHorizontalFold:([[Ljava/lang/Boolean;I)[[Ljava/lang/Boolean;\n 23: goto 59\n 26: aload_3\n 27: ldc #244 // String y\n 29: invokestatic #236 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifeq 47\n 35: aload_0\n 36: aload_1\n 37: aload_2\n 38: invokevirtual #247 // Method org/aoc2021/Day13$Fold.getCoordinate:()I\n 41: invokespecial #260 // Method applyVerticalFold:([[Ljava/lang/Boolean;I)[[Ljava/lang/Boolean;\n 44: goto 59\n 47: new #262 // class java/lang/IllegalArgumentException\n 50: dup\n 51: aload_2\n 52: invokevirtual #229 // Method org/aoc2021/Day13$Fold.getDirection:()Ljava/lang/String;\n 55: invokespecial #263 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 58: athrow\n 59: areturn\n\n private final java.lang.Boolean[][] applyHorizontalFold(java.lang.Boolean[][], int);\n Code:\n 0: iload_2\n 1: aload_1\n 2: checkcast #53 // class \"[Ljava/lang/Object;\"\n 5: arraylength\n 6: iconst_1\n 7: isub\n 8: iconst_2\n 9: idiv\n 10: if_icmpeq 48\n 13: new #262 // class java/lang/IllegalArgumentException\n 16: dup\n 17: new #265 // class java/lang/StringBuilder\n 20: dup\n 21: invokespecial #266 // Method java/lang/StringBuilder.\"<init>\":()V\n 24: iload_2\n 25: invokevirtual #270 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 28: bipush 32\n 30: invokevirtual #273 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 33: aload_1\n 34: checkcast #53 // class \"[Ljava/lang/Object;\"\n 37: arraylength\n 38: invokevirtual #270 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 41: invokevirtual #276 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 44: invokespecial #263 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 47: athrow\n 48: iconst_0\n 49: istore 4\n 51: iload_2\n 52: anewarray #55 // class \"[Ljava/lang/Boolean;\"\n 55: astore 5\n 57: iload 4\n 59: iload_2\n 60: if_icmpge 130\n 63: iload 4\n 65: istore 6\n 67: aload 5\n 69: iload 6\n 71: iconst_0\n 72: istore 7\n 74: aload_1\n 75: iconst_0\n 76: aaload\n 77: arraylength\n 78: istore 8\n 80: iload 8\n 82: anewarray #57 // class java/lang/Boolean\n 85: astore 9\n 87: istore 12\n 89: astore 11\n 91: iload 7\n 93: iload 8\n 95: if_icmpge 117\n 98: iload 7\n 100: istore 10\n 102: aload 9\n 104: iload 10\n 106: iconst_0\n 107: invokestatic #219 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 110: aastore\n 111: iinc 7, 1\n 114: goto 91\n 117: aload 11\n 119: iload 12\n 121: aload 9\n 123: aastore\n 124: iinc 4, 1\n 127: goto 57\n 130: aload 5\n 132: astore_3\n 133: iconst_0\n 134: istore 4\n 136: iload 4\n 138: iload_2\n 139: if_icmpge 184\n 142: iconst_0\n 143: istore 5\n 145: aload_1\n 146: iconst_0\n 147: aaload\n 148: arraylength\n 149: istore 6\n 151: iload 5\n 153: iload 6\n 155: if_icmpge 178\n 158: aload_3\n 159: iload 4\n 161: aaload\n 162: iload 5\n 164: aload_1\n 165: iload 4\n 167: aaload\n 168: iload 5\n 170: aaload\n 171: aastore\n 172: iinc 5, 1\n 175: goto 151\n 178: iinc 4, 1\n 181: goto 136\n 184: iload_2\n 185: iconst_1\n 186: iadd\n 187: istore 4\n 189: aload_1\n 190: checkcast #53 // class \"[Ljava/lang/Object;\"\n 193: arraylength\n 194: istore 5\n 196: iload 4\n 198: iload 5\n 200: if_icmpge 263\n 203: iconst_0\n 204: istore 6\n 206: aload_1\n 207: iconst_0\n 208: aaload\n 209: arraylength\n 210: istore 7\n 212: iload 6\n 214: iload 7\n 216: if_icmpge 257\n 219: aload_1\n 220: iload 4\n 222: aaload\n 223: iload 6\n 225: aaload\n 226: invokevirtual #61 // Method java/lang/Boolean.booleanValue:()Z\n 229: ifeq 251\n 232: aload_3\n 233: aload_1\n 234: checkcast #53 // class \"[Ljava/lang/Object;\"\n 237: arraylength\n 238: iconst_1\n 239: isub\n 240: iload 4\n 242: isub\n 243: aaload\n 244: iload 6\n 246: iconst_1\n 247: invokestatic #219 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 250: aastore\n 251: iinc 6, 1\n 254: goto 212\n 257: iinc 4, 1\n 260: goto 196\n 263: aload_3\n 264: areturn\n\n private final java.lang.Boolean[][] applyVerticalFold(java.lang.Boolean[][], int);\n Code:\n 0: iload_2\n 1: aload_1\n 2: iconst_0\n 3: aaload\n 4: arraylength\n 5: iconst_1\n 6: isub\n 7: iconst_2\n 8: idiv\n 9: if_icmpeq 46\n 12: new #262 // class java/lang/IllegalArgumentException\n 15: dup\n 16: new #265 // class java/lang/StringBuilder\n 19: dup\n 20: invokespecial #266 // Method java/lang/StringBuilder.\"<init>\":()V\n 23: iload_2\n 24: invokevirtual #270 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 27: bipush 32\n 29: invokevirtual #273 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 32: aload_1\n 33: iconst_0\n 34: aaload\n 35: arraylength\n 36: invokevirtual #270 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 39: invokevirtual #276 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 42: invokespecial #263 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 45: athrow\n 46: iconst_0\n 47: istore 4\n 49: aload_1\n 50: checkcast #53 // class \"[Ljava/lang/Object;\"\n 53: arraylength\n 54: istore 5\n 56: iload 5\n 58: anewarray #55 // class \"[Ljava/lang/Boolean;\"\n 61: astore 6\n 63: iload 4\n 65: iload 5\n 67: if_icmpge 129\n 70: iload 4\n 72: istore 7\n 74: aload 6\n 76: iload 7\n 78: iconst_0\n 79: istore 8\n 81: iload_2\n 82: anewarray #57 // class java/lang/Boolean\n 85: astore 9\n 87: istore 12\n 89: astore 11\n 91: iload 8\n 93: iload_2\n 94: if_icmpge 116\n 97: iload 8\n 99: istore 10\n 101: aload 9\n 103: iload 10\n 105: iconst_0\n 106: invokestatic #219 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 109: aastore\n 110: iinc 8, 1\n 113: goto 91\n 116: aload 11\n 118: iload 12\n 120: aload 9\n 122: aastore\n 123: iinc 4, 1\n 126: goto 63\n 129: aload 6\n 131: astore_3\n 132: iconst_0\n 133: istore 4\n 135: aload_1\n 136: checkcast #53 // class \"[Ljava/lang/Object;\"\n 139: arraylength\n 140: istore 5\n 142: iload 4\n 144: iload 5\n 146: if_icmpge 184\n 149: iconst_0\n 150: istore 6\n 152: iload 6\n 154: iload_2\n 155: if_icmpge 178\n 158: aload_3\n 159: iload 4\n 161: aaload\n 162: iload 6\n 164: aload_1\n 165: iload 4\n 167: aaload\n 168: iload 6\n 170: aaload\n 171: aastore\n 172: iinc 6, 1\n 175: goto 152\n 178: iinc 4, 1\n 181: goto 142\n 184: iconst_0\n 185: istore 4\n 187: aload_1\n 188: checkcast #53 // class \"[Ljava/lang/Object;\"\n 191: arraylength\n 192: istore 5\n 194: iload 4\n 196: iload 5\n 198: if_icmpge 262\n 201: iload_2\n 202: iconst_1\n 203: iadd\n 204: istore 6\n 206: aload_1\n 207: iconst_0\n 208: aaload\n 209: arraylength\n 210: istore 7\n 212: iload 6\n 214: iload 7\n 216: if_icmpge 256\n 219: aload_1\n 220: iload 4\n 222: aaload\n 223: iload 6\n 225: aaload\n 226: invokevirtual #61 // Method java/lang/Boolean.booleanValue:()Z\n 229: ifeq 250\n 232: aload_3\n 233: iload 4\n 235: aaload\n 236: aload_1\n 237: iconst_0\n 238: aaload\n 239: arraylength\n 240: iconst_1\n 241: isub\n 242: iload 6\n 244: isub\n 245: iconst_1\n 246: invokestatic #219 // Method java/lang/Boolean.valueOf:(Z)Ljava/lang/Boolean;\n 249: aastore\n 250: iinc 6, 1\n 253: goto 212\n 256: iinc 4, 1\n 259: goto 194\n 262: aload_3\n 263: areturn\n\n private final void printGrid(java.lang.Boolean[][]);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: aload_1\n 3: iconst_0\n 4: aaload\n 5: arraylength\n 6: istore_3\n 7: iload_2\n 8: iload_3\n 9: if_icmpge 75\n 12: iconst_0\n 13: istore 4\n 15: aload_1\n 16: checkcast #53 // class \"[Ljava/lang/Object;\"\n 19: arraylength\n 20: istore 5\n 22: iload 4\n 24: iload 5\n 26: if_icmpge 63\n 29: aload_1\n 30: iload 4\n 32: aaload\n 33: iload_2\n 34: aaload\n 35: invokevirtual #61 // Method java/lang/Boolean.booleanValue:()Z\n 38: ifeq 47\n 41: ldc_w #280 // String #\n 44: goto 50\n 47: ldc_w #282 // String\n 50: getstatic #288 // Field java/lang/System.out:Ljava/io/PrintStream;\n 53: swap\n 54: invokevirtual #294 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 57: iinc 4, 1\n 60: goto 22\n 63: getstatic #288 // Field java/lang/System.out:Ljava/io/PrintStream;\n 66: invokevirtual #297 // Method java/io/PrintStream.println:()V\n 69: iinc 2, 1\n 72: goto 7\n 75: return\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc_w #303 // String args\n 4: invokestatic #307 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: ldc_w #309 // String input13.txt\n 10: iconst_0\n 11: anewarray #122 // class java/lang/String\n 14: invokestatic #315 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 17: getstatic #321 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 20: invokestatic #327 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 23: astore_1\n 24: getstatic #102 // Field INSTANCE:Lorg/aoc2021/Day13;\n 27: aload_1\n 28: invokestatic #330 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 31: aload_1\n 32: invokespecial #332 // Method solvePart1:(Ljava/util/List;)I\n 35: istore_2\n 36: getstatic #288 // Field java/lang/System.out:Ljava/io/PrintStream;\n 39: iload_2\n 40: invokevirtual #334 // Method java/io/PrintStream.println:(I)V\n 43: getstatic #102 // Field INSTANCE:Lorg/aoc2021/Day13;\n 46: aload_1\n 47: invokespecial #336 // Method solvePart2:(Ljava/util/List;)V\n 50: return\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day13\n 3: dup\n 4: invokespecial #340 // Method \"<init>\":()V\n 7: putstatic #102 // Field INSTANCE:Lorg/aoc2021/Day13;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day13$Fold.class",
"javap": "Compiled from \"Day13.kt\"\npublic final class org.aoc2021.Day13$Fold {\n private final java.lang.String direction;\n\n private final int coordinate;\n\n public org.aoc2021.Day13$Fold(java.lang.String, int);\n Code:\n 0: aload_1\n 1: ldc #9 // String direction\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 direction:Ljava/lang/String;\n 15: aload_0\n 16: iload_2\n 17: putfield #25 // Field coordinate:I\n 20: return\n\n public final java.lang.String getDirection();\n Code:\n 0: aload_0\n 1: getfield #21 // Field direction:Ljava/lang/String;\n 4: areturn\n\n public final int getCoordinate();\n Code:\n 0: aload_0\n 1: getfield #25 // Field coordinate:I\n 4: ireturn\n\n public final java.lang.String component1();\n Code:\n 0: aload_0\n 1: getfield #21 // Field direction:Ljava/lang/String;\n 4: areturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #25 // Field coordinate:I\n 4: ireturn\n\n public final org.aoc2021.Day13$Fold copy(java.lang.String, int);\n Code:\n 0: aload_1\n 1: ldc #9 // String direction\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class org/aoc2021/Day13$Fold\n 9: dup\n 10: aload_1\n 11: iload_2\n 12: invokespecial #37 // Method \"<init>\":(Ljava/lang/String;I)V\n 15: areturn\n\n public static org.aoc2021.Day13$Fold copy$default(org.aoc2021.Day13$Fold, java.lang.String, 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 #21 // Field direction: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 #25 // Field coordinate:I\n 21: istore_2\n 22: aload_0\n 23: aload_1\n 24: iload_2\n 25: invokevirtual #41 // Method copy:(Ljava/lang/String;I)Lorg/aoc2021/Day13$Fold;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #44 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #45 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #47 // String Fold(direction=\n 9: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #21 // Field direction:Ljava/lang/String;\n 16: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 19: ldc #53 // String , coordinate=\n 21: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #25 // Field coordinate:I\n 28: invokevirtual #56 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #59 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #61 // 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 #21 // Field direction:Ljava/lang/String;\n 4: invokevirtual #66 // Method java/lang/String.hashCode:()I\n 7: istore_1\n 8: iload_1\n 9: bipush 31\n 11: imul\n 12: aload_0\n 13: getfield #25 // Field coordinate:I\n 16: invokestatic #71 // Method java/lang/Integer.hashCode:(I)I\n 19: iadd\n 20: istore_1\n 21: iload_1\n 22: 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 org/aoc2021/Day13$Fold\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day13$Fold\n 20: astore_2\n 21: aload_0\n 22: getfield #21 // Field direction:Ljava/lang/String;\n 25: aload_2\n 26: getfield #21 // Field direction:Ljava/lang/String;\n 29: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 32: ifne 37\n 35: iconst_0\n 36: ireturn\n 37: aload_0\n 38: getfield #25 // Field coordinate:I\n 41: aload_2\n 42: getfield #25 // Field coordinate:I\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: iconst_1\n 51: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day13$Point.class",
"javap": "Compiled from \"Day13.kt\"\npublic final class org.aoc2021.Day13$Point {\n private final int x;\n\n private final int y;\n\n public org.aoc2021.Day13$Point(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 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 org.aoc2021.Day13$Point copy(int, int);\n Code:\n 0: new #2 // class org/aoc2021/Day13$Point\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: invokespecial #28 // Method \"<init>\":(II)V\n 9: areturn\n\n public static org.aoc2021.Day13$Point copy$default(org.aoc2021.Day13$Point, 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 #32 // Method copy:(II)Lorg/aoc2021/Day13$Point;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #36 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #37 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #39 // String Point(x=\n 9: invokevirtual #43 // 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 #46 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #48 // String , y=\n 21: invokevirtual #43 // 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 #46 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #51 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #53 // 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 #59 // 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 #59 // 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 org/aoc2021/Day13$Point\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day13$Point\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": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day19.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
import kotlin.math.abs
typealias Vector = List<Int>
typealias Matrix = List<List<Int>>
private fun Vector.vectorAdd(vector: Vector): Vector {
return this.mapIndexed { i, value ->
value + vector[i]
}
}
private fun Vector.vectorSubtract(vector: Vector): Vector {
return this.mapIndexed { i, value ->
value - vector[i]
}
}
private fun Vector.matrixMultiply(matrix: Matrix): Vector {
return this.indices.map { i ->
matrix.indices.sumOf { j ->
this[j] * matrix[j][i]
}
}
}
private fun Matrix.multiply(matrix: Matrix): Matrix {
return this.map { vector -> vector.matrixMultiply(matrix) }
}
object Day19 {
data class ScannerLocation(val coordinates: Vector, val rotation: Matrix)
private val identityMatrix = listOf(
listOf(1, 0, 0),
listOf(0, 1, 0),
listOf(0, 0, 1),
)
private val xRotationMatrix = listOf(
listOf(1, 0, 0),
listOf(0, 0, -1),
listOf(0, 1, 0),
)
private val yRotationMatrix = listOf(
listOf(0, 0, -1),
listOf(0, 1, 0),
listOf(1, 0, 0),
)
private val zRotationMatrix = listOf(
listOf(0, 1, 0),
listOf(-1, 0, 0),
listOf(0, 0, 1),
)
private val all3DRotationMatrices = generateRotationMatrices()
private fun solve(lines: List<String>): Pair<Int, Int> {
val scanners = parseLines(lines)
val scannerLocations = findScanners(scanners)
val solution1 = countBeacons(scanners, scannerLocations)
val solution2 = scannerLocations.values.maxOf { a ->
scannerLocations.values.filter { it !== a }.maxOf { b ->
a.coordinates.vectorSubtract(b.coordinates).map(::abs).sum()
}
}
return solution1 to solution2
}
private fun parseLines(lines: List<String>): List<List<Vector>> {
if (lines.isEmpty()) {
return listOf()
}
val nextScanner = lines.drop(1)
.takeWhile(String::isNotBlank)
.map { line -> line.split(",").map(String::toInt) }
return listOf(nextScanner).plus(parseLines(lines.dropWhile(String::isNotBlank).drop(1)))
}
private fun findScanners(scanners: List<List<Vector>>): Map<Int, ScannerLocation> {
val scannerLocations = mutableMapOf(
0 to ScannerLocation(listOf(0, 0, 0), identityMatrix),
)
// Triple(rotation matrix, base beacon, other beacon distances)
val precomputedRotatedDistances = scanners.mapIndexed { i, beaconLocations ->
i to beaconLocations.flatMap { beaconLocation ->
all3DRotationMatrices.map { rotationMatrix ->
val rotatedBeaconLocation = beaconLocation.matrixMultiply(rotationMatrix)
val rotatedBeaconDistances = beaconLocations.filter { it !== beaconLocation }
.map { it.matrixMultiply(rotationMatrix).vectorSubtract(rotatedBeaconLocation) }
Triple(rotationMatrix, rotatedBeaconLocation, rotatedBeaconDistances.toSet())
}
}
}.toMap()
while (scannerLocations.size < scanners.size) {
val foundScannerIds = scanners.indices.filter { i -> scannerLocations.containsKey(i) }
foundScannerIds.forEach { foundScannerId ->
val foundScannerLocation = scannerLocations[foundScannerId]!!
val foundBeaconDistances = precomputedRotatedDistances[foundScannerId]!!
.filter { (rotationMatrix, _, _) -> rotationMatrix == foundScannerLocation.rotation }
val unknownScannerIds = scanners.indices.filter { i -> !scannerLocations.containsKey(i) }
unknownScannerIds.forEach { unknownScannerId ->
for (t in precomputedRotatedDistances[unknownScannerId]!!) {
val (rotationMatrix, rotatedBeaconLocation, rotatedBeaconDistances) = t
val matchingFoundDistances = foundBeaconDistances.find { (_, _, foundDistancesSet) ->
foundDistancesSet.intersect(rotatedBeaconDistances).size >= 11
}
if (matchingFoundDistances != null) {
val (_, foundBeaconLocation, _) = matchingFoundDistances
val scannerCoordinates = foundScannerLocation.coordinates
.vectorAdd(foundBeaconLocation)
.vectorSubtract(rotatedBeaconLocation)
scannerLocations[unknownScannerId] = ScannerLocation(scannerCoordinates, rotationMatrix)
break
}
}
}
}
}
return scannerLocations.toMap()
}
private fun countBeacons(scanners: List<List<Vector>>, scannerLocations: Map<Int, ScannerLocation>): Int {
val allBeaconLocations = mutableSetOf<Vector>()
scanners.forEachIndexed { i, beaconLocations ->
val scannerLocation = scannerLocations[i]!!
allBeaconLocations.addAll(beaconLocations.map { beaconLocation ->
beaconLocation.matrixMultiply(scannerLocation.rotation).vectorAdd(scannerLocation.coordinates)
})
}
return allBeaconLocations.size
}
private fun generateRotationMatrices(): List<Matrix> {
val result = mutableListOf<Matrix>()
var currentMatrix = identityMatrix
listOf(
zRotationMatrix to yRotationMatrix,
yRotationMatrix to xRotationMatrix,
xRotationMatrix to zRotationMatrix,
).forEach { (axis1Matrix, axis2Matrix) ->
currentMatrix = currentMatrix.multiply(axis2Matrix)
result.addAll(generateRotationMatricesForAxis(currentMatrix, axis1Matrix))
currentMatrix = currentMatrix.multiply(axis2Matrix).multiply(axis2Matrix)
result.addAll(generateRotationMatricesForAxis(currentMatrix, axis1Matrix))
}
return result.toList()
}
private fun generateRotationMatricesForAxis(matrix: Matrix, rotation: Matrix): List<Matrix> {
val result = mutableListOf<Matrix>()
var current = matrix
(1..4).forEach { _ ->
result.add(current)
current = current.multiply(rotation)
}
return result.toList()
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input19.txt"), Charsets.UTF_8)
val (solution1, solution2) = solve(lines)
println(solution1)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day19$ScannerLocation.class",
"javap": "Compiled from \"Day19.kt\"\npublic final class org.aoc2021.Day19$ScannerLocation {\n private final java.util.List<java.lang.Integer> coordinates;\n\n private final java.util.List<java.util.List<java.lang.Integer>> rotation;\n\n public org.aoc2021.Day19$ScannerLocation(java.util.List<java.lang.Integer>, java.util.List<? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: aload_1\n 1: ldc #10 // String coordinates\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 rotation\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 coordinates:Ljava/util/List;\n 21: aload_0\n 22: aload_2\n 23: putfield #26 // Field rotation:Ljava/util/List;\n 26: return\n\n public final java.util.List<java.lang.Integer> getCoordinates();\n Code:\n 0: aload_0\n 1: getfield #24 // Field coordinates:Ljava/util/List;\n 4: areturn\n\n public final java.util.List<java.util.List<java.lang.Integer>> getRotation();\n Code:\n 0: aload_0\n 1: getfield #26 // Field rotation:Ljava/util/List;\n 4: areturn\n\n public final java.util.List<java.lang.Integer> component1();\n Code:\n 0: aload_0\n 1: getfield #24 // Field coordinates:Ljava/util/List;\n 4: areturn\n\n public final java.util.List<java.util.List<java.lang.Integer>> component2();\n Code:\n 0: aload_0\n 1: getfield #26 // Field rotation:Ljava/util/List;\n 4: areturn\n\n public final org.aoc2021.Day19$ScannerLocation copy(java.util.List<java.lang.Integer>, java.util.List<? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: aload_1\n 1: ldc #10 // String coordinates\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 rotation\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #2 // class org/aoc2021/Day19$ScannerLocation\n 15: dup\n 16: aload_1\n 17: aload_2\n 18: invokespecial #40 // Method \"<init>\":(Ljava/util/List;Ljava/util/List;)V\n 21: areturn\n\n public static org.aoc2021.Day19$ScannerLocation copy$default(org.aoc2021.Day19$ScannerLocation, java.util.List, java.util.List, 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 coordinates:Ljava/util/List;\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 rotation:Ljava/util/List;\n 21: astore_2\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokevirtual #44 // Method copy:(Ljava/util/List;Ljava/util/List;)Lorg/aoc2021/Day19$ScannerLocation;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #48 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #49 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #51 // String ScannerLocation(coordinates=\n 9: invokevirtual #55 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #24 // Field coordinates:Ljava/util/List;\n 16: invokevirtual #58 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #60 // String , rotation=\n 21: invokevirtual #55 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #26 // Field rotation:Ljava/util/List;\n 28: invokevirtual #58 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #63 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #65 // 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 coordinates:Ljava/util/List;\n 4: invokevirtual #69 // 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 rotation:Ljava/util/List;\n 16: invokevirtual #69 // 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 org/aoc2021/Day19$ScannerLocation\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day19$ScannerLocation\n 20: astore_2\n 21: aload_0\n 22: getfield #24 // Field coordinates:Ljava/util/List;\n 25: aload_2\n 26: getfield #24 // Field coordinates:Ljava/util/List;\n 29: invokestatic #78 // 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 rotation:Ljava/util/List;\n 41: aload_2\n 42: getfield #26 // Field rotation:Ljava/util/List;\n 45: invokestatic #78 // 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": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day19Kt.class",
"javap": "Compiled from \"Day19.kt\"\npublic final class org.aoc2021.Day19Kt {\n private static final java.util.List<java.lang.Integer> vectorAdd(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: checkcast #9 // 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 #11 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #23 // 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: aload 4\n 36: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 41: astore 8\n 43: aload 8\n 45: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 50: ifeq 130\n 53: aload 8\n 55: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 60: astore 9\n 62: aload 5\n 64: iload 7\n 66: iinc 7, 1\n 69: istore 10\n 71: iload 10\n 73: ifge 79\n 76: invokestatic #41 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 79: iload 10\n 81: aload 9\n 83: checkcast #43 // class java/lang/Number\n 86: invokevirtual #47 // Method java/lang/Number.intValue:()I\n 89: istore 11\n 91: istore 12\n 93: astore 14\n 95: iconst_0\n 96: istore 13\n 98: iload 11\n 100: aload_1\n 101: iload 12\n 103: invokeinterface #53, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 108: checkcast #43 // class java/lang/Number\n 111: invokevirtual #47 // Method java/lang/Number.intValue:()I\n 114: iadd\n 115: invokestatic #59 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 118: aload 14\n 120: swap\n 121: invokeinterface #63, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 126: pop\n 127: goto 43\n 130: aload 5\n 132: checkcast #49 // class java/util/List\n 135: nop\n 136: areturn\n\n private static final java.util.List<java.lang.Integer> vectorSubtract(java.util.List<java.lang.Integer>, java.util.List<java.lang.Integer>);\n Code:\n 0: aload_0\n 1: checkcast #9 // 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 #11 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #23 // 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: aload 4\n 36: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 41: astore 8\n 43: aload 8\n 45: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 50: ifeq 130\n 53: aload 8\n 55: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 60: astore 9\n 62: aload 5\n 64: iload 7\n 66: iinc 7, 1\n 69: istore 10\n 71: iload 10\n 73: ifge 79\n 76: invokestatic #41 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 79: iload 10\n 81: aload 9\n 83: checkcast #43 // class java/lang/Number\n 86: invokevirtual #47 // Method java/lang/Number.intValue:()I\n 89: istore 11\n 91: istore 12\n 93: astore 14\n 95: iconst_0\n 96: istore 13\n 98: iload 11\n 100: aload_1\n 101: iload 12\n 103: invokeinterface #53, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 108: checkcast #43 // class java/lang/Number\n 111: invokevirtual #47 // Method java/lang/Number.intValue:()I\n 114: isub\n 115: invokestatic #59 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 118: aload 14\n 120: swap\n 121: invokeinterface #63, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 126: pop\n 127: goto 43\n 130: aload 5\n 132: checkcast #49 // class java/util/List\n 135: nop\n 136: areturn\n\n private static final java.util.List<java.lang.Integer> matrixMultiply(java.util.List<java.lang.Integer>, java.util.List<? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: checkcast #23 // class java/util/Collection\n 4: invokestatic #89 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 7: checkcast #9 // 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 #11 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #23 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 201\n 56: aload 7\n 58: checkcast #91 // class kotlin/collections/IntIterator\n 61: invokevirtual #94 // Method kotlin/collections/IntIterator.nextInt:()I\n 64: istore 8\n 66: aload 5\n 68: iload 8\n 70: istore 9\n 72: astore 19\n 74: iconst_0\n 75: istore 10\n 77: aload_1\n 78: checkcast #23 // class java/util/Collection\n 81: invokestatic #89 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 84: checkcast #9 // class java/lang/Iterable\n 87: astore 11\n 89: iconst_0\n 90: istore 12\n 92: aload 11\n 94: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 99: astore 13\n 101: aload 13\n 103: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 108: ifeq 183\n 111: aload 13\n 113: checkcast #91 // class kotlin/collections/IntIterator\n 116: invokevirtual #94 // Method kotlin/collections/IntIterator.nextInt:()I\n 119: istore 14\n 121: iload 12\n 123: iload 14\n 125: istore 15\n 127: istore 16\n 129: iconst_0\n 130: istore 17\n 132: aload_0\n 133: iload 15\n 135: invokeinterface #53, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 140: checkcast #43 // class java/lang/Number\n 143: invokevirtual #47 // Method java/lang/Number.intValue:()I\n 146: aload_1\n 147: iload 15\n 149: invokeinterface #53, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 154: checkcast #49 // class java/util/List\n 157: iload 9\n 159: invokeinterface #53, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 164: checkcast #43 // class java/lang/Number\n 167: invokevirtual #47 // Method java/lang/Number.intValue:()I\n 170: imul\n 171: istore 18\n 173: iload 16\n 175: iload 18\n 177: iadd\n 178: istore 12\n 180: goto 101\n 183: iload 12\n 185: nop\n 186: invokestatic #59 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 189: aload 19\n 191: swap\n 192: invokeinterface #63, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 197: pop\n 198: goto 46\n 201: aload 5\n 203: checkcast #49 // class java/util/List\n 206: nop\n 207: areturn\n\n private static final java.util.List<java.util.List<java.lang.Integer>> multiply(java.util.List<? extends java.util.List<java.lang.Integer>>, java.util.List<? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: aload_0\n 1: checkcast #9 // 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 #11 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #17 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #21 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #23 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #27, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #33, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 91\n 50: aload 7\n 52: invokeinterface #37, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #49 // class java/util/List\n 66: astore 9\n 68: astore 11\n 70: iconst_0\n 71: istore 10\n 73: aload 9\n 75: aload_1\n 76: invokestatic #107 // Method matrixMultiply:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 79: aload 11\n 81: swap\n 82: invokeinterface #63, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 87: pop\n 88: goto 40\n 91: aload 5\n 93: checkcast #49 // class java/util/List\n 96: nop\n 97: areturn\n\n public static final java.util.List access$vectorSubtract(java.util.List, java.util.List);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #112 // Method vectorSubtract:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 5: areturn\n\n public static final java.util.List access$matrixMultiply(java.util.List, java.util.List);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #107 // Method matrixMultiply:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 5: areturn\n\n public static final java.util.List access$vectorAdd(java.util.List, java.util.List);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #117 // Method vectorAdd:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 5: areturn\n\n public static final java.util.List access$multiply(java.util.List, java.util.List);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #120 // Method multiply:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 5: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day19.class",
"javap": "Compiled from \"Day19.kt\"\npublic final class org.aoc2021.Day19 {\n public static final org.aoc2021.Day19 INSTANCE;\n\n private static final java.util.List<java.util.List<java.lang.Integer>> identityMatrix;\n\n private static final java.util.List<java.util.List<java.lang.Integer>> xRotationMatrix;\n\n private static final java.util.List<java.util.List<java.lang.Integer>> yRotationMatrix;\n\n private static final java.util.List<java.util.List<java.lang.Integer>> zRotationMatrix;\n\n private static final java.util.List<java.util.List<java.util.List<java.lang.Integer>>> all3DRotationMatrices;\n\n private org.aoc2021.Day19();\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.lang.Integer, java.lang.Integer> solve(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #17 // Method parseLines:(Ljava/util/List;)Ljava/util/List;\n 5: astore_2\n 6: aload_0\n 7: aload_2\n 8: invokespecial #21 // Method findScanners:(Ljava/util/List;)Ljava/util/Map;\n 11: astore_3\n 12: aload_0\n 13: aload_2\n 14: aload_3\n 15: invokespecial #25 // Method countBeacons:(Ljava/util/List;Ljava/util/Map;)I\n 18: istore 4\n 20: aload_3\n 21: invokeinterface #31, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 26: checkcast #33 // class java/lang/Iterable\n 29: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 34: astore 6\n 36: aload 6\n 38: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 43: ifne 54\n 46: new #45 // class java/util/NoSuchElementException\n 49: dup\n 50: invokespecial #46 // Method java/util/NoSuchElementException.\"<init>\":()V\n 53: athrow\n 54: aload 6\n 56: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 61: checkcast #52 // class org/aoc2021/Day19$ScannerLocation\n 64: astore 7\n 66: iconst_0\n 67: istore 8\n 69: aload_3\n 70: invokeinterface #31, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 75: checkcast #33 // class java/lang/Iterable\n 78: astore 9\n 80: iconst_0\n 81: istore 10\n 83: aload 9\n 85: astore 11\n 87: new #54 // class java/util/ArrayList\n 90: dup\n 91: invokespecial #55 // Method java/util/ArrayList.\"<init>\":()V\n 94: checkcast #57 // class java/util/Collection\n 97: astore 12\n 99: iconst_0\n 100: istore 13\n 102: aload 11\n 104: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 109: astore 14\n 111: aload 14\n 113: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 118: ifeq 168\n 121: aload 14\n 123: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 128: astore 15\n 130: aload 15\n 132: checkcast #52 // class org/aoc2021/Day19$ScannerLocation\n 135: astore 16\n 137: iconst_0\n 138: istore 17\n 140: aload 16\n 142: aload 7\n 144: if_acmpeq 151\n 147: iconst_1\n 148: goto 152\n 151: iconst_0\n 152: ifeq 111\n 155: aload 12\n 157: aload 15\n 159: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 164: pop\n 165: goto 111\n 168: aload 12\n 170: checkcast #63 // class java/util/List\n 173: nop\n 174: checkcast #33 // class java/lang/Iterable\n 177: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 182: astore 10\n 184: aload 10\n 186: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 191: ifne 202\n 194: new #45 // class java/util/NoSuchElementException\n 197: dup\n 198: invokespecial #46 // Method java/util/NoSuchElementException.\"<init>\":()V\n 201: athrow\n 202: aload 10\n 204: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 209: checkcast #52 // class org/aoc2021/Day19$ScannerLocation\n 212: astore 11\n 214: iconst_0\n 215: istore 12\n 217: aload 7\n 219: invokevirtual #67 // Method org/aoc2021/Day19$ScannerLocation.getCoordinates:()Ljava/util/List;\n 222: aload 11\n 224: invokevirtual #67 // Method org/aoc2021/Day19$ScannerLocation.getCoordinates:()Ljava/util/List;\n 227: invokestatic #73 // Method org/aoc2021/Day19Kt.access$vectorSubtract:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 230: checkcast #33 // class java/lang/Iterable\n 233: astore 13\n 235: iconst_0\n 236: istore 14\n 238: aload 13\n 240: astore 15\n 242: new #54 // class java/util/ArrayList\n 245: dup\n 246: aload 13\n 248: bipush 10\n 250: invokestatic #79 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 253: invokespecial #82 // Method java/util/ArrayList.\"<init>\":(I)V\n 256: checkcast #57 // class java/util/Collection\n 259: astore 16\n 261: iconst_0\n 262: istore 17\n 264: aload 15\n 266: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 271: astore 18\n 273: aload 18\n 275: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 280: ifeq 330\n 283: aload 18\n 285: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 290: astore 19\n 292: aload 16\n 294: aload 19\n 296: checkcast #84 // class java/lang/Number\n 299: invokevirtual #88 // Method java/lang/Number.intValue:()I\n 302: istore 20\n 304: astore 21\n 306: iconst_0\n 307: istore 22\n 309: iload 20\n 311: invokestatic #94 // Method java/lang/Math.abs:(I)I\n 314: nop\n 315: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 318: aload 21\n 320: swap\n 321: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 326: pop\n 327: goto 273\n 330: aload 16\n 332: checkcast #63 // class java/util/List\n 335: nop\n 336: checkcast #33 // class java/lang/Iterable\n 339: invokestatic #104 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 342: istore 11\n 344: aload 10\n 346: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 351: ifeq 510\n 354: aload 10\n 356: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 361: checkcast #52 // class org/aoc2021/Day19$ScannerLocation\n 364: astore 12\n 366: iconst_0\n 367: istore 13\n 369: aload 7\n 371: invokevirtual #67 // Method org/aoc2021/Day19$ScannerLocation.getCoordinates:()Ljava/util/List;\n 374: aload 12\n 376: invokevirtual #67 // Method org/aoc2021/Day19$ScannerLocation.getCoordinates:()Ljava/util/List;\n 379: invokestatic #73 // Method org/aoc2021/Day19Kt.access$vectorSubtract:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 382: checkcast #33 // class java/lang/Iterable\n 385: astore 14\n 387: iconst_0\n 388: istore 15\n 390: aload 14\n 392: astore 16\n 394: new #54 // class java/util/ArrayList\n 397: dup\n 398: aload 14\n 400: bipush 10\n 402: invokestatic #79 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 405: invokespecial #82 // Method java/util/ArrayList.\"<init>\":(I)V\n 408: checkcast #57 // class java/util/Collection\n 411: astore 17\n 413: iconst_0\n 414: istore 18\n 416: aload 16\n 418: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 423: astore 19\n 425: aload 19\n 427: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 432: ifeq 482\n 435: aload 19\n 437: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 442: astore 20\n 444: aload 17\n 446: aload 20\n 448: checkcast #84 // class java/lang/Number\n 451: invokevirtual #88 // Method java/lang/Number.intValue:()I\n 454: istore 21\n 456: astore 22\n 458: iconst_0\n 459: istore 23\n 461: iload 21\n 463: invokestatic #94 // Method java/lang/Math.abs:(I)I\n 466: nop\n 467: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 470: aload 22\n 472: swap\n 473: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 478: pop\n 479: goto 425\n 482: aload 17\n 484: checkcast #63 // class java/util/List\n 487: nop\n 488: checkcast #33 // class java/lang/Iterable\n 491: invokestatic #104 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 494: istore 12\n 496: iload 11\n 498: iload 12\n 500: if_icmpge 344\n 503: iload 12\n 505: istore 11\n 507: goto 344\n 510: iload 11\n 512: nop\n 513: istore 7\n 515: aload 6\n 517: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 522: ifeq 1000\n 525: aload 6\n 527: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 532: checkcast #52 // class org/aoc2021/Day19$ScannerLocation\n 535: astore 8\n 537: iconst_0\n 538: istore 9\n 540: aload_3\n 541: invokeinterface #31, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 546: checkcast #33 // class java/lang/Iterable\n 549: astore 10\n 551: iconst_0\n 552: istore 11\n 554: aload 10\n 556: astore 12\n 558: new #54 // class java/util/ArrayList\n 561: dup\n 562: invokespecial #55 // Method java/util/ArrayList.\"<init>\":()V\n 565: checkcast #57 // class java/util/Collection\n 568: astore 13\n 570: iconst_0\n 571: istore 14\n 573: aload 12\n 575: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 580: astore 15\n 582: aload 15\n 584: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 589: ifeq 639\n 592: aload 15\n 594: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 599: astore 16\n 601: aload 16\n 603: checkcast #52 // class org/aoc2021/Day19$ScannerLocation\n 606: astore 17\n 608: iconst_0\n 609: istore 18\n 611: aload 17\n 613: aload 8\n 615: if_acmpeq 622\n 618: iconst_1\n 619: goto 623\n 622: iconst_0\n 623: ifeq 582\n 626: aload 13\n 628: aload 16\n 630: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 635: pop\n 636: goto 582\n 639: aload 13\n 641: checkcast #63 // class java/util/List\n 644: nop\n 645: checkcast #33 // class java/lang/Iterable\n 648: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 653: astore 11\n 655: aload 11\n 657: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 662: ifne 673\n 665: new #45 // class java/util/NoSuchElementException\n 668: dup\n 669: invokespecial #46 // Method java/util/NoSuchElementException.\"<init>\":()V\n 672: athrow\n 673: aload 11\n 675: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 680: checkcast #52 // class org/aoc2021/Day19$ScannerLocation\n 683: astore 12\n 685: iconst_0\n 686: istore 13\n 688: aload 8\n 690: invokevirtual #67 // Method org/aoc2021/Day19$ScannerLocation.getCoordinates:()Ljava/util/List;\n 693: aload 12\n 695: invokevirtual #67 // Method org/aoc2021/Day19$ScannerLocation.getCoordinates:()Ljava/util/List;\n 698: invokestatic #73 // Method org/aoc2021/Day19Kt.access$vectorSubtract:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 701: checkcast #33 // class java/lang/Iterable\n 704: astore 14\n 706: iconst_0\n 707: istore 15\n 709: aload 14\n 711: astore 16\n 713: new #54 // class java/util/ArrayList\n 716: dup\n 717: aload 14\n 719: bipush 10\n 721: invokestatic #79 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 724: invokespecial #82 // Method java/util/ArrayList.\"<init>\":(I)V\n 727: checkcast #57 // class java/util/Collection\n 730: astore 17\n 732: iconst_0\n 733: istore 18\n 735: aload 16\n 737: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 742: astore 19\n 744: aload 19\n 746: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 751: ifeq 801\n 754: aload 19\n 756: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 761: astore 20\n 763: aload 17\n 765: aload 20\n 767: checkcast #84 // class java/lang/Number\n 770: invokevirtual #88 // Method java/lang/Number.intValue:()I\n 773: istore 21\n 775: astore 22\n 777: iconst_0\n 778: istore 23\n 780: iload 21\n 782: invokestatic #94 // Method java/lang/Math.abs:(I)I\n 785: nop\n 786: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 789: aload 22\n 791: swap\n 792: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 797: pop\n 798: goto 744\n 801: aload 17\n 803: checkcast #63 // class java/util/List\n 806: nop\n 807: checkcast #33 // class java/lang/Iterable\n 810: invokestatic #104 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 813: istore 12\n 815: aload 11\n 817: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 822: ifeq 981\n 825: aload 11\n 827: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 832: checkcast #52 // class org/aoc2021/Day19$ScannerLocation\n 835: astore 13\n 837: iconst_0\n 838: istore 14\n 840: aload 8\n 842: invokevirtual #67 // Method org/aoc2021/Day19$ScannerLocation.getCoordinates:()Ljava/util/List;\n 845: aload 13\n 847: invokevirtual #67 // Method org/aoc2021/Day19$ScannerLocation.getCoordinates:()Ljava/util/List;\n 850: invokestatic #73 // Method org/aoc2021/Day19Kt.access$vectorSubtract:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 853: checkcast #33 // class java/lang/Iterable\n 856: astore 15\n 858: iconst_0\n 859: istore 16\n 861: aload 15\n 863: astore 17\n 865: new #54 // class java/util/ArrayList\n 868: dup\n 869: aload 15\n 871: bipush 10\n 873: invokestatic #79 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 876: invokespecial #82 // Method java/util/ArrayList.\"<init>\":(I)V\n 879: checkcast #57 // class java/util/Collection\n 882: astore 18\n 884: iconst_0\n 885: istore 19\n 887: aload 17\n 889: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 894: astore 20\n 896: aload 20\n 898: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 903: ifeq 953\n 906: aload 20\n 908: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 913: astore 21\n 915: aload 18\n 917: aload 21\n 919: checkcast #84 // class java/lang/Number\n 922: invokevirtual #88 // Method java/lang/Number.intValue:()I\n 925: istore 22\n 927: astore 23\n 929: iconst_0\n 930: istore 24\n 932: iload 22\n 934: invokestatic #94 // Method java/lang/Math.abs:(I)I\n 937: nop\n 938: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 941: aload 23\n 943: swap\n 944: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 949: pop\n 950: goto 896\n 953: aload 18\n 955: checkcast #63 // class java/util/List\n 958: nop\n 959: checkcast #33 // class java/lang/Iterable\n 962: invokestatic #104 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 965: istore 13\n 967: iload 12\n 969: iload 13\n 971: if_icmpge 815\n 974: iload 13\n 976: istore 12\n 978: goto 815\n 981: iload 12\n 983: nop\n 984: istore 8\n 986: iload 7\n 988: iload 8\n 990: if_icmpge 515\n 993: iload 8\n 995: istore 7\n 997: goto 515\n 1000: iload 7\n 1002: istore 5\n 1004: iload 4\n 1006: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1009: iload 5\n 1011: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1014: invokestatic #110 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 1017: areturn\n\n private final java.util.List<java.util.List<java.util.List<java.lang.Integer>>> parseLines(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: invokeinterface #145, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 6: ifeq 13\n 9: invokestatic #148 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 12: areturn\n 13: aload_1\n 14: checkcast #33 // class java/lang/Iterable\n 17: iconst_1\n 18: invokestatic #152 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 21: checkcast #33 // class java/lang/Iterable\n 24: astore_3\n 25: nop\n 26: iconst_0\n 27: istore 4\n 29: new #54 // class java/util/ArrayList\n 32: dup\n 33: invokespecial #55 // Method java/util/ArrayList.\"<init>\":()V\n 36: astore 5\n 38: aload_3\n 39: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 6\n 46: aload 6\n 48: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 109\n 56: aload 6\n 58: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 7\n 65: aload 7\n 67: checkcast #154 // class java/lang/String\n 70: astore 8\n 72: iconst_0\n 73: istore 9\n 75: aload 8\n 77: checkcast #156 // class java/lang/CharSequence\n 80: invokestatic #162 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 83: ifne 90\n 86: iconst_1\n 87: goto 91\n 90: iconst_0\n 91: nop\n 92: ifne 98\n 95: goto 109\n 98: aload 5\n 100: aload 7\n 102: invokevirtual #163 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 105: pop\n 106: goto 46\n 109: aload 5\n 111: checkcast #63 // class java/util/List\n 114: checkcast #33 // class java/lang/Iterable\n 117: astore_3\n 118: nop\n 119: iconst_0\n 120: istore 4\n 122: aload_3\n 123: astore 5\n 125: new #54 // class java/util/ArrayList\n 128: dup\n 129: aload_3\n 130: bipush 10\n 132: invokestatic #79 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 135: invokespecial #82 // Method java/util/ArrayList.\"<init>\":(I)V\n 138: checkcast #57 // class java/util/Collection\n 141: astore 6\n 143: iconst_0\n 144: istore 7\n 146: aload 5\n 148: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 153: astore 8\n 155: aload 8\n 157: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 162: ifeq 331\n 165: aload 8\n 167: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 172: astore 9\n 174: aload 6\n 176: aload 9\n 178: checkcast #154 // class java/lang/String\n 181: astore 10\n 183: astore 22\n 185: iconst_0\n 186: istore 11\n 188: aload 10\n 190: checkcast #156 // class java/lang/CharSequence\n 193: iconst_1\n 194: anewarray #154 // class java/lang/String\n 197: astore 12\n 199: aload 12\n 201: iconst_0\n 202: ldc #165 // String ,\n 204: aastore\n 205: aload 12\n 207: iconst_0\n 208: iconst_0\n 209: bipush 6\n 211: aconst_null\n 212: invokestatic #169 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 215: checkcast #33 // class java/lang/Iterable\n 218: astore 12\n 220: iconst_0\n 221: istore 13\n 223: aload 12\n 225: astore 14\n 227: new #54 // class java/util/ArrayList\n 230: dup\n 231: aload 12\n 233: bipush 10\n 235: invokestatic #79 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 238: invokespecial #82 // Method java/util/ArrayList.\"<init>\":(I)V\n 241: checkcast #57 // class java/util/Collection\n 244: astore 15\n 246: iconst_0\n 247: istore 16\n 249: aload 14\n 251: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 256: astore 17\n 258: aload 17\n 260: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 265: ifeq 312\n 268: aload 17\n 270: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 275: astore 18\n 277: aload 15\n 279: aload 18\n 281: checkcast #154 // class java/lang/String\n 284: astore 19\n 286: astore 20\n 288: iconst_0\n 289: istore 21\n 291: aload 19\n 293: invokestatic #173 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 296: nop\n 297: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 300: aload 20\n 302: swap\n 303: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 308: pop\n 309: goto 258\n 312: aload 15\n 314: checkcast #63 // class java/util/List\n 317: nop\n 318: nop\n 319: aload 22\n 321: swap\n 322: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 327: pop\n 328: goto 155\n 331: aload 6\n 333: checkcast #63 // class java/util/List\n 336: nop\n 337: astore_2\n 338: aload_2\n 339: invokestatic #177 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 342: checkcast #57 // class java/util/Collection\n 345: aload_0\n 346: aload_1\n 347: checkcast #33 // class java/lang/Iterable\n 350: astore_3\n 351: astore 23\n 353: astore 22\n 355: iconst_0\n 356: istore 4\n 358: iconst_0\n 359: istore 5\n 361: new #54 // class java/util/ArrayList\n 364: dup\n 365: invokespecial #55 // Method java/util/ArrayList.\"<init>\":()V\n 368: astore 6\n 370: aload_3\n 371: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 376: astore 7\n 378: aload 7\n 380: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 385: ifeq 457\n 388: aload 7\n 390: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 395: astore 8\n 397: iload 5\n 399: ifeq 413\n 402: aload 6\n 404: aload 8\n 406: invokevirtual #163 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 409: pop\n 410: goto 378\n 413: aload 8\n 415: checkcast #154 // class java/lang/String\n 418: astore 9\n 420: iconst_0\n 421: istore 10\n 423: aload 9\n 425: checkcast #156 // class java/lang/CharSequence\n 428: invokestatic #162 // Method kotlin/text/StringsKt.isBlank:(Ljava/lang/CharSequence;)Z\n 431: ifne 438\n 434: iconst_1\n 435: goto 439\n 438: iconst_0\n 439: nop\n 440: ifne 378\n 443: aload 6\n 445: aload 8\n 447: invokevirtual #163 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 450: pop\n 451: iconst_1\n 452: istore 5\n 454: goto 378\n 457: aload 6\n 459: checkcast #63 // class java/util/List\n 462: astore 24\n 464: aload 22\n 466: aload 23\n 468: aload 24\n 470: checkcast #33 // class java/lang/Iterable\n 473: iconst_1\n 474: invokestatic #152 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 477: invokespecial #17 // Method parseLines:(Ljava/util/List;)Ljava/util/List;\n 480: checkcast #33 // class java/lang/Iterable\n 483: invokestatic #181 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 486: areturn\n\n private final java.util.Map<java.lang.Integer, org.aoc2021.Day19$ScannerLocation> findScanners(java.util.List<? extends java.util.List<? extends java.util.List<java.lang.Integer>>>);\n Code:\n 0: iconst_1\n 1: anewarray #200 // class kotlin/Pair\n 4: astore_3\n 5: aload_3\n 6: iconst_0\n 7: iconst_0\n 8: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 11: new #52 // class org/aoc2021/Day19$ScannerLocation\n 14: dup\n 15: iconst_3\n 16: anewarray #96 // class java/lang/Integer\n 19: astore 4\n 21: aload 4\n 23: iconst_0\n 24: iconst_0\n 25: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 28: aastore\n 29: aload 4\n 31: iconst_1\n 32: iconst_0\n 33: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 36: aastore\n 37: aload 4\n 39: iconst_2\n 40: iconst_0\n 41: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 44: aastore\n 45: aload 4\n 47: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 50: getstatic #206 // Field identityMatrix:Ljava/util/List;\n 53: invokespecial #209 // Method org/aoc2021/Day19$ScannerLocation.\"<init>\":(Ljava/util/List;Ljava/util/List;)V\n 56: invokestatic #110 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 59: aastore\n 60: aload_3\n 61: invokestatic #215 // Method kotlin/collections/MapsKt.mutableMapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 64: astore_2\n 65: aload_1\n 66: checkcast #33 // class java/lang/Iterable\n 69: astore 4\n 71: iconst_0\n 72: istore 5\n 74: aload 4\n 76: astore 6\n 78: new #54 // class java/util/ArrayList\n 81: dup\n 82: aload 4\n 84: bipush 10\n 86: invokestatic #79 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 89: invokespecial #82 // Method java/util/ArrayList.\"<init>\":(I)V\n 92: checkcast #57 // class java/util/Collection\n 95: astore 7\n 97: iconst_0\n 98: istore 8\n 100: iconst_0\n 101: istore 9\n 103: aload 6\n 105: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 110: astore 10\n 112: aload 10\n 114: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 119: ifeq 615\n 122: aload 10\n 124: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 129: astore 11\n 131: aload 7\n 133: iload 9\n 135: iinc 9, 1\n 138: istore 12\n 140: iload 12\n 142: ifge 148\n 145: invokestatic #218 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 148: iload 12\n 150: aload 11\n 152: checkcast #63 // class java/util/List\n 155: astore 13\n 157: istore 14\n 159: astore 48\n 161: iconst_0\n 162: istore 15\n 164: iload 14\n 166: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 169: aload 13\n 171: checkcast #33 // class java/lang/Iterable\n 174: astore 16\n 176: astore 17\n 178: iconst_0\n 179: istore 18\n 181: aload 16\n 183: astore 19\n 185: new #54 // class java/util/ArrayList\n 188: dup\n 189: invokespecial #55 // Method java/util/ArrayList.\"<init>\":()V\n 192: checkcast #57 // class java/util/Collection\n 195: astore 20\n 197: iconst_0\n 198: istore 21\n 200: aload 19\n 202: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 207: astore 22\n 209: aload 22\n 211: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 216: ifeq 590\n 219: aload 22\n 221: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 226: astore 23\n 228: aload 23\n 230: checkcast #63 // class java/util/List\n 233: astore 24\n 235: iconst_0\n 236: istore 25\n 238: getstatic #221 // Field all3DRotationMatrices:Ljava/util/List;\n 241: checkcast #33 // class java/lang/Iterable\n 244: astore 26\n 246: iconst_0\n 247: istore 27\n 249: aload 26\n 251: astore 28\n 253: new #54 // class java/util/ArrayList\n 256: dup\n 257: aload 26\n 259: bipush 10\n 261: invokestatic #79 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 264: invokespecial #82 // Method java/util/ArrayList.\"<init>\":(I)V\n 267: checkcast #57 // class java/util/Collection\n 270: astore 29\n 272: iconst_0\n 273: istore 30\n 275: aload 28\n 277: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 282: astore 31\n 284: aload 31\n 286: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 291: ifeq 567\n 294: aload 31\n 296: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 301: astore 32\n 303: aload 29\n 305: aload 32\n 307: checkcast #63 // class java/util/List\n 310: astore 33\n 312: astore 34\n 314: iconst_0\n 315: istore 35\n 317: aload 24\n 319: aload 33\n 321: invokestatic #224 // Method org/aoc2021/Day19Kt.access$matrixMultiply:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 324: astore 36\n 326: aload 13\n 328: checkcast #33 // class java/lang/Iterable\n 331: astore 37\n 333: iconst_0\n 334: istore 38\n 336: aload 37\n 338: astore 39\n 340: new #54 // class java/util/ArrayList\n 343: dup\n 344: invokespecial #55 // Method java/util/ArrayList.\"<init>\":()V\n 347: checkcast #57 // class java/util/Collection\n 350: astore 40\n 352: iconst_0\n 353: istore 41\n 355: aload 39\n 357: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 362: astore 42\n 364: aload 42\n 366: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 371: ifeq 421\n 374: aload 42\n 376: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 381: astore 43\n 383: aload 43\n 385: checkcast #63 // class java/util/List\n 388: astore 44\n 390: iconst_0\n 391: istore 45\n 393: aload 44\n 395: aload 24\n 397: if_acmpeq 404\n 400: iconst_1\n 401: goto 405\n 404: iconst_0\n 405: ifeq 364\n 408: aload 40\n 410: aload 43\n 412: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 417: pop\n 418: goto 364\n 421: aload 40\n 423: checkcast #63 // class java/util/List\n 426: nop\n 427: checkcast #33 // class java/lang/Iterable\n 430: astore 37\n 432: nop\n 433: iconst_0\n 434: istore 38\n 436: aload 37\n 438: astore 39\n 440: new #54 // class java/util/ArrayList\n 443: dup\n 444: aload 37\n 446: bipush 10\n 448: invokestatic #79 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 451: invokespecial #82 // Method java/util/ArrayList.\"<init>\":(I)V\n 454: checkcast #57 // class java/util/Collection\n 457: astore 40\n 459: iconst_0\n 460: istore 41\n 462: aload 39\n 464: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 469: astore 42\n 471: aload 42\n 473: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 478: ifeq 528\n 481: aload 42\n 483: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 488: astore 43\n 490: aload 40\n 492: aload 43\n 494: checkcast #63 // class java/util/List\n 497: astore 44\n 499: astore 46\n 501: iconst_0\n 502: istore 45\n 504: aload 44\n 506: aload 33\n 508: invokestatic #224 // Method org/aoc2021/Day19Kt.access$matrixMultiply:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 511: aload 36\n 513: invokestatic #73 // Method org/aoc2021/Day19Kt.access$vectorSubtract:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 516: aload 46\n 518: swap\n 519: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 524: pop\n 525: goto 471\n 528: aload 40\n 530: checkcast #63 // class java/util/List\n 533: nop\n 534: astore 47\n 536: new #226 // class kotlin/Triple\n 539: dup\n 540: aload 33\n 542: aload 36\n 544: aload 47\n 546: checkcast #33 // class java/lang/Iterable\n 549: invokestatic #230 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 552: invokespecial #233 // Method kotlin/Triple.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V\n 555: aload 34\n 557: swap\n 558: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 563: pop\n 564: goto 284\n 567: aload 29\n 569: checkcast #63 // class java/util/List\n 572: nop\n 573: checkcast #33 // class java/lang/Iterable\n 576: nop\n 577: astore 24\n 579: aload 20\n 581: aload 24\n 583: invokestatic #237 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 586: pop\n 587: goto 209\n 590: aload 20\n 592: checkcast #63 // class java/util/List\n 595: nop\n 596: aload 17\n 598: swap\n 599: invokestatic #110 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 602: nop\n 603: aload 48\n 605: swap\n 606: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 611: pop\n 612: goto 112\n 615: aload 7\n 617: checkcast #63 // class java/util/List\n 620: nop\n 621: checkcast #33 // class java/lang/Iterable\n 624: invokestatic #241 // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;\n 627: astore_3\n 628: aload_2\n 629: invokeinterface #244, 1 // InterfaceMethod java/util/Map.size:()I\n 634: aload_1\n 635: invokeinterface #245, 1 // InterfaceMethod java/util/List.size:()I\n 640: if_icmpge 1369\n 643: aload_1\n 644: checkcast #57 // class java/util/Collection\n 647: invokestatic #249 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 650: checkcast #33 // class java/lang/Iterable\n 653: astore 5\n 655: iconst_0\n 656: istore 6\n 658: aload 5\n 660: astore 7\n 662: new #54 // class java/util/ArrayList\n 665: dup\n 666: invokespecial #55 // Method java/util/ArrayList.\"<init>\":()V\n 669: checkcast #57 // class java/util/Collection\n 672: astore 8\n 674: iconst_0\n 675: istore 9\n 677: aload 7\n 679: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 684: astore 10\n 686: aload 10\n 688: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 693: ifeq 745\n 696: aload 10\n 698: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 703: astore 11\n 705: aload 11\n 707: checkcast #84 // class java/lang/Number\n 710: invokevirtual #88 // Method java/lang/Number.intValue:()I\n 713: istore 12\n 715: iconst_0\n 716: istore 13\n 718: aload_2\n 719: iload 12\n 721: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 724: invokeinterface #252, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 729: ifeq 686\n 732: aload 8\n 734: aload 11\n 736: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 741: pop\n 742: goto 686\n 745: aload 8\n 747: checkcast #63 // class java/util/List\n 750: nop\n 751: astore 4\n 753: aload 4\n 755: checkcast #33 // class java/lang/Iterable\n 758: astore 5\n 760: iconst_0\n 761: istore 6\n 763: aload 5\n 765: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 770: astore 7\n 772: aload 7\n 774: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 779: ifeq 1365\n 782: aload 7\n 784: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 789: astore 8\n 791: aload 8\n 793: checkcast #84 // class java/lang/Number\n 796: invokevirtual #88 // Method java/lang/Number.intValue:()I\n 799: istore 9\n 801: iconst_0\n 802: istore 10\n 804: aload_2\n 805: iload 9\n 807: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 810: invokeinterface #256, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 815: dup\n 816: invokestatic #262 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 819: checkcast #52 // class org/aoc2021/Day19$ScannerLocation\n 822: astore 11\n 824: aload_3\n 825: iload 9\n 827: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 830: invokeinterface #256, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 835: dup\n 836: invokestatic #262 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 839: checkcast #33 // class java/lang/Iterable\n 842: astore 12\n 844: nop\n 845: iconst_0\n 846: istore 13\n 848: aload 12\n 850: astore 14\n 852: new #54 // class java/util/ArrayList\n 855: dup\n 856: invokespecial #55 // Method java/util/ArrayList.\"<init>\":()V\n 859: checkcast #57 // class java/util/Collection\n 862: astore 15\n 864: iconst_0\n 865: istore 16\n 867: aload 14\n 869: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 874: astore 17\n 876: aload 17\n 878: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 883: ifeq 941\n 886: aload 17\n 888: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 893: astore 18\n 895: aload 18\n 897: checkcast #226 // class kotlin/Triple\n 900: astore 19\n 902: iconst_0\n 903: istore 20\n 905: aload 19\n 907: invokevirtual #265 // Method kotlin/Triple.component1:()Ljava/lang/Object;\n 910: checkcast #63 // class java/util/List\n 913: astore 21\n 915: aload 21\n 917: aload 11\n 919: invokevirtual #268 // Method org/aoc2021/Day19$ScannerLocation.getRotation:()Ljava/util/List;\n 922: invokestatic #272 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 925: ifeq 876\n 928: aload 15\n 930: aload 18\n 932: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 937: pop\n 938: goto 876\n 941: aload 15\n 943: checkcast #63 // class java/util/List\n 946: nop\n 947: astore 22\n 949: aload_1\n 950: checkcast #57 // class java/util/Collection\n 953: invokestatic #249 // Method kotlin/collections/CollectionsKt.getIndices:(Ljava/util/Collection;)Lkotlin/ranges/IntRange;\n 956: checkcast #33 // class java/lang/Iterable\n 959: astore 13\n 961: iconst_0\n 962: istore 14\n 964: aload 13\n 966: astore 15\n 968: new #54 // class java/util/ArrayList\n 971: dup\n 972: invokespecial #55 // Method java/util/ArrayList.\"<init>\":()V\n 975: checkcast #57 // class java/util/Collection\n 978: astore 16\n 980: iconst_0\n 981: istore 17\n 983: aload 15\n 985: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 990: astore 18\n 992: aload 18\n 994: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 999: ifeq 1059\n 1002: aload 18\n 1004: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1009: astore 19\n 1011: aload 19\n 1013: checkcast #84 // class java/lang/Number\n 1016: invokevirtual #88 // Method java/lang/Number.intValue:()I\n 1019: istore 20\n 1021: iconst_0\n 1022: istore 21\n 1024: aload_2\n 1025: iload 20\n 1027: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1030: invokeinterface #252, 2 // InterfaceMethod java/util/Map.containsKey:(Ljava/lang/Object;)Z\n 1035: ifne 1042\n 1038: iconst_1\n 1039: goto 1043\n 1042: iconst_0\n 1043: ifeq 992\n 1046: aload 16\n 1048: aload 19\n 1050: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 1055: pop\n 1056: goto 992\n 1059: aload 16\n 1061: checkcast #63 // class java/util/List\n 1064: nop\n 1065: astore 12\n 1067: aload 12\n 1069: checkcast #33 // class java/lang/Iterable\n 1072: astore 13\n 1074: iconst_0\n 1075: istore 14\n 1077: aload 13\n 1079: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1084: astore 15\n 1086: aload 15\n 1088: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1093: ifeq 1359\n 1096: aload 15\n 1098: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1103: astore 16\n 1105: aload 16\n 1107: checkcast #84 // class java/lang/Number\n 1110: invokevirtual #88 // Method java/lang/Number.intValue:()I\n 1113: istore 17\n 1115: iconst_0\n 1116: istore 18\n 1118: aload_3\n 1119: iload 17\n 1121: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1124: invokeinterface #256, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 1129: dup\n 1130: invokestatic #262 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 1133: checkcast #63 // class java/util/List\n 1136: invokeinterface #273, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 1141: astore 19\n 1143: aload 19\n 1145: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1150: ifeq 1354\n 1153: aload 19\n 1155: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1160: checkcast #226 // class kotlin/Triple\n 1163: astore 20\n 1165: aload 20\n 1167: invokevirtual #265 // Method kotlin/Triple.component1:()Ljava/lang/Object;\n 1170: checkcast #63 // class java/util/List\n 1173: astore 21\n 1175: aload 20\n 1177: invokevirtual #276 // Method kotlin/Triple.component2:()Ljava/lang/Object;\n 1180: checkcast #63 // class java/util/List\n 1183: astore 23\n 1185: aload 20\n 1187: invokevirtual #279 // Method kotlin/Triple.component3:()Ljava/lang/Object;\n 1190: checkcast #281 // class java/util/Set\n 1193: astore 24\n 1195: aload 22\n 1197: checkcast #33 // class java/lang/Iterable\n 1200: astore 25\n 1202: aload 25\n 1204: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1209: astore 26\n 1211: aload 26\n 1213: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1218: ifeq 1286\n 1221: aload 26\n 1223: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1228: astore 27\n 1230: aload 27\n 1232: checkcast #226 // class kotlin/Triple\n 1235: astore 28\n 1237: iconst_0\n 1238: istore 29\n 1240: aload 28\n 1242: invokevirtual #279 // Method kotlin/Triple.component3:()Ljava/lang/Object;\n 1245: checkcast #281 // class java/util/Set\n 1248: astore 30\n 1250: aload 30\n 1252: checkcast #33 // class java/lang/Iterable\n 1255: aload 24\n 1257: checkcast #33 // class java/lang/Iterable\n 1260: invokestatic #285 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 1263: invokeinterface #286, 1 // InterfaceMethod java/util/Set.size:()I\n 1268: bipush 11\n 1270: if_icmplt 1277\n 1273: iconst_1\n 1274: goto 1278\n 1277: iconst_0\n 1278: ifeq 1211\n 1281: aload 27\n 1283: goto 1287\n 1286: aconst_null\n 1287: checkcast #226 // class kotlin/Triple\n 1290: astore 31\n 1292: aload 31\n 1294: ifnull 1143\n 1297: aload 31\n 1299: invokevirtual #276 // Method kotlin/Triple.component2:()Ljava/lang/Object;\n 1302: checkcast #63 // class java/util/List\n 1305: astore 32\n 1307: aload 11\n 1309: invokevirtual #67 // Method org/aoc2021/Day19$ScannerLocation.getCoordinates:()Ljava/util/List;\n 1312: aload 32\n 1314: invokestatic #289 // Method org/aoc2021/Day19Kt.access$vectorAdd:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 1317: aload 23\n 1319: invokestatic #73 // Method org/aoc2021/Day19Kt.access$vectorSubtract:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 1322: astore 25\n 1324: iload 17\n 1326: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1329: astore 27\n 1331: aload_2\n 1332: aload 27\n 1334: new #52 // class org/aoc2021/Day19$ScannerLocation\n 1337: dup\n 1338: aload 25\n 1340: aload 21\n 1342: invokespecial #209 // Method org/aoc2021/Day19$ScannerLocation.\"<init>\":(Ljava/util/List;Ljava/util/List;)V\n 1345: invokeinterface #293, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 1350: pop\n 1351: goto 1354\n 1354: nop\n 1355: nop\n 1356: goto 1086\n 1359: nop\n 1360: nop\n 1361: nop\n 1362: goto 772\n 1365: nop\n 1366: goto 628\n 1369: aload_2\n 1370: invokestatic #296 // Method kotlin/collections/MapsKt.toMap:(Ljava/util/Map;)Ljava/util/Map;\n 1373: areturn\n\n private final int countBeacons(java.util.List<? extends java.util.List<? extends java.util.List<java.lang.Integer>>>, java.util.Map<java.lang.Integer, org.aoc2021.Day19$ScannerLocation>);\n Code:\n 0: new #345 // class java/util/LinkedHashSet\n 3: dup\n 4: invokespecial #346 // Method java/util/LinkedHashSet.\"<init>\":()V\n 7: checkcast #281 // class java/util/Set\n 10: astore_3\n 11: aload_1\n 12: checkcast #33 // class java/lang/Iterable\n 15: astore 4\n 17: iconst_0\n 18: istore 5\n 20: iconst_0\n 21: istore 6\n 23: aload 4\n 25: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 30: astore 7\n 32: aload 7\n 34: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 39: ifeq 234\n 42: aload 7\n 44: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 49: astore 8\n 51: iload 6\n 53: iinc 6, 1\n 56: istore 9\n 58: iload 9\n 60: ifge 66\n 63: invokestatic #218 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 66: iload 9\n 68: aload 8\n 70: checkcast #63 // class java/util/List\n 73: astore 10\n 75: istore 11\n 77: iconst_0\n 78: istore 12\n 80: aload_2\n 81: iload 11\n 83: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 86: invokeinterface #256, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 91: dup\n 92: invokestatic #262 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 95: checkcast #52 // class org/aoc2021/Day19$ScannerLocation\n 98: astore 13\n 100: aload_3\n 101: aload 10\n 103: checkcast #33 // class java/lang/Iterable\n 106: astore 14\n 108: astore 15\n 110: iconst_0\n 111: istore 16\n 113: aload 14\n 115: astore 17\n 117: new #54 // class java/util/ArrayList\n 120: dup\n 121: aload 14\n 123: bipush 10\n 125: invokestatic #79 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 128: invokespecial #82 // Method java/util/ArrayList.\"<init>\":(I)V\n 131: checkcast #57 // class java/util/Collection\n 134: astore 18\n 136: iconst_0\n 137: istore 19\n 139: aload 17\n 141: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 146: astore 20\n 148: aload 20\n 150: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 155: ifeq 211\n 158: aload 20\n 160: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 165: astore 21\n 167: aload 18\n 169: aload 21\n 171: checkcast #63 // class java/util/List\n 174: astore 22\n 176: astore 23\n 178: iconst_0\n 179: istore 24\n 181: aload 22\n 183: aload 13\n 185: invokevirtual #268 // Method org/aoc2021/Day19$ScannerLocation.getRotation:()Ljava/util/List;\n 188: invokestatic #224 // Method org/aoc2021/Day19Kt.access$matrixMultiply:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 191: aload 13\n 193: invokevirtual #67 // Method org/aoc2021/Day19$ScannerLocation.getCoordinates:()Ljava/util/List;\n 196: invokestatic #289 // Method org/aoc2021/Day19Kt.access$vectorAdd:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 199: aload 23\n 201: swap\n 202: invokeinterface #61, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 207: pop\n 208: goto 148\n 211: aload 18\n 213: checkcast #63 // class java/util/List\n 216: nop\n 217: aload 15\n 219: swap\n 220: checkcast #57 // class java/util/Collection\n 223: invokeinterface #349, 2 // InterfaceMethod java/util/Set.addAll:(Ljava/util/Collection;)Z\n 228: pop\n 229: nop\n 230: nop\n 231: goto 32\n 234: nop\n 235: aload_3\n 236: invokeinterface #286, 1 // InterfaceMethod java/util/Set.size:()I\n 241: ireturn\n\n private final java.util.List<java.util.List<java.util.List<java.lang.Integer>>> generateRotationMatrices();\n Code:\n 0: new #54 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #55 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #63 // class java/util/List\n 10: astore_1\n 11: aconst_null\n 12: astore_2\n 13: getstatic #206 // Field identityMatrix:Ljava/util/List;\n 16: astore_2\n 17: iconst_3\n 18: anewarray #200 // class kotlin/Pair\n 21: astore_3\n 22: aload_3\n 23: iconst_0\n 24: getstatic #361 // Field zRotationMatrix:Ljava/util/List;\n 27: getstatic #364 // Field yRotationMatrix:Ljava/util/List;\n 30: invokestatic #110 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 33: aastore\n 34: aload_3\n 35: iconst_1\n 36: getstatic #364 // Field yRotationMatrix:Ljava/util/List;\n 39: getstatic #367 // Field xRotationMatrix:Ljava/util/List;\n 42: invokestatic #110 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 45: aastore\n 46: aload_3\n 47: iconst_2\n 48: getstatic #367 // Field xRotationMatrix:Ljava/util/List;\n 51: getstatic #361 // Field zRotationMatrix:Ljava/util/List;\n 54: invokestatic #110 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 57: aastore\n 58: aload_3\n 59: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 62: checkcast #33 // class java/lang/Iterable\n 65: astore_3\n 66: nop\n 67: iconst_0\n 68: istore 4\n 70: aload_3\n 71: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 76: astore 5\n 78: aload 5\n 80: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 85: ifeq 189\n 88: aload 5\n 90: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 95: astore 6\n 97: aload 6\n 99: checkcast #200 // class kotlin/Pair\n 102: astore 7\n 104: iconst_0\n 105: istore 8\n 107: aload 7\n 109: invokevirtual #368 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 112: checkcast #63 // class java/util/List\n 115: astore 9\n 117: aload 7\n 119: invokevirtual #369 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 122: checkcast #63 // class java/util/List\n 125: astore 10\n 127: aload_2\n 128: aload 10\n 130: invokestatic #372 // Method org/aoc2021/Day19Kt.access$multiply:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 133: astore_2\n 134: aload_1\n 135: getstatic #375 // Field INSTANCE:Lorg/aoc2021/Day19;\n 138: aload_2\n 139: aload 9\n 141: invokespecial #378 // Method generateRotationMatricesForAxis:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 144: checkcast #57 // class java/util/Collection\n 147: invokeinterface #379, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 152: pop\n 153: aload_2\n 154: aload 10\n 156: invokestatic #372 // Method org/aoc2021/Day19Kt.access$multiply:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 159: aload 10\n 161: invokestatic #372 // Method org/aoc2021/Day19Kt.access$multiply:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 164: astore_2\n 165: aload_1\n 166: getstatic #375 // Field INSTANCE:Lorg/aoc2021/Day19;\n 169: aload_2\n 170: aload 9\n 172: invokespecial #378 // Method generateRotationMatricesForAxis:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 175: checkcast #57 // class java/util/Collection\n 178: invokeinterface #379, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 183: pop\n 184: nop\n 185: nop\n 186: goto 78\n 189: nop\n 190: aload_1\n 191: checkcast #33 // class java/lang/Iterable\n 194: invokestatic #383 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 197: areturn\n\n private final java.util.List<java.util.List<java.util.List<java.lang.Integer>>> generateRotationMatricesForAxis(java.util.List<? extends java.util.List<java.lang.Integer>>, java.util.List<? extends java.util.List<java.lang.Integer>>);\n Code:\n 0: new #54 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #55 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #63 // class java/util/List\n 10: astore_3\n 11: aconst_null\n 12: astore 4\n 14: aload_1\n 15: astore 4\n 17: new #391 // class kotlin/ranges/IntRange\n 20: dup\n 21: iconst_1\n 22: iconst_4\n 23: invokespecial #394 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 26: checkcast #33 // class java/lang/Iterable\n 29: astore 5\n 31: iconst_0\n 32: istore 6\n 34: aload 5\n 36: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 41: astore 7\n 43: aload 7\n 45: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 50: ifeq 88\n 53: aload 7\n 55: checkcast #396 // class kotlin/collections/IntIterator\n 58: invokevirtual #399 // Method kotlin/collections/IntIterator.nextInt:()I\n 61: istore 8\n 63: iconst_0\n 64: istore 9\n 66: aload_3\n 67: aload 4\n 69: invokeinterface #400, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 74: pop\n 75: aload 4\n 77: aload_2\n 78: invokestatic #372 // Method org/aoc2021/Day19Kt.access$multiply:(Ljava/util/List;Ljava/util/List;)Ljava/util/List;\n 81: astore 4\n 83: nop\n 84: nop\n 85: goto 43\n 88: nop\n 89: aload_3\n 90: checkcast #33 // class java/lang/Iterable\n 93: invokestatic #383 // Method kotlin/collections/CollectionsKt.toList:(Ljava/lang/Iterable;)Ljava/util/List;\n 96: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc_w #410 // String args\n 4: invokestatic #414 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: ldc_w #416 // String input19.txt\n 10: iconst_0\n 11: anewarray #154 // class java/lang/String\n 14: invokestatic #422 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 17: getstatic #428 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 20: invokestatic #434 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 23: astore_1\n 24: getstatic #375 // Field INSTANCE:Lorg/aoc2021/Day19;\n 27: aload_1\n 28: invokestatic #262 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 31: aload_1\n 32: invokespecial #436 // Method solve:(Ljava/util/List;)Lkotlin/Pair;\n 35: astore_2\n 36: aload_2\n 37: invokevirtual #368 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 40: checkcast #84 // class java/lang/Number\n 43: invokevirtual #88 // Method java/lang/Number.intValue:()I\n 46: istore_3\n 47: aload_2\n 48: invokevirtual #369 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 51: checkcast #84 // class java/lang/Number\n 54: invokevirtual #88 // Method java/lang/Number.intValue:()I\n 57: istore 4\n 59: getstatic #442 // Field java/lang/System.out:Ljava/io/PrintStream;\n 62: iload_3\n 63: invokevirtual #447 // Method java/io/PrintStream.println:(I)V\n 66: getstatic #442 // Field java/lang/System.out:Ljava/io/PrintStream;\n 69: iload 4\n 71: invokevirtual #447 // Method java/io/PrintStream.println:(I)V\n 74: return\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day19\n 3: dup\n 4: invokespecial #450 // Method \"<init>\":()V\n 7: putstatic #375 // Field INSTANCE:Lorg/aoc2021/Day19;\n 10: iconst_3\n 11: anewarray #63 // class java/util/List\n 14: astore_0\n 15: aload_0\n 16: iconst_0\n 17: iconst_3\n 18: anewarray #96 // class java/lang/Integer\n 21: astore_1\n 22: aload_1\n 23: iconst_0\n 24: iconst_1\n 25: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 28: aastore\n 29: aload_1\n 30: iconst_1\n 31: iconst_0\n 32: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 35: aastore\n 36: aload_1\n 37: iconst_2\n 38: iconst_0\n 39: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 42: aastore\n 43: aload_1\n 44: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 47: aastore\n 48: aload_0\n 49: iconst_1\n 50: iconst_3\n 51: anewarray #96 // class java/lang/Integer\n 54: astore_1\n 55: aload_1\n 56: iconst_0\n 57: iconst_0\n 58: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 61: aastore\n 62: aload_1\n 63: iconst_1\n 64: iconst_1\n 65: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 68: aastore\n 69: aload_1\n 70: iconst_2\n 71: iconst_0\n 72: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 75: aastore\n 76: aload_1\n 77: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 80: aastore\n 81: aload_0\n 82: iconst_2\n 83: iconst_3\n 84: anewarray #96 // class java/lang/Integer\n 87: astore_1\n 88: aload_1\n 89: iconst_0\n 90: iconst_0\n 91: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 94: aastore\n 95: aload_1\n 96: iconst_1\n 97: iconst_0\n 98: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 101: aastore\n 102: aload_1\n 103: iconst_2\n 104: iconst_1\n 105: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 108: aastore\n 109: aload_1\n 110: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 113: aastore\n 114: aload_0\n 115: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 118: putstatic #206 // Field identityMatrix:Ljava/util/List;\n 121: iconst_3\n 122: anewarray #63 // class java/util/List\n 125: astore_0\n 126: aload_0\n 127: iconst_0\n 128: iconst_3\n 129: anewarray #96 // class java/lang/Integer\n 132: astore_1\n 133: aload_1\n 134: iconst_0\n 135: iconst_1\n 136: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 139: aastore\n 140: aload_1\n 141: iconst_1\n 142: iconst_0\n 143: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 146: aastore\n 147: aload_1\n 148: iconst_2\n 149: iconst_0\n 150: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 153: aastore\n 154: aload_1\n 155: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 158: aastore\n 159: aload_0\n 160: iconst_1\n 161: iconst_3\n 162: anewarray #96 // class java/lang/Integer\n 165: astore_1\n 166: aload_1\n 167: iconst_0\n 168: iconst_0\n 169: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 172: aastore\n 173: aload_1\n 174: iconst_1\n 175: iconst_0\n 176: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 179: aastore\n 180: aload_1\n 181: iconst_2\n 182: iconst_m1\n 183: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 186: aastore\n 187: aload_1\n 188: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 191: aastore\n 192: aload_0\n 193: iconst_2\n 194: iconst_3\n 195: anewarray #96 // class java/lang/Integer\n 198: astore_1\n 199: aload_1\n 200: iconst_0\n 201: iconst_0\n 202: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 205: aastore\n 206: aload_1\n 207: iconst_1\n 208: iconst_1\n 209: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 212: aastore\n 213: aload_1\n 214: iconst_2\n 215: iconst_0\n 216: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 219: aastore\n 220: aload_1\n 221: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 224: aastore\n 225: aload_0\n 226: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 229: putstatic #367 // Field xRotationMatrix:Ljava/util/List;\n 232: iconst_3\n 233: anewarray #63 // class java/util/List\n 236: astore_0\n 237: aload_0\n 238: iconst_0\n 239: iconst_3\n 240: anewarray #96 // class java/lang/Integer\n 243: astore_1\n 244: aload_1\n 245: iconst_0\n 246: iconst_0\n 247: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 250: aastore\n 251: aload_1\n 252: iconst_1\n 253: iconst_0\n 254: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 257: aastore\n 258: aload_1\n 259: iconst_2\n 260: iconst_m1\n 261: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 264: aastore\n 265: aload_1\n 266: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 269: aastore\n 270: aload_0\n 271: iconst_1\n 272: iconst_3\n 273: anewarray #96 // class java/lang/Integer\n 276: astore_1\n 277: aload_1\n 278: iconst_0\n 279: iconst_0\n 280: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 283: aastore\n 284: aload_1\n 285: iconst_1\n 286: iconst_1\n 287: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 290: aastore\n 291: aload_1\n 292: iconst_2\n 293: iconst_0\n 294: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 297: aastore\n 298: aload_1\n 299: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 302: aastore\n 303: aload_0\n 304: iconst_2\n 305: iconst_3\n 306: anewarray #96 // class java/lang/Integer\n 309: astore_1\n 310: aload_1\n 311: iconst_0\n 312: iconst_1\n 313: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 316: aastore\n 317: aload_1\n 318: iconst_1\n 319: iconst_0\n 320: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 323: aastore\n 324: aload_1\n 325: iconst_2\n 326: iconst_0\n 327: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 330: aastore\n 331: aload_1\n 332: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 335: aastore\n 336: aload_0\n 337: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 340: putstatic #364 // Field yRotationMatrix:Ljava/util/List;\n 343: iconst_3\n 344: anewarray #63 // class java/util/List\n 347: astore_0\n 348: aload_0\n 349: iconst_0\n 350: iconst_3\n 351: anewarray #96 // class java/lang/Integer\n 354: astore_1\n 355: aload_1\n 356: iconst_0\n 357: iconst_0\n 358: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 361: aastore\n 362: aload_1\n 363: iconst_1\n 364: iconst_1\n 365: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 368: aastore\n 369: aload_1\n 370: iconst_2\n 371: iconst_0\n 372: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 375: aastore\n 376: aload_1\n 377: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 380: aastore\n 381: aload_0\n 382: iconst_1\n 383: iconst_3\n 384: anewarray #96 // class java/lang/Integer\n 387: astore_1\n 388: aload_1\n 389: iconst_0\n 390: iconst_m1\n 391: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 394: aastore\n 395: aload_1\n 396: iconst_1\n 397: iconst_0\n 398: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 401: aastore\n 402: aload_1\n 403: iconst_2\n 404: iconst_0\n 405: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 408: aastore\n 409: aload_1\n 410: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 413: aastore\n 414: aload_0\n 415: iconst_2\n 416: iconst_3\n 417: anewarray #96 // class java/lang/Integer\n 420: astore_1\n 421: aload_1\n 422: iconst_0\n 423: iconst_0\n 424: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 427: aastore\n 428: aload_1\n 429: iconst_1\n 430: iconst_0\n 431: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 434: aastore\n 435: aload_1\n 436: iconst_2\n 437: iconst_1\n 438: invokestatic #100 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 441: aastore\n 442: aload_1\n 443: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 446: aastore\n 447: aload_0\n 448: invokestatic #203 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 451: putstatic #361 // Field zRotationMatrix:Ljava/util/List;\n 454: getstatic #375 // Field INSTANCE:Lorg/aoc2021/Day19;\n 457: invokespecial #452 // Method generateRotationMatrices:()Ljava/util/List;\n 460: putstatic #221 // Field all3DRotationMatrices:Ljava/util/List;\n 463: return\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day14.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
object Day14 {
private const val iterationsPart1 = 10
private const val iterationsPart2 = 40
private fun solve(lines: List<String>, iterations: Int): Long {
val start = lines[0]
val rules = lines.drop(2).map { it.split(" -> ") }.associate { it[0] to it[1] }
val startMap = start.windowed(2).groupBy { it }.mapValues { (_, values) -> values.size.toLong() }
val processed = (1..iterations).fold(startMap) { polymer, _ ->
doIteration(polymer, rules)
}
val countsByChar = processed.entries.flatMap { (pair, count) -> listOf( pair[0] to count, pair[1] to count ) }
.groupBy(Pair<Char, Long>::first, Pair<Char, Long>::second)
.mapValues { (_, counts) -> counts.sum() }
.mapValues { (c, count) ->
if (c == start.first() || c == start.last()) {
if (start.first() == start.last()) {
(count + 2) / 2
} else {
(count + 1) / 2
}
} else {
count / 2
}
}
return countsByChar.values.maxOrNull()!! - countsByChar.values.minOrNull()!!
}
private fun doIteration(polymer: Map<String, Long>, rules: Map<String, String>): Map<String, Long> {
val newMap = mutableMapOf<String, Long>()
polymer.forEach { (pair, count) ->
val rule = rules[pair]
if (rule != null) {
newMap.merge(pair[0] + rule, count) { a, b -> a + b }
newMap.merge(rule + pair[1], count) { a, b -> a + b }
} else {
newMap.merge(pair, count) { a, b -> a + b }
}
}
return newMap.toMap()
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input14.txt"), Charsets.UTF_8)
val solution1 = solve(lines, iterationsPart1)
println(solution1)
val solution2 = solve(lines, iterationsPart2)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day14.class",
"javap": "Compiled from \"Day14.kt\"\npublic final class org.aoc2021.Day14 {\n public static final org.aoc2021.Day14 INSTANCE;\n\n private static final int iterationsPart1;\n\n private static final int iterationsPart2;\n\n private org.aoc2021.Day14();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final long solve(java.util.List<java.lang.String>, int);\n Code:\n 0: aload_1\n 1: iconst_0\n 2: invokeinterface #19, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #21 // class java/lang/String\n 10: astore_3\n 11: aload_1\n 12: checkcast #23 // class java/lang/Iterable\n 15: iconst_2\n 16: invokestatic #29 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 19: checkcast #23 // class java/lang/Iterable\n 22: astore 5\n 24: iconst_0\n 25: istore 6\n 27: aload 5\n 29: astore 7\n 31: new #31 // class java/util/ArrayList\n 34: dup\n 35: aload 5\n 37: bipush 10\n 39: invokestatic #35 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 42: invokespecial #38 // Method java/util/ArrayList.\"<init>\":(I)V\n 45: checkcast #40 // class java/util/Collection\n 48: astore 8\n 50: iconst_0\n 51: istore 9\n 53: aload 7\n 55: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 60: astore 10\n 62: aload 10\n 64: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 69: ifeq 134\n 72: aload 10\n 74: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 79: astore 11\n 81: aload 8\n 83: aload 11\n 85: checkcast #21 // class java/lang/String\n 88: astore 12\n 90: astore 25\n 92: iconst_0\n 93: istore 13\n 95: aload 12\n 97: checkcast #56 // class java/lang/CharSequence\n 100: iconst_1\n 101: anewarray #21 // class java/lang/String\n 104: astore 14\n 106: aload 14\n 108: iconst_0\n 109: ldc #58 // String ->\n 111: aastore\n 112: aload 14\n 114: iconst_0\n 115: iconst_0\n 116: bipush 6\n 118: aconst_null\n 119: invokestatic #64 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 122: aload 25\n 124: swap\n 125: invokeinterface #68, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 130: pop\n 131: goto 62\n 134: aload 8\n 136: checkcast #15 // class java/util/List\n 139: nop\n 140: checkcast #23 // class java/lang/Iterable\n 143: astore 5\n 145: nop\n 146: iconst_0\n 147: istore 6\n 149: aload 5\n 151: bipush 10\n 153: invokestatic #35 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 156: invokestatic #74 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 159: bipush 16\n 161: invokestatic #80 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 164: istore 7\n 166: aload 5\n 168: astore 8\n 170: new #82 // class java/util/LinkedHashMap\n 173: dup\n 174: iload 7\n 176: invokespecial #83 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 179: checkcast #85 // class java/util/Map\n 182: astore 9\n 184: iconst_0\n 185: istore 10\n 187: aload 8\n 189: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 194: astore 11\n 196: aload 11\n 198: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 203: ifeq 271\n 206: aload 11\n 208: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 213: astore 12\n 215: aload 9\n 217: astore 13\n 219: aload 12\n 221: checkcast #15 // class java/util/List\n 224: astore 14\n 226: iconst_0\n 227: istore 15\n 229: aload 14\n 231: iconst_0\n 232: invokeinterface #19, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 237: aload 14\n 239: iconst_1\n 240: invokeinterface #19, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 245: invokestatic #91 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 248: astore 14\n 250: aload 13\n 252: aload 14\n 254: invokevirtual #96 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 257: aload 14\n 259: invokevirtual #99 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 262: invokeinterface #103, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 267: pop\n 268: goto 196\n 271: aload 9\n 273: nop\n 274: astore 4\n 276: aload_3\n 277: checkcast #56 // class java/lang/CharSequence\n 280: iconst_2\n 281: iconst_0\n 282: iconst_0\n 283: bipush 6\n 285: aconst_null\n 286: invokestatic #107 // Method kotlin/text/StringsKt.windowed$default:(Ljava/lang/CharSequence;IIZILjava/lang/Object;)Ljava/util/List;\n 289: checkcast #23 // class java/lang/Iterable\n 292: astore 6\n 294: iconst_0\n 295: istore 7\n 297: aload 6\n 299: astore 8\n 301: new #82 // class java/util/LinkedHashMap\n 304: dup\n 305: invokespecial #108 // Method java/util/LinkedHashMap.\"<init>\":()V\n 308: checkcast #85 // class java/util/Map\n 311: astore 9\n 313: iconst_0\n 314: istore 10\n 316: aload 8\n 318: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 323: astore 11\n 325: aload 11\n 327: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 332: ifeq 434\n 335: aload 11\n 337: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 342: astore 12\n 344: aload 12\n 346: checkcast #21 // class java/lang/String\n 349: astore 13\n 351: iconst_0\n 352: istore 14\n 354: aload 13\n 356: astore 15\n 358: aload 9\n 360: astore 16\n 362: iconst_0\n 363: istore 17\n 365: aload 16\n 367: aload 15\n 369: invokeinterface #111, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 374: astore 18\n 376: aload 18\n 378: ifnonnull 413\n 381: iconst_0\n 382: istore 19\n 384: new #31 // class java/util/ArrayList\n 387: dup\n 388: invokespecial #112 // Method java/util/ArrayList.\"<init>\":()V\n 391: checkcast #15 // class java/util/List\n 394: astore 19\n 396: aload 16\n 398: aload 15\n 400: aload 19\n 402: invokeinterface #103, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 407: pop\n 408: aload 19\n 410: goto 415\n 413: aload 18\n 415: nop\n 416: checkcast #15 // class java/util/List\n 419: astore 13\n 421: aload 13\n 423: aload 12\n 425: invokeinterface #113, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 430: pop\n 431: goto 325\n 434: aload 9\n 436: nop\n 437: astore 6\n 439: nop\n 440: iconst_0\n 441: istore 7\n 443: aload 6\n 445: astore 8\n 447: new #82 // class java/util/LinkedHashMap\n 450: dup\n 451: aload 6\n 453: invokeinterface #117, 1 // InterfaceMethod java/util/Map.size:()I\n 458: invokestatic #74 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 461: invokespecial #83 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 464: checkcast #85 // class java/util/Map\n 467: astore 9\n 469: iconst_0\n 470: istore 10\n 472: aload 8\n 474: invokeinterface #121, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 479: checkcast #23 // class java/lang/Iterable\n 482: astore 11\n 484: iconst_0\n 485: istore 12\n 487: aload 11\n 489: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 494: astore 13\n 496: aload 13\n 498: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 503: ifeq 593\n 506: aload 13\n 508: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 513: astore 14\n 515: aload 9\n 517: aload 14\n 519: checkcast #123 // class java/util/Map$Entry\n 522: astore 15\n 524: astore 16\n 526: iconst_0\n 527: istore 17\n 529: aload 15\n 531: invokeinterface #126, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 536: aload 16\n 538: swap\n 539: aload 14\n 541: checkcast #123 // class java/util/Map$Entry\n 544: astore 18\n 546: astore 26\n 548: astore 25\n 550: iconst_0\n 551: istore 19\n 553: aload 18\n 555: invokeinterface #129, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 560: checkcast #15 // class java/util/List\n 563: astore 20\n 565: aload 20\n 567: invokeinterface #130, 1 // InterfaceMethod java/util/List.size:()I\n 572: i2l\n 573: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 576: astore 27\n 578: aload 25\n 580: aload 26\n 582: aload 27\n 584: invokeinterface #103, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 589: pop\n 590: goto 496\n 593: aload 9\n 595: nop\n 596: nop\n 597: astore 5\n 599: new #138 // class kotlin/ranges/IntRange\n 602: dup\n 603: iconst_1\n 604: iload_2\n 605: invokespecial #141 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 608: checkcast #23 // class java/lang/Iterable\n 611: astore 7\n 613: iconst_0\n 614: istore 8\n 616: aload 5\n 618: astore 9\n 620: aload 7\n 622: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 627: astore 10\n 629: aload 10\n 631: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 636: ifeq 671\n 639: aload 10\n 641: checkcast #143 // class kotlin/collections/IntIterator\n 644: invokevirtual #146 // Method kotlin/collections/IntIterator.nextInt:()I\n 647: istore 11\n 649: aload 9\n 651: astore 13\n 653: iconst_0\n 654: istore 14\n 656: getstatic #149 // Field INSTANCE:Lorg/aoc2021/Day14;\n 659: aload 13\n 661: aload 4\n 663: invokespecial #153 // Method doIteration:(Ljava/util/Map;Ljava/util/Map;)Ljava/util/Map;\n 666: astore 9\n 668: goto 629\n 671: aload 9\n 673: astore 6\n 675: aload 6\n 677: invokeinterface #121, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 682: checkcast #23 // class java/lang/Iterable\n 685: astore 8\n 687: iconst_0\n 688: istore 9\n 690: aload 8\n 692: astore 10\n 694: new #31 // class java/util/ArrayList\n 697: dup\n 698: invokespecial #112 // Method java/util/ArrayList.\"<init>\":()V\n 701: checkcast #40 // class java/util/Collection\n 704: astore 11\n 706: iconst_0\n 707: istore 12\n 709: aload 10\n 711: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 716: astore 13\n 718: aload 13\n 720: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 725: ifeq 843\n 728: aload 13\n 730: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 735: astore 14\n 737: aload 14\n 739: checkcast #123 // class java/util/Map$Entry\n 742: astore 15\n 744: iconst_0\n 745: istore 16\n 747: aload 15\n 749: invokeinterface #126, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 754: checkcast #21 // class java/lang/String\n 757: astore 17\n 759: aload 15\n 761: invokeinterface #129, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 766: checkcast #155 // class java/lang/Number\n 769: invokevirtual #159 // Method java/lang/Number.longValue:()J\n 772: lstore 18\n 774: iconst_2\n 775: anewarray #93 // class kotlin/Pair\n 778: astore 20\n 780: aload 20\n 782: iconst_0\n 783: aload 17\n 785: iconst_0\n 786: invokevirtual #163 // Method java/lang/String.charAt:(I)C\n 789: invokestatic #168 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 792: lload 18\n 794: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 797: invokestatic #91 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 800: aastore\n 801: aload 20\n 803: iconst_1\n 804: aload 17\n 806: iconst_1\n 807: invokevirtual #163 // Method java/lang/String.charAt:(I)C\n 810: invokestatic #168 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 813: lload 18\n 815: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 818: invokestatic #91 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 821: aastore\n 822: aload 20\n 824: invokestatic #172 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 827: checkcast #23 // class java/lang/Iterable\n 830: astore 15\n 832: aload 11\n 834: aload 15\n 836: invokestatic #176 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 839: pop\n 840: goto 718\n 843: aload 11\n 845: checkcast #15 // class java/util/List\n 848: nop\n 849: checkcast #23 // class java/lang/Iterable\n 852: astore 8\n 854: nop\n 855: iconst_0\n 856: istore 9\n 858: aload 8\n 860: astore 10\n 862: new #82 // class java/util/LinkedHashMap\n 865: dup\n 866: invokespecial #108 // Method java/util/LinkedHashMap.\"<init>\":()V\n 869: checkcast #85 // class java/util/Map\n 872: astore 11\n 874: iconst_0\n 875: istore 12\n 877: aload 10\n 879: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 884: astore 13\n 886: aload 13\n 888: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 893: ifeq 1034\n 896: aload 13\n 898: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 903: astore 14\n 905: aload 14\n 907: checkcast #93 // class kotlin/Pair\n 910: astore 15\n 912: iconst_0\n 913: istore 16\n 915: aload 15\n 917: invokevirtual #96 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 920: checkcast #165 // class java/lang/Character\n 923: invokevirtual #180 // Method java/lang/Character.charValue:()C\n 926: invokestatic #168 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 929: astore 17\n 931: aload 11\n 933: astore 18\n 935: iconst_0\n 936: istore 19\n 938: aload 18\n 940: aload 17\n 942: invokeinterface #111, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 947: astore 20\n 949: aload 20\n 951: ifnonnull 986\n 954: iconst_0\n 955: istore 21\n 957: new #31 // class java/util/ArrayList\n 960: dup\n 961: invokespecial #112 // Method java/util/ArrayList.\"<init>\":()V\n 964: checkcast #15 // class java/util/List\n 967: astore 21\n 969: aload 18\n 971: aload 17\n 973: aload 21\n 975: invokeinterface #103, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 980: pop\n 981: aload 21\n 983: goto 988\n 986: aload 20\n 988: nop\n 989: checkcast #15 // class java/util/List\n 992: astore 15\n 994: aload 15\n 996: aload 14\n 998: checkcast #93 // class kotlin/Pair\n 1001: astore 16\n 1003: astore 25\n 1005: iconst_0\n 1006: istore 22\n 1008: aload 16\n 1010: invokevirtual #99 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 1013: checkcast #155 // class java/lang/Number\n 1016: invokevirtual #159 // Method java/lang/Number.longValue:()J\n 1019: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 1022: aload 25\n 1024: swap\n 1025: invokeinterface #113, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 1030: pop\n 1031: goto 886\n 1034: aload 11\n 1036: nop\n 1037: astore 8\n 1039: nop\n 1040: iconst_0\n 1041: istore 9\n 1043: aload 8\n 1045: astore 10\n 1047: new #82 // class java/util/LinkedHashMap\n 1050: dup\n 1051: aload 8\n 1053: invokeinterface #117, 1 // InterfaceMethod java/util/Map.size:()I\n 1058: invokestatic #74 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 1061: invokespecial #83 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 1064: checkcast #85 // class java/util/Map\n 1067: astore 11\n 1069: iconst_0\n 1070: istore 12\n 1072: aload 10\n 1074: invokeinterface #121, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 1079: checkcast #23 // class java/lang/Iterable\n 1082: astore 13\n 1084: iconst_0\n 1085: istore 14\n 1087: aload 13\n 1089: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1094: astore 15\n 1096: aload 15\n 1098: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1103: ifeq 1193\n 1106: aload 15\n 1108: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1113: astore 16\n 1115: aload 11\n 1117: aload 16\n 1119: checkcast #123 // class java/util/Map$Entry\n 1122: astore 17\n 1124: astore 18\n 1126: iconst_0\n 1127: istore 19\n 1129: aload 17\n 1131: invokeinterface #126, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 1136: aload 18\n 1138: swap\n 1139: aload 16\n 1141: checkcast #123 // class java/util/Map$Entry\n 1144: astore 20\n 1146: astore 26\n 1148: astore 25\n 1150: iconst_0\n 1151: istore 21\n 1153: aload 20\n 1155: invokeinterface #129, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 1160: checkcast #15 // class java/util/List\n 1163: astore 22\n 1165: aload 22\n 1167: checkcast #23 // class java/lang/Iterable\n 1170: invokestatic #184 // Method kotlin/collections/CollectionsKt.sumOfLong:(Ljava/lang/Iterable;)J\n 1173: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 1176: astore 27\n 1178: aload 25\n 1180: aload 26\n 1182: aload 27\n 1184: invokeinterface #103, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 1189: pop\n 1190: goto 1096\n 1193: aload 11\n 1195: nop\n 1196: nop\n 1197: astore 8\n 1199: nop\n 1200: iconst_0\n 1201: istore 9\n 1203: aload 8\n 1205: astore 10\n 1207: new #82 // class java/util/LinkedHashMap\n 1210: dup\n 1211: aload 8\n 1213: invokeinterface #117, 1 // InterfaceMethod java/util/Map.size:()I\n 1218: invokestatic #74 // Method kotlin/collections/MapsKt.mapCapacity:(I)I\n 1221: invokespecial #83 // Method java/util/LinkedHashMap.\"<init>\":(I)V\n 1224: checkcast #85 // class java/util/Map\n 1227: astore 11\n 1229: iconst_0\n 1230: istore 12\n 1232: aload 10\n 1234: invokeinterface #121, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 1239: checkcast #23 // class java/lang/Iterable\n 1242: astore 13\n 1244: iconst_0\n 1245: istore 14\n 1247: aload 13\n 1249: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1254: astore 15\n 1256: aload 15\n 1258: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1263: ifeq 1431\n 1266: aload 15\n 1268: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1273: astore 16\n 1275: aload 11\n 1277: aload 16\n 1279: checkcast #123 // class java/util/Map$Entry\n 1282: astore 17\n 1284: astore 18\n 1286: iconst_0\n 1287: istore 19\n 1289: aload 17\n 1291: invokeinterface #126, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 1296: aload 18\n 1298: swap\n 1299: aload 16\n 1301: checkcast #123 // class java/util/Map$Entry\n 1304: astore 20\n 1306: astore 26\n 1308: astore 25\n 1310: iconst_0\n 1311: istore 21\n 1313: aload 20\n 1315: invokeinterface #126, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 1320: checkcast #165 // class java/lang/Character\n 1323: invokevirtual #180 // Method java/lang/Character.charValue:()C\n 1326: istore 22\n 1328: aload 20\n 1330: invokeinterface #129, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 1335: checkcast #155 // class java/lang/Number\n 1338: invokevirtual #159 // Method java/lang/Number.longValue:()J\n 1341: lstore 23\n 1343: iload 22\n 1345: aload_3\n 1346: checkcast #56 // class java/lang/CharSequence\n 1349: invokestatic #188 // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C\n 1352: if_icmpeq 1367\n 1355: iload 22\n 1357: aload_3\n 1358: checkcast #56 // class java/lang/CharSequence\n 1361: invokestatic #191 // Method kotlin/text/StringsKt.last:(Ljava/lang/CharSequence;)C\n 1364: if_icmpne 1405\n 1367: aload_3\n 1368: checkcast #56 // class java/lang/CharSequence\n 1371: invokestatic #188 // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C\n 1374: aload_3\n 1375: checkcast #56 // class java/lang/CharSequence\n 1378: invokestatic #191 // Method kotlin/text/StringsKt.last:(Ljava/lang/CharSequence;)C\n 1381: if_icmpne 1395\n 1384: lload 23\n 1386: iconst_2\n 1387: i2l\n 1388: ladd\n 1389: iconst_2\n 1390: i2l\n 1391: ldiv\n 1392: goto 1410\n 1395: lload 23\n 1397: lconst_1\n 1398: ladd\n 1399: iconst_2\n 1400: i2l\n 1401: ldiv\n 1402: goto 1410\n 1405: lload 23\n 1407: iconst_2\n 1408: i2l\n 1409: ldiv\n 1410: nop\n 1411: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 1414: astore 27\n 1416: aload 25\n 1418: aload 26\n 1420: aload 27\n 1422: invokeinterface #103, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 1427: pop\n 1428: goto 1256\n 1431: aload 11\n 1433: nop\n 1434: nop\n 1435: astore 7\n 1437: aload 7\n 1439: invokeinterface #195, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 1444: checkcast #23 // class java/lang/Iterable\n 1447: invokestatic #199 // Method kotlin/collections/CollectionsKt.maxOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 1450: dup\n 1451: invokestatic #205 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 1454: checkcast #155 // class java/lang/Number\n 1457: invokevirtual #159 // Method java/lang/Number.longValue:()J\n 1460: aload 7\n 1462: invokeinterface #195, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 1467: checkcast #23 // class java/lang/Iterable\n 1470: invokestatic #208 // Method kotlin/collections/CollectionsKt.minOrNull:(Ljava/lang/Iterable;)Ljava/lang/Comparable;\n 1473: dup\n 1474: invokestatic #205 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 1477: checkcast #155 // class java/lang/Number\n 1480: invokevirtual #159 // Method java/lang/Number.longValue:()J\n 1483: lsub\n 1484: lreturn\n\n private final java.util.Map<java.lang.String, java.lang.Long> doIteration(java.util.Map<java.lang.String, java.lang.Long>, java.util.Map<java.lang.String, java.lang.String>);\n Code:\n 0: new #82 // class java/util/LinkedHashMap\n 3: dup\n 4: invokespecial #108 // Method java/util/LinkedHashMap.\"<init>\":()V\n 7: checkcast #85 // class java/util/Map\n 10: astore_3\n 11: aload_1\n 12: astore 4\n 14: iconst_0\n 15: istore 5\n 17: aload 4\n 19: invokeinterface #121, 1 // InterfaceMethod java/util/Map.entrySet:()Ljava/util/Set;\n 24: invokeinterface #288, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 29: astore 6\n 31: aload 6\n 33: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 38: ifeq 238\n 41: aload 6\n 43: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 48: checkcast #123 // class java/util/Map$Entry\n 51: astore 7\n 53: aload 7\n 55: astore 8\n 57: iconst_0\n 58: istore 9\n 60: aload 8\n 62: invokeinterface #126, 1 // InterfaceMethod java/util/Map$Entry.getKey:()Ljava/lang/Object;\n 67: checkcast #21 // class java/lang/String\n 70: astore 10\n 72: aload 8\n 74: invokeinterface #129, 1 // InterfaceMethod java/util/Map$Entry.getValue:()Ljava/lang/Object;\n 79: checkcast #155 // class java/lang/Number\n 82: invokevirtual #159 // Method java/lang/Number.longValue:()J\n 85: lstore 11\n 87: aload_2\n 88: aload 10\n 90: invokeinterface #111, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 95: checkcast #21 // class java/lang/String\n 98: astore 13\n 100: aload 13\n 102: ifnull 206\n 105: aload_3\n 106: aload 10\n 108: iconst_0\n 109: invokevirtual #163 // Method java/lang/String.charAt:(I)C\n 112: istore 14\n 114: new #290 // class java/lang/StringBuilder\n 117: dup\n 118: invokespecial #291 // Method java/lang/StringBuilder.\"<init>\":()V\n 121: iload 14\n 123: invokevirtual #295 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 126: aload 13\n 128: invokevirtual #298 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 131: invokevirtual #302 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 134: lload 11\n 136: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 139: invokedynamic #320, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function2;\n 144: invokedynamic #331, 0 // InvokeDynamic #1:apply:(Lkotlin/jvm/functions/Function2;)Ljava/util/function/BiFunction;\n 149: invokeinterface #335, 4 // InterfaceMethod java/util/Map.merge:(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;\n 154: pop\n 155: aload_3\n 156: new #290 // class java/lang/StringBuilder\n 159: dup\n 160: invokespecial #291 // Method java/lang/StringBuilder.\"<init>\":()V\n 163: aload 13\n 165: invokevirtual #298 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 168: aload 10\n 170: iconst_1\n 171: invokevirtual #163 // Method java/lang/String.charAt:(I)C\n 174: invokevirtual #295 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 177: invokevirtual #302 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 180: lload 11\n 182: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 185: invokedynamic #340, 0 // InvokeDynamic #2:invoke:()Lkotlin/jvm/functions/Function2;\n 190: invokedynamic #345, 0 // InvokeDynamic #3:apply:(Lkotlin/jvm/functions/Function2;)Ljava/util/function/BiFunction;\n 195: invokeinterface #335, 4 // InterfaceMethod java/util/Map.merge:(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;\n 200: checkcast #132 // class java/lang/Long\n 203: goto 232\n 206: aload_3\n 207: aload 10\n 209: lload 11\n 211: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 214: invokedynamic #350, 0 // InvokeDynamic #4:invoke:()Lkotlin/jvm/functions/Function2;\n 219: invokedynamic #355, 0 // InvokeDynamic #5:apply:(Lkotlin/jvm/functions/Function2;)Ljava/util/function/BiFunction;\n 224: invokeinterface #335, 4 // InterfaceMethod java/util/Map.merge:(Ljava/lang/Object;Ljava/lang/Object;Ljava/util/function/BiFunction;)Ljava/lang/Object;\n 229: checkcast #132 // class java/lang/Long\n 232: pop\n 233: nop\n 234: nop\n 235: goto 31\n 238: nop\n 239: aload_3\n 240: invokestatic #359 // Method kotlin/collections/MapsKt.toMap:(Ljava/util/Map;)Ljava/util/Map;\n 243: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc_w #370 // String args\n 4: invokestatic #374 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: ldc_w #376 // String input14.txt\n 10: iconst_0\n 11: anewarray #21 // class java/lang/String\n 14: invokestatic #382 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 17: getstatic #388 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 20: invokestatic #394 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 23: astore_1\n 24: getstatic #149 // Field INSTANCE:Lorg/aoc2021/Day14;\n 27: aload_1\n 28: invokestatic #205 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 31: aload_1\n 32: bipush 10\n 34: invokespecial #396 // Method solve:(Ljava/util/List;I)J\n 37: lstore_2\n 38: getstatic #402 // Field java/lang/System.out:Ljava/io/PrintStream;\n 41: lload_2\n 42: invokevirtual #408 // Method java/io/PrintStream.println:(J)V\n 45: getstatic #149 // Field INSTANCE:Lorg/aoc2021/Day14;\n 48: aload_1\n 49: bipush 40\n 51: invokespecial #396 // Method solve:(Ljava/util/List;I)J\n 54: lstore 4\n 56: getstatic #402 // Field java/lang/System.out:Ljava/io/PrintStream;\n 59: lload 4\n 61: invokevirtual #408 // Method java/io/PrintStream.println:(J)V\n 64: return\n\n private static final java.lang.Long doIteration$lambda$15$lambda$9(java.lang.Long, java.lang.Long);\n Code:\n 0: aload_0\n 1: ldc_w #413 // String a\n 4: invokestatic #374 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: ldc_w #415 // String b\n 11: invokestatic #374 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: aload_0\n 15: invokevirtual #416 // Method java/lang/Long.longValue:()J\n 18: aload_1\n 19: invokevirtual #416 // Method java/lang/Long.longValue:()J\n 22: ladd\n 23: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 26: areturn\n\n private static final java.lang.Long doIteration$lambda$15$lambda$10(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 #421, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 8: checkcast #132 // class java/lang/Long\n 11: areturn\n\n private static final java.lang.Long doIteration$lambda$15$lambda$11(java.lang.Long, java.lang.Long);\n Code:\n 0: aload_0\n 1: ldc_w #413 // String a\n 4: invokestatic #374 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: ldc_w #415 // String b\n 11: invokestatic #374 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: aload_0\n 15: invokevirtual #416 // Method java/lang/Long.longValue:()J\n 18: aload_1\n 19: invokevirtual #416 // Method java/lang/Long.longValue:()J\n 22: ladd\n 23: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 26: areturn\n\n private static final java.lang.Long doIteration$lambda$15$lambda$12(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 #421, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 8: checkcast #132 // class java/lang/Long\n 11: areturn\n\n private static final java.lang.Long doIteration$lambda$15$lambda$13(java.lang.Long, java.lang.Long);\n Code:\n 0: aload_0\n 1: ldc_w #413 // String a\n 4: invokestatic #374 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: aload_1\n 8: ldc_w #415 // String b\n 11: invokestatic #374 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 14: aload_0\n 15: invokevirtual #416 // Method java/lang/Long.longValue:()J\n 18: aload_1\n 19: invokevirtual #416 // Method java/lang/Long.longValue:()J\n 22: ladd\n 23: invokestatic #136 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 26: areturn\n\n private static final java.lang.Long doIteration$lambda$15$lambda$14(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 #421, 3 // InterfaceMethod kotlin/jvm/functions/Function2.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 8: checkcast #132 // class java/lang/Long\n 11: areturn\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day14\n 3: dup\n 4: invokespecial #426 // Method \"<init>\":()V\n 7: putstatic #149 // Field INSTANCE:Lorg/aoc2021/Day14;\n 10: return\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day4.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
class Board(boardLines: List<String>) {
companion object {
const val boardSize = 5
}
private val board: List<List<Int>>
private val chosenNumbers: Array<Array<Boolean>> = Array(boardSize) { Array(boardSize) { false } }
private val numberToPosition: Map<Int, Pair<Int, Int>>
init {
board = boardLines.drop(1).map { line ->
line.split(Regex(" +")).filter(String::isNotBlank).map(String::toInt)
}
numberToPosition = board.flatMapIndexed { i, row ->
row.mapIndexed { j, number -> number to (i to j) }
}.toMap()
}
fun processNumber(number: Int) {
numberToPosition[number]?.let { (i, j) ->
chosenNumbers[i][j] = true
}
}
private fun checkRows(): Boolean {
return chosenNumbers.any { row ->
row.all { it }
}
}
private fun checkColumns(): Boolean {
return (0 until boardSize).any { j ->
(0 until boardSize).all { i ->
chosenNumbers[i][j]
}
}
}
fun checkWin() = checkRows() || checkColumns()
fun sumUnmarkedNumbers(): Int {
return board.mapIndexed { i, row ->
row.filterIndexed { j, _ -> !chosenNumbers[i][j] }.sum()
}.sum()
}
}
object Day4 {
private fun solvePart1(filename: String): Int {
val lines = Files.readAllLines(Path.of(filename), Charsets.UTF_8)
val chosenNumbers = lines[0].split(",").map(String::toInt)
val boards = parseBoards(lines)
chosenNumbers.forEach { chosenNumber ->
boards.forEach { board ->
board.processNumber(chosenNumber)
if (board.checkWin()) {
return chosenNumber * board.sumUnmarkedNumbers()
}
}
}
throw IllegalArgumentException("no winning boards found")
}
private fun solvePart2(filename: String): Int {
val lines = Files.readAllLines(Path.of(filename), Charsets.UTF_8)
val chosenNumbers = lines[0].split(",").map(String::toInt)
val boards = parseBoards(lines)
return findSolution(chosenNumbers, boards)
}
private fun parseBoards(lines: List<String>): List<Board> {
return lines.drop(1).chunked(Board.boardSize + 1, ::Board)
}
private tailrec fun findSolution(chosenNumbers: List<Int>, boards: List<Board>): Int {
val chosenNumber = chosenNumbers[0]
boards.forEach { board ->
board.processNumber(chosenNumber)
}
if (boards.size == 1 && boards[0].checkWin()) {
return chosenNumber * boards[0].sumUnmarkedNumbers()
}
val remainingBoards = boards.filterNot(Board::checkWin)
return findSolution(chosenNumbers.drop(1), remainingBoards)
}
@JvmStatic
fun main(args: Array<String>) {
val filename = "input4.txt"
val solution1 = solvePart1(filename)
println(solution1)
val solution2 = solvePart2(filename)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day4.class",
"javap": "Compiled from \"Day4.kt\"\npublic final class org.aoc2021.Day4 {\n public static final org.aoc2021.Day4 INSTANCE;\n\n private org.aoc2021.Day4();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int solvePart1(java.lang.String);\n Code:\n 0: aload_1\n 1: iconst_0\n 2: anewarray #14 // class java/lang/String\n 5: invokestatic #20 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 8: getstatic #26 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 11: invokestatic #32 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 14: astore_2\n 15: aload_2\n 16: iconst_0\n 17: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 22: dup\n 23: ldc #40 // String get(...)\n 25: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 28: checkcast #48 // class java/lang/CharSequence\n 31: iconst_1\n 32: anewarray #14 // class java/lang/String\n 35: astore 4\n 37: aload 4\n 39: iconst_0\n 40: ldc #50 // String ,\n 42: aastore\n 43: aload 4\n 45: iconst_0\n 46: iconst_0\n 47: bipush 6\n 49: aconst_null\n 50: invokestatic #56 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 53: checkcast #58 // class java/lang/Iterable\n 56: astore 4\n 58: iconst_0\n 59: istore 5\n 61: aload 4\n 63: astore 6\n 65: new #60 // class java/util/ArrayList\n 68: dup\n 69: aload 4\n 71: bipush 10\n 73: invokestatic #66 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 76: invokespecial #69 // Method java/util/ArrayList.\"<init>\":(I)V\n 79: checkcast #71 // class java/util/Collection\n 82: astore 7\n 84: iconst_0\n 85: istore 8\n 87: aload 6\n 89: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 94: astore 9\n 96: aload 9\n 98: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 103: ifeq 150\n 106: aload 9\n 108: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 113: astore 10\n 115: aload 7\n 117: aload 10\n 119: checkcast #14 // class java/lang/String\n 122: astore 11\n 124: astore 17\n 126: iconst_0\n 127: istore 12\n 129: aload 11\n 131: invokestatic #90 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 134: nop\n 135: invokestatic #94 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 138: aload 17\n 140: swap\n 141: invokeinterface #98, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 146: pop\n 147: goto 96\n 150: aload 7\n 152: checkcast #34 // class java/util/List\n 155: nop\n 156: astore_3\n 157: aload_0\n 158: aload_2\n 159: invokestatic #102 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 162: aload_2\n 163: invokespecial #106 // Method parseBoards:(Ljava/util/List;)Ljava/util/List;\n 166: astore 4\n 168: aload_3\n 169: checkcast #58 // class java/lang/Iterable\n 172: astore 5\n 174: iconst_0\n 175: istore 6\n 177: aload 5\n 179: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 184: astore 7\n 186: aload 7\n 188: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 193: ifeq 301\n 196: aload 7\n 198: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 203: astore 8\n 205: aload 8\n 207: checkcast #108 // class java/lang/Number\n 210: invokevirtual #112 // Method java/lang/Number.intValue:()I\n 213: istore 9\n 215: iconst_0\n 216: istore 10\n 218: aload 4\n 220: checkcast #58 // class java/lang/Iterable\n 223: astore 11\n 225: iconst_0\n 226: istore 12\n 228: aload 11\n 230: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 235: astore 13\n 237: aload 13\n 239: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 244: ifeq 295\n 247: aload 13\n 249: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 254: astore 14\n 256: aload 14\n 258: checkcast #114 // class org/aoc2021/Board\n 261: astore 15\n 263: iconst_0\n 264: istore 16\n 266: aload 15\n 268: iload 9\n 270: invokevirtual #117 // Method org/aoc2021/Board.processNumber:(I)V\n 273: aload 15\n 275: invokevirtual #120 // Method org/aoc2021/Board.checkWin:()Z\n 278: ifeq 290\n 281: iload 9\n 283: aload 15\n 285: invokevirtual #123 // Method org/aoc2021/Board.sumUnmarkedNumbers:()I\n 288: imul\n 289: ireturn\n 290: nop\n 291: nop\n 292: goto 237\n 295: nop\n 296: nop\n 297: nop\n 298: goto 186\n 301: nop\n 302: new #125 // class java/lang/IllegalArgumentException\n 305: dup\n 306: ldc #127 // String no winning boards found\n 308: invokespecial #130 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 311: athrow\n\n private final int solvePart2(java.lang.String);\n Code:\n 0: aload_1\n 1: iconst_0\n 2: anewarray #14 // class java/lang/String\n 5: invokestatic #20 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 8: getstatic #26 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 11: invokestatic #32 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 14: astore_2\n 15: aload_2\n 16: iconst_0\n 17: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 22: dup\n 23: ldc #40 // String get(...)\n 25: invokestatic #46 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 28: checkcast #48 // class java/lang/CharSequence\n 31: iconst_1\n 32: anewarray #14 // class java/lang/String\n 35: astore 4\n 37: aload 4\n 39: iconst_0\n 40: ldc #50 // String ,\n 42: aastore\n 43: aload 4\n 45: iconst_0\n 46: iconst_0\n 47: bipush 6\n 49: aconst_null\n 50: invokestatic #56 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 53: checkcast #58 // class java/lang/Iterable\n 56: astore 4\n 58: iconst_0\n 59: istore 5\n 61: aload 4\n 63: astore 6\n 65: new #60 // class java/util/ArrayList\n 68: dup\n 69: aload 4\n 71: bipush 10\n 73: invokestatic #66 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 76: invokespecial #69 // Method java/util/ArrayList.\"<init>\":(I)V\n 79: checkcast #71 // class java/util/Collection\n 82: astore 7\n 84: iconst_0\n 85: istore 8\n 87: aload 6\n 89: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 94: astore 9\n 96: aload 9\n 98: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 103: ifeq 150\n 106: aload 9\n 108: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 113: astore 10\n 115: aload 7\n 117: aload 10\n 119: checkcast #14 // class java/lang/String\n 122: astore 11\n 124: astore 13\n 126: iconst_0\n 127: istore 12\n 129: aload 11\n 131: invokestatic #90 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 134: nop\n 135: invokestatic #94 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 138: aload 13\n 140: swap\n 141: invokeinterface #98, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 146: pop\n 147: goto 96\n 150: aload 7\n 152: checkcast #34 // class java/util/List\n 155: nop\n 156: astore_3\n 157: aload_0\n 158: aload_2\n 159: invokestatic #102 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 162: aload_2\n 163: invokespecial #106 // Method parseBoards:(Ljava/util/List;)Ljava/util/List;\n 166: astore 4\n 168: aload_0\n 169: aload_3\n 170: aload 4\n 172: invokespecial #161 // Method findSolution:(Ljava/util/List;Ljava/util/List;)I\n 175: ireturn\n\n private final java.util.List<org.aoc2021.Board> parseBoards(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #58 // class java/lang/Iterable\n 4: iconst_1\n 5: invokestatic #167 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 8: checkcast #58 // class java/lang/Iterable\n 11: bipush 6\n 13: getstatic #173 // Field org/aoc2021/Day4$parseBoards$1.INSTANCE:Lorg/aoc2021/Day4$parseBoards$1;\n 16: checkcast #175 // class kotlin/jvm/functions/Function1\n 19: invokestatic #179 // Method kotlin/collections/CollectionsKt.chunked:(Ljava/lang/Iterable;ILkotlin/jvm/functions/Function1;)Ljava/util/List;\n 22: areturn\n\n private final int findSolution(java.util.List<java.lang.Integer>, java.util.List<org.aoc2021.Board>);\n Code:\n 0: aload_0\n 1: astore_3\n 2: aload_1\n 3: iconst_0\n 4: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 9: checkcast #108 // class java/lang/Number\n 12: invokevirtual #112 // Method java/lang/Number.intValue:()I\n 15: istore 4\n 17: aload_2\n 18: checkcast #58 // class java/lang/Iterable\n 21: astore 5\n 23: iconst_0\n 24: istore 6\n 26: aload 5\n 28: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 33: astore 7\n 35: aload 7\n 37: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 42: ifeq 76\n 45: aload 7\n 47: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 52: astore 8\n 54: aload 8\n 56: checkcast #114 // class org/aoc2021/Board\n 59: astore 9\n 61: iconst_0\n 62: istore 10\n 64: aload 9\n 66: iload 4\n 68: invokevirtual #117 // Method org/aoc2021/Board.processNumber:(I)V\n 71: nop\n 72: nop\n 73: goto 35\n 76: nop\n 77: aload_2\n 78: invokeinterface #183, 1 // InterfaceMethod java/util/List.size:()I\n 83: iconst_1\n 84: if_icmpne 120\n 87: aload_2\n 88: iconst_0\n 89: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 94: checkcast #114 // class org/aoc2021/Board\n 97: invokevirtual #120 // Method org/aoc2021/Board.checkWin:()Z\n 100: ifeq 120\n 103: iload 4\n 105: aload_2\n 106: iconst_0\n 107: invokeinterface #38, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 112: checkcast #114 // class org/aoc2021/Board\n 115: invokevirtual #123 // Method org/aoc2021/Board.sumUnmarkedNumbers:()I\n 118: imul\n 119: ireturn\n 120: aload_2\n 121: checkcast #58 // class java/lang/Iterable\n 124: astore 6\n 126: iconst_0\n 127: istore 7\n 129: aload 6\n 131: astore 8\n 133: new #60 // class java/util/ArrayList\n 136: dup\n 137: invokespecial #184 // Method java/util/ArrayList.\"<init>\":()V\n 140: checkcast #71 // class java/util/Collection\n 143: astore 9\n 145: iconst_0\n 146: istore 10\n 148: aload 8\n 150: invokeinterface #75, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 155: astore 11\n 157: aload 11\n 159: invokeinterface #81, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 164: ifeq 207\n 167: aload 11\n 169: invokeinterface #85, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 174: astore 12\n 176: aload 12\n 178: checkcast #114 // class org/aoc2021/Board\n 181: astore 13\n 183: iconst_0\n 184: istore 14\n 186: aload 13\n 188: invokevirtual #120 // Method org/aoc2021/Board.checkWin:()Z\n 191: ifne 157\n 194: aload 9\n 196: aload 12\n 198: invokeinterface #98, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 203: pop\n 204: goto 157\n 207: aload 9\n 209: checkcast #34 // class java/util/List\n 212: nop\n 213: astore 5\n 215: aload_3\n 216: astore 6\n 218: aload_1\n 219: checkcast #58 // class java/lang/Iterable\n 222: iconst_1\n 223: invokestatic #167 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 226: astore 7\n 228: aload 6\n 230: astore_3\n 231: aload 7\n 233: astore_1\n 234: aload 5\n 236: astore_2\n 237: goto 2\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #198 // String args\n 3: invokestatic #201 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #203 // String input4.txt\n 8: astore_1\n 9: getstatic #205 // Field INSTANCE:Lorg/aoc2021/Day4;\n 12: aload_1\n 13: invokespecial #207 // Method solvePart1:(Ljava/lang/String;)I\n 16: istore_2\n 17: getstatic #213 // Field java/lang/System.out:Ljava/io/PrintStream;\n 20: iload_2\n 21: invokevirtual #218 // Method java/io/PrintStream.println:(I)V\n 24: getstatic #205 // Field INSTANCE:Lorg/aoc2021/Day4;\n 27: aload_1\n 28: invokespecial #220 // Method solvePart2:(Ljava/lang/String;)I\n 31: istore_3\n 32: getstatic #213 // Field java/lang/System.out:Ljava/io/PrintStream;\n 35: iload_3\n 36: invokevirtual #218 // Method java/io/PrintStream.println:(I)V\n 39: return\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day4\n 3: dup\n 4: invokespecial #225 // Method \"<init>\":()V\n 7: putstatic #205 // Field INSTANCE:Lorg/aoc2021/Day4;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day4$parseBoards$1.class",
"javap": "Compiled from \"Day4.kt\"\nfinal class org.aoc2021.Day4$parseBoards$1 extends kotlin.jvm.internal.FunctionReferenceImpl implements kotlin.jvm.functions.Function1<java.util.List<? extends java.lang.String>, org.aoc2021.Board> {\n public static final org.aoc2021.Day4$parseBoards$1 INSTANCE;\n\n org.aoc2021.Day4$parseBoards$1();\n Code:\n 0: aload_0\n 1: iconst_1\n 2: ldc #11 // class org/aoc2021/Board\n 4: ldc #12 // String <init>\n 6: ldc #14 // String <init>(Ljava/util/List;)V\n 8: iconst_0\n 9: invokespecial #17 // Method kotlin/jvm/internal/FunctionReferenceImpl.\"<init>\":(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V\n 12: return\n\n public final org.aoc2021.Board invoke(java.util.List<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: new #11 // class org/aoc2021/Board\n 9: dup\n 10: aload_1\n 11: invokespecial #33 // Method org/aoc2021/Board.\"<init>\":(Ljava/util/List;)V\n 14: 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/List\n 5: invokevirtual #39 // Method invoke:(Ljava/util/List;)Lorg/aoc2021/Board;\n 8: areturn\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day4$parseBoards$1\n 3: dup\n 4: invokespecial #44 // Method \"<init>\":()V\n 7: putstatic #47 // Field INSTANCE:Lorg/aoc2021/Day4$parseBoards$1;\n 10: return\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day10.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
object Day10 {
private val values = mapOf(
')' to 3,
']' to 57,
'}' to 1197,
'>' to 25137,
)
private fun solvePart1(lines: List<String>): Int {
return lines.sumOf { line ->
doLine(line)
}
}
private fun solvePart2(lines: List<String>): Long {
val scores = lines.filter { doLine(it) == 0 }
.map { line ->
solveIncompleteLine(line)
}
.sorted()
return scores[scores.size / 2]
}
private fun doLine(line: String): Int {
val chars = mutableListOf<Char>()
for (c in line) {
if (c in setOf('(', '[', '{', '<')) {
chars.add(c)
} else if (chars.isEmpty()) {
return values[c]!!
} else {
if (
(c == ')' && chars.last() != '(') ||
(c == ']' && chars.last() != '[') ||
(c == '}' && chars.last() != '{') ||
(c == '>' && chars.last() != '<')
) {
return values[c]!!
}
chars.removeLast()
}
}
return 0
}
private fun solveIncompleteLine(line: String): Long {
val chars = mutableListOf<Char>()
for (c in line) {
if (c in setOf('(', '[', '{', '<')) {
chars.add(c)
} else {
chars.removeLast()
}
}
return chars.reversed().fold(0L) { p, c ->
5 * p + when (c) {
'(' -> 1
'[' -> 2
'{' -> 3
'<' -> 4
else -> throw IllegalArgumentException("$c")
}
}
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input10.txt"), Charsets.UTF_8)
val solution1 = solvePart1(lines)
println(solution1)
val solution2 = solvePart2(lines)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day10.class",
"javap": "Compiled from \"Day10.kt\"\npublic final class org.aoc2021.Day10 {\n public static final org.aoc2021.Day10 INSTANCE;\n\n private static final java.util.Map<java.lang.Character, java.lang.Integer> values;\n\n private org.aoc2021.Day10();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int solvePart1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #15 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore 4\n 15: aload 4\n 17: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 22: ifeq 66\n 25: aload 4\n 27: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 32: astore 5\n 34: iload_3\n 35: aload 5\n 37: checkcast #31 // class java/lang/String\n 40: astore 6\n 42: istore 8\n 44: iconst_0\n 45: istore 7\n 47: getstatic #34 // Field INSTANCE:Lorg/aoc2021/Day10;\n 50: aload 6\n 52: invokespecial #38 // Method doLine:(Ljava/lang/String;)I\n 55: istore 9\n 57: iload 8\n 59: iload 9\n 61: iadd\n 62: istore_3\n 63: goto 15\n 66: iload_3\n 67: ireturn\n\n private final long solvePart2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #15 // 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 #49 // class java/util/ArrayList\n 14: dup\n 15: invokespecial #50 // Method java/util/ArrayList.\"<init>\":()V\n 18: checkcast #52 // class java/util/Collection\n 21: astore 6\n 23: iconst_0\n 24: istore 7\n 26: aload 5\n 28: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 33: astore 8\n 35: aload 8\n 37: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 42: ifeq 96\n 45: aload 8\n 47: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 52: astore 9\n 54: aload 9\n 56: checkcast #31 // class java/lang/String\n 59: astore 10\n 61: iconst_0\n 62: istore 11\n 64: getstatic #34 // Field INSTANCE:Lorg/aoc2021/Day10;\n 67: aload 10\n 69: invokespecial #38 // Method doLine:(Ljava/lang/String;)I\n 72: ifne 79\n 75: iconst_1\n 76: goto 80\n 79: iconst_0\n 80: ifeq 35\n 83: aload 6\n 85: aload 9\n 87: invokeinterface #56, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 92: pop\n 93: goto 35\n 96: aload 6\n 98: checkcast #58 // class java/util/List\n 101: nop\n 102: checkcast #15 // class java/lang/Iterable\n 105: astore_3\n 106: nop\n 107: iconst_0\n 108: istore 4\n 110: aload_3\n 111: astore 5\n 113: new #49 // class java/util/ArrayList\n 116: dup\n 117: aload_3\n 118: bipush 10\n 120: invokestatic #64 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 123: invokespecial #67 // Method java/util/ArrayList.\"<init>\":(I)V\n 126: checkcast #52 // class java/util/Collection\n 129: astore 6\n 131: iconst_0\n 132: istore 7\n 134: aload 5\n 136: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 141: astore 8\n 143: aload 8\n 145: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 150: ifeq 199\n 153: aload 8\n 155: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 160: astore 9\n 162: aload 6\n 164: aload 9\n 166: checkcast #31 // class java/lang/String\n 169: astore 10\n 171: astore 12\n 173: iconst_0\n 174: istore 11\n 176: getstatic #34 // Field INSTANCE:Lorg/aoc2021/Day10;\n 179: aload 10\n 181: invokespecial #71 // Method solveIncompleteLine:(Ljava/lang/String;)J\n 184: invokestatic #77 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 187: aload 12\n 189: swap\n 190: invokeinterface #56, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 195: pop\n 196: goto 143\n 199: aload 6\n 201: checkcast #58 // class java/util/List\n 204: nop\n 205: checkcast #15 // class java/lang/Iterable\n 208: invokestatic #81 // Method kotlin/collections/CollectionsKt.sorted:(Ljava/lang/Iterable;)Ljava/util/List;\n 211: astore_2\n 212: aload_2\n 213: aload_2\n 214: invokeinterface #85, 1 // InterfaceMethod java/util/List.size:()I\n 219: iconst_2\n 220: idiv\n 221: invokeinterface #89, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 226: checkcast #91 // class java/lang/Number\n 229: invokevirtual #95 // Method java/lang/Number.longValue:()J\n 232: lreturn\n\n private final int doLine(java.lang.String);\n Code:\n 0: new #49 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #50 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #58 // class java/util/List\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_1\n 14: invokevirtual #116 // Method java/lang/String.length:()I\n 17: istore 4\n 19: iload_3\n 20: iload 4\n 22: if_icmpge 271\n 25: aload_1\n 26: iload_3\n 27: invokevirtual #120 // Method java/lang/String.charAt:(I)C\n 30: istore 5\n 32: iconst_4\n 33: anewarray #122 // class java/lang/Character\n 36: astore 6\n 38: aload 6\n 40: iconst_0\n 41: bipush 40\n 43: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 46: aastore\n 47: aload 6\n 49: iconst_1\n 50: bipush 91\n 52: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 55: aastore\n 56: aload 6\n 58: iconst_2\n 59: bipush 123\n 61: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 64: aastore\n 65: aload 6\n 67: iconst_3\n 68: bipush 60\n 70: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 73: aastore\n 74: aload 6\n 76: invokestatic #131 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 79: iload 5\n 81: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 84: invokeinterface #136, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 89: ifeq 107\n 92: aload_2\n 93: iload 5\n 95: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 98: invokeinterface #137, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 103: pop\n 104: goto 265\n 107: aload_2\n 108: invokeinterface #140, 1 // InterfaceMethod java/util/List.isEmpty:()Z\n 113: ifeq 140\n 116: getstatic #144 // Field values:Ljava/util/Map;\n 119: iload 5\n 121: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 124: invokeinterface #149, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 129: dup\n 130: invokestatic #155 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 133: checkcast #91 // class java/lang/Number\n 136: invokevirtual #158 // Method java/lang/Number.intValue:()I\n 139: ireturn\n 140: iload 5\n 142: bipush 41\n 144: if_icmpne 162\n 147: aload_2\n 148: invokestatic #162 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 151: checkcast #122 // class java/lang/Character\n 154: invokevirtual #166 // Method java/lang/Character.charValue:()C\n 157: bipush 40\n 159: if_icmpne 228\n 162: iload 5\n 164: bipush 93\n 166: if_icmpne 184\n 169: aload_2\n 170: invokestatic #162 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 173: checkcast #122 // class java/lang/Character\n 176: invokevirtual #166 // Method java/lang/Character.charValue:()C\n 179: bipush 91\n 181: if_icmpne 228\n 184: iload 5\n 186: bipush 125\n 188: if_icmpne 206\n 191: aload_2\n 192: invokestatic #162 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 195: checkcast #122 // class java/lang/Character\n 198: invokevirtual #166 // Method java/lang/Character.charValue:()C\n 201: bipush 123\n 203: if_icmpne 228\n 206: iload 5\n 208: bipush 62\n 210: if_icmpne 252\n 213: aload_2\n 214: invokestatic #162 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 217: checkcast #122 // class java/lang/Character\n 220: invokevirtual #166 // Method java/lang/Character.charValue:()C\n 223: bipush 60\n 225: if_icmpeq 252\n 228: getstatic #144 // Field values:Ljava/util/Map;\n 231: iload 5\n 233: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 236: invokeinterface #149, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 241: dup\n 242: invokestatic #155 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 245: checkcast #91 // class java/lang/Number\n 248: invokevirtual #158 // Method java/lang/Number.intValue:()I\n 251: ireturn\n 252: aload_2\n 253: invokeinterface #169, 1 // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;\n 258: astore 6\n 260: aload 6\n 262: invokestatic #155 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 265: iinc 3, 1\n 268: goto 19\n 271: iconst_0\n 272: ireturn\n\n private final long solveIncompleteLine(java.lang.String);\n Code:\n 0: new #49 // class java/util/ArrayList\n 3: dup\n 4: invokespecial #50 // Method java/util/ArrayList.\"<init>\":()V\n 7: checkcast #58 // class java/util/List\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_1\n 14: invokevirtual #116 // Method java/lang/String.length:()I\n 17: istore 4\n 19: iload_3\n 20: iload 4\n 22: if_icmpge 126\n 25: aload_1\n 26: iload_3\n 27: invokevirtual #120 // Method java/lang/String.charAt:(I)C\n 30: istore 6\n 32: iconst_4\n 33: anewarray #122 // class java/lang/Character\n 36: astore 7\n 38: aload 7\n 40: iconst_0\n 41: bipush 40\n 43: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 46: aastore\n 47: aload 7\n 49: iconst_1\n 50: bipush 91\n 52: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 55: aastore\n 56: aload 7\n 58: iconst_2\n 59: bipush 123\n 61: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 64: aastore\n 65: aload 7\n 67: iconst_3\n 68: bipush 60\n 70: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 73: aastore\n 74: aload 7\n 76: invokestatic #131 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 79: iload 6\n 81: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 84: invokeinterface #136, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 89: ifeq 107\n 92: aload_2\n 93: iload 6\n 95: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 98: invokeinterface #137, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 103: pop\n 104: goto 120\n 107: aload_2\n 108: invokeinterface #169, 1 // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;\n 113: astore 7\n 115: aload 7\n 117: invokestatic #155 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 120: iinc 3, 1\n 123: goto 19\n 126: aload_2\n 127: checkcast #15 // class java/lang/Iterable\n 130: invokestatic #177 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 133: checkcast #15 // class java/lang/Iterable\n 136: astore_3\n 137: lconst_0\n 138: lstore 4\n 140: iconst_0\n 141: istore 6\n 143: lload 4\n 145: lstore 7\n 147: aload_3\n 148: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 153: astore 9\n 155: aload 9\n 157: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 162: ifeq 277\n 165: aload 9\n 167: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 172: astore 10\n 174: lload 7\n 176: aload 10\n 178: checkcast #122 // class java/lang/Character\n 181: invokevirtual #166 // Method java/lang/Character.charValue:()C\n 184: istore 11\n 186: lstore 12\n 188: iconst_0\n 189: istore 14\n 191: iconst_5\n 192: i2l\n 193: lload 12\n 195: lmul\n 196: iload 11\n 198: lookupswitch { // 4\n 40: 240\n 60: 252\n 91: 244\n 123: 248\n default: 256\n }\n 240: iconst_1\n 241: goto 269\n 244: iconst_2\n 245: goto 269\n 248: iconst_3\n 249: goto 269\n 252: iconst_4\n 253: goto 269\n 256: new #179 // class java/lang/IllegalArgumentException\n 259: dup\n 260: iload 11\n 262: invokestatic #182 // Method java/lang/String.valueOf:(C)Ljava/lang/String;\n 265: invokespecial #185 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 268: athrow\n 269: i2l\n 270: ladd\n 271: nop\n 272: lstore 7\n 274: goto 155\n 277: lload 7\n 279: lreturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #199 // String args\n 3: invokestatic #203 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #205 // String input10.txt\n 8: iconst_0\n 9: anewarray #31 // class java/lang/String\n 12: invokestatic #211 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 15: getstatic #217 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 18: invokestatic #223 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 21: astore_1\n 22: getstatic #34 // Field INSTANCE:Lorg/aoc2021/Day10;\n 25: aload_1\n 26: invokestatic #155 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 29: aload_1\n 30: invokespecial #225 // Method solvePart1:(Ljava/util/List;)I\n 33: istore_2\n 34: getstatic #231 // Field java/lang/System.out:Ljava/io/PrintStream;\n 37: iload_2\n 38: invokevirtual #236 // Method java/io/PrintStream.println:(I)V\n 41: getstatic #34 // Field INSTANCE:Lorg/aoc2021/Day10;\n 44: aload_1\n 45: invokespecial #238 // Method solvePart2:(Ljava/util/List;)J\n 48: lstore_3\n 49: getstatic #231 // Field java/lang/System.out:Ljava/io/PrintStream;\n 52: lload_3\n 53: invokevirtual #241 // Method java/io/PrintStream.println:(J)V\n 56: return\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day10\n 3: dup\n 4: invokespecial #246 // Method \"<init>\":()V\n 7: putstatic #34 // Field INSTANCE:Lorg/aoc2021/Day10;\n 10: iconst_4\n 11: anewarray #248 // class kotlin/Pair\n 14: astore_0\n 15: aload_0\n 16: iconst_0\n 17: bipush 41\n 19: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 22: iconst_3\n 23: invokestatic #253 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 26: invokestatic #259 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 29: aastore\n 30: aload_0\n 31: iconst_1\n 32: bipush 93\n 34: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 37: bipush 57\n 39: invokestatic #253 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 42: invokestatic #259 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 45: aastore\n 46: aload_0\n 47: iconst_2\n 48: bipush 125\n 50: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 53: sipush 1197\n 56: invokestatic #253 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 59: invokestatic #259 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 62: aastore\n 63: aload_0\n 64: iconst_3\n 65: bipush 62\n 67: invokestatic #125 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 70: sipush 25137\n 73: invokestatic #253 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 76: invokestatic #259 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 79: aastore\n 80: aload_0\n 81: invokestatic #265 // Method kotlin/collections/MapsKt.mapOf:([Lkotlin/Pair;)Ljava/util/Map;\n 84: putstatic #144 // Field values:Ljava/util/Map;\n 87: return\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day12.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
object Day12 {
private fun solvePart1(lines: List<String>): Int {
val points = parseLines(lines)
return search("start", points)
}
private fun solvePart2(lines: List<String>): Int {
val points = parseLines(lines)
return searchPart2("start", points)
}
private fun parseLines(lines: List<String>): Map<String, List<String>> {
return lines.flatMap { line ->
val (b, e) = line.split("-")
listOf(b to e, e to b)
}
.groupBy(Pair<String, String>::first, Pair<String, String>::second)
}
private fun search(p: String, points: Map<String, List<String>>, visitedSmallCaves: Set<String> = setOf()): Int {
return points[p]!!.filter { edge ->
edge != "start" && !visitedSmallCaves.contains(edge)
}
.sumOf { edge ->
if (edge == "end") {
1
} else {
val newVisitedCaves = if (edge.all(Char::isLowerCase)) {
visitedSmallCaves.plus(edge)
} else {
visitedSmallCaves
}
search(edge, points, newVisitedCaves)
}
}
}
private fun searchPart2(
p: String,
points: Map<String, List<String>>,
visitedSmallCaves: Set<String> = setOf(),
visitedTwice: Boolean = false,
): Int {
return points[p]!!.filter { it != "start" }
.sumOf { edge ->
if (edge == "end") {
1
} else if (visitedSmallCaves.contains(edge) && visitedTwice) {
0
} else {
val newVisitedTwice = if (visitedSmallCaves.contains(edge)) true else visitedTwice
val newVisitedCaves = if (edge.all(Char::isLowerCase)) {
visitedSmallCaves.plus(edge)
} else {
visitedSmallCaves
}
searchPart2(edge, points, newVisitedCaves, newVisitedTwice)
}
}
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input12.txt"), Charsets.UTF_8)
val solution1 = solvePart1(lines)
println(solution1)
val solution2 = solvePart2(lines)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day12.class",
"javap": "Compiled from \"Day12.kt\"\npublic final class org.aoc2021.Day12 {\n public static final org.aoc2021.Day12 INSTANCE;\n\n private org.aoc2021.Day12();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int solvePart1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #17 // Method parseLines:(Ljava/util/List;)Ljava/util/Map;\n 5: astore_2\n 6: aload_0\n 7: ldc #19 // String start\n 9: aload_2\n 10: aconst_null\n 11: iconst_4\n 12: aconst_null\n 13: invokestatic #23 // Method search$default:(Lorg/aoc2021/Day12;Ljava/lang/String;Ljava/util/Map;Ljava/util/Set;ILjava/lang/Object;)I\n 16: ireturn\n\n private final int solvePart2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #17 // Method parseLines:(Ljava/util/List;)Ljava/util/Map;\n 5: astore_2\n 6: aload_0\n 7: ldc #19 // String start\n 9: aload_2\n 10: aconst_null\n 11: iconst_0\n 12: bipush 12\n 14: aconst_null\n 15: invokestatic #32 // Method searchPart2$default:(Lorg/aoc2021/Day12;Ljava/lang/String;Ljava/util/Map;Ljava/util/Set;ZILjava/lang/Object;)I\n 18: ireturn\n\n private final java.util.Map<java.lang.String, java.util.List<java.lang.String>> parseLines(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #35 // 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 #37 // class java/util/ArrayList\n 13: dup\n 14: invokespecial #38 // Method java/util/ArrayList.\"<init>\":()V\n 17: checkcast #40 // class java/util/Collection\n 20: astore 5\n 22: iconst_0\n 23: istore 6\n 25: aload 4\n 27: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 32: astore 7\n 34: aload 7\n 36: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 41: ifeq 167\n 44: aload 7\n 46: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 51: astore 8\n 53: aload 8\n 55: checkcast #56 // class java/lang/String\n 58: astore 9\n 60: iconst_0\n 61: istore 10\n 63: aload 9\n 65: checkcast #58 // class java/lang/CharSequence\n 68: iconst_1\n 69: anewarray #56 // class java/lang/String\n 72: astore 11\n 74: aload 11\n 76: iconst_0\n 77: ldc #60 // String -\n 79: aastore\n 80: aload 11\n 82: iconst_0\n 83: iconst_0\n 84: bipush 6\n 86: aconst_null\n 87: invokestatic #66 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 90: astore 12\n 92: aload 12\n 94: iconst_0\n 95: invokeinterface #72, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 100: checkcast #56 // class java/lang/String\n 103: astore 11\n 105: aload 12\n 107: iconst_1\n 108: invokeinterface #72, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 113: checkcast #56 // class java/lang/String\n 116: astore 13\n 118: iconst_2\n 119: anewarray #74 // class kotlin/Pair\n 122: astore 14\n 124: aload 14\n 126: iconst_0\n 127: aload 11\n 129: aload 13\n 131: invokestatic #80 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 134: aastore\n 135: aload 14\n 137: iconst_1\n 138: aload 13\n 140: aload 11\n 142: invokestatic #80 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 145: aastore\n 146: aload 14\n 148: invokestatic #86 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 151: checkcast #35 // class java/lang/Iterable\n 154: astore 9\n 156: aload 5\n 158: aload 9\n 160: invokestatic #90 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 163: pop\n 164: goto 34\n 167: aload 5\n 169: checkcast #68 // class java/util/List\n 172: nop\n 173: checkcast #35 // class java/lang/Iterable\n 176: astore_2\n 177: nop\n 178: iconst_0\n 179: istore_3\n 180: aload_2\n 181: astore 4\n 183: new #92 // class java/util/LinkedHashMap\n 186: dup\n 187: invokespecial #93 // Method java/util/LinkedHashMap.\"<init>\":()V\n 190: checkcast #95 // class java/util/Map\n 193: astore 5\n 195: iconst_0\n 196: istore 6\n 198: aload 4\n 200: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 205: astore 7\n 207: aload 7\n 209: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 214: ifeq 343\n 217: aload 7\n 219: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 224: astore 8\n 226: aload 8\n 228: checkcast #74 // class kotlin/Pair\n 231: astore 9\n 233: iconst_0\n 234: istore 10\n 236: aload 9\n 238: invokevirtual #98 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 241: checkcast #56 // class java/lang/String\n 244: astore 11\n 246: aload 5\n 248: astore 12\n 250: iconst_0\n 251: istore 13\n 253: aload 12\n 255: aload 11\n 257: invokeinterface #101, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 262: astore 14\n 264: aload 14\n 266: ifnonnull 301\n 269: iconst_0\n 270: istore 15\n 272: new #37 // class java/util/ArrayList\n 275: dup\n 276: invokespecial #38 // Method java/util/ArrayList.\"<init>\":()V\n 279: checkcast #68 // class java/util/List\n 282: astore 15\n 284: aload 12\n 286: aload 11\n 288: aload 15\n 290: invokeinterface #105, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 295: pop\n 296: aload 15\n 298: goto 303\n 301: aload 14\n 303: nop\n 304: checkcast #68 // class java/util/List\n 307: astore 9\n 309: aload 9\n 311: aload 8\n 313: checkcast #74 // class kotlin/Pair\n 316: astore 10\n 318: astore 17\n 320: iconst_0\n 321: istore 16\n 323: aload 10\n 325: invokevirtual #108 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 328: checkcast #56 // class java/lang/String\n 331: aload 17\n 333: swap\n 334: invokeinterface #112, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 339: pop\n 340: goto 207\n 343: aload 5\n 345: nop\n 346: areturn\n\n private final int search(java.lang.String, java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>, java.util.Set<java.lang.String>);\n Code:\n 0: aload_2\n 1: aload_1\n 2: invokeinterface #101, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: dup\n 8: invokestatic #151 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 11: checkcast #35 // class java/lang/Iterable\n 14: astore 4\n 16: iconst_0\n 17: istore 5\n 19: aload 4\n 21: astore 6\n 23: new #37 // class java/util/ArrayList\n 26: dup\n 27: invokespecial #38 // Method java/util/ArrayList.\"<init>\":()V\n 30: checkcast #40 // class java/util/Collection\n 33: astore 7\n 35: iconst_0\n 36: istore 8\n 38: aload 6\n 40: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 9\n 47: aload 9\n 49: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 118\n 57: aload 9\n 59: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 10\n 66: aload 10\n 68: checkcast #56 // class java/lang/String\n 71: astore 11\n 73: iconst_0\n 74: istore 12\n 76: aload 11\n 78: ldc #19 // String start\n 80: invokestatic #155 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 83: ifne 101\n 86: aload_3\n 87: aload 11\n 89: invokeinterface #160, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 94: ifne 101\n 97: iconst_1\n 98: goto 102\n 101: iconst_0\n 102: ifeq 47\n 105: aload 7\n 107: aload 10\n 109: invokeinterface #161, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 114: pop\n 115: goto 47\n 118: aload 7\n 120: checkcast #68 // class java/util/List\n 123: nop\n 124: checkcast #35 // class java/lang/Iterable\n 127: astore 4\n 129: iconst_0\n 130: istore 5\n 132: aload 4\n 134: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 139: astore 6\n 141: aload 6\n 143: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 148: ifeq 290\n 151: aload 6\n 153: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 158: astore 7\n 160: iload 5\n 162: aload 7\n 164: checkcast #56 // class java/lang/String\n 167: astore 8\n 169: istore 17\n 171: iconst_0\n 172: istore 9\n 174: aload 8\n 176: ldc #163 // String end\n 178: invokestatic #155 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 181: ifeq 188\n 184: iconst_1\n 185: goto 277\n 188: aload 8\n 190: checkcast #58 // class java/lang/CharSequence\n 193: astore 10\n 195: iconst_0\n 196: istore 11\n 198: iconst_0\n 199: istore 12\n 201: iload 12\n 203: aload 10\n 205: invokeinterface #167, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 210: if_icmpge 250\n 213: aload 10\n 215: iload 12\n 217: invokeinterface #171, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 222: istore 13\n 224: iload 13\n 226: istore 14\n 228: iconst_0\n 229: istore 15\n 231: iload 14\n 233: invokestatic #177 // Method java/lang/Character.isLowerCase:(C)Z\n 236: nop\n 237: ifne 244\n 240: iconst_0\n 241: goto 251\n 244: iinc 12, 1\n 247: goto 201\n 250: iconst_1\n 251: ifeq 263\n 254: aload_3\n 255: aload 8\n 257: invokestatic #183 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Object;)Ljava/util/Set;\n 260: goto 264\n 263: aload_3\n 264: astore 16\n 266: getstatic #186 // Field INSTANCE:Lorg/aoc2021/Day12;\n 269: aload 8\n 271: aload_2\n 272: aload 16\n 274: invokespecial #188 // Method search:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Set;)I\n 277: nop\n 278: istore 18\n 280: iload 17\n 282: iload 18\n 284: iadd\n 285: istore 5\n 287: goto 141\n 290: iload 5\n 292: ireturn\n\n static int search$default(org.aoc2021.Day12, java.lang.String, java.util.Map, java.util.Set, int, java.lang.Object);\n Code:\n 0: iload 4\n 2: iconst_4\n 3: iand\n 4: ifeq 11\n 7: invokestatic #209 // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;\n 10: astore_3\n 11: aload_0\n 12: aload_1\n 13: aload_2\n 14: aload_3\n 15: invokespecial #188 // Method search:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Set;)I\n 18: ireturn\n\n private final int searchPart2(java.lang.String, java.util.Map<java.lang.String, ? extends java.util.List<java.lang.String>>, java.util.Set<java.lang.String>, boolean);\n Code:\n 0: aload_2\n 1: aload_1\n 2: invokeinterface #101, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: dup\n 8: invokestatic #151 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 11: checkcast #35 // class java/lang/Iterable\n 14: astore 5\n 16: iconst_0\n 17: istore 6\n 19: aload 5\n 21: astore 7\n 23: new #37 // class java/util/ArrayList\n 26: dup\n 27: invokespecial #38 // Method java/util/ArrayList.\"<init>\":()V\n 30: checkcast #40 // class java/util/Collection\n 33: astore 8\n 35: iconst_0\n 36: istore 9\n 38: aload 7\n 40: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 10\n 47: aload 10\n 49: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 107\n 57: aload 10\n 59: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 11\n 66: aload 11\n 68: checkcast #56 // class java/lang/String\n 71: astore 12\n 73: iconst_0\n 74: istore 13\n 76: aload 12\n 78: ldc #19 // String start\n 80: invokestatic #155 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 83: ifne 90\n 86: iconst_1\n 87: goto 91\n 90: iconst_0\n 91: ifeq 47\n 94: aload 8\n 96: aload 11\n 98: invokeinterface #161, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 103: pop\n 104: goto 47\n 107: aload 8\n 109: checkcast #68 // class java/util/List\n 112: nop\n 113: checkcast #35 // class java/lang/Iterable\n 116: astore 5\n 118: iconst_0\n 119: istore 6\n 121: aload 5\n 123: invokeinterface #44, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 128: astore 7\n 130: aload 7\n 132: invokeinterface #50, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 137: ifeq 320\n 140: aload 7\n 142: invokeinterface #54, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 147: astore 8\n 149: iload 6\n 151: aload 8\n 153: checkcast #56 // class java/lang/String\n 156: astore 9\n 158: istore 19\n 160: iconst_0\n 161: istore 10\n 163: aload 9\n 165: ldc #163 // String end\n 167: invokestatic #155 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 170: ifeq 177\n 173: iconst_1\n 174: goto 307\n 177: aload_3\n 178: aload 9\n 180: invokeinterface #160, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 185: ifeq 197\n 188: iload 4\n 190: ifeq 197\n 193: iconst_0\n 194: goto 307\n 197: aload_3\n 198: aload 9\n 200: invokeinterface #160, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 205: ifeq 212\n 208: iconst_1\n 209: goto 214\n 212: iload 4\n 214: istore 11\n 216: aload 9\n 218: checkcast #58 // class java/lang/CharSequence\n 221: astore 12\n 223: iconst_0\n 224: istore 13\n 226: iconst_0\n 227: istore 14\n 229: iload 14\n 231: aload 12\n 233: invokeinterface #167, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 238: if_icmpge 278\n 241: aload 12\n 243: iload 14\n 245: invokeinterface #171, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 250: istore 15\n 252: iload 15\n 254: istore 16\n 256: iconst_0\n 257: istore 17\n 259: iload 16\n 261: invokestatic #177 // Method java/lang/Character.isLowerCase:(C)Z\n 264: nop\n 265: ifne 272\n 268: iconst_0\n 269: goto 279\n 272: iinc 14, 1\n 275: goto 229\n 278: iconst_1\n 279: ifeq 291\n 282: aload_3\n 283: aload 9\n 285: invokestatic #183 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Object;)Ljava/util/Set;\n 288: goto 292\n 291: aload_3\n 292: astore 18\n 294: getstatic #186 // Field INSTANCE:Lorg/aoc2021/Day12;\n 297: aload 9\n 299: aload_2\n 300: aload 18\n 302: iload 11\n 304: invokespecial #214 // Method searchPart2:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Set;Z)I\n 307: nop\n 308: istore 20\n 310: iload 19\n 312: iload 20\n 314: iadd\n 315: istore 6\n 317: goto 130\n 320: iload 6\n 322: ireturn\n\n static int searchPart2$default(org.aoc2021.Day12, java.lang.String, java.util.Map, java.util.Set, boolean, int, java.lang.Object);\n Code:\n 0: iload 5\n 2: iconst_4\n 3: iand\n 4: ifeq 11\n 7: invokestatic #209 // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;\n 10: astore_3\n 11: iload 5\n 13: bipush 8\n 15: iand\n 16: ifeq 22\n 19: iconst_0\n 20: istore 4\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: aload_3\n 26: iload 4\n 28: invokespecial #214 // Method searchPart2:(Ljava/lang/String;Ljava/util/Map;Ljava/util/Set;Z)I\n 31: ireturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #227 // String args\n 3: invokestatic #231 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #233 // String input12.txt\n 8: iconst_0\n 9: anewarray #56 // class java/lang/String\n 12: invokestatic #239 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 15: getstatic #245 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 18: invokestatic #251 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 21: astore_1\n 22: getstatic #186 // Field INSTANCE:Lorg/aoc2021/Day12;\n 25: aload_1\n 26: invokestatic #151 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 29: aload_1\n 30: invokespecial #253 // Method solvePart1:(Ljava/util/List;)I\n 33: istore_2\n 34: getstatic #259 // Field java/lang/System.out:Ljava/io/PrintStream;\n 37: iload_2\n 38: invokevirtual #265 // Method java/io/PrintStream.println:(I)V\n 41: getstatic #186 // Field INSTANCE:Lorg/aoc2021/Day12;\n 44: aload_1\n 45: invokespecial #267 // Method solvePart2:(Ljava/util/List;)I\n 48: istore_3\n 49: getstatic #259 // Field java/lang/System.out:Ljava/io/PrintStream;\n 52: iload_3\n 53: invokevirtual #265 // Method java/io/PrintStream.println:(I)V\n 56: return\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day12\n 3: dup\n 4: invokespecial #272 // Method \"<init>\":()V\n 7: putstatic #186 // Field INSTANCE:Lorg/aoc2021/Day12;\n 10: return\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day21.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
import kotlin.math.max
object Day21 {
data class Key(val p1Pos: Int, val p1Score: Int, val p2Pos: Int, val p2Score: Int, val isP1Turn: Boolean)
private fun solvePart1(lines: List<String>): Int {
var (p1Pos, p2Pos) = parseStartingPositions(lines)
var die = 1
var rolls = 0
var p1Score = 0
var p2Score = 0
while (true) {
(1..3).forEach { _ ->
p1Pos += die
die = (die % 100) + 1
rolls++
}
p1Pos = ((p1Pos - 1) % 10) + 1
p1Score += p1Pos
if (p1Score >= 1000) {
return rolls * p2Score
}
(1..3).forEach { _ ->
p2Pos += die
die = (die % 100) + 1
rolls++
}
p2Pos = ((p2Pos - 1) % 10) + 1
p2Score += p2Pos
if (p2Score >= 1000) {
return rolls * p1Score
}
}
}
private fun solvePart2(lines: List<String>): Long {
val (start1, start2) = parseStartingPositions(lines)
val (p1Wins, p2Wins) = computeWinningUniverses(Key(start1, 0, start2, 0, true))
return max(p1Wins, p2Wins)
}
private fun computeWinningUniverses(
key: Key,
memoizedResults: MutableMap<Key, Pair<Long, Long>> = mutableMapOf(),
): Pair<Long, Long> {
memoizedResults[key]?.let { return it }
if (key.p1Score >= 21) {
return 1L to 0L
}
if (key.p2Score >= 21) {
return 0L to 1L
}
var p1WinSum = 0L
var p2WinSum = 0L
for (i in 1..3) {
for (j in 1..3) {
for (k in 1..3) {
val (newP1Pos, newP1Score) = if (key.isP1Turn) {
computeNewPosScore(key.p1Pos, key.p1Score, i, j, k)
} else {
key.p1Pos to key.p1Score
}
val (newP2Pos, newP2Score) = if (!key.isP1Turn) {
computeNewPosScore(key.p2Pos, key.p2Score, i, j, k)
} else {
key.p2Pos to key.p2Score
}
val newKey = Key(newP1Pos, newP1Score, newP2Pos, newP2Score, !key.isP1Turn)
val (p1Wins, p2Wins) = computeWinningUniverses(newKey, memoizedResults)
p1WinSum += p1Wins
p2WinSum += p2Wins
}
}
}
memoizedResults[key] = p1WinSum to p2WinSum
return p1WinSum to p2WinSum
}
private fun computeNewPosScore(pos: Int, score: Int, i: Int, j: Int, k: Int): Pair<Int, Int> {
val newPos = ((pos + i + j + k - 1) % 10) + 1
return newPos to (score + newPos)
}
private fun parseStartingPositions(lines: List<String>): Pair<Int, Int> {
return lines[0].split(" ").last().toInt() to lines[1].split(" ").last().toInt()
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input21.txt"), Charsets.UTF_8)
val solution1 = solvePart1(lines)
println(solution1)
val solution2 = solvePart2(lines)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day21.class",
"javap": "Compiled from \"Day21.kt\"\npublic final class org.aoc2021.Day21 {\n public static final org.aoc2021.Day21 INSTANCE;\n\n private org.aoc2021.Day21();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int solvePart1(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #17 // Method parseStartingPositions:(Ljava/util/List;)Lkotlin/Pair;\n 5: astore_2\n 6: iconst_0\n 7: istore_3\n 8: aload_2\n 9: invokevirtual #23 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 12: checkcast #25 // class java/lang/Number\n 15: invokevirtual #29 // Method java/lang/Number.intValue:()I\n 18: istore_3\n 19: iconst_0\n 20: istore 4\n 22: aload_2\n 23: invokevirtual #32 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 26: checkcast #25 // class java/lang/Number\n 29: invokevirtual #29 // Method java/lang/Number.intValue:()I\n 32: istore 4\n 34: iconst_0\n 35: istore 5\n 37: iconst_1\n 38: istore 5\n 40: iconst_0\n 41: istore 6\n 43: iconst_0\n 44: istore 7\n 46: iconst_0\n 47: istore 8\n 49: nop\n 50: new #34 // class kotlin/ranges/IntRange\n 53: dup\n 54: iconst_1\n 55: iconst_3\n 56: invokespecial #37 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 59: checkcast #39 // class java/lang/Iterable\n 62: astore 9\n 64: iconst_0\n 65: istore 10\n 67: aload 9\n 69: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 74: astore 11\n 76: aload 11\n 78: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 83: ifeq 124\n 86: aload 11\n 88: checkcast #51 // class kotlin/collections/IntIterator\n 91: invokevirtual #54 // Method kotlin/collections/IntIterator.nextInt:()I\n 94: istore 12\n 96: iconst_0\n 97: istore 13\n 99: iload_3\n 100: iload 5\n 102: iadd\n 103: istore_3\n 104: iload 5\n 106: bipush 100\n 108: irem\n 109: iconst_1\n 110: iadd\n 111: istore 5\n 113: iload 6\n 115: iconst_1\n 116: iadd\n 117: istore 6\n 119: nop\n 120: nop\n 121: goto 76\n 124: nop\n 125: iload_3\n 126: iconst_1\n 127: isub\n 128: bipush 10\n 130: irem\n 131: iconst_1\n 132: iadd\n 133: istore_3\n 134: iload 7\n 136: iload_3\n 137: iadd\n 138: istore 7\n 140: iload 7\n 142: sipush 1000\n 145: if_icmplt 154\n 148: iload 6\n 150: iload 8\n 152: imul\n 153: ireturn\n 154: new #34 // class kotlin/ranges/IntRange\n 157: dup\n 158: iconst_1\n 159: iconst_3\n 160: invokespecial #37 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 163: checkcast #39 // class java/lang/Iterable\n 166: astore 9\n 168: iconst_0\n 169: istore 10\n 171: aload 9\n 173: invokeinterface #43, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 178: astore 11\n 180: aload 11\n 182: invokeinterface #49, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 187: ifeq 230\n 190: aload 11\n 192: checkcast #51 // class kotlin/collections/IntIterator\n 195: invokevirtual #54 // Method kotlin/collections/IntIterator.nextInt:()I\n 198: istore 12\n 200: iconst_0\n 201: istore 13\n 203: iload 4\n 205: iload 5\n 207: iadd\n 208: istore 4\n 210: iload 5\n 212: bipush 100\n 214: irem\n 215: iconst_1\n 216: iadd\n 217: istore 5\n 219: iload 6\n 221: iconst_1\n 222: iadd\n 223: istore 6\n 225: nop\n 226: nop\n 227: goto 180\n 230: nop\n 231: iload 4\n 233: iconst_1\n 234: isub\n 235: bipush 10\n 237: irem\n 238: iconst_1\n 239: iadd\n 240: istore 4\n 242: iload 8\n 244: iload 4\n 246: iadd\n 247: istore 8\n 249: iload 8\n 251: sipush 1000\n 254: if_icmplt 49\n 257: iload 6\n 259: iload 7\n 261: imul\n 262: ireturn\n\n private final long solvePart2(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #17 // Method parseStartingPositions:(Ljava/util/List;)Lkotlin/Pair;\n 5: astore_2\n 6: aload_2\n 7: invokevirtual #23 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 10: checkcast #25 // class java/lang/Number\n 13: invokevirtual #29 // Method java/lang/Number.intValue:()I\n 16: istore_3\n 17: aload_2\n 18: invokevirtual #32 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 21: checkcast #25 // class java/lang/Number\n 24: invokevirtual #29 // Method java/lang/Number.intValue:()I\n 27: istore 4\n 29: aload_0\n 30: new #76 // class org/aoc2021/Day21$Key\n 33: dup\n 34: iload_3\n 35: iconst_0\n 36: iload 4\n 38: iconst_0\n 39: iconst_1\n 40: invokespecial #79 // Method org/aoc2021/Day21$Key.\"<init>\":(IIIIZ)V\n 43: aconst_null\n 44: iconst_2\n 45: aconst_null\n 46: invokestatic #83 // Method computeWinningUniverses$default:(Lorg/aoc2021/Day21;Lorg/aoc2021/Day21$Key;Ljava/util/Map;ILjava/lang/Object;)Lkotlin/Pair;\n 49: astore 5\n 51: aload 5\n 53: invokevirtual #23 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 56: checkcast #25 // class java/lang/Number\n 59: invokevirtual #87 // Method java/lang/Number.longValue:()J\n 62: lstore 6\n 64: aload 5\n 66: invokevirtual #32 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 69: checkcast #25 // class java/lang/Number\n 72: invokevirtual #87 // Method java/lang/Number.longValue:()J\n 75: lstore 8\n 77: lload 6\n 79: lload 8\n 81: invokestatic #93 // Method java/lang/Math.max:(JJ)J\n 84: lreturn\n\n private final kotlin.Pair<java.lang.Long, java.lang.Long> computeWinningUniverses(org.aoc2021.Day21$Key, java.util.Map<org.aoc2021.Day21$Key, kotlin.Pair<java.lang.Long, java.lang.Long>>);\n Code:\n 0: aload_2\n 1: aload_1\n 2: invokeinterface #107, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 7: checkcast #19 // class kotlin/Pair\n 10: astore_3\n 11: aload_3\n 12: ifnull 24\n 15: aload_3\n 16: astore 5\n 18: iconst_0\n 19: istore 6\n 21: aload 5\n 23: areturn\n 24: aload_1\n 25: invokevirtual #110 // Method org/aoc2021/Day21$Key.getP1Score:()I\n 28: bipush 21\n 30: if_icmplt 45\n 33: lconst_1\n 34: invokestatic #116 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 37: lconst_0\n 38: invokestatic #116 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 41: invokestatic #122 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 44: areturn\n 45: aload_1\n 46: invokevirtual #125 // Method org/aoc2021/Day21$Key.getP2Score:()I\n 49: bipush 21\n 51: if_icmplt 66\n 54: lconst_0\n 55: invokestatic #116 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 58: lconst_1\n 59: invokestatic #116 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 62: invokestatic #122 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 65: areturn\n 66: lconst_0\n 67: lstore_3\n 68: lconst_0\n 69: lstore 5\n 71: iconst_1\n 72: istore 7\n 74: iload 7\n 76: iconst_4\n 77: if_icmpge 338\n 80: iconst_1\n 81: istore 8\n 83: iload 8\n 85: iconst_4\n 86: if_icmpge 332\n 89: iconst_1\n 90: istore 9\n 92: iload 9\n 94: iconst_4\n 95: if_icmpge 326\n 98: aload_1\n 99: invokevirtual #128 // Method org/aoc2021/Day21$Key.isP1Turn:()Z\n 102: ifeq 126\n 105: aload_0\n 106: aload_1\n 107: invokevirtual #131 // Method org/aoc2021/Day21$Key.getP1Pos:()I\n 110: aload_1\n 111: invokevirtual #110 // Method org/aoc2021/Day21$Key.getP1Score:()I\n 114: iload 7\n 116: iload 8\n 118: iload 9\n 120: invokespecial #135 // Method computeNewPosScore:(IIIII)Lkotlin/Pair;\n 123: goto 143\n 126: aload_1\n 127: invokevirtual #131 // Method org/aoc2021/Day21$Key.getP1Pos:()I\n 130: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 133: aload_1\n 134: invokevirtual #110 // Method org/aoc2021/Day21$Key.getP1Score:()I\n 137: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 140: invokestatic #122 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 143: astore 10\n 145: aload 10\n 147: invokevirtual #23 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 150: checkcast #25 // class java/lang/Number\n 153: invokevirtual #29 // Method java/lang/Number.intValue:()I\n 156: istore 11\n 158: aload 10\n 160: invokevirtual #32 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 163: checkcast #25 // class java/lang/Number\n 166: invokevirtual #29 // Method java/lang/Number.intValue:()I\n 169: istore 12\n 171: aload_1\n 172: invokevirtual #128 // Method org/aoc2021/Day21$Key.isP1Turn:()Z\n 175: ifne 199\n 178: aload_0\n 179: aload_1\n 180: invokevirtual #143 // Method org/aoc2021/Day21$Key.getP2Pos:()I\n 183: aload_1\n 184: invokevirtual #125 // Method org/aoc2021/Day21$Key.getP2Score:()I\n 187: iload 7\n 189: iload 8\n 191: iload 9\n 193: invokespecial #135 // Method computeNewPosScore:(IIIII)Lkotlin/Pair;\n 196: goto 216\n 199: aload_1\n 200: invokevirtual #143 // Method org/aoc2021/Day21$Key.getP2Pos:()I\n 203: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 206: aload_1\n 207: invokevirtual #125 // Method org/aoc2021/Day21$Key.getP2Score:()I\n 210: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 213: invokestatic #122 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 216: astore 13\n 218: aload 13\n 220: invokevirtual #23 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 223: checkcast #25 // class java/lang/Number\n 226: invokevirtual #29 // Method java/lang/Number.intValue:()I\n 229: istore 14\n 231: aload 13\n 233: invokevirtual #32 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 236: checkcast #25 // class java/lang/Number\n 239: invokevirtual #29 // Method java/lang/Number.intValue:()I\n 242: istore 15\n 244: new #76 // class org/aoc2021/Day21$Key\n 247: dup\n 248: iload 11\n 250: iload 12\n 252: iload 14\n 254: iload 15\n 256: aload_1\n 257: invokevirtual #128 // Method org/aoc2021/Day21$Key.isP1Turn:()Z\n 260: ifne 267\n 263: iconst_1\n 264: goto 268\n 267: iconst_0\n 268: invokespecial #79 // Method org/aoc2021/Day21$Key.\"<init>\":(IIIIZ)V\n 271: astore 16\n 273: aload_0\n 274: aload 16\n 276: aload_2\n 277: invokespecial #145 // Method computeWinningUniverses:(Lorg/aoc2021/Day21$Key;Ljava/util/Map;)Lkotlin/Pair;\n 280: astore 17\n 282: aload 17\n 284: invokevirtual #23 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 287: checkcast #25 // class java/lang/Number\n 290: invokevirtual #87 // Method java/lang/Number.longValue:()J\n 293: lstore 18\n 295: aload 17\n 297: invokevirtual #32 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 300: checkcast #25 // class java/lang/Number\n 303: invokevirtual #87 // Method java/lang/Number.longValue:()J\n 306: lstore 20\n 308: lload_3\n 309: lload 18\n 311: ladd\n 312: lstore_3\n 313: lload 5\n 315: lload 20\n 317: ladd\n 318: lstore 5\n 320: iinc 9, 1\n 323: goto 92\n 326: iinc 8, 1\n 329: goto 83\n 332: iinc 7, 1\n 335: goto 74\n 338: aload_2\n 339: aload_1\n 340: lload_3\n 341: invokestatic #116 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 344: lload 5\n 346: invokestatic #116 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 349: invokestatic #122 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 352: invokeinterface #149, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 357: pop\n 358: lload_3\n 359: invokestatic #116 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 362: lload 5\n 364: invokestatic #116 // Method java/lang/Long.valueOf:(J)Ljava/lang/Long;\n 367: invokestatic #122 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 370: areturn\n\n static kotlin.Pair computeWinningUniverses$default(org.aoc2021.Day21, org.aoc2021.Day21$Key, java.util.Map, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_2\n 2: iand\n 3: ifeq 17\n 6: new #168 // class java/util/LinkedHashMap\n 9: dup\n 10: invokespecial #169 // Method java/util/LinkedHashMap.\"<init>\":()V\n 13: checkcast #103 // class java/util/Map\n 16: astore_2\n 17: aload_0\n 18: aload_1\n 19: aload_2\n 20: invokespecial #145 // Method computeWinningUniverses:(Lorg/aoc2021/Day21$Key;Ljava/util/Map;)Lkotlin/Pair;\n 23: areturn\n\n private final kotlin.Pair<java.lang.Integer, java.lang.Integer> computeNewPosScore(int, int, int, int, int);\n Code:\n 0: iload_1\n 1: iload_3\n 2: iadd\n 3: iload 4\n 5: iadd\n 6: iload 5\n 8: iadd\n 9: iconst_1\n 10: isub\n 11: bipush 10\n 13: irem\n 14: iconst_1\n 15: iadd\n 16: istore 6\n 18: iload 6\n 20: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 23: iload_2\n 24: iload 6\n 26: iadd\n 27: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 30: invokestatic #122 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 33: areturn\n\n private final kotlin.Pair<java.lang.Integer, java.lang.Integer> parseStartingPositions(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: iconst_0\n 2: invokeinterface #177, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #179 // class java/lang/CharSequence\n 10: iconst_1\n 11: anewarray #181 // class java/lang/String\n 14: astore_2\n 15: aload_2\n 16: iconst_0\n 17: ldc #183 // 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 #189 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: invokestatic #195 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 32: checkcast #181 // class java/lang/String\n 35: invokestatic #199 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 38: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 41: aload_1\n 42: iconst_1\n 43: invokeinterface #177, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 48: checkcast #179 // class java/lang/CharSequence\n 51: iconst_1\n 52: anewarray #181 // class java/lang/String\n 55: astore_2\n 56: aload_2\n 57: iconst_0\n 58: ldc #183 // String\n 60: aastore\n 61: aload_2\n 62: iconst_0\n 63: iconst_0\n 64: bipush 6\n 66: aconst_null\n 67: invokestatic #189 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 70: invokestatic #195 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 73: checkcast #181 // class java/lang/String\n 76: invokestatic #199 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 79: invokestatic #140 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 82: invokestatic #122 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 85: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #205 // String args\n 3: invokestatic #211 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #213 // String input21.txt\n 8: iconst_0\n 9: anewarray #181 // class java/lang/String\n 12: invokestatic #219 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 15: getstatic #225 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 18: invokestatic #231 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 21: astore_1\n 22: getstatic #234 // Field INSTANCE:Lorg/aoc2021/Day21;\n 25: aload_1\n 26: invokestatic #238 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 29: aload_1\n 30: invokespecial #240 // Method solvePart1:(Ljava/util/List;)I\n 33: istore_2\n 34: getstatic #246 // Field java/lang/System.out:Ljava/io/PrintStream;\n 37: iload_2\n 38: invokevirtual #252 // Method java/io/PrintStream.println:(I)V\n 41: getstatic #234 // Field INSTANCE:Lorg/aoc2021/Day21;\n 44: aload_1\n 45: invokespecial #254 // Method solvePart2:(Ljava/util/List;)J\n 48: lstore_3\n 49: getstatic #246 // Field java/lang/System.out:Ljava/io/PrintStream;\n 52: lload_3\n 53: invokevirtual #257 // Method java/io/PrintStream.println:(J)V\n 56: return\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day21\n 3: dup\n 4: invokespecial #262 // Method \"<init>\":()V\n 7: putstatic #234 // Field INSTANCE:Lorg/aoc2021/Day21;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day21$Key.class",
"javap": "Compiled from \"Day21.kt\"\npublic final class org.aoc2021.Day21$Key {\n private final int p1Pos;\n\n private final int p1Score;\n\n private final int p2Pos;\n\n private final int p2Score;\n\n private final boolean isP1Turn;\n\n public org.aoc2021.Day21$Key(int, int, int, int, boolean);\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 p1Pos:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field p1Score:I\n 14: aload_0\n 15: iload_3\n 16: putfield #19 // Field p2Pos:I\n 19: aload_0\n 20: iload 4\n 22: putfield #22 // Field p2Score:I\n 25: aload_0\n 26: iload 5\n 28: putfield #26 // Field isP1Turn:Z\n 31: return\n\n public final int getP1Pos();\n Code:\n 0: aload_0\n 1: getfield #13 // Field p1Pos:I\n 4: ireturn\n\n public final int getP1Score();\n Code:\n 0: aload_0\n 1: getfield #16 // Field p1Score:I\n 4: ireturn\n\n public final int getP2Pos();\n Code:\n 0: aload_0\n 1: getfield #19 // Field p2Pos:I\n 4: ireturn\n\n public final int getP2Score();\n Code:\n 0: aload_0\n 1: getfield #22 // Field p2Score:I\n 4: ireturn\n\n public final boolean isP1Turn();\n Code:\n 0: aload_0\n 1: getfield #26 // Field isP1Turn:Z\n 4: ireturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field p1Pos:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field p1Score:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #19 // Field p2Pos:I\n 4: ireturn\n\n public final int component4();\n Code:\n 0: aload_0\n 1: getfield #22 // Field p2Score:I\n 4: ireturn\n\n public final boolean component5();\n Code:\n 0: aload_0\n 1: getfield #26 // Field isP1Turn:Z\n 4: ireturn\n\n public final org.aoc2021.Day21$Key copy(int, int, int, int, boolean);\n Code:\n 0: new #2 // class org/aoc2021/Day21$Key\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: iload_3\n 7: iload 4\n 9: iload 5\n 11: invokespecial #44 // Method \"<init>\":(IIIIZ)V\n 14: areturn\n\n public static org.aoc2021.Day21$Key copy$default(org.aoc2021.Day21$Key, int, int, int, int, boolean, int, java.lang.Object);\n Code:\n 0: iload 6\n 2: iconst_1\n 3: iand\n 4: ifeq 12\n 7: aload_0\n 8: getfield #13 // Field p1Pos:I\n 11: istore_1\n 12: iload 6\n 14: iconst_2\n 15: iand\n 16: ifeq 24\n 19: aload_0\n 20: getfield #16 // Field p1Score:I\n 23: istore_2\n 24: iload 6\n 26: iconst_4\n 27: iand\n 28: ifeq 36\n 31: aload_0\n 32: getfield #19 // Field p2Pos:I\n 35: istore_3\n 36: iload 6\n 38: bipush 8\n 40: iand\n 41: ifeq 50\n 44: aload_0\n 45: getfield #22 // Field p2Score:I\n 48: istore 4\n 50: iload 6\n 52: bipush 16\n 54: iand\n 55: ifeq 64\n 58: aload_0\n 59: getfield #26 // Field isP1Turn:Z\n 62: istore 5\n 64: aload_0\n 65: iload_1\n 66: iload_2\n 67: iload_3\n 68: iload 4\n 70: iload 5\n 72: invokevirtual #48 // Method copy:(IIIIZ)Lorg/aoc2021/Day21$Key;\n 75: 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 Key(p1Pos=\n 9: invokevirtual #59 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field p1Pos:I\n 16: invokevirtual #62 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #64 // String , p1Score=\n 21: invokevirtual #59 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field p1Score:I\n 28: invokevirtual #62 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #66 // String , p2Pos=\n 33: invokevirtual #59 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #19 // Field p2Pos:I\n 40: invokevirtual #62 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 43: ldc #68 // String , p2Score=\n 45: invokevirtual #59 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 48: aload_0\n 49: getfield #22 // Field p2Score:I\n 52: invokevirtual #62 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 55: ldc #70 // String , isP1Turn=\n 57: invokevirtual #59 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 60: aload_0\n 61: getfield #26 // Field isP1Turn:Z\n 64: invokevirtual #73 // Method java/lang/StringBuilder.append:(Z)Ljava/lang/StringBuilder;\n 67: bipush 41\n 69: invokevirtual #76 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 72: invokevirtual #78 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 75: areturn\n\n public int hashCode();\n Code:\n 0: aload_0\n 1: getfield #13 // Field p1Pos: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 p1Score: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: bipush 31\n 24: imul\n 25: aload_0\n 26: getfield #19 // Field p2Pos:I\n 29: invokestatic #84 // 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 #22 // Field p2Score:I\n 42: invokestatic #84 // 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 #26 // Field isP1Turn:Z\n 55: invokestatic #89 // Method java/lang/Boolean.hashCode:(Z)I\n 58: iadd\n 59: istore_1\n 60: iload_1\n 61: 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 org/aoc2021/Day21$Key\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day21$Key\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field p1Pos:I\n 25: aload_2\n 26: getfield #13 // Field p1Pos:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field p1Score:I\n 38: aload_2\n 39: getfield #16 // Field p1Score:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #19 // Field p2Pos:I\n 51: aload_2\n 52: getfield #19 // Field p2Pos:I\n 55: if_icmpeq 60\n 58: iconst_0\n 59: ireturn\n 60: aload_0\n 61: getfield #22 // Field p2Score:I\n 64: aload_2\n 65: getfield #22 // Field p2Score:I\n 68: if_icmpeq 73\n 71: iconst_0\n 72: ireturn\n 73: aload_0\n 74: getfield #26 // Field isP1Turn:Z\n 77: aload_2\n 78: getfield #26 // Field isP1Turn:Z\n 81: if_icmpeq 86\n 84: iconst_0\n 85: ireturn\n 86: iconst_1\n 87: ireturn\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day20.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
object Day20 {
private const val iterationsPart1 = 2
private const val iterationsPart2 = 50
data class Image(
val lit: Set<Pair<Int, Int>>,
val outOfBoundsLit: Boolean,
)
private fun solve(lines: List<String>, iterations: Int): Int {
val (algorithm, image) = parseInput(lines)
val processed = (1..iterations).fold(image) { prevImage, _ ->
processImage(algorithm, prevImage)
}
return processed.lit.size
}
private fun processImage(algorithm: String, image: Image): Image {
val newImage = mutableSetOf<Pair<Int, Int>>()
val minX = image.lit.minOf { it.first }
val maxX = image.lit.maxOf { it.first }
val minY = image.lit.minOf { it.second }
val maxY = image.lit.maxOf { it.second }
for (i in (minX - 1)..(maxX + 1)) {
for (j in (minY - 1)..(maxY + 1)) {
val algorithmIndex = computeAlgorithmIndex(image, i, j, minX, maxX, minY, maxY)
if (algorithm[algorithmIndex] == '#') {
newImage.add(i to j)
}
}
}
val newOutOfBoundsLit = if (image.outOfBoundsLit) (algorithm.last() == '#') else (algorithm.first() == '#')
return Image(newImage.toSet(), newOutOfBoundsLit)
}
private fun computeAlgorithmIndex(image: Image, i: Int, j: Int, minX: Int, maxX: Int, minY: Int, maxY: Int): Int {
var algorithmIndex = 0
for (dx in -1..1) {
for (dy in -1..1) {
algorithmIndex *= 2
if (image.lit.contains(i + dx to j + dy)) {
algorithmIndex++
} else if (i + dx < minX || i + dx > maxX || j + dy < minY || j + dy > maxY) {
if (image.outOfBoundsLit) {
algorithmIndex++
}
}
}
}
return algorithmIndex
}
private fun parseInput(lines: List<String>): Pair<String, Image> {
val algorithm = lines[0]
val litPixels = lines.drop(2).flatMapIndexed { i, line ->
line.mapIndexed { j, c ->
if (c == '#') (i to j) else null
}.filterNotNull()
}.toSet()
return algorithm to Image(litPixels, false)
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input20.txt"), Charsets.UTF_8)
val solution1 = solve(lines, iterationsPart1)
println(solution1)
val solution2 = solve(lines, iterationsPart2)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day20$Image.class",
"javap": "Compiled from \"Day20.kt\"\npublic final class org.aoc2021.Day20$Image {\n private final java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>> lit;\n\n private final boolean outOfBoundsLit;\n\n public org.aoc2021.Day20$Image(java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>>, boolean);\n Code:\n 0: aload_1\n 1: ldc #10 // String lit\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 lit:Ljava/util/Set;\n 15: aload_0\n 16: iload_2\n 17: putfield #26 // Field outOfBoundsLit:Z\n 20: return\n\n public final java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>> getLit();\n Code:\n 0: aload_0\n 1: getfield #22 // Field lit:Ljava/util/Set;\n 4: areturn\n\n public final boolean getOutOfBoundsLit();\n Code:\n 0: aload_0\n 1: getfield #26 // Field outOfBoundsLit:Z\n 4: ireturn\n\n public final java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>> component1();\n Code:\n 0: aload_0\n 1: getfield #22 // Field lit:Ljava/util/Set;\n 4: areturn\n\n public final boolean component2();\n Code:\n 0: aload_0\n 1: getfield #26 // Field outOfBoundsLit:Z\n 4: ireturn\n\n public final org.aoc2021.Day20$Image copy(java.util.Set<kotlin.Pair<java.lang.Integer, java.lang.Integer>>, boolean);\n Code:\n 0: aload_1\n 1: ldc #10 // String lit\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #2 // class org/aoc2021/Day20$Image\n 9: dup\n 10: aload_1\n 11: iload_2\n 12: invokespecial #40 // Method \"<init>\":(Ljava/util/Set;Z)V\n 15: areturn\n\n public static org.aoc2021.Day20$Image copy$default(org.aoc2021.Day20$Image, java.util.Set, boolean, 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 lit:Ljava/util/Set;\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 outOfBoundsLit:Z\n 21: istore_2\n 22: aload_0\n 23: aload_1\n 24: iload_2\n 25: invokevirtual #44 // Method copy:(Ljava/util/Set;Z)Lorg/aoc2021/Day20$Image;\n 28: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #48 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #49 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #51 // String Image(lit=\n 9: invokevirtual #55 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #22 // Field lit:Ljava/util/Set;\n 16: invokevirtual #58 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #60 // String , outOfBoundsLit=\n 21: invokevirtual #55 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #26 // Field outOfBoundsLit:Z\n 28: invokevirtual #63 // Method java/lang/StringBuilder.append:(Z)Ljava/lang/StringBuilder;\n 31: bipush 41\n 33: invokevirtual #66 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 36: invokevirtual #68 // 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 lit:Ljava/util/Set;\n 4: invokevirtual #72 // 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 outOfBoundsLit:Z\n 16: invokestatic #77 // Method java/lang/Boolean.hashCode:(Z)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 org/aoc2021/Day20$Image\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day20$Image\n 20: astore_2\n 21: aload_0\n 22: getfield #22 // Field lit:Ljava/util/Set;\n 25: aload_2\n 26: getfield #22 // Field lit:Ljava/util/Set;\n 29: invokestatic #86 // 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 outOfBoundsLit:Z\n 41: aload_2\n 42: getfield #26 // Field outOfBoundsLit:Z\n 45: if_icmpeq 50\n 48: iconst_0\n 49: ireturn\n 50: iconst_1\n 51: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day20.class",
"javap": "Compiled from \"Day20.kt\"\npublic final class org.aoc2021.Day20 {\n public static final org.aoc2021.Day20 INSTANCE;\n\n private static final int iterationsPart1;\n\n private static final int iterationsPart2;\n\n private org.aoc2021.Day20();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int solve(java.util.List<java.lang.String>, int);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #17 // Method parseInput:(Ljava/util/List;)Lkotlin/Pair;\n 5: astore_3\n 6: aload_3\n 7: invokevirtual #23 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 10: checkcast #25 // class java/lang/String\n 13: astore 4\n 15: aload_3\n 16: invokevirtual #28 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 19: checkcast #30 // class org/aoc2021/Day20$Image\n 22: astore 5\n 24: new #32 // class kotlin/ranges/IntRange\n 27: dup\n 28: iconst_1\n 29: iload_2\n 30: invokespecial #35 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 33: checkcast #37 // class java/lang/Iterable\n 36: astore 7\n 38: iconst_0\n 39: istore 8\n 41: aload 5\n 43: astore 9\n 45: aload 7\n 47: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 52: astore 10\n 54: aload 10\n 56: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 61: ifeq 96\n 64: aload 10\n 66: checkcast #49 // class kotlin/collections/IntIterator\n 69: invokevirtual #53 // Method kotlin/collections/IntIterator.nextInt:()I\n 72: istore 11\n 74: aload 9\n 76: astore 12\n 78: iconst_0\n 79: istore 13\n 81: getstatic #56 // Field INSTANCE:Lorg/aoc2021/Day20;\n 84: aload 4\n 86: aload 12\n 88: invokespecial #60 // Method processImage:(Ljava/lang/String;Lorg/aoc2021/Day20$Image;)Lorg/aoc2021/Day20$Image;\n 91: astore 9\n 93: goto 54\n 96: aload 9\n 98: astore 6\n 100: aload 6\n 102: invokevirtual #64 // Method org/aoc2021/Day20$Image.getLit:()Ljava/util/Set;\n 105: invokeinterface #69, 1 // InterfaceMethod java/util/Set.size:()I\n 110: ireturn\n\n private final org.aoc2021.Day20$Image processImage(java.lang.String, org.aoc2021.Day20$Image);\n Code:\n 0: new #90 // class java/util/LinkedHashSet\n 3: dup\n 4: invokespecial #91 // Method java/util/LinkedHashSet.\"<init>\":()V\n 7: checkcast #66 // class java/util/Set\n 10: astore_3\n 11: aload_2\n 12: invokevirtual #64 // Method org/aoc2021/Day20$Image.getLit:()Ljava/util/Set;\n 15: checkcast #37 // class java/lang/Iterable\n 18: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 23: astore 6\n 25: aload 6\n 27: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 32: ifne 43\n 35: new #93 // class java/util/NoSuchElementException\n 38: dup\n 39: invokespecial #94 // Method java/util/NoSuchElementException.\"<init>\":()V\n 42: athrow\n 43: aload 6\n 45: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 50: checkcast #19 // class kotlin/Pair\n 53: astore 7\n 55: iconst_0\n 56: istore 8\n 58: aload 7\n 60: invokevirtual #100 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 63: checkcast #102 // class java/lang/Number\n 66: invokevirtual #105 // Method java/lang/Number.intValue:()I\n 69: istore 7\n 71: aload 6\n 73: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 78: ifeq 123\n 81: aload 6\n 83: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 88: checkcast #19 // class kotlin/Pair\n 91: astore 8\n 93: iconst_0\n 94: istore 9\n 96: aload 8\n 98: invokevirtual #100 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 101: checkcast #102 // class java/lang/Number\n 104: invokevirtual #105 // Method java/lang/Number.intValue:()I\n 107: istore 8\n 109: iload 7\n 111: iload 8\n 113: if_icmple 71\n 116: iload 8\n 118: istore 7\n 120: goto 71\n 123: iload 7\n 125: istore 4\n 127: aload_2\n 128: invokevirtual #64 // Method org/aoc2021/Day20$Image.getLit:()Ljava/util/Set;\n 131: checkcast #37 // class java/lang/Iterable\n 134: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 139: astore 7\n 141: aload 7\n 143: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 148: ifne 159\n 151: new #93 // class java/util/NoSuchElementException\n 154: dup\n 155: invokespecial #94 // Method java/util/NoSuchElementException.\"<init>\":()V\n 158: athrow\n 159: aload 7\n 161: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 166: checkcast #19 // class kotlin/Pair\n 169: astore 8\n 171: iconst_0\n 172: istore 9\n 174: aload 8\n 176: invokevirtual #100 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 179: checkcast #102 // class java/lang/Number\n 182: invokevirtual #105 // Method java/lang/Number.intValue:()I\n 185: istore 8\n 187: aload 7\n 189: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 194: ifeq 239\n 197: aload 7\n 199: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 204: checkcast #19 // class kotlin/Pair\n 207: astore 9\n 209: iconst_0\n 210: istore 10\n 212: aload 9\n 214: invokevirtual #100 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 217: checkcast #102 // class java/lang/Number\n 220: invokevirtual #105 // Method java/lang/Number.intValue:()I\n 223: istore 9\n 225: iload 8\n 227: iload 9\n 229: if_icmpge 187\n 232: iload 9\n 234: istore 8\n 236: goto 187\n 239: iload 8\n 241: istore 5\n 243: aload_2\n 244: invokevirtual #64 // Method org/aoc2021/Day20$Image.getLit:()Ljava/util/Set;\n 247: checkcast #37 // class java/lang/Iterable\n 250: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 255: astore 8\n 257: aload 8\n 259: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 264: ifne 275\n 267: new #93 // class java/util/NoSuchElementException\n 270: dup\n 271: invokespecial #94 // Method java/util/NoSuchElementException.\"<init>\":()V\n 274: athrow\n 275: aload 8\n 277: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 282: checkcast #19 // class kotlin/Pair\n 285: astore 9\n 287: iconst_0\n 288: istore 10\n 290: aload 9\n 292: invokevirtual #108 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 295: checkcast #102 // class java/lang/Number\n 298: invokevirtual #105 // Method java/lang/Number.intValue:()I\n 301: istore 9\n 303: aload 8\n 305: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 310: ifeq 355\n 313: aload 8\n 315: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 320: checkcast #19 // class kotlin/Pair\n 323: astore 10\n 325: iconst_0\n 326: istore 11\n 328: aload 10\n 330: invokevirtual #108 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 333: checkcast #102 // class java/lang/Number\n 336: invokevirtual #105 // Method java/lang/Number.intValue:()I\n 339: istore 10\n 341: iload 9\n 343: iload 10\n 345: if_icmple 303\n 348: iload 10\n 350: istore 9\n 352: goto 303\n 355: iload 9\n 357: istore 6\n 359: aload_2\n 360: invokevirtual #64 // Method org/aoc2021/Day20$Image.getLit:()Ljava/util/Set;\n 363: checkcast #37 // class java/lang/Iterable\n 366: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 371: astore 9\n 373: aload 9\n 375: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 380: ifne 391\n 383: new #93 // class java/util/NoSuchElementException\n 386: dup\n 387: invokespecial #94 // Method java/util/NoSuchElementException.\"<init>\":()V\n 390: athrow\n 391: aload 9\n 393: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 398: checkcast #19 // class kotlin/Pair\n 401: astore 10\n 403: iconst_0\n 404: istore 11\n 406: aload 10\n 408: invokevirtual #108 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 411: checkcast #102 // class java/lang/Number\n 414: invokevirtual #105 // Method java/lang/Number.intValue:()I\n 417: istore 10\n 419: aload 9\n 421: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 426: ifeq 471\n 429: aload 9\n 431: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 436: checkcast #19 // class kotlin/Pair\n 439: astore 11\n 441: iconst_0\n 442: istore 12\n 444: aload 11\n 446: invokevirtual #108 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 449: checkcast #102 // class java/lang/Number\n 452: invokevirtual #105 // Method java/lang/Number.intValue:()I\n 455: istore 11\n 457: iload 10\n 459: iload 11\n 461: if_icmpge 419\n 464: iload 11\n 466: istore 10\n 468: goto 419\n 471: iload 10\n 473: istore 7\n 475: iload 4\n 477: iconst_1\n 478: isub\n 479: istore 8\n 481: iload 5\n 483: iconst_1\n 484: iadd\n 485: istore 9\n 487: iload 8\n 489: iload 9\n 491: if_icmpgt 589\n 494: iload 6\n 496: iconst_1\n 497: isub\n 498: istore 10\n 500: iload 7\n 502: iconst_1\n 503: iadd\n 504: istore 11\n 506: iload 10\n 508: iload 11\n 510: if_icmpgt 576\n 513: aload_0\n 514: aload_2\n 515: iload 8\n 517: iload 10\n 519: iload 4\n 521: iload 5\n 523: iload 6\n 525: iload 7\n 527: invokespecial #112 // Method computeAlgorithmIndex:(Lorg/aoc2021/Day20$Image;IIIIII)I\n 530: istore 12\n 532: aload_1\n 533: iload 12\n 535: invokevirtual #116 // Method java/lang/String.charAt:(I)C\n 538: bipush 35\n 540: if_icmpne 563\n 543: aload_3\n 544: iload 8\n 546: invokestatic #122 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 549: iload 10\n 551: invokestatic #122 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 554: invokestatic #128 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 557: invokeinterface #132, 2 // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z\n 562: pop\n 563: iload 10\n 565: iload 11\n 567: if_icmpeq 576\n 570: iinc 10, 1\n 573: goto 513\n 576: iload 8\n 578: iload 9\n 580: if_icmpeq 589\n 583: iinc 8, 1\n 586: goto 494\n 589: aload_2\n 590: invokevirtual #135 // Method org/aoc2021/Day20$Image.getOutOfBoundsLit:()Z\n 593: ifeq 616\n 596: aload_1\n 597: checkcast #137 // class java/lang/CharSequence\n 600: invokestatic #143 // Method kotlin/text/StringsKt.last:(Ljava/lang/CharSequence;)C\n 603: bipush 35\n 605: if_icmpne 612\n 608: iconst_1\n 609: goto 633\n 612: iconst_0\n 613: goto 633\n 616: aload_1\n 617: checkcast #137 // class java/lang/CharSequence\n 620: invokestatic #146 // Method kotlin/text/StringsKt.first:(Ljava/lang/CharSequence;)C\n 623: bipush 35\n 625: if_icmpne 632\n 628: iconst_1\n 629: goto 633\n 632: iconst_0\n 633: istore 8\n 635: new #30 // class org/aoc2021/Day20$Image\n 638: dup\n 639: aload_3\n 640: checkcast #37 // class java/lang/Iterable\n 643: invokestatic #152 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 646: iload 8\n 648: invokespecial #155 // Method org/aoc2021/Day20$Image.\"<init>\":(Ljava/util/Set;Z)V\n 651: areturn\n\n private final int computeAlgorithmIndex(org.aoc2021.Day20$Image, int, int, int, int, int, int);\n Code:\n 0: iconst_0\n 1: istore 8\n 3: iconst_m1\n 4: istore 9\n 6: iload 9\n 8: iconst_2\n 9: if_icmpge 120\n 12: iconst_m1\n 13: istore 10\n 15: iload 10\n 17: iconst_2\n 18: if_icmpge 114\n 21: iload 8\n 23: iconst_2\n 24: imul\n 25: istore 8\n 27: aload_1\n 28: invokevirtual #64 // Method org/aoc2021/Day20$Image.getLit:()Ljava/util/Set;\n 31: iload_2\n 32: iload 9\n 34: iadd\n 35: invokestatic #122 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 38: iload_3\n 39: iload 10\n 41: iadd\n 42: invokestatic #122 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 45: invokestatic #128 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 48: invokeinterface #175, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 53: ifeq 62\n 56: iinc 8, 1\n 59: goto 108\n 62: iload_2\n 63: iload 9\n 65: iadd\n 66: iload 4\n 68: if_icmplt 98\n 71: iload_2\n 72: iload 9\n 74: iadd\n 75: iload 5\n 77: if_icmpgt 98\n 80: iload_3\n 81: iload 10\n 83: iadd\n 84: iload 6\n 86: if_icmplt 98\n 89: iload_3\n 90: iload 10\n 92: iadd\n 93: iload 7\n 95: if_icmple 108\n 98: aload_1\n 99: invokevirtual #135 // Method org/aoc2021/Day20$Image.getOutOfBoundsLit:()Z\n 102: ifeq 108\n 105: iinc 8, 1\n 108: iinc 10, 1\n 111: goto 15\n 114: iinc 9, 1\n 117: goto 6\n 120: iload 8\n 122: ireturn\n\n private final kotlin.Pair<java.lang.String, org.aoc2021.Day20$Image> parseInput(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: iconst_0\n 2: invokeinterface #182, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 7: checkcast #25 // class java/lang/String\n 10: astore_2\n 11: aload_1\n 12: checkcast #37 // class java/lang/Iterable\n 15: iconst_2\n 16: invokestatic #186 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 19: checkcast #37 // class java/lang/Iterable\n 22: astore 4\n 24: new #188 // class java/util/ArrayList\n 27: dup\n 28: invokespecial #189 // Method java/util/ArrayList.\"<init>\":()V\n 31: checkcast #191 // class java/util/Collection\n 34: astore 5\n 36: iconst_0\n 37: istore 6\n 39: aload 4\n 41: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 46: astore 7\n 48: aload 7\n 50: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 55: ifeq 243\n 58: aload 7\n 60: invokeinterface #97, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 65: astore 8\n 67: iload 6\n 69: iinc 6, 1\n 72: istore 9\n 74: iload 9\n 76: ifge 82\n 79: invokestatic #194 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 82: iload 9\n 84: aload 8\n 86: checkcast #25 // class java/lang/String\n 89: astore 10\n 91: istore 11\n 93: iconst_0\n 94: istore 12\n 96: aload 10\n 98: checkcast #137 // class java/lang/CharSequence\n 101: astore 13\n 103: iconst_0\n 104: istore 14\n 106: aload 13\n 108: astore 15\n 110: new #188 // class java/util/ArrayList\n 113: dup\n 114: aload 13\n 116: invokeinterface #197, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 121: invokespecial #200 // Method java/util/ArrayList.\"<init>\":(I)V\n 124: checkcast #191 // class java/util/Collection\n 127: astore 16\n 129: iconst_0\n 130: istore 17\n 132: iconst_0\n 133: istore 18\n 135: iconst_0\n 136: istore 19\n 138: iload 19\n 140: aload 15\n 142: invokeinterface #197, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 147: if_icmpge 218\n 150: aload 15\n 152: iload 19\n 154: invokeinterface #201, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 159: istore 20\n 161: aload 16\n 163: iload 18\n 165: iinc 18, 1\n 168: iload 20\n 170: istore 21\n 172: istore 22\n 174: astore 23\n 176: iconst_0\n 177: istore 24\n 179: iload 21\n 181: bipush 35\n 183: if_icmpne 202\n 186: iload 11\n 188: invokestatic #122 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 191: iload 22\n 193: invokestatic #122 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 196: invokestatic #128 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 199: goto 203\n 202: aconst_null\n 203: aload 23\n 205: swap\n 206: invokeinterface #202, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 211: pop\n 212: iinc 19, 1\n 215: goto 138\n 218: aload 16\n 220: checkcast #88 // class java/util/List\n 223: nop\n 224: checkcast #37 // class java/lang/Iterable\n 227: invokestatic #206 // Method kotlin/collections/CollectionsKt.filterNotNull:(Ljava/lang/Iterable;)Ljava/util/List;\n 230: checkcast #37 // class java/lang/Iterable\n 233: aload 5\n 235: swap\n 236: invokestatic #210 // Method kotlin/collections/CollectionsKt.addAll:(Ljava/util/Collection;Ljava/lang/Iterable;)Z\n 239: pop\n 240: goto 48\n 243: aload 5\n 245: checkcast #88 // class java/util/List\n 248: checkcast #37 // class java/lang/Iterable\n 251: invokestatic #152 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 254: astore_3\n 255: aload_2\n 256: new #30 // class org/aoc2021/Day20$Image\n 259: dup\n 260: aload_3\n 261: iconst_0\n 262: invokespecial #155 // Method org/aoc2021/Day20$Image.\"<init>\":(Ljava/util/Set;Z)V\n 265: invokestatic #128 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 268: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #231 // String args\n 3: invokestatic #237 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #239 // String input20.txt\n 8: iconst_0\n 9: anewarray #25 // class java/lang/String\n 12: invokestatic #245 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 15: getstatic #251 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 18: invokestatic #257 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 21: astore_1\n 22: getstatic #56 // Field INSTANCE:Lorg/aoc2021/Day20;\n 25: aload_1\n 26: invokestatic #261 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 29: aload_1\n 30: iconst_2\n 31: invokespecial #263 // Method solve:(Ljava/util/List;I)I\n 34: istore_2\n 35: getstatic #269 // Field java/lang/System.out:Ljava/io/PrintStream;\n 38: iload_2\n 39: invokevirtual #274 // Method java/io/PrintStream.println:(I)V\n 42: getstatic #56 // Field INSTANCE:Lorg/aoc2021/Day20;\n 45: aload_1\n 46: bipush 50\n 48: invokespecial #263 // Method solve:(Ljava/util/List;I)I\n 51: istore_3\n 52: getstatic #269 // Field java/lang/System.out:Ljava/io/PrintStream;\n 55: iload_3\n 56: invokevirtual #274 // Method java/io/PrintStream.println:(I)V\n 59: return\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day20\n 3: dup\n 4: invokespecial #279 // Method \"<init>\":()V\n 7: putstatic #56 // Field INSTANCE:Lorg/aoc2021/Day20;\n 10: return\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day8.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
object Day8 {
private fun solvePart1(lines: List<String>): Int {
return lines.sumOf { line ->
val outputDigits = line.split(" | ")[1].split(" ")
outputDigits.count { setOf(2, 3, 4, 7).contains(it.length) }
}
}
private fun solvePart2(lines: List<String>): Int {
return lines.sumOf { line ->
val (referenceDigits, outputDigits) = line.split(" | ").let {
it[0].split(" ") to it[1].split(" ")
}
solveLine(referenceDigits, outputDigits)
}
}
private fun solveLine(referenceDigits: List<String>, outputDigits: List<String>): Int {
val digitToChars = Array(10) { setOf<Char>() }
val referenceSets = referenceDigits.map(String::toSet)
digitToChars[1] = referenceSets.single { it.size == 2 }
digitToChars[4] = referenceSets.single { it.size == 4 }
digitToChars[7] = referenceSets.single { it.size == 3 }
digitToChars[8] = referenceSets.single { it.size == 7 }
digitToChars[3] = referenceSets.single { referenceSet ->
referenceSet.size == 5 && referenceSet.containsAll(digitToChars[1])
}
digitToChars[2] = referenceSets.single { referenceSet ->
referenceSet.size == 5 && referenceSet.intersect(digitToChars[4]).size == 2
}
digitToChars[5] = referenceSets.single { referenceSet ->
referenceSet.size == 5 && referenceSet.intersect(digitToChars[4]).size == 3 &&
referenceSet != digitToChars[3]
}
digitToChars[6] = referenceSets.single { referenceSet ->
referenceSet.size == 6 && referenceSet.intersect(digitToChars[1]).size == 1
}
digitToChars[9] = referenceSets.single { referenceSet ->
referenceSet.size == 6 && referenceSet.containsAll(digitToChars[4])
}
digitToChars[0] = referenceSets.single { referenceSet ->
referenceSet.size == 6 && referenceSet != digitToChars[6] && referenceSet != digitToChars[9]
}
val setToDigit = digitToChars.mapIndexed { index, chars -> chars to index}.toMap()
return outputDigits.fold(0) { sum, outputDigit ->
10 * sum + setToDigit[outputDigit.toSet()]!!
}
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input8.txt"), Charsets.UTF_8)
val solution1 = solvePart1(lines)
println(solution1)
val solution2 = solvePart2(lines)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day8.class",
"javap": "Compiled from \"Day8.kt\"\npublic final class org.aoc2021.Day8 {\n public static final org.aoc2021.Day8 INSTANCE;\n\n private org.aoc2021.Day8();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int solvePart1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #15 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore 4\n 15: aload 4\n 17: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 22: ifeq 271\n 25: aload 4\n 27: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 32: astore 5\n 34: iload_3\n 35: aload 5\n 37: checkcast #31 // class java/lang/String\n 40: astore 6\n 42: istore 17\n 44: iconst_0\n 45: istore 7\n 47: aload 6\n 49: checkcast #33 // class java/lang/CharSequence\n 52: iconst_1\n 53: anewarray #31 // class java/lang/String\n 56: astore 8\n 58: aload 8\n 60: iconst_0\n 61: ldc #35 // String |\n 63: aastore\n 64: aload 8\n 66: iconst_0\n 67: iconst_0\n 68: bipush 6\n 70: aconst_null\n 71: invokestatic #41 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 74: iconst_1\n 75: invokeinterface #47, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 80: checkcast #33 // class java/lang/CharSequence\n 83: iconst_1\n 84: anewarray #31 // class java/lang/String\n 87: astore 8\n 89: aload 8\n 91: iconst_0\n 92: ldc #49 // String\n 94: aastore\n 95: aload 8\n 97: iconst_0\n 98: iconst_0\n 99: bipush 6\n 101: aconst_null\n 102: invokestatic #41 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 105: astore 9\n 107: aload 9\n 109: checkcast #15 // class java/lang/Iterable\n 112: astore 8\n 114: iconst_0\n 115: istore 10\n 117: aload 8\n 119: instanceof #51 // class java/util/Collection\n 122: ifeq 142\n 125: aload 8\n 127: checkcast #51 // class java/util/Collection\n 130: invokeinterface #54, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 135: ifeq 142\n 138: iconst_0\n 139: goto 259\n 142: iconst_0\n 143: istore 11\n 145: aload 8\n 147: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 152: astore 12\n 154: aload 12\n 156: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 161: ifeq 257\n 164: aload 12\n 166: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 171: astore 13\n 173: aload 13\n 175: checkcast #31 // class java/lang/String\n 178: astore 14\n 180: iconst_0\n 181: istore 15\n 183: iconst_4\n 184: anewarray #56 // class java/lang/Integer\n 187: astore 16\n 189: aload 16\n 191: iconst_0\n 192: iconst_2\n 193: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 196: aastore\n 197: aload 16\n 199: iconst_1\n 200: iconst_3\n 201: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 204: aastore\n 205: aload 16\n 207: iconst_2\n 208: iconst_4\n 209: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 212: aastore\n 213: aload 16\n 215: iconst_3\n 216: bipush 7\n 218: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 221: aastore\n 222: aload 16\n 224: invokestatic #66 // Method kotlin/collections/SetsKt.setOf:([Ljava/lang/Object;)Ljava/util/Set;\n 227: aload 14\n 229: invokevirtual #70 // Method java/lang/String.length:()I\n 232: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 235: invokeinterface #76, 2 // InterfaceMethod java/util/Set.contains:(Ljava/lang/Object;)Z\n 240: ifeq 154\n 243: iinc 11, 1\n 246: iload 11\n 248: ifge 154\n 251: invokestatic #81 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 254: goto 154\n 257: iload 11\n 259: nop\n 260: istore 18\n 262: iload 17\n 264: iload 18\n 266: iadd\n 267: istore_3\n 268: goto 15\n 271: iload_3\n 272: ireturn\n\n private final int solvePart2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #15 // class java/lang/Iterable\n 4: astore_2\n 5: iconst_0\n 6: istore_3\n 7: aload_2\n 8: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 13: astore 4\n 15: aload 4\n 17: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 22: ifeq 192\n 25: aload 4\n 27: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 32: astore 5\n 34: iload_3\n 35: aload 5\n 37: checkcast #31 // class java/lang/String\n 40: astore 6\n 42: istore 13\n 44: iconst_0\n 45: istore 7\n 47: aload 6\n 49: checkcast #33 // class java/lang/CharSequence\n 52: iconst_1\n 53: anewarray #31 // class java/lang/String\n 56: astore 8\n 58: aload 8\n 60: iconst_0\n 61: ldc #35 // String |\n 63: aastore\n 64: aload 8\n 66: iconst_0\n 67: iconst_0\n 68: bipush 6\n 70: aconst_null\n 71: invokestatic #41 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 74: astore 9\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: iconst_0\n 82: invokeinterface #47, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 87: checkcast #33 // class java/lang/CharSequence\n 90: iconst_1\n 91: anewarray #31 // class java/lang/String\n 94: astore 11\n 96: aload 11\n 98: iconst_0\n 99: ldc #49 // String\n 101: aastore\n 102: aload 11\n 104: iconst_0\n 105: iconst_0\n 106: bipush 6\n 108: aconst_null\n 109: invokestatic #41 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 112: aload 9\n 114: iconst_1\n 115: invokeinterface #47, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 120: checkcast #33 // class java/lang/CharSequence\n 123: iconst_1\n 124: anewarray #31 // class java/lang/String\n 127: astore 11\n 129: aload 11\n 131: iconst_0\n 132: ldc #49 // String\n 134: aastore\n 135: aload 11\n 137: iconst_0\n 138: iconst_0\n 139: bipush 6\n 141: aconst_null\n 142: invokestatic #41 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 145: invokestatic #103 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 148: nop\n 149: astore 12\n 151: aload 12\n 153: invokevirtual #108 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 156: checkcast #43 // class java/util/List\n 159: astore 8\n 161: aload 12\n 163: invokevirtual #111 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 166: checkcast #43 // class java/util/List\n 169: astore 9\n 171: getstatic #114 // Field INSTANCE:Lorg/aoc2021/Day8;\n 174: aload 8\n 176: aload 9\n 178: invokespecial #118 // Method solveLine:(Ljava/util/List;Ljava/util/List;)I\n 181: istore 14\n 183: iload 13\n 185: iload 14\n 187: iadd\n 188: istore_3\n 189: goto 15\n 192: iload_3\n 193: ireturn\n\n private final int solveLine(java.util.List<java.lang.String>, java.util.List<java.lang.String>);\n Code:\n 0: iconst_0\n 1: istore 4\n 3: bipush 10\n 5: anewarray #72 // class java/util/Set\n 8: astore 5\n 10: iload 4\n 12: bipush 10\n 14: if_icmpge 35\n 17: iload 4\n 19: istore 6\n 21: aload 5\n 23: iload 6\n 25: invokestatic #126 // Method kotlin/collections/SetsKt.emptySet:()Ljava/util/Set;\n 28: aastore\n 29: iinc 4, 1\n 32: goto 10\n 35: aload 5\n 37: astore_3\n 38: aload_1\n 39: checkcast #15 // class java/lang/Iterable\n 42: astore 5\n 44: iconst_0\n 45: istore 6\n 47: aload 5\n 49: astore 7\n 51: new #128 // class java/util/ArrayList\n 54: dup\n 55: aload 5\n 57: bipush 10\n 59: invokestatic #132 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 62: invokespecial #135 // Method java/util/ArrayList.\"<init>\":(I)V\n 65: checkcast #51 // class java/util/Collection\n 68: astore 8\n 70: iconst_0\n 71: istore 9\n 73: aload 7\n 75: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 80: astore 10\n 82: aload 10\n 84: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 89: ifeq 135\n 92: aload 10\n 94: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 99: astore 11\n 101: aload 8\n 103: aload 11\n 105: checkcast #31 // class java/lang/String\n 108: astore 12\n 110: astore 18\n 112: iconst_0\n 113: istore 13\n 115: aload 12\n 117: checkcast #33 // class java/lang/CharSequence\n 120: invokestatic #139 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 123: aload 18\n 125: swap\n 126: invokeinterface #142, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 131: pop\n 132: goto 82\n 135: aload 8\n 137: checkcast #43 // class java/util/List\n 140: nop\n 141: astore 4\n 143: aload_3\n 144: iconst_1\n 145: aload 4\n 147: checkcast #15 // class java/lang/Iterable\n 150: astore 5\n 152: istore 19\n 154: astore 18\n 156: iconst_0\n 157: istore 6\n 159: aconst_null\n 160: astore 7\n 162: iconst_0\n 163: istore 8\n 165: aload 5\n 167: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 172: astore 9\n 174: aload 9\n 176: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 181: ifeq 247\n 184: aload 9\n 186: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 191: astore 10\n 193: aload 10\n 195: checkcast #72 // class java/util/Set\n 198: astore 11\n 200: iconst_0\n 201: istore 12\n 203: aload 11\n 205: invokeinterface #145, 1 // InterfaceMethod java/util/Set.size:()I\n 210: iconst_2\n 211: if_icmpne 218\n 214: iconst_1\n 215: goto 219\n 218: iconst_0\n 219: ifeq 174\n 222: iload 8\n 224: ifeq 237\n 227: new #147 // class java/lang/IllegalArgumentException\n 230: dup\n 231: ldc #149 // String Collection contains more than one matching element.\n 233: invokespecial #152 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 236: athrow\n 237: aload 10\n 239: astore 7\n 241: iconst_1\n 242: istore 8\n 244: goto 174\n 247: iload 8\n 249: ifne 262\n 252: new #154 // class java/util/NoSuchElementException\n 255: dup\n 256: ldc #156 // String Collection contains no element matching the predicate.\n 258: invokespecial #157 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 261: athrow\n 262: aload 7\n 264: astore 20\n 266: aload 18\n 268: iload 19\n 270: aload 20\n 272: aastore\n 273: aload_3\n 274: iconst_4\n 275: aload 4\n 277: checkcast #15 // class java/lang/Iterable\n 280: astore 5\n 282: istore 19\n 284: astore 18\n 286: iconst_0\n 287: istore 6\n 289: aconst_null\n 290: astore 7\n 292: iconst_0\n 293: istore 8\n 295: aload 5\n 297: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 302: astore 9\n 304: aload 9\n 306: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 311: ifeq 377\n 314: aload 9\n 316: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 321: astore 10\n 323: aload 10\n 325: checkcast #72 // class java/util/Set\n 328: astore 11\n 330: iconst_0\n 331: istore 12\n 333: aload 11\n 335: invokeinterface #145, 1 // InterfaceMethod java/util/Set.size:()I\n 340: iconst_4\n 341: if_icmpne 348\n 344: iconst_1\n 345: goto 349\n 348: iconst_0\n 349: ifeq 304\n 352: iload 8\n 354: ifeq 367\n 357: new #147 // class java/lang/IllegalArgumentException\n 360: dup\n 361: ldc #149 // String Collection contains more than one matching element.\n 363: invokespecial #152 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 366: athrow\n 367: aload 10\n 369: astore 7\n 371: iconst_1\n 372: istore 8\n 374: goto 304\n 377: iload 8\n 379: ifne 392\n 382: new #154 // class java/util/NoSuchElementException\n 385: dup\n 386: ldc #156 // String Collection contains no element matching the predicate.\n 388: invokespecial #157 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 391: athrow\n 392: aload 7\n 394: astore 20\n 396: aload 18\n 398: iload 19\n 400: aload 20\n 402: aastore\n 403: aload_3\n 404: bipush 7\n 406: aload 4\n 408: checkcast #15 // class java/lang/Iterable\n 411: astore 5\n 413: istore 19\n 415: astore 18\n 417: iconst_0\n 418: istore 6\n 420: aconst_null\n 421: astore 7\n 423: iconst_0\n 424: istore 8\n 426: aload 5\n 428: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 433: astore 9\n 435: aload 9\n 437: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 442: ifeq 508\n 445: aload 9\n 447: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 452: astore 10\n 454: aload 10\n 456: checkcast #72 // class java/util/Set\n 459: astore 11\n 461: iconst_0\n 462: istore 12\n 464: aload 11\n 466: invokeinterface #145, 1 // InterfaceMethod java/util/Set.size:()I\n 471: iconst_3\n 472: if_icmpne 479\n 475: iconst_1\n 476: goto 480\n 479: iconst_0\n 480: ifeq 435\n 483: iload 8\n 485: ifeq 498\n 488: new #147 // class java/lang/IllegalArgumentException\n 491: dup\n 492: ldc #149 // String Collection contains more than one matching element.\n 494: invokespecial #152 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 497: athrow\n 498: aload 10\n 500: astore 7\n 502: iconst_1\n 503: istore 8\n 505: goto 435\n 508: iload 8\n 510: ifne 523\n 513: new #154 // class java/util/NoSuchElementException\n 516: dup\n 517: ldc #156 // String Collection contains no element matching the predicate.\n 519: invokespecial #157 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 522: athrow\n 523: aload 7\n 525: astore 20\n 527: aload 18\n 529: iload 19\n 531: aload 20\n 533: aastore\n 534: aload_3\n 535: bipush 8\n 537: aload 4\n 539: checkcast #15 // class java/lang/Iterable\n 542: astore 5\n 544: istore 19\n 546: astore 18\n 548: iconst_0\n 549: istore 6\n 551: aconst_null\n 552: astore 7\n 554: iconst_0\n 555: istore 8\n 557: aload 5\n 559: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 564: astore 9\n 566: aload 9\n 568: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 573: ifeq 640\n 576: aload 9\n 578: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 583: astore 10\n 585: aload 10\n 587: checkcast #72 // class java/util/Set\n 590: astore 11\n 592: iconst_0\n 593: istore 12\n 595: aload 11\n 597: invokeinterface #145, 1 // InterfaceMethod java/util/Set.size:()I\n 602: bipush 7\n 604: if_icmpne 611\n 607: iconst_1\n 608: goto 612\n 611: iconst_0\n 612: ifeq 566\n 615: iload 8\n 617: ifeq 630\n 620: new #147 // class java/lang/IllegalArgumentException\n 623: dup\n 624: ldc #149 // String Collection contains more than one matching element.\n 626: invokespecial #152 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 629: athrow\n 630: aload 10\n 632: astore 7\n 634: iconst_1\n 635: istore 8\n 637: goto 566\n 640: iload 8\n 642: ifne 655\n 645: new #154 // class java/util/NoSuchElementException\n 648: dup\n 649: ldc #156 // String Collection contains no element matching the predicate.\n 651: invokespecial #157 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 654: athrow\n 655: aload 7\n 657: astore 20\n 659: aload 18\n 661: iload 19\n 663: aload 20\n 665: aastore\n 666: aload_3\n 667: iconst_3\n 668: aload 4\n 670: checkcast #15 // class java/lang/Iterable\n 673: astore 5\n 675: istore 19\n 677: astore 18\n 679: iconst_0\n 680: istore 6\n 682: aconst_null\n 683: astore 7\n 685: iconst_0\n 686: istore 8\n 688: aload 5\n 690: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 695: astore 9\n 697: aload 9\n 699: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 704: ifeq 786\n 707: aload 9\n 709: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 714: astore 10\n 716: aload 10\n 718: checkcast #72 // class java/util/Set\n 721: astore 11\n 723: iconst_0\n 724: istore 12\n 726: aload 11\n 728: invokeinterface #145, 1 // InterfaceMethod java/util/Set.size:()I\n 733: iconst_5\n 734: if_icmpne 757\n 737: aload 11\n 739: aload_3\n 740: iconst_1\n 741: aaload\n 742: checkcast #51 // class java/util/Collection\n 745: invokeinterface #161, 2 // InterfaceMethod java/util/Set.containsAll:(Ljava/util/Collection;)Z\n 750: ifeq 757\n 753: iconst_1\n 754: goto 758\n 757: iconst_0\n 758: ifeq 697\n 761: iload 8\n 763: ifeq 776\n 766: new #147 // class java/lang/IllegalArgumentException\n 769: dup\n 770: ldc #149 // String Collection contains more than one matching element.\n 772: invokespecial #152 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 775: athrow\n 776: aload 10\n 778: astore 7\n 780: iconst_1\n 781: istore 8\n 783: goto 697\n 786: iload 8\n 788: ifne 801\n 791: new #154 // class java/util/NoSuchElementException\n 794: dup\n 795: ldc #156 // String Collection contains no element matching the predicate.\n 797: invokespecial #157 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 800: athrow\n 801: aload 7\n 803: astore 20\n 805: aload 18\n 807: iload 19\n 809: aload 20\n 811: aastore\n 812: aload_3\n 813: iconst_2\n 814: aload 4\n 816: checkcast #15 // class java/lang/Iterable\n 819: astore 5\n 821: istore 19\n 823: astore 18\n 825: iconst_0\n 826: istore 6\n 828: aconst_null\n 829: astore 7\n 831: iconst_0\n 832: istore 8\n 834: aload 5\n 836: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 841: astore 9\n 843: aload 9\n 845: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 850: ifeq 939\n 853: aload 9\n 855: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 860: astore 10\n 862: aload 10\n 864: checkcast #72 // class java/util/Set\n 867: astore 11\n 869: iconst_0\n 870: istore 12\n 872: aload 11\n 874: invokeinterface #145, 1 // InterfaceMethod java/util/Set.size:()I\n 879: iconst_5\n 880: if_icmpne 910\n 883: aload 11\n 885: checkcast #15 // class java/lang/Iterable\n 888: aload_3\n 889: iconst_4\n 890: aaload\n 891: checkcast #15 // class java/lang/Iterable\n 894: invokestatic #165 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 897: invokeinterface #145, 1 // InterfaceMethod java/util/Set.size:()I\n 902: iconst_2\n 903: if_icmpne 910\n 906: iconst_1\n 907: goto 911\n 910: iconst_0\n 911: ifeq 843\n 914: iload 8\n 916: ifeq 929\n 919: new #147 // class java/lang/IllegalArgumentException\n 922: dup\n 923: ldc #149 // String Collection contains more than one matching element.\n 925: invokespecial #152 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 928: athrow\n 929: aload 10\n 931: astore 7\n 933: iconst_1\n 934: istore 8\n 936: goto 843\n 939: iload 8\n 941: ifne 954\n 944: new #154 // class java/util/NoSuchElementException\n 947: dup\n 948: ldc #156 // String Collection contains no element matching the predicate.\n 950: invokespecial #157 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 953: athrow\n 954: aload 7\n 956: astore 20\n 958: aload 18\n 960: iload 19\n 962: aload 20\n 964: aastore\n 965: aload_3\n 966: iconst_5\n 967: aload 4\n 969: checkcast #15 // class java/lang/Iterable\n 972: astore 5\n 974: istore 19\n 976: astore 18\n 978: iconst_0\n 979: istore 6\n 981: aconst_null\n 982: astore 7\n 984: iconst_0\n 985: istore 8\n 987: aload 5\n 989: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 994: astore 9\n 996: aload 9\n 998: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1003: ifeq 1103\n 1006: aload 9\n 1008: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1013: astore 10\n 1015: aload 10\n 1017: checkcast #72 // class java/util/Set\n 1020: astore 11\n 1022: iconst_0\n 1023: istore 12\n 1025: aload 11\n 1027: invokeinterface #145, 1 // InterfaceMethod java/util/Set.size:()I\n 1032: iconst_5\n 1033: if_icmpne 1074\n 1036: aload 11\n 1038: checkcast #15 // class java/lang/Iterable\n 1041: aload_3\n 1042: iconst_4\n 1043: aaload\n 1044: checkcast #15 // class java/lang/Iterable\n 1047: invokestatic #165 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 1050: invokeinterface #145, 1 // InterfaceMethod java/util/Set.size:()I\n 1055: iconst_3\n 1056: if_icmpne 1074\n 1059: aload 11\n 1061: aload_3\n 1062: iconst_3\n 1063: aaload\n 1064: invokestatic #171 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 1067: ifne 1074\n 1070: iconst_1\n 1071: goto 1075\n 1074: iconst_0\n 1075: ifeq 996\n 1078: iload 8\n 1080: ifeq 1093\n 1083: new #147 // class java/lang/IllegalArgumentException\n 1086: dup\n 1087: ldc #149 // String Collection contains more than one matching element.\n 1089: invokespecial #152 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 1092: athrow\n 1093: aload 10\n 1095: astore 7\n 1097: iconst_1\n 1098: istore 8\n 1100: goto 996\n 1103: iload 8\n 1105: ifne 1118\n 1108: new #154 // class java/util/NoSuchElementException\n 1111: dup\n 1112: ldc #156 // String Collection contains no element matching the predicate.\n 1114: invokespecial #157 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 1117: athrow\n 1118: aload 7\n 1120: astore 20\n 1122: aload 18\n 1124: iload 19\n 1126: aload 20\n 1128: aastore\n 1129: aload_3\n 1130: bipush 6\n 1132: aload 4\n 1134: checkcast #15 // class java/lang/Iterable\n 1137: astore 5\n 1139: istore 19\n 1141: astore 18\n 1143: iconst_0\n 1144: istore 6\n 1146: aconst_null\n 1147: astore 7\n 1149: iconst_0\n 1150: istore 8\n 1152: aload 5\n 1154: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1159: astore 9\n 1161: aload 9\n 1163: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1168: ifeq 1258\n 1171: aload 9\n 1173: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1178: astore 10\n 1180: aload 10\n 1182: checkcast #72 // class java/util/Set\n 1185: astore 11\n 1187: iconst_0\n 1188: istore 12\n 1190: aload 11\n 1192: invokeinterface #145, 1 // InterfaceMethod java/util/Set.size:()I\n 1197: bipush 6\n 1199: if_icmpne 1229\n 1202: aload 11\n 1204: checkcast #15 // class java/lang/Iterable\n 1207: aload_3\n 1208: iconst_1\n 1209: aaload\n 1210: checkcast #15 // class java/lang/Iterable\n 1213: invokestatic #165 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 1216: invokeinterface #145, 1 // InterfaceMethod java/util/Set.size:()I\n 1221: iconst_1\n 1222: if_icmpne 1229\n 1225: iconst_1\n 1226: goto 1230\n 1229: iconst_0\n 1230: ifeq 1161\n 1233: iload 8\n 1235: ifeq 1248\n 1238: new #147 // class java/lang/IllegalArgumentException\n 1241: dup\n 1242: ldc #149 // String Collection contains more than one matching element.\n 1244: invokespecial #152 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 1247: athrow\n 1248: aload 10\n 1250: astore 7\n 1252: iconst_1\n 1253: istore 8\n 1255: goto 1161\n 1258: iload 8\n 1260: ifne 1273\n 1263: new #154 // class java/util/NoSuchElementException\n 1266: dup\n 1267: ldc #156 // String Collection contains no element matching the predicate.\n 1269: invokespecial #157 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 1272: athrow\n 1273: aload 7\n 1275: astore 20\n 1277: aload 18\n 1279: iload 19\n 1281: aload 20\n 1283: aastore\n 1284: aload_3\n 1285: bipush 9\n 1287: aload 4\n 1289: checkcast #15 // class java/lang/Iterable\n 1292: astore 5\n 1294: istore 19\n 1296: astore 18\n 1298: iconst_0\n 1299: istore 6\n 1301: aconst_null\n 1302: astore 7\n 1304: iconst_0\n 1305: istore 8\n 1307: aload 5\n 1309: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1314: astore 9\n 1316: aload 9\n 1318: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1323: ifeq 1406\n 1326: aload 9\n 1328: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1333: astore 10\n 1335: aload 10\n 1337: checkcast #72 // class java/util/Set\n 1340: astore 11\n 1342: iconst_0\n 1343: istore 12\n 1345: aload 11\n 1347: invokeinterface #145, 1 // InterfaceMethod java/util/Set.size:()I\n 1352: bipush 6\n 1354: if_icmpne 1377\n 1357: aload 11\n 1359: aload_3\n 1360: iconst_4\n 1361: aaload\n 1362: checkcast #51 // class java/util/Collection\n 1365: invokeinterface #161, 2 // InterfaceMethod java/util/Set.containsAll:(Ljava/util/Collection;)Z\n 1370: ifeq 1377\n 1373: iconst_1\n 1374: goto 1378\n 1377: iconst_0\n 1378: ifeq 1316\n 1381: iload 8\n 1383: ifeq 1396\n 1386: new #147 // class java/lang/IllegalArgumentException\n 1389: dup\n 1390: ldc #149 // String Collection contains more than one matching element.\n 1392: invokespecial #152 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 1395: athrow\n 1396: aload 10\n 1398: astore 7\n 1400: iconst_1\n 1401: istore 8\n 1403: goto 1316\n 1406: iload 8\n 1408: ifne 1421\n 1411: new #154 // class java/util/NoSuchElementException\n 1414: dup\n 1415: ldc #156 // String Collection contains no element matching the predicate.\n 1417: invokespecial #157 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 1420: athrow\n 1421: aload 7\n 1423: astore 20\n 1425: aload 18\n 1427: iload 19\n 1429: aload 20\n 1431: aastore\n 1432: aload_3\n 1433: iconst_0\n 1434: aload 4\n 1436: checkcast #15 // class java/lang/Iterable\n 1439: astore 5\n 1441: istore 19\n 1443: astore 18\n 1445: iconst_0\n 1446: istore 6\n 1448: aconst_null\n 1449: astore 7\n 1451: iconst_0\n 1452: istore 8\n 1454: aload 5\n 1456: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1461: astore 9\n 1463: aload 9\n 1465: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1470: ifeq 1561\n 1473: aload 9\n 1475: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1480: astore 10\n 1482: aload 10\n 1484: checkcast #72 // class java/util/Set\n 1487: astore 11\n 1489: iconst_0\n 1490: istore 12\n 1492: aload 11\n 1494: invokeinterface #145, 1 // InterfaceMethod java/util/Set.size:()I\n 1499: bipush 6\n 1501: if_icmpne 1532\n 1504: aload 11\n 1506: aload_3\n 1507: bipush 6\n 1509: aaload\n 1510: invokestatic #171 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 1513: ifne 1532\n 1516: aload 11\n 1518: aload_3\n 1519: bipush 9\n 1521: aaload\n 1522: invokestatic #171 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 1525: ifne 1532\n 1528: iconst_1\n 1529: goto 1533\n 1532: iconst_0\n 1533: ifeq 1463\n 1536: iload 8\n 1538: ifeq 1551\n 1541: new #147 // class java/lang/IllegalArgumentException\n 1544: dup\n 1545: ldc #149 // String Collection contains more than one matching element.\n 1547: invokespecial #152 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 1550: athrow\n 1551: aload 10\n 1553: astore 7\n 1555: iconst_1\n 1556: istore 8\n 1558: goto 1463\n 1561: iload 8\n 1563: ifne 1576\n 1566: new #154 // class java/util/NoSuchElementException\n 1569: dup\n 1570: ldc #156 // String Collection contains no element matching the predicate.\n 1572: invokespecial #157 // Method java/util/NoSuchElementException.\"<init>\":(Ljava/lang/String;)V\n 1575: athrow\n 1576: aload 7\n 1578: astore 20\n 1580: aload 18\n 1582: iload 19\n 1584: aload 20\n 1586: aastore\n 1587: aload_3\n 1588: astore 6\n 1590: iconst_0\n 1591: istore 7\n 1593: aload 6\n 1595: astore 8\n 1597: new #128 // class java/util/ArrayList\n 1600: dup\n 1601: aload 6\n 1603: arraylength\n 1604: invokespecial #135 // Method java/util/ArrayList.\"<init>\":(I)V\n 1607: checkcast #51 // class java/util/Collection\n 1610: astore 9\n 1612: iconst_0\n 1613: istore 10\n 1615: iconst_0\n 1616: istore 11\n 1618: iconst_0\n 1619: istore 12\n 1621: aload 8\n 1623: arraylength\n 1624: istore 13\n 1626: iload 12\n 1628: iload 13\n 1630: if_icmpge 1683\n 1633: aload 8\n 1635: iload 12\n 1637: aaload\n 1638: astore 14\n 1640: aload 9\n 1642: iload 11\n 1644: iinc 11, 1\n 1647: aload 14\n 1649: astore 15\n 1651: istore 16\n 1653: astore 18\n 1655: iconst_0\n 1656: istore 17\n 1658: aload 15\n 1660: iload 16\n 1662: invokestatic #60 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 1665: invokestatic #103 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 1668: aload 18\n 1670: swap\n 1671: invokeinterface #142, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 1676: pop\n 1677: iinc 12, 1\n 1680: goto 1626\n 1683: aload 9\n 1685: checkcast #43 // class java/util/List\n 1688: nop\n 1689: checkcast #15 // class java/lang/Iterable\n 1692: invokestatic #177 // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;\n 1695: astore 5\n 1697: aload_2\n 1698: checkcast #15 // class java/lang/Iterable\n 1701: astore 6\n 1703: iconst_0\n 1704: istore 7\n 1706: iconst_0\n 1707: istore 8\n 1709: iload 7\n 1711: istore 9\n 1713: aload 6\n 1715: invokeinterface #19, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 1720: astore 10\n 1722: aload 10\n 1724: invokeinterface #25, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 1729: ifeq 1791\n 1732: aload 10\n 1734: invokeinterface #29, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 1739: astore 11\n 1741: iload 9\n 1743: aload 11\n 1745: checkcast #31 // class java/lang/String\n 1748: astore 12\n 1750: istore 13\n 1752: iconst_0\n 1753: istore 14\n 1755: bipush 10\n 1757: iload 13\n 1759: imul\n 1760: aload 5\n 1762: aload 12\n 1764: checkcast #33 // class java/lang/CharSequence\n 1767: invokestatic #139 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 1770: invokeinterface #182, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 1775: dup\n 1776: invokestatic #186 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 1779: checkcast #188 // class java/lang/Number\n 1782: invokevirtual #191 // Method java/lang/Number.intValue:()I\n 1785: iadd\n 1786: istore 9\n 1788: goto 1722\n 1791: iload 9\n 1793: ireturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #245 // String args\n 3: invokestatic #249 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #251 // String input8.txt\n 8: iconst_0\n 9: anewarray #31 // class java/lang/String\n 12: invokestatic #257 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 15: getstatic #263 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 18: invokestatic #269 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 21: astore_1\n 22: getstatic #114 // Field INSTANCE:Lorg/aoc2021/Day8;\n 25: aload_1\n 26: invokestatic #186 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 29: aload_1\n 30: invokespecial #271 // Method solvePart1:(Ljava/util/List;)I\n 33: istore_2\n 34: getstatic #277 // Field java/lang/System.out:Ljava/io/PrintStream;\n 37: iload_2\n 38: invokevirtual #282 // Method java/io/PrintStream.println:(I)V\n 41: getstatic #114 // Field INSTANCE:Lorg/aoc2021/Day8;\n 44: aload_1\n 45: invokespecial #284 // Method solvePart2:(Ljava/util/List;)I\n 48: istore_3\n 49: getstatic #277 // Field java/lang/System.out:Ljava/io/PrintStream;\n 52: iload_3\n 53: invokevirtual #282 // Method java/io/PrintStream.println:(I)V\n 56: return\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day8\n 3: dup\n 4: invokespecial #289 // Method \"<init>\":()V\n 7: putstatic #114 // Field INSTANCE:Lorg/aoc2021/Day8;\n 10: return\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day25.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
object Day25 {
private fun solve(lines: List<String>): Int {
var grid = parseInput(lines)
var turns = 0
while (true) {
turns++
val prevGrid = grid
grid = simulateTurn(grid)
if (prevGrid == grid) {
return turns
}
}
}
private fun simulateTurn(grid: List<List<Char>>): List<List<Char>> {
return moveDown(moveRight(grid))
}
private fun moveRight(grid: List<List<Char>>): List<List<Char>> {
val newGrid = Array(grid.size) { Array(grid[0].size) { 'X' } }
for (i in grid.indices) {
for (j in grid[0].indices) {
if (grid[i][j] == '>') {
val nj = (j + 1) % grid[0].size
if (grid[i][nj] == '.') {
newGrid[i][j] = '.'
newGrid[i][nj] = '>'
} else if (newGrid[i][j] == 'X') {
newGrid[i][j] = '>'
}
} else if (newGrid[i][j] == 'X') {
newGrid[i][j] = grid[i][j]
}
}
}
return newGrid.map(Array<Char>::toList)
}
private fun moveDown(grid: List<List<Char>>): List<List<Char>> {
val newGrid = Array(grid.size) { Array(grid[0].size) { 'X' } }
for (i in grid.indices) {
for (j in grid[0].indices) {
if (grid[i][j] == 'v') {
val ni = (i + 1) % grid.size
if (grid[ni][j] == '.') {
newGrid[i][j] = '.'
newGrid[ni][j] = 'v'
} else if (newGrid[i][j] == 'X') {
newGrid[i][j] = 'v'
}
} else if (newGrid[i][j] == 'X') {
newGrid[i][j] = grid[i][j]
}
}
}
return newGrid.map(Array<Char>::toList)
}
private fun parseInput(lines: List<String>): List<List<Char>> {
return lines.map { line -> line.toCharArray().toList() }
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input25.txt"), Charsets.UTF_8)
val solution = solve(lines)
println(solution)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day25.class",
"javap": "Compiled from \"Day25.kt\"\npublic final class org.aoc2021.Day25 {\n public static final org.aoc2021.Day25 INSTANCE;\n\n private org.aoc2021.Day25();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int solve(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #17 // Method parseInput:(Ljava/util/List;)Ljava/util/List;\n 5: astore_2\n 6: iconst_0\n 7: istore_3\n 8: nop\n 9: iinc 3, 1\n 12: aload_2\n 13: astore 4\n 15: aload_0\n 16: aload_2\n 17: invokespecial #20 // Method simulateTurn:(Ljava/util/List;)Ljava/util/List;\n 20: astore_2\n 21: aload 4\n 23: aload_2\n 24: invokestatic #26 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 27: ifeq 8\n 30: iload_3\n 31: ireturn\n\n private final java.util.List<java.util.List<java.lang.Character>> simulateTurn(java.util.List<? extends java.util.List<java.lang.Character>>);\n Code:\n 0: aload_0\n 1: aload_0\n 2: aload_1\n 3: invokespecial #38 // Method moveRight:(Ljava/util/List;)Ljava/util/List;\n 6: invokespecial #41 // Method moveDown:(Ljava/util/List;)Ljava/util/List;\n 9: areturn\n\n private final java.util.List<java.util.List<java.lang.Character>> moveRight(java.util.List<? extends java.util.List<java.lang.Character>>);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: aload_1\n 3: invokeinterface #45, 1 // InterfaceMethod java/util/List.size:()I\n 8: istore 4\n 10: iload 4\n 12: anewarray #47 // class \"[Ljava/lang/Character;\"\n 15: astore 5\n 17: iload_3\n 18: iload 4\n 20: if_icmpge 101\n 23: iload_3\n 24: istore 6\n 26: aload 5\n 28: iload 6\n 30: iconst_0\n 31: istore 7\n 33: aload_1\n 34: iconst_0\n 35: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 40: checkcast #34 // class java/util/List\n 43: invokeinterface #45, 1 // InterfaceMethod java/util/List.size:()I\n 48: istore 8\n 50: iload 8\n 52: anewarray #53 // class java/lang/Character\n 55: astore 9\n 57: istore 14\n 59: astore 13\n 61: iload 7\n 63: iload 8\n 65: if_icmpge 88\n 68: iload 7\n 70: istore 10\n 72: aload 9\n 74: iload 10\n 76: bipush 88\n 78: invokestatic #57 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 81: aastore\n 82: iinc 7, 1\n 85: goto 61\n 88: aload 13\n 90: iload 14\n 92: aload 9\n 94: aastore\n 95: iinc 3, 1\n 98: goto 17\n 101: aload 5\n 103: astore_2\n 104: iconst_0\n 105: istore_3\n 106: aload_1\n 107: checkcast #59 // class java/util/Collection\n 110: invokeinterface #60, 1 // InterfaceMethod java/util/Collection.size:()I\n 115: istore 4\n 117: iload_3\n 118: iload 4\n 120: if_icmpge 330\n 123: iconst_0\n 124: istore 5\n 126: aload_1\n 127: iconst_0\n 128: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 133: checkcast #59 // class java/util/Collection\n 136: invokeinterface #60, 1 // InterfaceMethod java/util/Collection.size:()I\n 141: istore 6\n 143: iload 5\n 145: iload 6\n 147: if_icmpge 324\n 150: aload_1\n 151: iload_3\n 152: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 157: checkcast #34 // class java/util/List\n 160: iload 5\n 162: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 167: checkcast #53 // class java/lang/Character\n 170: invokevirtual #64 // Method java/lang/Character.charValue:()C\n 173: bipush 62\n 175: if_icmpne 281\n 178: iload 5\n 180: iconst_1\n 181: iadd\n 182: aload_1\n 183: iconst_0\n 184: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 189: checkcast #34 // class java/util/List\n 192: invokeinterface #45, 1 // InterfaceMethod java/util/List.size:()I\n 197: irem\n 198: istore 7\n 200: aload_1\n 201: iload_3\n 202: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 207: checkcast #34 // class java/util/List\n 210: iload 7\n 212: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 217: checkcast #53 // class java/lang/Character\n 220: invokevirtual #64 // Method java/lang/Character.charValue:()C\n 223: bipush 46\n 225: if_icmpne 253\n 228: aload_2\n 229: iload_3\n 230: aaload\n 231: iload 5\n 233: bipush 46\n 235: invokestatic #57 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 238: aastore\n 239: aload_2\n 240: iload_3\n 241: aaload\n 242: iload 7\n 244: bipush 62\n 246: invokestatic #57 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 249: aastore\n 250: goto 318\n 253: aload_2\n 254: iload_3\n 255: aaload\n 256: iload 5\n 258: aaload\n 259: invokevirtual #64 // Method java/lang/Character.charValue:()C\n 262: bipush 88\n 264: if_icmpne 318\n 267: aload_2\n 268: iload_3\n 269: aaload\n 270: iload 5\n 272: bipush 62\n 274: invokestatic #57 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 277: aastore\n 278: goto 318\n 281: aload_2\n 282: iload_3\n 283: aaload\n 284: iload 5\n 286: aaload\n 287: invokevirtual #64 // Method java/lang/Character.charValue:()C\n 290: bipush 88\n 292: if_icmpne 318\n 295: aload_2\n 296: iload_3\n 297: aaload\n 298: iload 5\n 300: aload_1\n 301: iload_3\n 302: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 307: checkcast #34 // class java/util/List\n 310: iload 5\n 312: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 317: aastore\n 318: iinc 5, 1\n 321: goto 143\n 324: iinc 3, 1\n 327: goto 117\n 330: aload_2\n 331: checkcast #66 // class \"[Ljava/lang/Object;\"\n 334: astore_3\n 335: iconst_0\n 336: istore 4\n 338: aload_3\n 339: astore 5\n 341: new #68 // class java/util/ArrayList\n 344: dup\n 345: aload_3\n 346: arraylength\n 347: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 350: checkcast #59 // class java/util/Collection\n 353: astore 6\n 355: iconst_0\n 356: istore 7\n 358: iconst_0\n 359: istore 8\n 361: aload 5\n 363: arraylength\n 364: istore 9\n 366: iload 8\n 368: iload 9\n 370: if_icmpge 414\n 373: aload 5\n 375: iload 8\n 377: aaload\n 378: astore 10\n 380: aload 6\n 382: aload 10\n 384: checkcast #47 // class \"[Ljava/lang/Character;\"\n 387: astore 11\n 389: astore 13\n 391: iconst_0\n 392: istore 12\n 394: aload 11\n 396: invokestatic #77 // Method kotlin/collections/ArraysKt.toList:([Ljava/lang/Object;)Ljava/util/List;\n 399: aload 13\n 401: swap\n 402: invokeinterface #81, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 407: pop\n 408: iinc 8, 1\n 411: goto 366\n 414: aload 6\n 416: checkcast #34 // class java/util/List\n 419: nop\n 420: areturn\n\n private final java.util.List<java.util.List<java.lang.Character>> moveDown(java.util.List<? extends java.util.List<java.lang.Character>>);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: aload_1\n 3: invokeinterface #45, 1 // InterfaceMethod java/util/List.size:()I\n 8: istore 4\n 10: iload 4\n 12: anewarray #47 // class \"[Ljava/lang/Character;\"\n 15: astore 5\n 17: iload_3\n 18: iload 4\n 20: if_icmpge 101\n 23: iload_3\n 24: istore 6\n 26: aload 5\n 28: iload 6\n 30: iconst_0\n 31: istore 7\n 33: aload_1\n 34: iconst_0\n 35: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 40: checkcast #34 // class java/util/List\n 43: invokeinterface #45, 1 // InterfaceMethod java/util/List.size:()I\n 48: istore 8\n 50: iload 8\n 52: anewarray #53 // class java/lang/Character\n 55: astore 9\n 57: istore 14\n 59: astore 13\n 61: iload 7\n 63: iload 8\n 65: if_icmpge 88\n 68: iload 7\n 70: istore 10\n 72: aload 9\n 74: iload 10\n 76: bipush 88\n 78: invokestatic #57 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 81: aastore\n 82: iinc 7, 1\n 85: goto 61\n 88: aload 13\n 90: iload 14\n 92: aload 9\n 94: aastore\n 95: iinc 3, 1\n 98: goto 17\n 101: aload 5\n 103: astore_2\n 104: iconst_0\n 105: istore_3\n 106: aload_1\n 107: checkcast #59 // class java/util/Collection\n 110: invokeinterface #60, 1 // InterfaceMethod java/util/Collection.size:()I\n 115: istore 4\n 117: iload_3\n 118: iload 4\n 120: if_icmpge 322\n 123: iconst_0\n 124: istore 5\n 126: aload_1\n 127: iconst_0\n 128: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 133: checkcast #59 // class java/util/Collection\n 136: invokeinterface #60, 1 // InterfaceMethod java/util/Collection.size:()I\n 141: istore 6\n 143: iload 5\n 145: iload 6\n 147: if_icmpge 316\n 150: aload_1\n 151: iload_3\n 152: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 157: checkcast #34 // class java/util/List\n 160: iload 5\n 162: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 167: checkcast #53 // class java/lang/Character\n 170: invokevirtual #64 // Method java/lang/Character.charValue:()C\n 173: bipush 118\n 175: if_icmpne 273\n 178: iload_3\n 179: iconst_1\n 180: iadd\n 181: aload_1\n 182: invokeinterface #45, 1 // InterfaceMethod java/util/List.size:()I\n 187: irem\n 188: istore 7\n 190: aload_1\n 191: iload 7\n 193: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 198: checkcast #34 // class java/util/List\n 201: iload 5\n 203: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 208: checkcast #53 // class java/lang/Character\n 211: invokevirtual #64 // Method java/lang/Character.charValue:()C\n 214: bipush 46\n 216: if_icmpne 245\n 219: aload_2\n 220: iload_3\n 221: aaload\n 222: iload 5\n 224: bipush 46\n 226: invokestatic #57 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 229: aastore\n 230: aload_2\n 231: iload 7\n 233: aaload\n 234: iload 5\n 236: bipush 118\n 238: invokestatic #57 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 241: aastore\n 242: goto 310\n 245: aload_2\n 246: iload_3\n 247: aaload\n 248: iload 5\n 250: aaload\n 251: invokevirtual #64 // Method java/lang/Character.charValue:()C\n 254: bipush 88\n 256: if_icmpne 310\n 259: aload_2\n 260: iload_3\n 261: aaload\n 262: iload 5\n 264: bipush 118\n 266: invokestatic #57 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 269: aastore\n 270: goto 310\n 273: aload_2\n 274: iload_3\n 275: aaload\n 276: iload 5\n 278: aaload\n 279: invokevirtual #64 // Method java/lang/Character.charValue:()C\n 282: bipush 88\n 284: if_icmpne 310\n 287: aload_2\n 288: iload_3\n 289: aaload\n 290: iload 5\n 292: aload_1\n 293: iload_3\n 294: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 299: checkcast #34 // class java/util/List\n 302: iload 5\n 304: invokeinterface #51, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 309: aastore\n 310: iinc 5, 1\n 313: goto 143\n 316: iinc 3, 1\n 319: goto 117\n 322: aload_2\n 323: checkcast #66 // class \"[Ljava/lang/Object;\"\n 326: astore_3\n 327: iconst_0\n 328: istore 4\n 330: aload_3\n 331: astore 5\n 333: new #68 // class java/util/ArrayList\n 336: dup\n 337: aload_3\n 338: arraylength\n 339: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 342: checkcast #59 // class java/util/Collection\n 345: astore 6\n 347: iconst_0\n 348: istore 7\n 350: iconst_0\n 351: istore 8\n 353: aload 5\n 355: arraylength\n 356: istore 9\n 358: iload 8\n 360: iload 9\n 362: if_icmpge 406\n 365: aload 5\n 367: iload 8\n 369: aaload\n 370: astore 10\n 372: aload 6\n 374: aload 10\n 376: checkcast #47 // class \"[Ljava/lang/Character;\"\n 379: astore 11\n 381: astore 13\n 383: iconst_0\n 384: istore 12\n 386: aload 11\n 388: invokestatic #77 // Method kotlin/collections/ArraysKt.toList:([Ljava/lang/Object;)Ljava/util/List;\n 391: aload 13\n 393: swap\n 394: invokeinterface #81, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 399: pop\n 400: iinc 8, 1\n 403: goto 358\n 406: aload 6\n 408: checkcast #34 // class java/util/List\n 411: nop\n 412: areturn\n\n private final java.util.List<java.util.List<java.lang.Character>> parseInput(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #102 // 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 #68 // class java/util/ArrayList\n 13: dup\n 14: aload_2\n 15: bipush 10\n 17: invokestatic #108 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 20: invokespecial #71 // Method java/util/ArrayList.\"<init>\":(I)V\n 23: checkcast #59 // class java/util/Collection\n 26: astore 5\n 28: iconst_0\n 29: istore 6\n 31: aload 4\n 33: invokeinterface #112, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 7\n 40: aload 7\n 42: invokeinterface #118, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 99\n 50: aload 7\n 52: invokeinterface #122, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 8\n 59: aload 5\n 61: aload 8\n 63: checkcast #124 // 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: invokevirtual #128 // Method java/lang/String.toCharArray:()[C\n 78: dup\n 79: ldc #130 // String toCharArray(...)\n 81: invokestatic #134 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 84: invokestatic #137 // Method kotlin/collections/ArraysKt.toList:([C)Ljava/util/List;\n 87: aload 11\n 89: swap\n 90: invokeinterface #81, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 95: pop\n 96: goto 40\n 99: aload 5\n 101: checkcast #34 // class java/util/List\n 104: nop\n 105: areturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #147 // String args\n 3: invokestatic #150 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: ldc #152 // String input25.txt\n 8: iconst_0\n 9: anewarray #124 // class java/lang/String\n 12: invokestatic #158 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 15: getstatic #164 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 18: invokestatic #170 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 21: astore_1\n 22: getstatic #173 // Field INSTANCE:Lorg/aoc2021/Day25;\n 25: aload_1\n 26: invokestatic #177 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 29: aload_1\n 30: invokespecial #179 // Method solve:(Ljava/util/List;)I\n 33: istore_2\n 34: getstatic #185 // Field java/lang/System.out:Ljava/io/PrintStream;\n 37: iload_2\n 38: invokevirtual #190 // Method java/io/PrintStream.println:(I)V\n 41: return\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day25\n 3: dup\n 4: invokespecial #194 // Method \"<init>\":()V\n 7: putstatic #173 // Field INSTANCE:Lorg/aoc2021/Day25;\n 10: return\n}\n",
"javap_err": ""
}
] |
jsgroth__advent-of-code-2021__ba81fad/src/org/aoc2021/Day18.kt
|
package org.aoc2021
import java.nio.file.Files
import java.nio.file.Path
object Day18 {
data class TreeNode(val left: TreeNode? = null, val right: TreeNode? = null, val value: Int? = null)
private fun solvePart1(lines: List<String>): Int {
val snailfishNumbers = lines.map(Day18::parseSnailfishNumber)
val snailfishSum = snailfishNumbers.reduce(Day18::addSnailfishNumbers)
return magnitude(snailfishSum)
}
private fun solvePart2(lines: List<String>): Int {
val snailfishNumbers = lines.map(Day18::parseSnailfishNumber)
return snailfishNumbers.maxOf { snailfishNumber ->
snailfishNumbers.filter { it !== snailfishNumber }.maxOf { otherNumber ->
magnitude(addSnailfishNumbers(snailfishNumber, otherNumber))
}
}
}
private fun parseSnailfishNumber(line: String): TreeNode {
return parseNode(line, 0, false).first
}
private fun parseNode(line: String, i: Int, parsingRight: Boolean): Pair<TreeNode, Int> {
return if (line[i] == '[') {
val (left, j) = parseNode(line, i + 1, false)
val (right, k) = parseNode(line, j + 1, true)
TreeNode(left = left, right = right) to k + 1
} else {
val endChar = if (parsingRight) ']' else ','
val end = line.indexOf(endChar, startIndex = i)
val value = line.substring(i, end).toInt()
TreeNode(value = value) to end
}
}
private fun addSnailfishNumbers(first: TreeNode, second: TreeNode): TreeNode {
return reduceSnailfishNumber(TreeNode(left = first, right = second))
}
private tailrec fun reduceSnailfishNumber(number: TreeNode): TreeNode {
findNodeToExplode(number)?.let { nodeToExplode ->
return reduceSnailfishNumber(explode(number, nodeToExplode))
}
findNodeToSplit(number)?.let { nodeToSplit ->
return reduceSnailfishNumber(split(number, nodeToSplit))
}
return number
}
private fun findNodeToExplode(number: TreeNode, depth: Int = 0): TreeNode? {
if (depth == 4 && number.left != null && number.right != null) {
return number
}
if (number.left == null || number.right == null) {
return null
}
findNodeToExplode(number.left, depth + 1)?.let { return it }
return findNodeToExplode(number.right, depth + 1)
}
private fun explode(number: TreeNode, nodeToExplode: TreeNode): TreeNode {
val allNodes = traverse(number)
val nodeToExplodeIndex = allNodes.indexOfFirst { it === nodeToExplode }
val lastValueBefore = allNodes.subList(0, nodeToExplodeIndex - 1).findLast { it.value != null }
val firstValueAfter = allNodes.subList(nodeToExplodeIndex + 2, allNodes.size).find { it.value != null }
return doExplode(number, nodeToExplode, lastValueBefore, firstValueAfter)
}
private fun traverse(number: TreeNode): List<TreeNode> {
return if (number.left == null || number.right == null) {
listOf(number)
} else {
traverse(number.left).plus(number).plus(traverse(number.right))
}
}
private fun doExplode(
number: TreeNode,
nodeToExplode: TreeNode,
lastValueBefore: TreeNode?,
firstValueAfter: TreeNode?,
): TreeNode {
if (number === nodeToExplode) {
return TreeNode(value = 0)
}
if (number === lastValueBefore) {
return TreeNode(value = number.value!! + nodeToExplode.left!!.value!!)
}
if (number === firstValueAfter) {
return TreeNode(value = number.value!! + nodeToExplode.right!!.value!!)
}
if (number.left == null || number.right == null) {
return number
}
return TreeNode(
left = doExplode(number.left, nodeToExplode, lastValueBefore, firstValueAfter),
right = doExplode(number.right, nodeToExplode, lastValueBefore, firstValueAfter),
)
}
private fun findNodeToSplit(number: TreeNode): TreeNode? {
if (number.value != null && number.value >= 10) {
return number
}
if (number.left == null || number.right == null) {
return null
}
findNodeToSplit(number.left)?.let { return it }
return findNodeToSplit(number.right)
}
private fun split(number: TreeNode, nodeToSplit: TreeNode): TreeNode {
if (number === nodeToSplit) {
return TreeNode(
left = TreeNode(value = number.value!! / 2),
right = TreeNode(value = number.value / 2 + (number.value % 2)),
)
}
if (number.left == null || number.right == null) {
return number
}
return TreeNode(
left = split(number.left, nodeToSplit),
right = split(number.right, nodeToSplit),
)
}
private fun magnitude(number: TreeNode): Int {
if (number.left == null || number.right == null) {
return number.value!!
}
return 3 * magnitude(number.left) + 2 * magnitude(number.right)
}
@JvmStatic
fun main(args: Array<String>) {
val lines = Files.readAllLines(Path.of("input18.txt"), Charsets.UTF_8)
val solution1 = solvePart1(lines)
println(solution1)
val solution2 = solvePart2(lines)
println(solution2)
}
}
|
[
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day18.class",
"javap": "Compiled from \"Day18.kt\"\npublic final class org.aoc2021.Day18 {\n public static final org.aoc2021.Day18 INSTANCE;\n\n private org.aoc2021.Day18();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n private final int solvePart1(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #15 // class java/lang/Iterable\n 4: astore_3\n 5: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 8: astore 4\n 10: iconst_0\n 11: istore 5\n 13: aload_3\n 14: astore 6\n 16: new #20 // class java/util/ArrayList\n 19: dup\n 20: aload_3\n 21: bipush 10\n 23: invokestatic #26 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #29 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #31 // class java/util/Collection\n 32: astore 7\n 34: iconst_0\n 35: istore 8\n 37: aload 6\n 39: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 9\n 46: aload 9\n 48: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 98\n 56: aload 9\n 58: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 10\n 65: aload 7\n 67: aload 10\n 69: checkcast #47 // class java/lang/String\n 72: astore 11\n 74: astore 13\n 76: iconst_0\n 77: istore 12\n 79: aload 4\n 81: aload 11\n 83: invokespecial #51 // Method parseSnailfishNumber:(Ljava/lang/String;)Lorg/aoc2021/Day18$TreeNode;\n 86: aload 13\n 88: swap\n 89: invokeinterface #55, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 94: pop\n 95: goto 46\n 98: aload 7\n 100: checkcast #57 // class java/util/List\n 103: nop\n 104: astore_2\n 105: aload_2\n 106: checkcast #15 // class java/lang/Iterable\n 109: astore 4\n 111: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 114: astore 5\n 116: iconst_0\n 117: istore 6\n 119: aload 4\n 121: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 126: astore 7\n 128: aload 7\n 130: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 135: ifne 148\n 138: new #59 // class java/lang/UnsupportedOperationException\n 141: dup\n 142: ldc #61 // String Empty collection can\\'t be reduced.\n 144: invokespecial #64 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 147: athrow\n 148: aload 7\n 150: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 155: astore 8\n 157: aload 7\n 159: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 164: ifeq 203\n 167: aload 8\n 169: aload 7\n 171: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 176: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 179: astore 9\n 181: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 184: astore 10\n 186: iconst_0\n 187: istore 11\n 189: aload 5\n 191: aload 10\n 193: aload 9\n 195: invokespecial #70 // Method addSnailfishNumbers:(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 198: astore 8\n 200: goto 157\n 203: aload 8\n 205: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 208: astore_3\n 209: aload_0\n 210: aload_3\n 211: invokespecial #74 // Method magnitude:(Lorg/aoc2021/Day18$TreeNode;)I\n 214: ireturn\n\n private final int solvePart2(java.util.List<java.lang.String>);\n Code:\n 0: aload_1\n 1: checkcast #15 // class java/lang/Iterable\n 4: astore_3\n 5: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 8: astore 4\n 10: iconst_0\n 11: istore 5\n 13: aload_3\n 14: astore 6\n 16: new #20 // class java/util/ArrayList\n 19: dup\n 20: aload_3\n 21: bipush 10\n 23: invokestatic #26 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #29 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #31 // class java/util/Collection\n 32: astore 7\n 34: iconst_0\n 35: istore 8\n 37: aload 6\n 39: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 9\n 46: aload 9\n 48: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 98\n 56: aload 9\n 58: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 10\n 65: aload 7\n 67: aload 10\n 69: checkcast #47 // class java/lang/String\n 72: astore 11\n 74: astore 17\n 76: iconst_0\n 77: istore 12\n 79: aload 4\n 81: aload 11\n 83: invokespecial #51 // Method parseSnailfishNumber:(Ljava/lang/String;)Lorg/aoc2021/Day18$TreeNode;\n 86: aload 17\n 88: swap\n 89: invokeinterface #55, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 94: pop\n 95: goto 46\n 98: aload 7\n 100: checkcast #57 // class java/util/List\n 103: nop\n 104: astore_2\n 105: aload_2\n 106: checkcast #15 // class java/lang/Iterable\n 109: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 114: astore 4\n 116: aload 4\n 118: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 123: ifne 134\n 126: new #102 // class java/util/NoSuchElementException\n 129: dup\n 130: invokespecial #103 // Method java/util/NoSuchElementException.\"<init>\":()V\n 133: athrow\n 134: aload 4\n 136: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 141: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 144: astore 5\n 146: iconst_0\n 147: istore 6\n 149: aload_2\n 150: checkcast #15 // class java/lang/Iterable\n 153: astore 7\n 155: iconst_0\n 156: istore 8\n 158: aload 7\n 160: astore 9\n 162: new #20 // class java/util/ArrayList\n 165: dup\n 166: invokespecial #104 // Method java/util/ArrayList.\"<init>\":()V\n 169: checkcast #31 // class java/util/Collection\n 172: astore 10\n 174: iconst_0\n 175: istore 11\n 177: aload 9\n 179: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 184: astore 12\n 186: aload 12\n 188: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 193: ifeq 243\n 196: aload 12\n 198: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 203: astore 13\n 205: aload 13\n 207: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 210: astore 14\n 212: iconst_0\n 213: istore 15\n 215: aload 14\n 217: aload 5\n 219: if_acmpeq 226\n 222: iconst_1\n 223: goto 227\n 226: iconst_0\n 227: ifeq 186\n 230: aload 10\n 232: aload 13\n 234: invokeinterface #55, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 239: pop\n 240: goto 186\n 243: aload 10\n 245: checkcast #57 // class java/util/List\n 248: nop\n 249: checkcast #15 // class java/lang/Iterable\n 252: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 257: astore 8\n 259: aload 8\n 261: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 266: ifne 277\n 269: new #102 // class java/util/NoSuchElementException\n 272: dup\n 273: invokespecial #103 // Method java/util/NoSuchElementException.\"<init>\":()V\n 276: athrow\n 277: aload 8\n 279: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 284: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 287: astore 9\n 289: iconst_0\n 290: istore 10\n 292: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 295: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 298: aload 5\n 300: aload 9\n 302: invokespecial #70 // Method addSnailfishNumbers:(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 305: invokespecial #74 // Method magnitude:(Lorg/aoc2021/Day18$TreeNode;)I\n 308: istore 9\n 310: aload 8\n 312: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 317: ifeq 367\n 320: aload 8\n 322: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 327: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 330: astore 10\n 332: iconst_0\n 333: istore 11\n 335: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 338: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 341: aload 5\n 343: aload 10\n 345: invokespecial #70 // Method addSnailfishNumbers:(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 348: invokespecial #74 // Method magnitude:(Lorg/aoc2021/Day18$TreeNode;)I\n 351: istore 10\n 353: iload 9\n 355: iload 10\n 357: if_icmpge 310\n 360: iload 10\n 362: istore 9\n 364: goto 310\n 367: iload 9\n 369: nop\n 370: istore 5\n 372: aload 4\n 374: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 379: ifeq 634\n 382: aload 4\n 384: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 389: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 392: astore 6\n 394: iconst_0\n 395: istore 7\n 397: aload_2\n 398: checkcast #15 // class java/lang/Iterable\n 401: astore 8\n 403: iconst_0\n 404: istore 9\n 406: aload 8\n 408: astore 10\n 410: new #20 // class java/util/ArrayList\n 413: dup\n 414: invokespecial #104 // Method java/util/ArrayList.\"<init>\":()V\n 417: checkcast #31 // class java/util/Collection\n 420: astore 11\n 422: iconst_0\n 423: istore 12\n 425: aload 10\n 427: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 432: astore 13\n 434: aload 13\n 436: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 441: ifeq 491\n 444: aload 13\n 446: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 451: astore 14\n 453: aload 14\n 455: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 458: astore 15\n 460: iconst_0\n 461: istore 16\n 463: aload 15\n 465: aload 6\n 467: if_acmpeq 474\n 470: iconst_1\n 471: goto 475\n 474: iconst_0\n 475: ifeq 434\n 478: aload 11\n 480: aload 14\n 482: invokeinterface #55, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 487: pop\n 488: goto 434\n 491: aload 11\n 493: checkcast #57 // class java/util/List\n 496: nop\n 497: checkcast #15 // class java/lang/Iterable\n 500: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 505: astore 9\n 507: aload 9\n 509: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 514: ifne 525\n 517: new #102 // class java/util/NoSuchElementException\n 520: dup\n 521: invokespecial #103 // Method java/util/NoSuchElementException.\"<init>\":()V\n 524: athrow\n 525: aload 9\n 527: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 532: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 535: astore 10\n 537: iconst_0\n 538: istore 11\n 540: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 543: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 546: aload 6\n 548: aload 10\n 550: invokespecial #70 // Method addSnailfishNumbers:(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 553: invokespecial #74 // Method magnitude:(Lorg/aoc2021/Day18$TreeNode;)I\n 556: istore 10\n 558: aload 9\n 560: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 565: ifeq 615\n 568: aload 9\n 570: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 575: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 578: astore 11\n 580: iconst_0\n 581: istore 12\n 583: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 586: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 589: aload 6\n 591: aload 11\n 593: invokespecial #70 // Method addSnailfishNumbers:(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 596: invokespecial #74 // Method magnitude:(Lorg/aoc2021/Day18$TreeNode;)I\n 599: istore 11\n 601: iload 10\n 603: iload 11\n 605: if_icmpge 558\n 608: iload 11\n 610: istore 10\n 612: goto 558\n 615: iload 10\n 617: nop\n 618: istore 6\n 620: iload 5\n 622: iload 6\n 624: if_icmpge 372\n 627: iload 6\n 629: istore 5\n 631: goto 372\n 634: iload 5\n 636: ireturn\n\n private final org.aoc2021.Day18$TreeNode parseSnailfishNumber(java.lang.String);\n Code:\n 0: aload_0\n 1: aload_1\n 2: iconst_0\n 3: iconst_0\n 4: invokespecial #120 // Method parseNode:(Ljava/lang/String;IZ)Lkotlin/Pair;\n 7: invokevirtual #125 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 10: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 13: areturn\n\n private final kotlin.Pair<org.aoc2021.Day18$TreeNode, java.lang.Integer> parseNode(java.lang.String, int, boolean);\n Code:\n 0: aload_1\n 1: iload_2\n 2: invokevirtual #131 // Method java/lang/String.charAt:(I)C\n 5: bipush 91\n 7: if_icmpne 106\n 10: aload_0\n 11: aload_1\n 12: iload_2\n 13: iconst_1\n 14: iadd\n 15: iconst_0\n 16: invokespecial #120 // Method parseNode:(Ljava/lang/String;IZ)Lkotlin/Pair;\n 19: astore 4\n 21: aload 4\n 23: invokevirtual #134 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 26: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 29: astore 5\n 31: aload 4\n 33: invokevirtual #137 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 36: checkcast #139 // class java/lang/Number\n 39: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 42: istore 6\n 44: aload_0\n 45: aload_1\n 46: iload 6\n 48: iconst_1\n 49: iadd\n 50: iconst_1\n 51: invokespecial #120 // Method parseNode:(Ljava/lang/String;IZ)Lkotlin/Pair;\n 54: astore 7\n 56: aload 7\n 58: invokevirtual #134 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 61: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 64: astore 8\n 66: aload 7\n 68: invokevirtual #137 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 71: checkcast #139 // class java/lang/Number\n 74: invokevirtual #143 // Method java/lang/Number.intValue:()I\n 77: istore 9\n 79: new #66 // class org/aoc2021/Day18$TreeNode\n 82: dup\n 83: aload 5\n 85: aload 8\n 87: aconst_null\n 88: iconst_4\n 89: aconst_null\n 90: invokespecial #146 // Method org/aoc2021/Day18$TreeNode.\"<init>\":(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Ljava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 93: iload 9\n 95: iconst_1\n 96: iadd\n 97: invokestatic #152 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 100: invokestatic #158 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 103: goto 177\n 106: iload_3\n 107: ifeq 115\n 110: bipush 93\n 112: goto 117\n 115: bipush 44\n 117: istore 4\n 119: aload_1\n 120: checkcast #160 // class java/lang/CharSequence\n 123: iload 4\n 125: iload_2\n 126: iconst_0\n 127: iconst_4\n 128: aconst_null\n 129: invokestatic #166 // Method kotlin/text/StringsKt.indexOf$default:(Ljava/lang/CharSequence;CIZILjava/lang/Object;)I\n 132: istore 5\n 134: nop\n 135: aload_1\n 136: iload_2\n 137: iload 5\n 139: invokevirtual #170 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 142: dup\n 143: ldc #172 // String substring(...)\n 145: invokestatic #178 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 148: invokestatic #182 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 151: istore 6\n 153: new #66 // class org/aoc2021/Day18$TreeNode\n 156: dup\n 157: aconst_null\n 158: aconst_null\n 159: iload 6\n 161: invokestatic #152 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 164: iconst_3\n 165: aconst_null\n 166: invokespecial #146 // Method org/aoc2021/Day18$TreeNode.\"<init>\":(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Ljava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 169: iload 5\n 171: invokestatic #152 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 174: invokestatic #158 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 177: areturn\n\n private final org.aoc2021.Day18$TreeNode addSnailfishNumbers(org.aoc2021.Day18$TreeNode, org.aoc2021.Day18$TreeNode);\n Code:\n 0: aload_0\n 1: new #66 // class org/aoc2021/Day18$TreeNode\n 4: dup\n 5: aload_1\n 6: aload_2\n 7: aconst_null\n 8: iconst_4\n 9: aconst_null\n 10: invokespecial #146 // Method org/aoc2021/Day18$TreeNode.\"<init>\":(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Ljava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 13: invokespecial #197 // Method reduceSnailfishNumber:(Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 16: areturn\n\n private final org.aoc2021.Day18$TreeNode reduceSnailfishNumber(org.aoc2021.Day18$TreeNode);\n Code:\n 0: aload_0\n 1: astore 7\n 3: aload_1\n 4: astore 8\n 6: aload 7\n 8: checkcast #2 // class org/aoc2021/Day18\n 11: aload 8\n 13: iconst_0\n 14: iconst_2\n 15: aconst_null\n 16: invokestatic #203 // Method findNodeToExplode$default:(Lorg/aoc2021/Day18;Lorg/aoc2021/Day18$TreeNode;IILjava/lang/Object;)Lorg/aoc2021/Day18$TreeNode;\n 19: astore_2\n 20: aload_2\n 21: ifnull 56\n 24: aload_2\n 25: astore_3\n 26: iconst_0\n 27: istore 4\n 29: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 32: astore 5\n 34: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 37: aload 8\n 39: aload_3\n 40: invokespecial #206 // Method explode:(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 43: astore 6\n 45: aload 5\n 47: astore 7\n 49: aload 6\n 51: astore 8\n 53: goto 106\n 56: aload 7\n 58: checkcast #2 // class org/aoc2021/Day18\n 61: aload 8\n 63: invokespecial #209 // Method findNodeToSplit:(Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 66: astore_2\n 67: aload_2\n 68: ifnull 103\n 71: aload_2\n 72: astore_3\n 73: iconst_0\n 74: istore 4\n 76: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 79: astore 5\n 81: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 84: aload 8\n 86: aload_3\n 87: invokespecial #212 // Method split:(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 90: astore 6\n 92: aload 5\n 94: astore 7\n 96: aload 6\n 98: astore 8\n 100: goto 106\n 103: aload 8\n 105: areturn\n 106: aload 8\n 108: astore_1\n 109: goto 6\n\n private final org.aoc2021.Day18$TreeNode findNodeToExplode(org.aoc2021.Day18$TreeNode, int);\n Code:\n 0: iload_2\n 1: iconst_4\n 2: if_icmpne 21\n 5: aload_1\n 6: invokevirtual #223 // Method org/aoc2021/Day18$TreeNode.getLeft:()Lorg/aoc2021/Day18$TreeNode;\n 9: ifnull 21\n 12: aload_1\n 13: invokevirtual #226 // Method org/aoc2021/Day18$TreeNode.getRight:()Lorg/aoc2021/Day18$TreeNode;\n 16: ifnull 21\n 19: aload_1\n 20: areturn\n 21: aload_1\n 22: invokevirtual #223 // Method org/aoc2021/Day18$TreeNode.getLeft:()Lorg/aoc2021/Day18$TreeNode;\n 25: ifnull 35\n 28: aload_1\n 29: invokevirtual #226 // Method org/aoc2021/Day18$TreeNode.getRight:()Lorg/aoc2021/Day18$TreeNode;\n 32: ifnonnull 37\n 35: aconst_null\n 36: areturn\n 37: aload_0\n 38: aload_1\n 39: invokevirtual #223 // Method org/aoc2021/Day18$TreeNode.getLeft:()Lorg/aoc2021/Day18$TreeNode;\n 42: iload_2\n 43: iconst_1\n 44: iadd\n 45: invokespecial #228 // Method findNodeToExplode:(Lorg/aoc2021/Day18$TreeNode;I)Lorg/aoc2021/Day18$TreeNode;\n 48: astore_3\n 49: aload_3\n 50: ifnull 62\n 53: aload_3\n 54: astore 4\n 56: iconst_0\n 57: istore 5\n 59: aload 4\n 61: areturn\n 62: aload_0\n 63: aload_1\n 64: invokevirtual #226 // Method org/aoc2021/Day18$TreeNode.getRight:()Lorg/aoc2021/Day18$TreeNode;\n 67: iload_2\n 68: iconst_1\n 69: iadd\n 70: invokespecial #228 // Method findNodeToExplode:(Lorg/aoc2021/Day18$TreeNode;I)Lorg/aoc2021/Day18$TreeNode;\n 73: areturn\n\n static org.aoc2021.Day18$TreeNode findNodeToExplode$default(org.aoc2021.Day18, org.aoc2021.Day18$TreeNode, int, int, java.lang.Object);\n Code:\n 0: iload_3\n 1: iconst_2\n 2: iand\n 3: ifeq 8\n 6: iconst_0\n 7: istore_2\n 8: aload_0\n 9: aload_1\n 10: iload_2\n 11: invokespecial #228 // Method findNodeToExplode:(Lorg/aoc2021/Day18$TreeNode;I)Lorg/aoc2021/Day18$TreeNode;\n 14: areturn\n\n private final org.aoc2021.Day18$TreeNode explode(org.aoc2021.Day18$TreeNode, org.aoc2021.Day18$TreeNode);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokespecial #234 // Method traverse:(Lorg/aoc2021/Day18$TreeNode;)Ljava/util/List;\n 5: astore_3\n 6: aload_3\n 7: astore 5\n 9: iconst_0\n 10: istore 6\n 12: iconst_0\n 13: istore 7\n 15: aload 5\n 17: invokeinterface #235, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 22: astore 8\n 24: aload 8\n 26: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 31: ifeq 78\n 34: aload 8\n 36: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 41: astore 9\n 43: aload 9\n 45: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 48: astore 10\n 50: iconst_0\n 51: istore 11\n 53: aload 10\n 55: aload_2\n 56: if_acmpne 63\n 59: iconst_1\n 60: goto 64\n 63: iconst_0\n 64: ifeq 72\n 67: iload 7\n 69: goto 79\n 72: iinc 7, 1\n 75: goto 24\n 78: iconst_m1\n 79: istore 4\n 81: aload_3\n 82: iconst_0\n 83: iload 4\n 85: iconst_1\n 86: isub\n 87: invokeinterface #239, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 92: astore 7\n 94: aload 7\n 96: aload 7\n 98: invokeinterface #242, 1 // InterfaceMethod java/util/List.size:()I\n 103: invokeinterface #246, 2 // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;\n 108: astore 8\n 110: aload 8\n 112: invokeinterface #251, 1 // InterfaceMethod java/util/ListIterator.hasPrevious:()Z\n 117: ifeq 160\n 120: aload 8\n 122: invokeinterface #254, 1 // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;\n 127: astore 9\n 129: aload 9\n 131: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 134: astore 10\n 136: iconst_0\n 137: istore 11\n 139: aload 10\n 141: invokevirtual #258 // Method org/aoc2021/Day18$TreeNode.getValue:()Ljava/lang/Integer;\n 144: ifnull 151\n 147: iconst_1\n 148: goto 152\n 151: iconst_0\n 152: ifeq 110\n 155: aload 9\n 157: goto 161\n 160: aconst_null\n 161: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 164: astore 5\n 166: aload_3\n 167: iload 4\n 169: iconst_2\n 170: iadd\n 171: aload_3\n 172: invokeinterface #242, 1 // InterfaceMethod java/util/List.size:()I\n 177: invokeinterface #239, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 182: checkcast #15 // class java/lang/Iterable\n 185: astore 8\n 187: aload 8\n 189: invokeinterface #35, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 194: astore 9\n 196: aload 9\n 198: invokeinterface #41, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 203: ifeq 246\n 206: aload 9\n 208: invokeinterface #45, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 213: astore 10\n 215: aload 10\n 217: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 220: astore 11\n 222: iconst_0\n 223: istore 12\n 225: aload 11\n 227: invokevirtual #258 // Method org/aoc2021/Day18$TreeNode.getValue:()Ljava/lang/Integer;\n 230: ifnull 237\n 233: iconst_1\n 234: goto 238\n 237: iconst_0\n 238: ifeq 196\n 241: aload 10\n 243: goto 247\n 246: aconst_null\n 247: checkcast #66 // class org/aoc2021/Day18$TreeNode\n 250: astore 6\n 252: aload_0\n 253: aload_1\n 254: aload_2\n 255: aload 5\n 257: aload 6\n 259: invokespecial #262 // Method doExplode:(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 262: areturn\n\n private final java.util.List<org.aoc2021.Day18$TreeNode> traverse(org.aoc2021.Day18$TreeNode);\n Code:\n 0: aload_1\n 1: invokevirtual #223 // Method org/aoc2021/Day18$TreeNode.getLeft:()Lorg/aoc2021/Day18$TreeNode;\n 4: ifnull 14\n 7: aload_1\n 8: invokevirtual #226 // Method org/aoc2021/Day18$TreeNode.getRight:()Lorg/aoc2021/Day18$TreeNode;\n 11: ifnonnull 21\n 14: aload_1\n 15: invokestatic #278 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 18: goto 53\n 21: aload_0\n 22: aload_1\n 23: invokevirtual #223 // Method org/aoc2021/Day18$TreeNode.getLeft:()Lorg/aoc2021/Day18$TreeNode;\n 26: invokespecial #234 // Method traverse:(Lorg/aoc2021/Day18$TreeNode;)Ljava/util/List;\n 29: checkcast #31 // class java/util/Collection\n 32: aload_1\n 33: invokestatic #282 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Object;)Ljava/util/List;\n 36: checkcast #31 // class java/util/Collection\n 39: aload_0\n 40: aload_1\n 41: invokevirtual #226 // Method org/aoc2021/Day18$TreeNode.getRight:()Lorg/aoc2021/Day18$TreeNode;\n 44: invokespecial #234 // Method traverse:(Lorg/aoc2021/Day18$TreeNode;)Ljava/util/List;\n 47: checkcast #15 // class java/lang/Iterable\n 50: invokestatic #285 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 53: areturn\n\n private final org.aoc2021.Day18$TreeNode doExplode(org.aoc2021.Day18$TreeNode, org.aoc2021.Day18$TreeNode, org.aoc2021.Day18$TreeNode, org.aoc2021.Day18$TreeNode);\n Code:\n 0: aload_1\n 1: aload_2\n 2: if_acmpne 21\n 5: new #66 // class org/aoc2021/Day18$TreeNode\n 8: dup\n 9: aconst_null\n 10: aconst_null\n 11: iconst_0\n 12: invokestatic #152 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 15: iconst_3\n 16: aconst_null\n 17: invokespecial #146 // Method org/aoc2021/Day18$TreeNode.\"<init>\":(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Ljava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 20: areturn\n 21: aload_1\n 22: aload_3\n 23: if_acmpne 71\n 26: new #66 // class org/aoc2021/Day18$TreeNode\n 29: dup\n 30: aconst_null\n 31: aconst_null\n 32: aload_1\n 33: invokevirtual #258 // Method org/aoc2021/Day18$TreeNode.getValue:()Ljava/lang/Integer;\n 36: dup\n 37: invokestatic #289 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 40: invokevirtual #290 // Method java/lang/Integer.intValue:()I\n 43: aload_2\n 44: invokevirtual #223 // Method org/aoc2021/Day18$TreeNode.getLeft:()Lorg/aoc2021/Day18$TreeNode;\n 47: dup\n 48: invokestatic #289 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 51: invokevirtual #258 // Method org/aoc2021/Day18$TreeNode.getValue:()Ljava/lang/Integer;\n 54: dup\n 55: invokestatic #289 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 58: invokevirtual #290 // Method java/lang/Integer.intValue:()I\n 61: iadd\n 62: invokestatic #152 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 65: iconst_3\n 66: aconst_null\n 67: invokespecial #146 // Method org/aoc2021/Day18$TreeNode.\"<init>\":(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Ljava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 70: areturn\n 71: aload_1\n 72: aload 4\n 74: if_acmpne 122\n 77: new #66 // class org/aoc2021/Day18$TreeNode\n 80: dup\n 81: aconst_null\n 82: aconst_null\n 83: aload_1\n 84: invokevirtual #258 // Method org/aoc2021/Day18$TreeNode.getValue:()Ljava/lang/Integer;\n 87: dup\n 88: invokestatic #289 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 91: invokevirtual #290 // Method java/lang/Integer.intValue:()I\n 94: aload_2\n 95: invokevirtual #226 // Method org/aoc2021/Day18$TreeNode.getRight:()Lorg/aoc2021/Day18$TreeNode;\n 98: dup\n 99: invokestatic #289 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 102: invokevirtual #258 // Method org/aoc2021/Day18$TreeNode.getValue:()Ljava/lang/Integer;\n 105: dup\n 106: invokestatic #289 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 109: invokevirtual #290 // Method java/lang/Integer.intValue:()I\n 112: iadd\n 113: invokestatic #152 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 116: iconst_3\n 117: aconst_null\n 118: invokespecial #146 // Method org/aoc2021/Day18$TreeNode.\"<init>\":(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Ljava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 121: areturn\n 122: aload_1\n 123: invokevirtual #223 // Method org/aoc2021/Day18$TreeNode.getLeft:()Lorg/aoc2021/Day18$TreeNode;\n 126: ifnull 136\n 129: aload_1\n 130: invokevirtual #226 // Method org/aoc2021/Day18$TreeNode.getRight:()Lorg/aoc2021/Day18$TreeNode;\n 133: ifnonnull 138\n 136: aload_1\n 137: areturn\n 138: new #66 // class org/aoc2021/Day18$TreeNode\n 141: dup\n 142: aload_0\n 143: aload_1\n 144: invokevirtual #223 // Method org/aoc2021/Day18$TreeNode.getLeft:()Lorg/aoc2021/Day18$TreeNode;\n 147: aload_2\n 148: aload_3\n 149: aload 4\n 151: invokespecial #262 // Method doExplode:(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 154: aload_0\n 155: aload_1\n 156: invokevirtual #226 // Method org/aoc2021/Day18$TreeNode.getRight:()Lorg/aoc2021/Day18$TreeNode;\n 159: aload_2\n 160: aload_3\n 161: aload 4\n 163: invokespecial #262 // Method doExplode:(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 166: aconst_null\n 167: iconst_4\n 168: aconst_null\n 169: invokespecial #146 // Method org/aoc2021/Day18$TreeNode.\"<init>\":(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Ljava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 172: areturn\n\n private final org.aoc2021.Day18$TreeNode findNodeToSplit(org.aoc2021.Day18$TreeNode);\n Code:\n 0: aload_1\n 1: invokevirtual #258 // Method org/aoc2021/Day18$TreeNode.getValue:()Ljava/lang/Integer;\n 4: ifnull 21\n 7: aload_1\n 8: invokevirtual #258 // Method org/aoc2021/Day18$TreeNode.getValue:()Ljava/lang/Integer;\n 11: invokevirtual #290 // Method java/lang/Integer.intValue:()I\n 14: bipush 10\n 16: if_icmplt 21\n 19: aload_1\n 20: areturn\n 21: aload_1\n 22: invokevirtual #223 // Method org/aoc2021/Day18$TreeNode.getLeft:()Lorg/aoc2021/Day18$TreeNode;\n 25: ifnull 35\n 28: aload_1\n 29: invokevirtual #226 // Method org/aoc2021/Day18$TreeNode.getRight:()Lorg/aoc2021/Day18$TreeNode;\n 32: ifnonnull 37\n 35: aconst_null\n 36: areturn\n 37: aload_0\n 38: aload_1\n 39: invokevirtual #223 // Method org/aoc2021/Day18$TreeNode.getLeft:()Lorg/aoc2021/Day18$TreeNode;\n 42: invokespecial #209 // Method findNodeToSplit:(Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 45: astore_2\n 46: aload_2\n 47: ifnull 57\n 50: aload_2\n 51: astore_3\n 52: iconst_0\n 53: istore 4\n 55: aload_3\n 56: areturn\n 57: aload_0\n 58: aload_1\n 59: invokevirtual #226 // Method org/aoc2021/Day18$TreeNode.getRight:()Lorg/aoc2021/Day18$TreeNode;\n 62: invokespecial #209 // Method findNodeToSplit:(Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 65: areturn\n\n private final org.aoc2021.Day18$TreeNode split(org.aoc2021.Day18$TreeNode, org.aoc2021.Day18$TreeNode);\n Code:\n 0: aload_1\n 1: aload_2\n 2: if_acmpne 76\n 5: new #66 // class org/aoc2021/Day18$TreeNode\n 8: dup\n 9: new #66 // class org/aoc2021/Day18$TreeNode\n 12: dup\n 13: aconst_null\n 14: aconst_null\n 15: aload_1\n 16: invokevirtual #258 // Method org/aoc2021/Day18$TreeNode.getValue:()Ljava/lang/Integer;\n 19: dup\n 20: invokestatic #289 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 23: invokevirtual #290 // Method java/lang/Integer.intValue:()I\n 26: iconst_2\n 27: idiv\n 28: invokestatic #152 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 31: iconst_3\n 32: aconst_null\n 33: invokespecial #146 // Method org/aoc2021/Day18$TreeNode.\"<init>\":(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Ljava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 36: new #66 // class org/aoc2021/Day18$TreeNode\n 39: dup\n 40: aconst_null\n 41: aconst_null\n 42: aload_1\n 43: invokevirtual #258 // Method org/aoc2021/Day18$TreeNode.getValue:()Ljava/lang/Integer;\n 46: invokevirtual #290 // Method java/lang/Integer.intValue:()I\n 49: iconst_2\n 50: idiv\n 51: aload_1\n 52: invokevirtual #258 // Method org/aoc2021/Day18$TreeNode.getValue:()Ljava/lang/Integer;\n 55: invokevirtual #290 // Method java/lang/Integer.intValue:()I\n 58: iconst_2\n 59: irem\n 60: iadd\n 61: invokestatic #152 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 64: iconst_3\n 65: aconst_null\n 66: invokespecial #146 // Method org/aoc2021/Day18$TreeNode.\"<init>\":(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Ljava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 69: aconst_null\n 70: iconst_4\n 71: aconst_null\n 72: invokespecial #146 // Method org/aoc2021/Day18$TreeNode.\"<init>\":(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Ljava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 75: areturn\n 76: aload_1\n 77: invokevirtual #223 // Method org/aoc2021/Day18$TreeNode.getLeft:()Lorg/aoc2021/Day18$TreeNode;\n 80: ifnull 90\n 83: aload_1\n 84: invokevirtual #226 // Method org/aoc2021/Day18$TreeNode.getRight:()Lorg/aoc2021/Day18$TreeNode;\n 87: ifnonnull 92\n 90: aload_1\n 91: areturn\n 92: new #66 // class org/aoc2021/Day18$TreeNode\n 95: dup\n 96: aload_0\n 97: aload_1\n 98: invokevirtual #223 // Method org/aoc2021/Day18$TreeNode.getLeft:()Lorg/aoc2021/Day18$TreeNode;\n 101: aload_2\n 102: invokespecial #212 // Method split:(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 105: aload_0\n 106: aload_1\n 107: invokevirtual #226 // Method org/aoc2021/Day18$TreeNode.getRight:()Lorg/aoc2021/Day18$TreeNode;\n 110: aload_2\n 111: invokespecial #212 // Method split:(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;)Lorg/aoc2021/Day18$TreeNode;\n 114: aconst_null\n 115: iconst_4\n 116: aconst_null\n 117: invokespecial #146 // Method org/aoc2021/Day18$TreeNode.\"<init>\":(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Ljava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 120: areturn\n\n private final int magnitude(org.aoc2021.Day18$TreeNode);\n Code:\n 0: aload_1\n 1: invokevirtual #223 // Method org/aoc2021/Day18$TreeNode.getLeft:()Lorg/aoc2021/Day18$TreeNode;\n 4: ifnull 14\n 7: aload_1\n 8: invokevirtual #226 // Method org/aoc2021/Day18$TreeNode.getRight:()Lorg/aoc2021/Day18$TreeNode;\n 11: ifnonnull 26\n 14: aload_1\n 15: invokevirtual #258 // Method org/aoc2021/Day18$TreeNode.getValue:()Ljava/lang/Integer;\n 18: dup\n 19: invokestatic #289 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 22: invokevirtual #290 // Method java/lang/Integer.intValue:()I\n 25: ireturn\n 26: iconst_3\n 27: aload_0\n 28: aload_1\n 29: invokevirtual #223 // Method org/aoc2021/Day18$TreeNode.getLeft:()Lorg/aoc2021/Day18$TreeNode;\n 32: invokespecial #74 // Method magnitude:(Lorg/aoc2021/Day18$TreeNode;)I\n 35: imul\n 36: iconst_2\n 37: aload_0\n 38: aload_1\n 39: invokevirtual #226 // Method org/aoc2021/Day18$TreeNode.getRight:()Lorg/aoc2021/Day18$TreeNode;\n 42: invokespecial #74 // Method magnitude:(Lorg/aoc2021/Day18$TreeNode;)I\n 45: imul\n 46: iadd\n 47: ireturn\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc_w #297 // String args\n 4: invokestatic #300 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 7: ldc_w #302 // String input18.txt\n 10: iconst_0\n 11: anewarray #47 // class java/lang/String\n 14: invokestatic #308 // InterfaceMethod java/nio/file/Path.of:(Ljava/lang/String;[Ljava/lang/String;)Ljava/nio/file/Path;\n 17: getstatic #314 // Field kotlin/text/Charsets.UTF_8:Ljava/nio/charset/Charset;\n 20: invokestatic #320 // Method java/nio/file/Files.readAllLines:(Ljava/nio/file/Path;Ljava/nio/charset/Charset;)Ljava/util/List;\n 23: astore_1\n 24: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 27: aload_1\n 28: invokestatic #289 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 31: aload_1\n 32: invokespecial #322 // Method solvePart1:(Ljava/util/List;)I\n 35: istore_2\n 36: getstatic #328 // Field java/lang/System.out:Ljava/io/PrintStream;\n 39: iload_2\n 40: invokevirtual #333 // Method java/io/PrintStream.println:(I)V\n 43: getstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 46: aload_1\n 47: invokespecial #335 // Method solvePart2:(Ljava/util/List;)I\n 50: istore_3\n 51: getstatic #328 // Field java/lang/System.out:Ljava/io/PrintStream;\n 54: iload_3\n 55: invokevirtual #333 // Method java/io/PrintStream.println:(I)V\n 58: return\n\n static {};\n Code:\n 0: new #2 // class org/aoc2021/Day18\n 3: dup\n 4: invokespecial #340 // Method \"<init>\":()V\n 7: putstatic #18 // Field INSTANCE:Lorg/aoc2021/Day18;\n 10: return\n}\n",
"javap_err": ""
},
{
"class_path": "jsgroth__advent-of-code-2021__ba81fad/org/aoc2021/Day18$TreeNode.class",
"javap": "Compiled from \"Day18.kt\"\npublic final class org.aoc2021.Day18$TreeNode {\n private final org.aoc2021.Day18$TreeNode left;\n\n private final org.aoc2021.Day18$TreeNode right;\n\n private final java.lang.Integer value;\n\n public org.aoc2021.Day18$TreeNode(org.aoc2021.Day18$TreeNode, org.aoc2021.Day18$TreeNode, java.lang.Integer);\n Code:\n 0: aload_0\n 1: invokespecial #10 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: aload_1\n 6: putfield #14 // Field left:Lorg/aoc2021/Day18$TreeNode;\n 9: aload_0\n 10: aload_2\n 11: putfield #17 // Field right:Lorg/aoc2021/Day18$TreeNode;\n 14: aload_0\n 15: aload_3\n 16: putfield #21 // Field value:Ljava/lang/Integer;\n 19: return\n\n public org.aoc2021.Day18$TreeNode(org.aoc2021.Day18$TreeNode, org.aoc2021.Day18$TreeNode, java.lang.Integer, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload 4\n 2: iconst_1\n 3: iand\n 4: ifeq 9\n 7: aconst_null\n 8: astore_1\n 9: iload 4\n 11: iconst_2\n 12: iand\n 13: ifeq 18\n 16: aconst_null\n 17: astore_2\n 18: iload 4\n 20: iconst_4\n 21: iand\n 22: ifeq 27\n 25: aconst_null\n 26: astore_3\n 27: aload_0\n 28: aload_1\n 29: aload_2\n 30: aload_3\n 31: invokespecial #25 // Method \"<init>\":(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Ljava/lang/Integer;)V\n 34: return\n\n public final org.aoc2021.Day18$TreeNode getLeft();\n Code:\n 0: aload_0\n 1: getfield #14 // Field left:Lorg/aoc2021/Day18$TreeNode;\n 4: areturn\n\n public final org.aoc2021.Day18$TreeNode getRight();\n Code:\n 0: aload_0\n 1: getfield #17 // Field right:Lorg/aoc2021/Day18$TreeNode;\n 4: areturn\n\n public final java.lang.Integer getValue();\n Code:\n 0: aload_0\n 1: getfield #21 // Field value:Ljava/lang/Integer;\n 4: areturn\n\n public final org.aoc2021.Day18$TreeNode component1();\n Code:\n 0: aload_0\n 1: getfield #14 // Field left:Lorg/aoc2021/Day18$TreeNode;\n 4: areturn\n\n public final org.aoc2021.Day18$TreeNode component2();\n Code:\n 0: aload_0\n 1: getfield #17 // Field right:Lorg/aoc2021/Day18$TreeNode;\n 4: areturn\n\n public final java.lang.Integer component3();\n Code:\n 0: aload_0\n 1: getfield #21 // Field value:Ljava/lang/Integer;\n 4: areturn\n\n public final org.aoc2021.Day18$TreeNode copy(org.aoc2021.Day18$TreeNode, org.aoc2021.Day18$TreeNode, java.lang.Integer);\n Code:\n 0: new #2 // class org/aoc2021/Day18$TreeNode\n 3: dup\n 4: aload_1\n 5: aload_2\n 6: aload_3\n 7: invokespecial #25 // Method \"<init>\":(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Ljava/lang/Integer;)V\n 10: areturn\n\n public static org.aoc2021.Day18$TreeNode copy$default(org.aoc2021.Day18$TreeNode, org.aoc2021.Day18$TreeNode, org.aoc2021.Day18$TreeNode, java.lang.Integer, 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 left:Lorg/aoc2021/Day18$TreeNode;\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 #17 // Field right:Lorg/aoc2021/Day18$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 value:Ljava/lang/Integer;\n 35: astore_3\n 36: aload_0\n 37: aload_1\n 38: aload_2\n 39: aload_3\n 40: invokevirtual #40 // Method copy:(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Ljava/lang/Integer;)Lorg/aoc2021/Day18$TreeNode;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #44 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #45 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #47 // String TreeNode(left=\n 9: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #14 // Field left:Lorg/aoc2021/Day18$TreeNode;\n 16: invokevirtual #54 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 19: ldc #56 // String , right=\n 21: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #17 // Field right:Lorg/aoc2021/Day18$TreeNode;\n 28: invokevirtual #54 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 31: ldc #58 // String , value=\n 33: invokevirtual #51 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #21 // Field value:Ljava/lang/Integer;\n 40: invokevirtual #54 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #61 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #63 // 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 left:Lorg/aoc2021/Day18$TreeNode;\n 4: ifnonnull 11\n 7: iconst_0\n 8: goto 18\n 11: aload_0\n 12: getfield #14 // Field left:Lorg/aoc2021/Day18$TreeNode;\n 15: invokevirtual #67 // Method hashCode:()I\n 18: istore_1\n 19: iload_1\n 20: bipush 31\n 22: imul\n 23: aload_0\n 24: getfield #17 // Field right:Lorg/aoc2021/Day18$TreeNode;\n 27: ifnonnull 34\n 30: iconst_0\n 31: goto 41\n 34: aload_0\n 35: getfield #17 // Field right:Lorg/aoc2021/Day18$TreeNode;\n 38: invokevirtual #67 // Method hashCode:()I\n 41: iadd\n 42: istore_1\n 43: iload_1\n 44: bipush 31\n 46: imul\n 47: aload_0\n 48: getfield #21 // Field value:Ljava/lang/Integer;\n 51: ifnonnull 58\n 54: iconst_0\n 55: goto 65\n 58: aload_0\n 59: getfield #21 // Field value:Ljava/lang/Integer;\n 62: invokevirtual #68 // Method java/lang/Object.hashCode:()I\n 65: iadd\n 66: istore_1\n 67: iload_1\n 68: 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 org/aoc2021/Day18$TreeNode\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class org/aoc2021/Day18$TreeNode\n 20: astore_2\n 21: aload_0\n 22: getfield #14 // Field left:Lorg/aoc2021/Day18$TreeNode;\n 25: aload_2\n 26: getfield #14 // Field left:Lorg/aoc2021/Day18$TreeNode;\n 29: invokestatic #78 // 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 #17 // Field right:Lorg/aoc2021/Day18$TreeNode;\n 41: aload_2\n 42: getfield #17 // Field right:Lorg/aoc2021/Day18$TreeNode;\n 45: invokestatic #78 // 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 #21 // Field value:Ljava/lang/Integer;\n 57: aload_2\n 58: getfield #21 // Field value:Ljava/lang/Integer;\n 61: invokestatic #78 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 64: ifne 69\n 67: iconst_0\n 68: ireturn\n 69: iconst_1\n 70: ireturn\n\n public org.aoc2021.Day18$TreeNode();\n Code:\n 0: aload_0\n 1: aconst_null\n 2: aconst_null\n 3: aconst_null\n 4: bipush 7\n 6: aconst_null\n 7: invokespecial #82 // Method \"<init>\":(Lorg/aoc2021/Day18$TreeNode;Lorg/aoc2021/Day18$TreeNode;Ljava/lang/Integer;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 10: return\n}\n",
"javap_err": ""
}
] |
techstay__algorithm-study__1380ce1/kotlin-algorithm-sample/src/main/kotlin/yitian/study/algorithm/problem/ModProblem.kt
|
package yitian.study.algorithm.problem
/**
* 一筐鸡蛋:
* 1个1个拿,正好拿完。
* 2个2个拿,还剩1个。
* 3个3个拿,正好拿完。
* 4个4个拿,还剩1个。
* 5个5个拿,还差1个。
* 6个6个拿,还剩3个。
* 7个7个拿,正好拿完。
* 8个8个拿,还剩1个。
* 9个9个拿,正好拿完。
* 问:筐里最少有几个鸡蛋?
*
*/
class ModProblem
/**
* 直接暴力穷举
*/
fun answer1() {
var n = 0
while (true) {
if (n % 2 == 1 && n % 4 == 1 && n % 5 == 4 && n % 6 == 3 && n % 7 == 0 && n % 8 == 1 && n % 9 == 0) {
break
}
n++
}
println(n)
}
/**
* 改良版本
*/
fun answer2() {
var n = 63
var count = 0
while (true) {
count++
if (n % 4 == 1 && n % 5 == 4 && n % 6 == 3 && n % 8 == 1) {
break
}
n += 63 * 2
}
println("n=$n,count=$count")
}
/**
* 更优化版本
*/
fun answer3() {
var n = 63 * 3
var count = 0
while (true) {
count++
if (n % 8 == 1) {
break
}
n += 630
}
println("n=$n,count=$count")
}
/**
* 计算一个可以让所有余数都相等的数
*/
fun cal(): Int {
//由题意推出来的除数和余数的结果
val numbers = hashMapOf(
2 to 1,
3 to 0,
4 to 1,
5 to 4,
6 to 3,
7 to 0,
8 to 1,
9 to 0)
var n = 0
while (true) {
n++
for (k in numbers.keys) {
val old = numbers[k]
numbers[k] = (old!! + 1) % k
}
val set = numbers.values.toSet()
if (set.size == 1) {
break
}
}
println("这个数是:$n")
return n
}
/**
* greatest common divisor
* a和b的最大公约数
*/
tailrec fun gcd(a: Int, b: Int): Int {
val c = if (a > b) a % b else b % a
if (c == 0)
return b
else
return gcd(b, c)
}
/**
* lowest common multiple
* a和b的最小公倍数
*/
fun lcm(a: Int, b: Int): Int {
val c = gcd(a, b)
return a * b / c
}
/**
* 最后一种,通过把所有余数凑成相同的
* 然后使用最小公倍数来计算
*/
fun answer4() {
val n = cal()
val lcmOfAll = (2..10).reduce(::lcm)
println("结果是${lcmOfAll - n}")
}
fun main(args: Array<String>) {
answer1()
answer2()
answer3()
answer4()
}
|
[
{
"class_path": "techstay__algorithm-study__1380ce1/yitian/study/algorithm/problem/ModProblem.class",
"javap": "Compiled from \"ModProblem.kt\"\npublic final class yitian.study.algorithm.problem.ModProblem {\n public yitian.study.algorithm.problem.ModProblem();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n}\n",
"javap_err": ""
},
{
"class_path": "techstay__algorithm-study__1380ce1/yitian/study/algorithm/problem/ModProblemKt.class",
"javap": "Compiled from \"ModProblem.kt\"\npublic final class yitian.study.algorithm.problem.ModProblemKt {\n public static final void answer1();\n Code:\n 0: iconst_0\n 1: istore_0\n 2: nop\n 3: iload_0\n 4: iconst_2\n 5: irem\n 6: iconst_1\n 7: if_icmpne 57\n 10: iload_0\n 11: iconst_4\n 12: irem\n 13: iconst_1\n 14: if_icmpne 57\n 17: iload_0\n 18: iconst_5\n 19: irem\n 20: iconst_4\n 21: if_icmpne 57\n 24: iload_0\n 25: bipush 6\n 27: irem\n 28: iconst_3\n 29: if_icmpne 57\n 32: iload_0\n 33: bipush 7\n 35: irem\n 36: ifne 57\n 39: iload_0\n 40: bipush 8\n 42: irem\n 43: iconst_1\n 44: if_icmpne 57\n 47: iload_0\n 48: bipush 9\n 50: irem\n 51: ifne 57\n 54: goto 63\n 57: iinc 0, 1\n 60: goto 2\n 63: getstatic #12 // Field java/lang/System.out:Ljava/io/PrintStream;\n 66: iload_0\n 67: invokevirtual #18 // Method java/io/PrintStream.println:(I)V\n 70: return\n\n public static final void answer2();\n Code:\n 0: bipush 63\n 2: istore_0\n 3: iconst_0\n 4: istore_1\n 5: nop\n 6: iinc 1, 1\n 9: iload_0\n 10: iconst_4\n 11: irem\n 12: iconst_1\n 13: if_icmpne 42\n 16: iload_0\n 17: iconst_5\n 18: irem\n 19: iconst_4\n 20: if_icmpne 42\n 23: iload_0\n 24: bipush 6\n 26: irem\n 27: iconst_3\n 28: if_icmpne 42\n 31: iload_0\n 32: bipush 8\n 34: irem\n 35: iconst_1\n 36: if_icmpne 42\n 39: goto 48\n 42: iinc 0, 126\n 45: goto 5\n 48: new #23 // class java/lang/StringBuilder\n 51: dup\n 52: invokespecial #26 // Method java/lang/StringBuilder.\"<init>\":()V\n 55: ldc #28 // String n=\n 57: invokevirtual #32 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 60: iload_0\n 61: invokevirtual #35 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 64: ldc #37 // String ,count=\n 66: invokevirtual #32 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 69: iload_1\n 70: invokevirtual #35 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 73: invokevirtual #41 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 76: getstatic #12 // Field java/lang/System.out:Ljava/io/PrintStream;\n 79: swap\n 80: invokevirtual #44 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 83: return\n\n public static final void answer3();\n Code:\n 0: sipush 189\n 3: istore_0\n 4: iconst_0\n 5: istore_1\n 6: nop\n 7: iinc 1, 1\n 10: iload_0\n 11: bipush 8\n 13: irem\n 14: iconst_1\n 15: if_icmpne 21\n 18: goto 30\n 21: iload_0\n 22: sipush 630\n 25: iadd\n 26: istore_0\n 27: goto 6\n 30: new #23 // class java/lang/StringBuilder\n 33: dup\n 34: invokespecial #26 // Method java/lang/StringBuilder.\"<init>\":()V\n 37: ldc #28 // String n=\n 39: invokevirtual #32 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 42: iload_0\n 43: invokevirtual #35 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 46: ldc #37 // String ,count=\n 48: invokevirtual #32 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 51: iload_1\n 52: invokevirtual #35 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 55: invokevirtual #41 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 58: getstatic #12 // Field java/lang/System.out:Ljava/io/PrintStream;\n 61: swap\n 62: invokevirtual #44 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 65: return\n\n public static final int cal();\n Code:\n 0: bipush 8\n 2: anewarray #50 // class kotlin/Pair\n 5: astore_1\n 6: aload_1\n 7: iconst_0\n 8: iconst_2\n 9: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 12: iconst_1\n 13: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 16: invokestatic #62 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 19: aastore\n 20: aload_1\n 21: iconst_1\n 22: iconst_3\n 23: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 26: iconst_0\n 27: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 30: invokestatic #62 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 33: aastore\n 34: aload_1\n 35: iconst_2\n 36: iconst_4\n 37: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 40: iconst_1\n 41: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 44: invokestatic #62 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 47: aastore\n 48: aload_1\n 49: iconst_3\n 50: iconst_5\n 51: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 54: iconst_4\n 55: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 58: invokestatic #62 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 61: aastore\n 62: aload_1\n 63: iconst_4\n 64: bipush 6\n 66: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 69: iconst_3\n 70: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 73: invokestatic #62 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 76: aastore\n 77: aload_1\n 78: iconst_5\n 79: bipush 7\n 81: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 84: iconst_0\n 85: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 88: invokestatic #62 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 91: aastore\n 92: aload_1\n 93: bipush 6\n 95: bipush 8\n 97: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 100: iconst_1\n 101: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 104: invokestatic #62 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 107: aastore\n 108: aload_1\n 109: bipush 7\n 111: bipush 9\n 113: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 116: iconst_0\n 117: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 120: invokestatic #62 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 123: aastore\n 124: aload_1\n 125: invokestatic #68 // Method kotlin/collections/MapsKt.hashMapOf:([Lkotlin/Pair;)Ljava/util/HashMap;\n 128: astore_0\n 129: iconst_0\n 130: istore_1\n 131: nop\n 132: iinc 1, 1\n 135: aload_0\n 136: invokevirtual #74 // Method java/util/HashMap.keySet:()Ljava/util/Set;\n 139: invokeinterface #80, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 144: astore_2\n 145: aload_2\n 146: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 151: ifeq 223\n 154: aload_2\n 155: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 160: dup\n 161: ldc #92 // String next(...)\n 163: invokestatic #98 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 166: checkcast #100 // class java/lang/Number\n 169: invokevirtual #103 // Method java/lang/Number.intValue:()I\n 172: istore_3\n 173: aload_0\n 174: iload_3\n 175: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 178: invokevirtual #107 // Method java/util/HashMap.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 181: checkcast #52 // class java/lang/Integer\n 184: astore 4\n 186: iload_3\n 187: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 190: astore 5\n 192: aload_0\n 193: checkcast #109 // class java/util/Map\n 196: aload 5\n 198: aload 4\n 200: dup\n 201: invokestatic #112 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 204: invokevirtual #113 // Method java/lang/Integer.intValue:()I\n 207: iconst_1\n 208: iadd\n 209: iload_3\n 210: irem\n 211: invokestatic #56 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 214: invokeinterface #117, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 219: pop\n 220: goto 145\n 223: aload_0\n 224: invokevirtual #121 // Method java/util/HashMap.values:()Ljava/util/Collection;\n 227: dup\n 228: ldc #123 // String <get-values>(...)\n 230: invokestatic #98 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 233: checkcast #125 // class java/lang/Iterable\n 236: invokestatic #131 // Method kotlin/collections/CollectionsKt.toSet:(Ljava/lang/Iterable;)Ljava/util/Set;\n 239: astore_2\n 240: aload_2\n 241: invokeinterface #134, 1 // InterfaceMethod java/util/Set.size:()I\n 246: iconst_1\n 247: if_icmpne 131\n 250: goto 253\n 253: new #23 // class java/lang/StringBuilder\n 256: dup\n 257: invokespecial #26 // Method java/lang/StringBuilder.\"<init>\":()V\n 260: ldc #136 // String 这个数是:\n 262: invokevirtual #32 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 265: iload_1\n 266: invokevirtual #35 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 269: invokevirtual #41 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 272: getstatic #12 // Field java/lang/System.out:Ljava/io/PrintStream;\n 275: swap\n 276: invokevirtual #44 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 279: iload_1\n 280: ireturn\n\n public static final int gcd(int, int);\n Code:\n 0: iload_0\n 1: iload_1\n 2: if_icmple 11\n 5: iload_0\n 6: iload_1\n 7: irem\n 8: goto 14\n 11: iload_1\n 12: iload_0\n 13: irem\n 14: istore_2\n 15: iload_2\n 16: ifne 21\n 19: iload_1\n 20: ireturn\n 21: iload_1\n 22: istore_0\n 23: iload_2\n 24: istore_1\n 25: goto 0\n\n public static final int lcm(int, int);\n Code:\n 0: iload_0\n 1: iload_1\n 2: invokestatic #151 // Method gcd:(II)I\n 5: istore_2\n 6: iload_0\n 7: iload_1\n 8: imul\n 9: iload_2\n 10: idiv\n 11: ireturn\n\n public static final void answer4();\n Code:\n 0: invokestatic #154 // Method cal:()I\n 3: istore_0\n 4: new #156 // class kotlin/ranges/IntRange\n 7: dup\n 8: iconst_2\n 9: bipush 10\n 11: invokespecial #159 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 14: checkcast #125 // class java/lang/Iterable\n 17: astore_2\n 18: iconst_0\n 19: istore_3\n 20: aload_2\n 21: invokeinterface #160, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 26: astore 4\n 28: aload 4\n 30: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 35: ifne 48\n 38: new #162 // class java/lang/UnsupportedOperationException\n 41: dup\n 42: ldc #164 // String Empty collection can\\'t be reduced.\n 44: invokespecial #167 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 47: athrow\n 48: aload 4\n 50: checkcast #169 // class kotlin/collections/IntIterator\n 53: invokevirtual #172 // Method kotlin/collections/IntIterator.nextInt:()I\n 56: istore 5\n 58: aload 4\n 60: invokeinterface #86, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 65: ifeq 97\n 68: iload 5\n 70: aload 4\n 72: checkcast #169 // class kotlin/collections/IntIterator\n 75: invokevirtual #172 // Method kotlin/collections/IntIterator.nextInt:()I\n 78: istore 6\n 80: istore 7\n 82: iconst_0\n 83: istore 8\n 85: iload 7\n 87: iload 6\n 89: invokestatic #174 // Method lcm:(II)I\n 92: istore 5\n 94: goto 58\n 97: iload 5\n 99: istore_1\n 100: new #23 // class java/lang/StringBuilder\n 103: dup\n 104: invokespecial #26 // Method java/lang/StringBuilder.\"<init>\":()V\n 107: ldc #176 // String 结果是\n 109: invokevirtual #32 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 112: iload_1\n 113: iload_0\n 114: isub\n 115: invokevirtual #35 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 118: invokevirtual #41 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 121: getstatic #12 // Field java/lang/System.out:Ljava/io/PrintStream;\n 124: swap\n 125: invokevirtual #44 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 128: return\n\n public static final void main(java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #191 // String args\n 3: invokestatic #194 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: invokestatic #196 // Method answer1:()V\n 9: invokestatic #198 // Method answer2:()V\n 12: invokestatic #200 // Method answer3:()V\n 15: invokestatic #202 // Method answer4:()V\n 18: return\n}\n",
"javap_err": ""
}
] |
aallam__string-similarity-kotlin__40cd4eb/string-similarity/src/commonMain/kotlin/com/aallam/similarity/JaroWinkler.kt
|
package com.aallam.similarity
import kotlin.math.max
import kotlin.math.min
/**
* The Jaro–Winkler distance metric is designed and best suited for short strings such as person names, and to detect
* typos; it is (roughly) a variation of Damerau-Levenshtein, where the substitution of 2 close characters is considered
* less important than the substitution of 2 characters that a far from each other.
*
* Jaro-Winkler was developed in the area of record linkage (duplicate detection) (Winkler, 1990).
* It returns a value in the interval [0.0, 1.0].
*
* @param threshold The current value of the threshold used for adding the Winkler bonus. The default value is 0.7.
*
* [Jaro–Winkler distance](https://en.wikipedia.org/wiki/Jaro%E2%80%93Winkler_distance)
*/
public class JaroWinkler(
private val threshold: Double = 0.7
) {
/**
* Compute Jaro-Winkler similarity.
*
*
* @param first the first string to compare.
* @param second the second string to compare.
* @return The Jaro-Winkler similarity in the range [0, 1]
*/
public fun similarity(first: String, second: String): Double {
if (first == second) return 1.0
val (m, t, l, p) = matchStrings(first, second)
if (m == 0f) return 0.0
// Jaro similarity = 1/3 * (m/|s1| + m/|s2| + (m-t)/m)
val sj = ((m / first.length) + (m / second.length) + ((m - t) / m)) / 3.0
// Winkler similarity = Sj + P * L * (1 – Sj)
return if (sj > threshold) sj + p * l * (1 - sj) else sj
}
/**
* Return 1 - similarity.
* @param first the first string to compare.
* @param second the second string to compare.
* @return 1 - similarity.
*/
public fun distance(first: String, second: String): Double {
return 1.0 - similarity(first, second)
}
/**
* Matches two given strings and returns the count of matching characters, transpositions, the length of the
* common prefix, and the scaling factor.
*
* @param first The first string to compare.
* @param second The second string to compare.
*/
private fun matchStrings(first: String, second: String): Match {
val min = minOf(first, second)
val max = maxOf(first, second)
val (matchIndexes, matchFlags, matches) = computeStringMatch(max, min)
val ms1 = CharArray(matches).apply { fill(min, matchIndexes) }
val ms2 = CharArray(matches).apply { fill(max, matchFlags) }
val transpositions = transpositions(ms1, ms2)
val prefix = commonPrefix(min, max)
val scaling = min(JW_SCALING_FACTOR, 1.0 / max.length)
return Match(matches.toFloat(), transpositions, prefix, scaling)
}
/**
* Computes the matching indexes and flags between two strings.
*
* @param max the longer string
* @param min the shorter string
*/
private fun computeStringMatch(max: String, min: String): StringMatchInfo {
val range = max(max.length / 2 - 1, 0)
val matchIndexes = IntArray(min.length) { -1 }
val matchFlags = BooleanArray(max.length)
var matches = 0
for (i in min.indices) {
val char = min[i]
var xi = max(i - range, 0)
val xn = min(i + range + 1, max.length)
while (xi < xn) {
if (!matchFlags[xi] && char == max[xi]) {
matchIndexes[i] = xi
matchFlags[xi] = true
matches++
break
}
xi++
}
}
return StringMatchInfo(matchIndexes, matchFlags, matches)
}
/**
* Fills this character array with the characters from [max] at the positions indicated by the corresponding value
* in [flags].
*
* @param max the string from which to take the characters.
* @param flags the boolean array indicating which characters in the max string should be included.
*/
private fun CharArray.fill(max: String, flags: BooleanArray) {
var si = 0
for (i in max.indices) {
if (flags[i]) {
this[si] = max[i]
si++
}
}
}
/**
* Fills the character array with characters from the given string [min], based on the specified match [indexes].
*
* @param min the string containing the characters to be copied into the character array.
* @param indexes the indexes indicating which characters to copy from `min`. Any index value of -1 will be ignored.
*/
private fun CharArray.fill(min: String, indexes: IntArray) {
var si = 0
for (i in min.indices) {
if (indexes[i] != -1) {
this[si] = min[i]
si++
}
}
}
/**
* Calculates the length of the common prefix between two strings.
*
* @param min the shorter of the two strings being compared
* @param max the longer of the two strings being compared
*/
private fun commonPrefix(min: String, max: String): Int {
var prefix = 0
for (mi in min.indices) {
if (min[mi] != max[mi]) break
prefix++
}
return prefix
}
/**
* Calculates the number of transpositions between two matched strings.
*
* @param ms1 the first matched string.
* @param ms2 the second matched string.
*/
private fun transpositions(ms1: CharArray, ms2: CharArray): Int {
var transpositions = 0
for (mi in ms1.indices) {
if (ms1[mi] != ms2[mi]) {
transpositions++
}
}
return transpositions / 2
}
public companion object {
/** The standard value for the scaling factor */
private const val JW_SCALING_FACTOR = 0.1
}
}
/**
* Represents information about the matching indexes and flags between two strings,
* along with the total number of matches found.
*
* @param matchIndexes matching indexes
* @param matchFlags matching flags
* @param matches total number of matches found
*/
internal data class StringMatchInfo(
val matchIndexes: IntArray,
val matchFlags: BooleanArray,
val matches: Int
)
/**
* Represents a set of parameters that describe the similarity between two strings.
*
* @param matches number of matching characters
* @param transpositions number of transpositions
* @param prefix length of common prefix
* @param scaling scaling factor
*/
internal data class Match(
val matches: Float,
val transpositions: Int,
val prefix: Int,
val scaling: Double,
)
|
[
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/JaroWinkler$Companion.class",
"javap": "Compiled from \"JaroWinkler.kt\"\npublic final class com.aallam.similarity.JaroWinkler$Companion {\n private com.aallam.similarity.JaroWinkler$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public com.aallam.similarity.JaroWinkler$Companion(kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: invokespecial #12 // Method \"<init>\":()V\n 4: return\n}\n",
"javap_err": ""
},
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/JaroWinkler.class",
"javap": "Compiled from \"JaroWinkler.kt\"\npublic final class com.aallam.similarity.JaroWinkler {\n public static final com.aallam.similarity.JaroWinkler$Companion Companion;\n\n private final double threshold;\n\n private static final double JW_SCALING_FACTOR;\n\n public com.aallam.similarity.JaroWinkler(double);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: dload_1\n 6: putfield #13 // Field threshold:D\n 9: return\n\n public com.aallam.similarity.JaroWinkler(double, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload_3\n 1: iconst_1\n 2: iand\n 3: ifeq 10\n 6: ldc2_w #17 // double 0.7d\n 9: dstore_1\n 10: aload_0\n 11: dload_1\n 12: invokespecial #20 // Method \"<init>\":(D)V\n 15: return\n\n public final double similarity(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #25 // String first\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #33 // String second\n 9: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #37 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 17: ifeq 22\n 20: dconst_1\n 21: dreturn\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokespecial #41 // Method matchStrings:(Ljava/lang/String;Ljava/lang/String;)Lcom/aallam/similarity/Match;\n 28: astore_3\n 29: aload_3\n 30: invokevirtual #47 // Method com/aallam/similarity/Match.component1:()F\n 33: fstore 4\n 35: aload_3\n 36: invokevirtual #51 // Method com/aallam/similarity/Match.component2:()I\n 39: istore 5\n 41: aload_3\n 42: invokevirtual #54 // Method com/aallam/similarity/Match.component3:()I\n 45: istore 6\n 47: aload_3\n 48: invokevirtual #58 // Method com/aallam/similarity/Match.component4:()D\n 51: dstore 7\n 53: fload 4\n 55: fconst_0\n 56: fcmpg\n 57: ifne 64\n 60: iconst_1\n 61: goto 65\n 64: iconst_0\n 65: ifeq 70\n 68: dconst_0\n 69: dreturn\n 70: fload 4\n 72: aload_1\n 73: invokevirtual #63 // Method java/lang/String.length:()I\n 76: i2f\n 77: fdiv\n 78: fload 4\n 80: aload_2\n 81: invokevirtual #63 // Method java/lang/String.length:()I\n 84: i2f\n 85: fdiv\n 86: fadd\n 87: fload 4\n 89: iload 5\n 91: i2f\n 92: fsub\n 93: fload 4\n 95: fdiv\n 96: fadd\n 97: f2d\n 98: ldc2_w #64 // double 3.0d\n 101: ddiv\n 102: dstore 9\n 104: dload 9\n 106: aload_0\n 107: getfield #13 // Field threshold:D\n 110: dcmpl\n 111: ifle 132\n 114: dload 9\n 116: dload 7\n 118: iload 6\n 120: i2d\n 121: dmul\n 122: iconst_1\n 123: i2d\n 124: dload 9\n 126: dsub\n 127: dmul\n 128: dadd\n 129: goto 134\n 132: dload 9\n 134: dreturn\n\n public final double distance(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #25 // String first\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #33 // String second\n 9: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: dconst_1\n 13: aload_0\n 14: aload_1\n 15: aload_2\n 16: invokevirtual #76 // Method similarity:(Ljava/lang/String;Ljava/lang/String;)D\n 19: dsub\n 20: dreturn\n\n private final com.aallam.similarity.Match matchStrings(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #78 // class java/lang/Comparable\n 4: aload_2\n 5: checkcast #78 // class java/lang/Comparable\n 8: invokestatic #84 // Method kotlin/comparisons/ComparisonsKt.minOf:(Ljava/lang/Comparable;Ljava/lang/Comparable;)Ljava/lang/Comparable;\n 11: checkcast #60 // class java/lang/String\n 14: astore_3\n 15: aload_1\n 16: checkcast #78 // class java/lang/Comparable\n 19: aload_2\n 20: checkcast #78 // class java/lang/Comparable\n 23: invokestatic #87 // Method kotlin/comparisons/ComparisonsKt.maxOf:(Ljava/lang/Comparable;Ljava/lang/Comparable;)Ljava/lang/Comparable;\n 26: checkcast #60 // class java/lang/String\n 29: astore 4\n 31: aload_0\n 32: aload 4\n 34: aload_3\n 35: invokespecial #91 // Method computeStringMatch:(Ljava/lang/String;Ljava/lang/String;)Lcom/aallam/similarity/StringMatchInfo;\n 38: astore 5\n 40: aload 5\n 42: invokevirtual #96 // Method com/aallam/similarity/StringMatchInfo.component1:()[I\n 45: astore 6\n 47: aload 5\n 49: invokevirtual #99 // Method com/aallam/similarity/StringMatchInfo.component2:()[Z\n 52: astore 7\n 54: aload 5\n 56: invokevirtual #100 // Method com/aallam/similarity/StringMatchInfo.component3:()I\n 59: istore 8\n 61: iload 8\n 63: newarray char\n 65: astore 10\n 67: aload 10\n 69: astore 11\n 71: iconst_0\n 72: istore 12\n 74: aload_0\n 75: aload 11\n 77: aload_3\n 78: aload 6\n 80: invokespecial #104 // Method fill:([CLjava/lang/String;[I)V\n 83: aload 10\n 85: astore 9\n 87: iload 8\n 89: newarray char\n 91: astore 11\n 93: aload 11\n 95: astore 12\n 97: iconst_0\n 98: istore 13\n 100: aload_0\n 101: aload 12\n 103: aload 4\n 105: aload 7\n 107: invokespecial #107 // Method fill:([CLjava/lang/String;[Z)V\n 110: aload 11\n 112: astore 10\n 114: aload_0\n 115: aload 9\n 117: aload 10\n 119: invokespecial #111 // Method transpositions:([C[C)I\n 122: istore 11\n 124: aload_0\n 125: aload_3\n 126: aload 4\n 128: invokespecial #115 // Method commonPrefix:(Ljava/lang/String;Ljava/lang/String;)I\n 131: istore 12\n 133: ldc2_w #116 // double 0.1d\n 136: dconst_1\n 137: aload 4\n 139: invokevirtual #63 // Method java/lang/String.length:()I\n 142: i2d\n 143: ddiv\n 144: invokestatic #123 // Method java/lang/Math.min:(DD)D\n 147: dstore 13\n 149: new #43 // class com/aallam/similarity/Match\n 152: dup\n 153: iload 8\n 155: i2f\n 156: iload 11\n 158: iload 12\n 160: dload 13\n 162: invokespecial #126 // Method com/aallam/similarity/Match.\"<init>\":(FIID)V\n 165: areturn\n\n private final com.aallam.similarity.StringMatchInfo computeStringMatch(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: invokevirtual #63 // Method java/lang/String.length:()I\n 4: iconst_2\n 5: idiv\n 6: iconst_1\n 7: isub\n 8: iconst_0\n 9: invokestatic #144 // Method java/lang/Math.max:(II)I\n 12: istore_3\n 13: iconst_0\n 14: istore 5\n 16: aload_2\n 17: invokevirtual #63 // Method java/lang/String.length:()I\n 20: istore 6\n 22: iload 6\n 24: newarray int\n 26: astore 7\n 28: iload 5\n 30: iload 6\n 32: if_icmpge 51\n 35: iload 5\n 37: istore 8\n 39: aload 7\n 41: iload 8\n 43: iconst_m1\n 44: iastore\n 45: iinc 5, 1\n 48: goto 28\n 51: aload 7\n 53: astore 4\n 55: aload_1\n 56: invokevirtual #63 // Method java/lang/String.length:()I\n 59: newarray boolean\n 61: astore 5\n 63: iconst_0\n 64: istore 6\n 66: iconst_0\n 67: istore 7\n 69: aload_2\n 70: checkcast #146 // class java/lang/CharSequence\n 73: invokeinterface #147, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 78: istore 8\n 80: iload 7\n 82: iload 8\n 84: if_icmpge 177\n 87: aload_2\n 88: iload 7\n 90: invokevirtual #151 // Method java/lang/String.charAt:(I)C\n 93: istore 9\n 95: iload 7\n 97: iload_3\n 98: isub\n 99: iconst_0\n 100: invokestatic #144 // Method java/lang/Math.max:(II)I\n 103: istore 10\n 105: iload 7\n 107: iload_3\n 108: iadd\n 109: iconst_1\n 110: iadd\n 111: aload_1\n 112: invokevirtual #63 // Method java/lang/String.length:()I\n 115: invokestatic #153 // Method java/lang/Math.min:(II)I\n 118: istore 11\n 120: iload 10\n 122: iload 11\n 124: if_icmpge 171\n 127: aload 5\n 129: iload 10\n 131: baload\n 132: ifne 165\n 135: iload 9\n 137: aload_1\n 138: iload 10\n 140: invokevirtual #151 // Method java/lang/String.charAt:(I)C\n 143: if_icmpne 165\n 146: aload 4\n 148: iload 7\n 150: iload 10\n 152: iastore\n 153: aload 5\n 155: iload 10\n 157: iconst_1\n 158: bastore\n 159: iinc 6, 1\n 162: goto 171\n 165: iinc 10, 1\n 168: goto 120\n 171: iinc 7, 1\n 174: goto 80\n 177: new #93 // class com/aallam/similarity/StringMatchInfo\n 180: dup\n 181: aload 4\n 183: aload 5\n 185: iload 6\n 187: invokespecial #156 // Method com/aallam/similarity/StringMatchInfo.\"<init>\":([I[ZI)V\n 190: areturn\n\n private final void fill(char[], java.lang.String, boolean[]);\n Code:\n 0: iconst_0\n 1: istore 4\n 3: iconst_0\n 4: istore 5\n 6: aload_2\n 7: checkcast #146 // class java/lang/CharSequence\n 10: invokeinterface #147, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 15: istore 6\n 17: iload 5\n 19: iload 6\n 21: if_icmpge 50\n 24: aload_3\n 25: iload 5\n 27: baload\n 28: ifeq 44\n 31: aload_1\n 32: iload 4\n 34: aload_2\n 35: iload 5\n 37: invokevirtual #151 // Method java/lang/String.charAt:(I)C\n 40: castore\n 41: iinc 4, 1\n 44: iinc 5, 1\n 47: goto 17\n 50: return\n\n private final void fill(char[], java.lang.String, int[]);\n Code:\n 0: iconst_0\n 1: istore 4\n 3: iconst_0\n 4: istore 5\n 6: aload_2\n 7: checkcast #146 // class java/lang/CharSequence\n 10: invokeinterface #147, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 15: istore 6\n 17: iload 5\n 19: iload 6\n 21: if_icmpge 51\n 24: aload_3\n 25: iload 5\n 27: iaload\n 28: iconst_m1\n 29: if_icmpeq 45\n 32: aload_1\n 33: iload 4\n 35: aload_2\n 36: iload 5\n 38: invokevirtual #151 // Method java/lang/String.charAt:(I)C\n 41: castore\n 42: iinc 4, 1\n 45: iinc 5, 1\n 48: goto 17\n 51: return\n\n private final int commonPrefix(java.lang.String, java.lang.String);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: iconst_0\n 3: istore 4\n 5: aload_1\n 6: checkcast #146 // class java/lang/CharSequence\n 9: invokeinterface #147, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 14: istore 5\n 16: iload 4\n 18: iload 5\n 20: if_icmpge 47\n 23: aload_1\n 24: iload 4\n 26: invokevirtual #151 // Method java/lang/String.charAt:(I)C\n 29: aload_2\n 30: iload 4\n 32: invokevirtual #151 // Method java/lang/String.charAt:(I)C\n 35: if_icmpne 47\n 38: iinc 3, 1\n 41: iinc 4, 1\n 44: goto 16\n 47: iload_3\n 48: ireturn\n\n private final int transpositions(char[], char[]);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: iconst_0\n 3: istore 4\n 5: aload_1\n 6: arraylength\n 7: istore 5\n 9: iload 4\n 11: iload 5\n 13: if_icmpge 36\n 16: aload_1\n 17: iload 4\n 19: caload\n 20: aload_2\n 21: iload 4\n 23: caload\n 24: if_icmpeq 30\n 27: iinc 3, 1\n 30: iinc 4, 1\n 33: goto 9\n 36: iload_3\n 37: iconst_2\n 38: idiv\n 39: ireturn\n\n public com.aallam.similarity.JaroWinkler();\n Code:\n 0: aload_0\n 1: dconst_0\n 2: iconst_1\n 3: aconst_null\n 4: invokespecial #171 // Method \"<init>\":(DILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 7: return\n\n static {};\n Code:\n 0: new #174 // class com/aallam/similarity/JaroWinkler$Companion\n 3: dup\n 4: aconst_null\n 5: invokespecial #177 // Method com/aallam/similarity/JaroWinkler$Companion.\"<init>\":(Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 8: putstatic #181 // Field Companion:Lcom/aallam/similarity/JaroWinkler$Companion;\n 11: return\n}\n",
"javap_err": ""
}
] |
aallam__string-similarity-kotlin__40cd4eb/string-similarity/src/commonMain/kotlin/com/aallam/similarity/OptimalStringAlignment.kt
|
package com.aallam.similarity
import kotlin.math.min
/**
* Implementation of the Optimal String Alignment (sometimes called the restricted edit distance) variant
* of the Damerau-Levenshtein distance.
*
* The difference between the two algorithms consists in that the Optimal String Alignment algorithm computes the number
* of edit operations needed to make the strings equal under the condition that no substring is edited more than once,
* whereas Damerau-Levenshtein presents no such restriction.
*/
public class OptimalStringAlignment {
/**
* Compute the distance between strings: the minimum number of operations needed to transform one string into the
* other (insertion, deletion, substitution of a single character, or a transposition of two adjacent characters)
* while no substring is edited more than once.
*
* @param first the first string to compare.
* @param second the second string to compare.
*/
public fun distance(first: String, second: String): Int {
if (first == second) return 0
val n = first.length
val m = second.length
if (n == 0) return m
if (m == 0) return n
// create the distance matrix H[0..first.length+1][0..second.length+1]
val distanceMatrix = Array(n + 2) { IntArray(m + 2) }
// initialize top row and leftmost column
for (i in 0..n) distanceMatrix[i][0] = i
for (j in 0..m) distanceMatrix[0][j] = j
// fill the distance matrix
for (i in 1..n) {
for (j in 1..m) {
val cost = if (first[i - 1] == second[j - 1]) 0 else 1
val substitution = distanceMatrix[i - 1][j - 1] + cost
val insertion = distanceMatrix[i][j - 1] + 1
val deletion = distanceMatrix[i - 1][j] + 1
distanceMatrix[i][j] = minOf(substitution, insertion, deletion)
// transposition check
if (i > 1 && j > 1 && first[i - 1] == second[j - 2] && first[i - 2] == second[j - 1]) {
distanceMatrix[i][j] = min(distanceMatrix[i][j], distanceMatrix[i - 2][j - 2] + cost)
}
}
}
return distanceMatrix[n][m]
}
}
|
[
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/OptimalStringAlignment.class",
"javap": "Compiled from \"OptimalStringAlignment.kt\"\npublic final class com.aallam.similarity.OptimalStringAlignment {\n public com.aallam.similarity.OptimalStringAlignment();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int distance(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String first\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 second\n 9: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #27 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 17: ifeq 22\n 20: iconst_0\n 21: ireturn\n 22: aload_1\n 23: invokevirtual #33 // Method java/lang/String.length:()I\n 26: istore_3\n 27: aload_2\n 28: invokevirtual #33 // Method java/lang/String.length:()I\n 31: istore 4\n 33: iload_3\n 34: ifne 40\n 37: iload 4\n 39: ireturn\n 40: iload 4\n 42: ifne 47\n 45: iload_3\n 46: ireturn\n 47: iconst_0\n 48: istore 6\n 50: iload_3\n 51: iconst_2\n 52: iadd\n 53: istore 7\n 55: iload 7\n 57: anewarray #35 // class \"[I\"\n 60: astore 8\n 62: iload 6\n 64: iload 7\n 66: if_icmpge 90\n 69: iload 6\n 71: istore 9\n 73: aload 8\n 75: iload 9\n 77: iload 4\n 79: iconst_2\n 80: iadd\n 81: newarray int\n 83: aastore\n 84: iinc 6, 1\n 87: goto 62\n 90: aload 8\n 92: astore 5\n 94: iconst_0\n 95: istore 6\n 97: iload 6\n 99: iload_3\n 100: if_icmpgt 124\n 103: aload 5\n 105: iload 6\n 107: aaload\n 108: iconst_0\n 109: iload 6\n 111: iastore\n 112: iload 6\n 114: iload_3\n 115: if_icmpeq 124\n 118: iinc 6, 1\n 121: goto 103\n 124: iconst_0\n 125: istore 6\n 127: iload 6\n 129: iload 4\n 131: if_icmpgt 156\n 134: aload 5\n 136: iconst_0\n 137: aaload\n 138: iload 6\n 140: iload 6\n 142: iastore\n 143: iload 6\n 145: iload 4\n 147: if_icmpeq 156\n 150: iinc 6, 1\n 153: goto 134\n 156: iconst_1\n 157: istore 6\n 159: iload 6\n 161: iload_3\n 162: if_icmpgt 375\n 165: iconst_1\n 166: istore 7\n 168: iload 7\n 170: iload 4\n 172: if_icmpgt 363\n 175: aload_1\n 176: iload 6\n 178: iconst_1\n 179: isub\n 180: invokevirtual #39 // Method java/lang/String.charAt:(I)C\n 183: aload_2\n 184: iload 7\n 186: iconst_1\n 187: isub\n 188: invokevirtual #39 // Method java/lang/String.charAt:(I)C\n 191: if_icmpne 198\n 194: iconst_0\n 195: goto 199\n 198: iconst_1\n 199: istore 8\n 201: aload 5\n 203: iload 6\n 205: iconst_1\n 206: isub\n 207: aaload\n 208: iload 7\n 210: iconst_1\n 211: isub\n 212: iaload\n 213: iload 8\n 215: iadd\n 216: istore 9\n 218: aload 5\n 220: iload 6\n 222: aaload\n 223: iload 7\n 225: iconst_1\n 226: isub\n 227: iaload\n 228: iconst_1\n 229: iadd\n 230: istore 10\n 232: aload 5\n 234: iload 6\n 236: iconst_1\n 237: isub\n 238: aaload\n 239: iload 7\n 241: iaload\n 242: iconst_1\n 243: iadd\n 244: istore 11\n 246: aload 5\n 248: iload 6\n 250: aaload\n 251: iload 7\n 253: iload 9\n 255: iload 10\n 257: iload 11\n 259: invokestatic #45 // Method java/lang/Math.min:(II)I\n 262: invokestatic #45 // Method java/lang/Math.min:(II)I\n 265: iastore\n 266: iload 6\n 268: iconst_1\n 269: if_icmple 350\n 272: iload 7\n 274: iconst_1\n 275: if_icmple 350\n 278: aload_1\n 279: iload 6\n 281: iconst_1\n 282: isub\n 283: invokevirtual #39 // Method java/lang/String.charAt:(I)C\n 286: aload_2\n 287: iload 7\n 289: iconst_2\n 290: isub\n 291: invokevirtual #39 // Method java/lang/String.charAt:(I)C\n 294: if_icmpne 350\n 297: aload_1\n 298: iload 6\n 300: iconst_2\n 301: isub\n 302: invokevirtual #39 // Method java/lang/String.charAt:(I)C\n 305: aload_2\n 306: iload 7\n 308: iconst_1\n 309: isub\n 310: invokevirtual #39 // Method java/lang/String.charAt:(I)C\n 313: if_icmpne 350\n 316: aload 5\n 318: iload 6\n 320: aaload\n 321: iload 7\n 323: aload 5\n 325: iload 6\n 327: aaload\n 328: iload 7\n 330: iaload\n 331: aload 5\n 333: iload 6\n 335: iconst_2\n 336: isub\n 337: aaload\n 338: iload 7\n 340: iconst_2\n 341: isub\n 342: iaload\n 343: iload 8\n 345: iadd\n 346: invokestatic #45 // Method java/lang/Math.min:(II)I\n 349: iastore\n 350: iload 7\n 352: iload 4\n 354: if_icmpeq 363\n 357: iinc 7, 1\n 360: goto 175\n 363: iload 6\n 365: iload_3\n 366: if_icmpeq 375\n 369: iinc 6, 1\n 372: goto 165\n 375: aload 5\n 377: iload_3\n 378: aaload\n 379: iload 4\n 381: iaload\n 382: ireturn\n}\n",
"javap_err": ""
}
] |
aallam__string-similarity-kotlin__40cd4eb/string-similarity/src/commonMain/kotlin/com/aallam/similarity/SorensenDice.kt
|
package com.aallam.similarity
import com.aallam.similarity.internal.Shingle
/**
* Sorensen-Dice coefficient, aka Sørensen index, Dice's coefficient or Czekanowski's binary (non-quantitative) index.
*
* The strings are first converted to boolean sets of k-shingles (sequences of k characters), then the similarity is
* computed as 2 * |A inter B| / (|A| + |B|).
*
* Attention: Sorensen-Dice distance (and similarity) does not satisfy triangle inequality.
*
* [Sørensen–Dice coefficient](https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient)
*
* @param k length of k-shingles
*/
public class SorensenDice(public val k: Int = 3) {
/**
* Similarity is computed as 2 * |A ∩ B| / (|A| + |B|).
*
* @param first The first string to compare.
* @param second The second string to compare.
*/
public fun similarity(first: String, second: String): Double {
if (first == second) return 1.0
val profile1 = Shingle.profile(first, k)
val profile2 = Shingle.profile(second, k)
val intersect = profile1.keys.intersect(profile2.keys)
return (2.0 * intersect.size) / (profile1.size + profile2.size)
}
/**
* Returns 1 - similarity.
*
* @param first The first string to compare.
* @param second The second string to compare.
*/
public fun distance(first: String, second: String): Double {
return 1.0 - similarity(first, second)
}
}
|
[
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/SorensenDice.class",
"javap": "Compiled from \"SorensenDice.kt\"\npublic final class com.aallam.similarity.SorensenDice {\n private final int k;\n\n public com.aallam.similarity.SorensenDice(int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field k:I\n 9: return\n\n public com.aallam.similarity.SorensenDice(int, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 8\n 6: iconst_3\n 7: istore_1\n 8: aload_0\n 9: iload_1\n 10: invokespecial #18 // Method \"<init>\":(I)V\n 13: return\n\n public final int getK();\n Code:\n 0: aload_0\n 1: getfield #13 // Field k:I\n 4: ireturn\n\n public final double similarity(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #25 // String first\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #33 // String second\n 9: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #37 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 17: ifeq 22\n 20: dconst_1\n 21: dreturn\n 22: getstatic #43 // Field com/aallam/similarity/internal/Shingle.Companion:Lcom/aallam/similarity/internal/Shingle$Companion;\n 25: aload_1\n 26: checkcast #45 // class java/lang/CharSequence\n 29: aload_0\n 30: getfield #13 // Field k:I\n 33: invokevirtual #51 // Method com/aallam/similarity/internal/Shingle$Companion.profile:(Ljava/lang/CharSequence;I)Ljava/util/Map;\n 36: astore_3\n 37: getstatic #43 // Field com/aallam/similarity/internal/Shingle.Companion:Lcom/aallam/similarity/internal/Shingle$Companion;\n 40: aload_2\n 41: checkcast #45 // class java/lang/CharSequence\n 44: aload_0\n 45: getfield #13 // Field k:I\n 48: invokevirtual #51 // Method com/aallam/similarity/internal/Shingle$Companion.profile:(Ljava/lang/CharSequence;I)Ljava/util/Map;\n 51: astore 4\n 53: aload_3\n 54: invokeinterface #57, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 59: checkcast #59 // class java/lang/Iterable\n 62: aload 4\n 64: invokeinterface #57, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 69: checkcast #59 // class java/lang/Iterable\n 72: invokestatic #65 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 75: astore 5\n 77: ldc2_w #66 // double 2.0d\n 80: aload 5\n 82: invokeinterface #72, 1 // InterfaceMethod java/util/Set.size:()I\n 87: i2d\n 88: dmul\n 89: aload_3\n 90: invokeinterface #73, 1 // InterfaceMethod java/util/Map.size:()I\n 95: aload 4\n 97: invokeinterface #73, 1 // InterfaceMethod java/util/Map.size:()I\n 102: iadd\n 103: i2d\n 104: ddiv\n 105: dreturn\n\n public final double distance(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #25 // String first\n 3: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #33 // String second\n 9: invokestatic #31 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: dconst_1\n 13: aload_0\n 14: aload_1\n 15: aload_2\n 16: invokevirtual #81 // Method similarity:(Ljava/lang/String;Ljava/lang/String;)D\n 19: dsub\n 20: dreturn\n\n public com.aallam.similarity.SorensenDice();\n Code:\n 0: aload_0\n 1: iconst_0\n 2: iconst_1\n 3: aconst_null\n 4: invokespecial #83 // Method \"<init>\":(IILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 7: return\n}\n",
"javap_err": ""
}
] |
aallam__string-similarity-kotlin__40cd4eb/string-similarity/src/commonMain/kotlin/com/aallam/similarity/LongestCommonSubsequence.kt
|
package com.aallam.similarity
import kotlin.math.max
/**
* The longest common subsequence (LCS) problem consists in finding the longest subsequence common to two (or more)
* sequences. It differs from problems of finding common substrings: unlike substrings, subsequences are not required
* to occupy consecutive positions within the original sequences.
*
* LCS distance is equivalent to Levenshtein distance, when only insertion and deletion is allowed (no substitution),
* or when the cost of the substitution is the double of the cost of an insertion or deletion.
*/
public class LongestCommonSubsequence {
/**
* Return the LCS distance between strings [first] (length n) and [second] (length m),
* computed as `|n| + |m| - 2 * |LCS(first, second)|`, with min = 0 max = n + m
*
* @param first the first string to compare.
* @param second the second string to compare.
*/
public fun distance(first: String, second: String): Int {
if (first == second) return 0
return first.length + second.length - 2 * length(first, second)
}
/**
* Return the length of the longest common subsequence (LCS) between strings [first]
* and [second].
*
* @param first the first string to compare.
* @param second the second string to compare.
*/
public fun length(first: String, second: String): Int {
val n = first.length
val m = second.length
val x = first.toCharArray()
val y = second.toCharArray()
val c = Array(n + 1) { IntArray(m + 1) }
for (i in 1..n) {
for (j in 1..m) {
if (x[i - 1] == y[j - 1]) {
c[i][j] = c[i - 1][j - 1] + 1
} else {
c[i][j] = max(c[i][j - 1], c[i - 1][j])
}
}
}
return c[n][m]
}
}
|
[
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/LongestCommonSubsequence.class",
"javap": "Compiled from \"LongestCommonSubsequence.kt\"\npublic final class com.aallam.similarity.LongestCommonSubsequence {\n public com.aallam.similarity.LongestCommonSubsequence();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int distance(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String first\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 second\n 9: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #27 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 17: ifeq 22\n 20: iconst_0\n 21: ireturn\n 22: aload_1\n 23: invokevirtual #33 // Method java/lang/String.length:()I\n 26: aload_2\n 27: invokevirtual #33 // Method java/lang/String.length:()I\n 30: iadd\n 31: iconst_2\n 32: aload_0\n 33: aload_1\n 34: aload_2\n 35: invokevirtual #35 // Method length:(Ljava/lang/String;Ljava/lang/String;)I\n 38: imul\n 39: isub\n 40: ireturn\n\n public final int length(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String first\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 second\n 9: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: invokevirtual #33 // Method java/lang/String.length:()I\n 16: istore_3\n 17: aload_2\n 18: invokevirtual #33 // Method java/lang/String.length:()I\n 21: istore 4\n 23: aload_1\n 24: invokevirtual #40 // Method java/lang/String.toCharArray:()[C\n 27: dup\n 28: ldc #42 // String toCharArray(...)\n 30: invokestatic #45 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 33: astore 5\n 35: aload_2\n 36: invokevirtual #40 // Method java/lang/String.toCharArray:()[C\n 39: dup\n 40: ldc #42 // String toCharArray(...)\n 42: invokestatic #45 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 45: astore 6\n 47: iconst_0\n 48: istore 8\n 50: iload_3\n 51: iconst_1\n 52: iadd\n 53: istore 9\n 55: iload 9\n 57: anewarray #47 // class \"[I\"\n 60: astore 10\n 62: iload 8\n 64: iload 9\n 66: if_icmpge 90\n 69: iload 8\n 71: istore 11\n 73: aload 10\n 75: iload 11\n 77: iload 4\n 79: iconst_1\n 80: iadd\n 81: newarray int\n 83: aastore\n 84: iinc 8, 1\n 87: goto 62\n 90: aload 10\n 92: astore 7\n 94: iconst_1\n 95: istore 8\n 97: iload 8\n 99: iload_3\n 100: if_icmpgt 211\n 103: iconst_1\n 104: istore 9\n 106: iload 9\n 108: iload 4\n 110: if_icmpgt 199\n 113: aload 5\n 115: iload 8\n 117: iconst_1\n 118: isub\n 119: caload\n 120: aload 6\n 122: iload 9\n 124: iconst_1\n 125: isub\n 126: caload\n 127: if_icmpne 155\n 130: aload 7\n 132: iload 8\n 134: aaload\n 135: iload 9\n 137: aload 7\n 139: iload 8\n 141: iconst_1\n 142: isub\n 143: aaload\n 144: iload 9\n 146: iconst_1\n 147: isub\n 148: iaload\n 149: iconst_1\n 150: iadd\n 151: iastore\n 152: goto 186\n 155: aload 7\n 157: iload 8\n 159: aaload\n 160: iload 9\n 162: aload 7\n 164: iload 8\n 166: aaload\n 167: iload 9\n 169: iconst_1\n 170: isub\n 171: iaload\n 172: aload 7\n 174: iload 8\n 176: iconst_1\n 177: isub\n 178: aaload\n 179: iload 9\n 181: iaload\n 182: invokestatic #53 // Method java/lang/Math.max:(II)I\n 185: iastore\n 186: iload 9\n 188: iload 4\n 190: if_icmpeq 199\n 193: iinc 9, 1\n 196: goto 113\n 199: iload 8\n 201: iload_3\n 202: if_icmpeq 211\n 205: iinc 8, 1\n 208: goto 103\n 211: aload 7\n 213: iload_3\n 214: aaload\n 215: iload 4\n 217: iaload\n 218: ireturn\n}\n",
"javap_err": ""
}
] |
aallam__string-similarity-kotlin__40cd4eb/string-similarity/src/commonMain/kotlin/com/aallam/similarity/NGram.kt
|
package com.aallam.similarity
import kotlin.math.max
import kotlin.math.min
/**
* N-Gram Similarity as defined by Kondrak, "N-Gram Similarity and Distance", String Processing and Information
* Retrieval, Lecture Notes in Computer Science Volume 3772, 2005, pp 115-126.
*
* The algorithm uses affixing with special character '\n' to increase the weight of first characters.
* The normalization is achieved by dividing the total similarity score the original length of the longest word.
*
* [N-Gram Similarity and Distance](http://webdocs.cs.ualberta.ca/~kondrak/papers/spire05.pdf)
*
* @param n n-gram length.
*/
public class NGram(private val n: Int = 2) {
/**
* Compute n-gram distance, in the range `[0, 1]`.
*
* @param first the first string to compare.
* @param second the second string to compare.
*/
public fun distance(first: String, second: String): Double {
if (first == second) return 0.0
val sl = first.length
val tl = second.length
if (sl == 0 || tl == 0) return 1.0
val special = '\n'
var cost = 0
if (sl < n || tl < n) {
val ni = min(sl, tl)
for (i in 0..ni) {
if (first[i] == second[i]) cost++
}
return cost.toDouble() / max(sl, tl)
}
// construct `sa` with prefix
val sa = CharArray(sl + n - 1) { i ->
if (i < n - 1) special else first[i - n + 1]
}
var p = DoubleArray(sl + 1) { it.toDouble() } // 'previous' cost array, horizontally
var d = DoubleArray(sl + 1) // cost array, horizontally
var tj = CharArray(n) // jth n-gram of t
for (j in 1..tl) {
// construct tj n-gram
if (j < n) {
for (ti in 0..<n - j) {
tj[ti] = special // add prefix
}
for (ti in n - j..<n) {
tj[ti] = second[ti - (n - j)]
}
} else {
tj = second.substring(j - n, j).toCharArray()
}
d[0] = j.toDouble()
for (i in 1..sl) {
cost = 0
var tn = n
// compare sa to tj
for (ni in 0..<n) {
if (sa[i - 1 + ni] != tj[ni]) {
cost++
} else if (sa[i - 1 + ni] == special) {
tn-- // discount matches on prefix
}
}
val ec = cost.toDouble() / tn
// minimum of cell to the left+1, to the top+1,
// diagonally left and up +cost
d[i] = minOf(d[i - 1] + 1, p[i] + 1, p[i - 1] + ec)
}
// copy current distance counts to 'previous row' distance counts
val swap = p
p = d
d = swap
}
// our last action in the above loop was to switch d and p, so p now
// actually has the most recent cost counts
return p[sl] / max(tl, sl)
}
}
|
[
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/NGram.class",
"javap": "Compiled from \"NGram.kt\"\npublic final class com.aallam.similarity.NGram {\n private final int n;\n\n public com.aallam.similarity.NGram(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 n:I\n 9: return\n\n public com.aallam.similarity.NGram(int, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 8\n 6: iconst_2\n 7: istore_1\n 8: aload_0\n 9: iload_1\n 10: invokespecial #18 // Method \"<init>\":(I)V\n 13: return\n\n public final double distance(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #23 // String first\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #31 // String second\n 9: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #35 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 17: ifeq 22\n 20: dconst_0\n 21: dreturn\n 22: aload_1\n 23: invokevirtual #41 // Method java/lang/String.length:()I\n 26: istore_3\n 27: aload_2\n 28: invokevirtual #41 // Method java/lang/String.length:()I\n 31: istore 4\n 33: iload_3\n 34: ifeq 42\n 37: iload 4\n 39: ifne 44\n 42: dconst_1\n 43: dreturn\n 44: bipush 10\n 46: istore 5\n 48: iconst_0\n 49: istore 6\n 51: iload_3\n 52: aload_0\n 53: getfield #13 // Field n:I\n 56: if_icmplt 68\n 59: iload 4\n 61: aload_0\n 62: getfield #13 // Field n:I\n 65: if_icmpge 129\n 68: iload_3\n 69: iload 4\n 71: invokestatic #47 // Method java/lang/Math.min:(II)I\n 74: istore 7\n 76: iconst_0\n 77: istore 8\n 79: iload 8\n 81: iload 7\n 83: if_icmpgt 117\n 86: aload_1\n 87: iload 8\n 89: invokevirtual #51 // Method java/lang/String.charAt:(I)C\n 92: aload_2\n 93: iload 8\n 95: invokevirtual #51 // Method java/lang/String.charAt:(I)C\n 98: if_icmpne 104\n 101: iinc 6, 1\n 104: iload 8\n 106: iload 7\n 108: if_icmpeq 117\n 111: iinc 8, 1\n 114: goto 86\n 117: iload 6\n 119: i2d\n 120: iload_3\n 121: iload 4\n 123: invokestatic #54 // Method java/lang/Math.max:(II)I\n 126: i2d\n 127: ddiv\n 128: dreturn\n 129: iconst_0\n 130: istore 8\n 132: iload_3\n 133: aload_0\n 134: getfield #13 // Field n:I\n 137: iadd\n 138: iconst_1\n 139: isub\n 140: istore 9\n 142: iload 9\n 144: newarray char\n 146: astore 10\n 148: iload 8\n 150: iload 9\n 152: if_icmpge 199\n 155: iload 8\n 157: istore 11\n 159: aload 10\n 161: iload 11\n 163: iload 11\n 165: aload_0\n 166: getfield #13 // Field n:I\n 169: iconst_1\n 170: isub\n 171: if_icmpge 179\n 174: iload 5\n 176: goto 192\n 179: aload_1\n 180: iload 11\n 182: aload_0\n 183: getfield #13 // Field n:I\n 186: isub\n 187: iconst_1\n 188: iadd\n 189: invokevirtual #51 // Method java/lang/String.charAt:(I)C\n 192: castore\n 193: iinc 8, 1\n 196: goto 148\n 199: aload 10\n 201: astore 7\n 203: iconst_0\n 204: istore 9\n 206: iload_3\n 207: iconst_1\n 208: iadd\n 209: istore 10\n 211: iload 10\n 213: newarray double\n 215: astore 11\n 217: iload 9\n 219: iload 10\n 221: if_icmpge 242\n 224: iload 9\n 226: istore 12\n 228: aload 11\n 230: iload 12\n 232: iload 12\n 234: i2d\n 235: dastore\n 236: iinc 9, 1\n 239: goto 217\n 242: aload 11\n 244: astore 8\n 246: iload_3\n 247: iconst_1\n 248: iadd\n 249: newarray double\n 251: astore 9\n 253: aload_0\n 254: getfield #13 // Field n:I\n 257: newarray char\n 259: astore 10\n 261: iconst_1\n 262: istore 11\n 264: iload 11\n 266: iload 4\n 268: if_icmpgt 563\n 271: iload 11\n 273: aload_0\n 274: getfield #13 // Field n:I\n 277: if_icmpge 359\n 280: iconst_0\n 281: istore 12\n 283: aload_0\n 284: getfield #13 // Field n:I\n 287: iload 11\n 289: isub\n 290: istore 13\n 292: iload 12\n 294: iload 13\n 296: if_icmpge 312\n 299: aload 10\n 301: iload 12\n 303: iload 5\n 305: castore\n 306: iinc 12, 1\n 309: goto 292\n 312: aload_0\n 313: getfield #13 // Field n:I\n 316: iload 11\n 318: isub\n 319: istore 12\n 321: aload_0\n 322: getfield #13 // Field n:I\n 325: istore 13\n 327: iload 12\n 329: iload 13\n 331: if_icmpge 389\n 334: aload 10\n 336: iload 12\n 338: aload_2\n 339: iload 12\n 341: aload_0\n 342: getfield #13 // Field n:I\n 345: iload 11\n 347: isub\n 348: isub\n 349: invokevirtual #51 // Method java/lang/String.charAt:(I)C\n 352: castore\n 353: iinc 12, 1\n 356: goto 327\n 359: aload_2\n 360: iload 11\n 362: aload_0\n 363: getfield #13 // Field n:I\n 366: isub\n 367: iload 11\n 369: invokevirtual #58 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 372: dup\n 373: ldc #60 // String substring(...)\n 375: invokestatic #63 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 378: invokevirtual #67 // Method java/lang/String.toCharArray:()[C\n 381: dup\n 382: ldc #69 // String toCharArray(...)\n 384: invokestatic #63 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 387: astore 10\n 389: aload 9\n 391: iconst_0\n 392: iload 11\n 394: i2d\n 395: dastore\n 396: iconst_1\n 397: istore 12\n 399: iload 12\n 401: iload_3\n 402: if_icmpgt 538\n 405: iconst_0\n 406: istore 6\n 408: aload_0\n 409: getfield #13 // Field n:I\n 412: istore 13\n 414: iconst_0\n 415: istore 14\n 417: aload_0\n 418: getfield #13 // Field n:I\n 421: istore 15\n 423: iload 14\n 425: iload 15\n 427: if_icmpge 478\n 430: aload 7\n 432: iload 12\n 434: iconst_1\n 435: isub\n 436: iload 14\n 438: iadd\n 439: caload\n 440: aload 10\n 442: iload 14\n 444: caload\n 445: if_icmpeq 454\n 448: iinc 6, 1\n 451: goto 472\n 454: aload 7\n 456: iload 12\n 458: iconst_1\n 459: isub\n 460: iload 14\n 462: iadd\n 463: caload\n 464: iload 5\n 466: if_icmpne 472\n 469: iinc 13, -1\n 472: iinc 14, 1\n 475: goto 423\n 478: iload 6\n 480: i2d\n 481: iload 13\n 483: i2d\n 484: ddiv\n 485: dstore 14\n 487: aload 9\n 489: iload 12\n 491: aload 9\n 493: iload 12\n 495: iconst_1\n 496: isub\n 497: daload\n 498: iconst_1\n 499: i2d\n 500: dadd\n 501: aload 8\n 503: iload 12\n 505: daload\n 506: iconst_1\n 507: i2d\n 508: dadd\n 509: aload 8\n 511: iload 12\n 513: iconst_1\n 514: isub\n 515: daload\n 516: dload 14\n 518: dadd\n 519: invokestatic #72 // Method java/lang/Math.min:(DD)D\n 522: invokestatic #72 // Method java/lang/Math.min:(DD)D\n 525: dastore\n 526: iload 12\n 528: iload_3\n 529: if_icmpeq 538\n 532: iinc 12, 1\n 535: goto 405\n 538: aload 8\n 540: astore 12\n 542: aload 9\n 544: astore 8\n 546: aload 12\n 548: astore 9\n 550: iload 11\n 552: iload 4\n 554: if_icmpeq 563\n 557: iinc 11, 1\n 560: goto 271\n 563: aload 8\n 565: iload_3\n 566: daload\n 567: iload 4\n 569: iload_3\n 570: invokestatic #54 // Method java/lang/Math.max:(II)I\n 573: i2d\n 574: ddiv\n 575: dreturn\n\n public com.aallam.similarity.NGram();\n Code:\n 0: aload_0\n 1: iconst_0\n 2: iconst_1\n 3: aconst_null\n 4: invokespecial #96 // Method \"<init>\":(IILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 7: return\n}\n",
"javap_err": ""
}
] |
aallam__string-similarity-kotlin__40cd4eb/string-similarity/src/commonMain/kotlin/com/aallam/similarity/QGram.kt
|
package com.aallam.similarity
import com.aallam.similarity.internal.Profile
import com.aallam.similarity.internal.Shingle
import kotlin.math.abs
/**
* Q-gram distance, as defined by Ukkonen in [Approximate string-matching with q-grams and maximal matches](http://www.sciencedirect.com/science/article/pii/0304397592901434).
* The distance between two strings is defined as the L1 norm of the difference of their profiles (the number
* of occurrences of each n-gram).
*
* Q-gram distance is a lower bound on Levenshtein distance, but can be computed in O(m+n), where Levenshtein
* requires O(m.n).
*
* @param k length of k-shingles
*/
public class QGram(private val k: Int = 3) {
/**
* The distance between two strings is defined as the L1 norm of the
* difference of their profiles (the number of occurence of each k-shingle).
*
* @param first the first string to compare.
* @param second the second string to compare.
*/
public fun distance(first: String, second: String): Int {
if (first == second) return 0
val p1 = Shingle.profile(first, k)
val p2 = Shingle.profile(second, k)
return distance(p1, p2)
}
/**
* Compute QGram distance using precomputed profiles.
*/
private fun distance(first: Profile, second: Profile): Int {
var agg = 0
for (key in (first.keys + second.keys)) {
var v1 = 0
var v2 = 0
first[key]?.let { v1 = it }
second[key]?.let { v2 = it }
agg += abs(v1 - v2)
}
return agg
}
}
|
[
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/QGram.class",
"javap": "Compiled from \"QGram.kt\"\npublic final class com.aallam.similarity.QGram {\n private final int k;\n\n public com.aallam.similarity.QGram(int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field k:I\n 9: return\n\n public com.aallam.similarity.QGram(int, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 8\n 6: iconst_3\n 7: istore_1\n 8: aload_0\n 9: iload_1\n 10: invokespecial #18 // Method \"<init>\":(I)V\n 13: return\n\n public final int distance(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #23 // String first\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #31 // String second\n 9: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #35 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 17: ifeq 22\n 20: iconst_0\n 21: ireturn\n 22: getstatic #41 // Field com/aallam/similarity/internal/Shingle.Companion:Lcom/aallam/similarity/internal/Shingle$Companion;\n 25: aload_1\n 26: checkcast #43 // class java/lang/CharSequence\n 29: aload_0\n 30: getfield #13 // Field k:I\n 33: invokevirtual #49 // Method com/aallam/similarity/internal/Shingle$Companion.profile:(Ljava/lang/CharSequence;I)Ljava/util/Map;\n 36: astore_3\n 37: getstatic #41 // Field com/aallam/similarity/internal/Shingle.Companion:Lcom/aallam/similarity/internal/Shingle$Companion;\n 40: aload_2\n 41: checkcast #43 // class java/lang/CharSequence\n 44: aload_0\n 45: getfield #13 // Field k:I\n 48: invokevirtual #49 // Method com/aallam/similarity/internal/Shingle$Companion.profile:(Ljava/lang/CharSequence;I)Ljava/util/Map;\n 51: astore 4\n 53: aload_0\n 54: aload_3\n 55: aload 4\n 57: invokespecial #52 // Method distance:(Ljava/util/Map;Ljava/util/Map;)I\n 60: ireturn\n\n private final int distance(java.util.Map<java.lang.String, java.lang.Integer>, java.util.Map<java.lang.String, java.lang.Integer>);\n Code:\n 0: iconst_0\n 1: istore_3\n 2: aload_1\n 3: invokeinterface #63, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 8: aload_2\n 9: invokeinterface #63, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 14: checkcast #65 // class java/lang/Iterable\n 17: invokestatic #71 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Iterable;)Ljava/util/Set;\n 20: invokeinterface #77, 1 // InterfaceMethod java/util/Set.iterator:()Ljava/util/Iterator;\n 25: astore 4\n 27: aload 4\n 29: invokeinterface #83, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 34: ifeq 139\n 37: aload 4\n 39: invokeinterface #87, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 44: checkcast #89 // class java/lang/String\n 47: astore 5\n 49: iconst_0\n 50: istore 6\n 52: iconst_0\n 53: istore 7\n 55: aload_1\n 56: aload 5\n 58: invokeinterface #93, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 63: checkcast #95 // class java/lang/Integer\n 66: dup\n 67: ifnull 88\n 70: checkcast #97 // class java/lang/Number\n 73: invokevirtual #101 // Method java/lang/Number.intValue:()I\n 76: istore 8\n 78: iconst_0\n 79: istore 9\n 81: iload 8\n 83: istore 6\n 85: goto 90\n 88: pop\n 89: nop\n 90: aload_2\n 91: aload 5\n 93: invokeinterface #93, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 98: checkcast #95 // class java/lang/Integer\n 101: dup\n 102: ifnull 123\n 105: checkcast #97 // class java/lang/Number\n 108: invokevirtual #101 // Method java/lang/Number.intValue:()I\n 111: istore 8\n 113: iconst_0\n 114: istore 9\n 116: iload 8\n 118: istore 7\n 120: goto 125\n 123: pop\n 124: nop\n 125: iload_3\n 126: iload 6\n 128: iload 7\n 130: isub\n 131: invokestatic #107 // Method java/lang/Math.abs:(I)I\n 134: iadd\n 135: istore_3\n 136: goto 27\n 139: iload_3\n 140: ireturn\n\n public com.aallam.similarity.QGram();\n Code:\n 0: aload_0\n 1: iconst_0\n 2: iconst_1\n 3: aconst_null\n 4: invokespecial #116 // Method \"<init>\":(IILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 7: return\n}\n",
"javap_err": ""
}
] |
aallam__string-similarity-kotlin__40cd4eb/string-similarity/src/commonMain/kotlin/com/aallam/similarity/WeightedLevenshtein.kt
|
package com.aallam.similarity
import kotlin.math.min
/**
* Implementation of Levenshtein that allows to define different weights for different character substitutions.
*
* @param weights the strategy to determine character operations weights.
*/
public class WeightedLevenshtein(
private val weights: OperationsWeights
) {
public fun distance(first: CharSequence, second: CharSequence, limit: Double = Double.MAX_VALUE): Double {
if (first == second) return 0.0
if (first.isEmpty()) return second.length.toDouble()
if (second.isEmpty()) return first.length.toDouble()
// initial costs is the edit distance from an empty string, which corresponds to the characters to insert.
// the array size is : length + 1 (empty string)
var cost = DoubleArray(first.length + 1)
var newCost = DoubleArray(first.length + 1)
first.forEachIndexed { i, char ->
cost[i + 1] = cost[i] + weights.insertion(char)
}
for (i in 1..second.length) {
// calculate new costs from the previous row.
// the first element of the new row is the edit distance (deletes) to match empty string
val secondChar = second[i - 1]
val deletionCost = weights.deletion(secondChar)
newCost[0] = cost[0] + deletionCost
var minCost = newCost[0]
// fill in the rest of the row
for (j in 1..first.length) {
// if it's the same char at the same position, no edit cost.
val firstChar = first[j - 1]
val edit = if (firstChar == secondChar) 0.0 else weights.substitution(firstChar, secondChar)
val replace = cost[j - 1] + edit
val insert = cost[j] + weights.insertion(secondChar)
val delete = newCost[j - 1] + weights.deletion(firstChar)
newCost[j] = minOf(insert, delete, replace)
minCost = min(minCost, newCost[j])
}
if (minCost >= limit) return limit
// flip references of current and previous row
val swap = cost
cost = newCost
newCost = swap
}
return cost.last()
}
}
/**
* Used to indicate the cost of character operations (add, replace, delete).
* The cost should always be in the range `[O, 1]`.
*
* Default implementation of all operations is `1.0`.
*
* Examples:
* - In an OCR application, cost('o', 'a') could be 0.4.
* - In a check-spelling application, cost('u', 'i') could be 0.4 because these are next to each other on the keyboard.
*/
public interface OperationsWeights {
/**
* Indicate the cost of substitution.
* The cost in the range `[0, 1]`.
*
* @param first first character of the substitution.
* @param second second character of the substitution.
*/
public fun substitution(first: Char, second: Char): Double = 1.0
/**
* Get the cost to delete a given character.
* The cost in the range `[0, 1]`.
*
* @param char the character being inserted.
*/
public fun deletion(char: Char): Double = 1.0
/**
* Get the cost to insert a given character.
* The cost in the range `[0, 1]`.
*
* @param char the character being inserted.
*/
public fun insertion(char: Char): Double = 1.0
}
|
[
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/WeightedLevenshtein.class",
"javap": "Compiled from \"WeightedLevenshtein.kt\"\npublic final class com.aallam.similarity.WeightedLevenshtein {\n private final com.aallam.similarity.OperationsWeights weights;\n\n public com.aallam.similarity.WeightedLevenshtein(com.aallam.similarity.OperationsWeights);\n Code:\n 0: aload_1\n 1: ldc #9 // String weights\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 weights:Lcom/aallam/similarity/OperationsWeights;\n 15: return\n\n public final double distance(java.lang.CharSequence, java.lang.CharSequence, double);\n Code:\n 0: aload_1\n 1: ldc #27 // String first\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #29 // String second\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #33 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 17: ifeq 22\n 20: dconst_0\n 21: dreturn\n 22: aload_1\n 23: invokeinterface #39, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 28: ifne 35\n 31: iconst_1\n 32: goto 36\n 35: iconst_0\n 36: ifeq 47\n 39: aload_2\n 40: invokeinterface #39, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 45: i2d\n 46: dreturn\n 47: aload_2\n 48: invokeinterface #39, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 53: ifne 60\n 56: iconst_1\n 57: goto 61\n 60: iconst_0\n 61: ifeq 72\n 64: aload_1\n 65: invokeinterface #39, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 70: i2d\n 71: dreturn\n 72: aconst_null\n 73: astore 5\n 75: aload_1\n 76: invokeinterface #39, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 81: iconst_1\n 82: iadd\n 83: newarray double\n 85: astore 5\n 87: aload_1\n 88: invokeinterface #39, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 93: iconst_1\n 94: iadd\n 95: newarray double\n 97: astore 6\n 99: aload_1\n 100: astore 7\n 102: iconst_0\n 103: istore 8\n 105: iconst_0\n 106: istore 9\n 108: iconst_0\n 109: istore 10\n 111: iload 10\n 113: aload 7\n 115: invokeinterface #39, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 120: if_icmpge 180\n 123: aload 7\n 125: iload 10\n 127: invokeinterface #43, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 132: istore 11\n 134: iload 9\n 136: iinc 9, 1\n 139: iload 11\n 141: istore 12\n 143: istore 13\n 145: iconst_0\n 146: istore 14\n 148: aload 5\n 150: iload 13\n 152: iconst_1\n 153: iadd\n 154: aload 5\n 156: iload 13\n 158: daload\n 159: aload_0\n 160: getfield #21 // Field weights:Lcom/aallam/similarity/OperationsWeights;\n 163: iload 12\n 165: invokeinterface #49, 2 // InterfaceMethod com/aallam/similarity/OperationsWeights.insertion:(C)D\n 170: dadd\n 171: dastore\n 172: nop\n 173: nop\n 174: iinc 10, 1\n 177: goto 111\n 180: nop\n 181: iconst_1\n 182: istore 7\n 184: aload_2\n 185: invokeinterface #39, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 190: istore 8\n 192: iload 7\n 194: iload 8\n 196: if_icmpgt 425\n 199: aload_2\n 200: iload 7\n 202: iconst_1\n 203: isub\n 204: invokeinterface #43, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 209: istore 9\n 211: aload_0\n 212: getfield #21 // Field weights:Lcom/aallam/similarity/OperationsWeights;\n 215: iload 9\n 217: invokeinterface #52, 2 // InterfaceMethod com/aallam/similarity/OperationsWeights.deletion:(C)D\n 222: dstore 10\n 224: aload 6\n 226: iconst_0\n 227: aload 5\n 229: iconst_0\n 230: daload\n 231: dload 10\n 233: dadd\n 234: dastore\n 235: aload 6\n 237: iconst_0\n 238: daload\n 239: dstore 12\n 241: iconst_1\n 242: istore 14\n 244: aload_1\n 245: invokeinterface #39, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 250: istore 15\n 252: iload 14\n 254: iload 15\n 256: if_icmpgt 391\n 259: aload_1\n 260: iload 14\n 262: iconst_1\n 263: isub\n 264: invokeinterface #43, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 269: istore 16\n 271: iload 16\n 273: iload 9\n 275: if_icmpne 282\n 278: dconst_0\n 279: goto 295\n 282: aload_0\n 283: getfield #21 // Field weights:Lcom/aallam/similarity/OperationsWeights;\n 286: iload 16\n 288: iload 9\n 290: invokeinterface #56, 3 // InterfaceMethod com/aallam/similarity/OperationsWeights.substitution:(CC)D\n 295: dstore 17\n 297: aload 5\n 299: iload 14\n 301: iconst_1\n 302: isub\n 303: daload\n 304: dload 17\n 306: dadd\n 307: dstore 19\n 309: aload 5\n 311: iload 14\n 313: daload\n 314: aload_0\n 315: getfield #21 // Field weights:Lcom/aallam/similarity/OperationsWeights;\n 318: iload 9\n 320: invokeinterface #49, 2 // InterfaceMethod com/aallam/similarity/OperationsWeights.insertion:(C)D\n 325: dadd\n 326: dstore 21\n 328: aload 6\n 330: iload 14\n 332: iconst_1\n 333: isub\n 334: daload\n 335: aload_0\n 336: getfield #21 // Field weights:Lcom/aallam/similarity/OperationsWeights;\n 339: iload 16\n 341: invokeinterface #52, 2 // InterfaceMethod com/aallam/similarity/OperationsWeights.deletion:(C)D\n 346: dadd\n 347: dstore 23\n 349: aload 6\n 351: iload 14\n 353: dload 21\n 355: dload 23\n 357: dload 19\n 359: invokestatic #62 // Method java/lang/Math.min:(DD)D\n 362: invokestatic #62 // Method java/lang/Math.min:(DD)D\n 365: dastore\n 366: dload 12\n 368: aload 6\n 370: iload 14\n 372: daload\n 373: invokestatic #62 // Method java/lang/Math.min:(DD)D\n 376: dstore 12\n 378: iload 14\n 380: iload 15\n 382: if_icmpeq 391\n 385: iinc 14, 1\n 388: goto 259\n 391: dload 12\n 393: dload_3\n 394: dcmpl\n 395: iflt 400\n 398: dload_3\n 399: dreturn\n 400: aload 5\n 402: astore 14\n 404: aload 6\n 406: astore 5\n 408: aload 14\n 410: astore 6\n 412: iload 7\n 414: iload 8\n 416: if_icmpeq 425\n 419: iinc 7, 1\n 422: goto 199\n 425: aload 5\n 427: invokestatic #68 // Method kotlin/collections/ArraysKt.last:([D)D\n 430: dreturn\n\n public static double distance$default(com.aallam.similarity.WeightedLevenshtein, java.lang.CharSequence, java.lang.CharSequence, double, int, java.lang.Object);\n Code:\n 0: iload 5\n 2: iconst_4\n 3: iand\n 4: ifeq 11\n 7: ldc2_w #98 // double 1.7976931348623157E308d\n 10: dstore_3\n 11: aload_0\n 12: aload_1\n 13: aload_2\n 14: dload_3\n 15: invokevirtual #101 // Method distance:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;D)D\n 18: dreturn\n}\n",
"javap_err": ""
}
] |
aallam__string-similarity-kotlin__40cd4eb/string-similarity/src/commonMain/kotlin/com/aallam/similarity/DamerauLevenshtein.kt
|
package com.aallam.similarity
/**
* Damerau-Levenshtein distance with transposition (*unrestricted Damerau-Levenshtein* distance).
*
* The distance is the minimum number of operations needed to transform one string into the other, where an operation
* is defined as an insertion, deletion, or substitution of a single character, or a transposition of two adjacent
* characters. It does respect triangle inequality, and is thus a metric distance.
*
* [Damerau–Levenshtein](https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance#Distance_with_adjacent_transpositions)
*/
public class DamerauLevenshtein {
/**
* Compute the distance between strings: the minimum number of operations needed to transform one string into the
* other (insertion, deletion, substitution of a single character, or a transposition of two adjacent characters).
*
* @param first the first string to compare.
* @param second the second string to compare.
*/
public fun distance(first: CharSequence, second: CharSequence): Int {
// infinite distance is the max possible distance
val n = first.length
val m = second.length
val infinity = n + m
// create and initialize the character array indices
val charsRowIndex = mutableMapOf<Char, Int>()
for (index in first.indices) charsRowIndex[first[index]] = 0
for (char in second) charsRowIndex[char] = 0
// create the distance matrix H[0 .. first.length+1][0 .. second.length+1]
val distanceMatrix = Array(n + 2) { IntArray(m + 2) }
// initialize the left edge
for (i in first.indices) {
distanceMatrix[i + 1][0] = infinity
distanceMatrix[i + 1][1] = i
}
// initialize top edge
for (j in second.indices) {
distanceMatrix[0][j + 1] = infinity
distanceMatrix[1][j + 1] = j
}
// fill in the distance matrix
for (i in 1..n) {
var lastMatch = 0
for (j in 1..m) {
val lastRowIndex = charsRowIndex.getValue(second[j - 1])
val previousMatch = lastMatch
val cost: Int
if (first[i - 1] == second[j - 1]) {
cost = 0
lastMatch = j
} else {
cost = 1
}
val substitution = distanceMatrix[i][j] + cost
val insertion = distanceMatrix[i + 1][j] + 1
val deletion = distanceMatrix[i][j + 1] + 1
val transposition =
distanceMatrix[lastRowIndex][previousMatch] + (i - lastRowIndex - 1) + 1 + (j - previousMatch - 1)
distanceMatrix[i + 1][j + 1] = minOf(substitution, insertion, deletion, transposition)
}
charsRowIndex[first[i - 1]] = i
}
return distanceMatrix[n + 1][m + 1]
}
}
|
[
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/DamerauLevenshtein.class",
"javap": "Compiled from \"DamerauLevenshtein.kt\"\npublic final class com.aallam.similarity.DamerauLevenshtein {\n public com.aallam.similarity.DamerauLevenshtein();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int distance(java.lang.CharSequence, java.lang.CharSequence);\n Code:\n 0: aload_1\n 1: ldc #15 // String first\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 second\n 9: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: invokeinterface #29, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 18: istore_3\n 19: aload_2\n 20: invokeinterface #29, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 25: istore 4\n 27: iload_3\n 28: iload 4\n 30: iadd\n 31: istore 5\n 33: new #31 // class java/util/LinkedHashMap\n 36: dup\n 37: invokespecial #32 // Method java/util/LinkedHashMap.\"<init>\":()V\n 40: checkcast #34 // class java/util/Map\n 43: astore 6\n 45: iconst_0\n 46: istore 7\n 48: aload_1\n 49: invokeinterface #29, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 54: istore 8\n 56: iload 7\n 58: iload 8\n 60: if_icmpge 92\n 63: aload 6\n 65: aload_1\n 66: iload 7\n 68: invokeinterface #38, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 73: invokestatic #44 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 76: iconst_0\n 77: invokestatic #49 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 80: invokeinterface #53, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 85: pop\n 86: iinc 7, 1\n 89: goto 56\n 92: iconst_0\n 93: istore 7\n 95: iload 7\n 97: aload_2\n 98: invokeinterface #29, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 103: if_icmpge 140\n 106: aload_2\n 107: iload 7\n 109: invokeinterface #38, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 114: istore 8\n 116: iload 8\n 118: invokestatic #44 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 121: aload 6\n 123: swap\n 124: iconst_0\n 125: invokestatic #49 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 128: invokeinterface #53, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 133: pop\n 134: iinc 7, 1\n 137: goto 95\n 140: iconst_0\n 141: istore 8\n 143: iload_3\n 144: iconst_2\n 145: iadd\n 146: istore 9\n 148: iload 9\n 150: anewarray #55 // class \"[I\"\n 153: astore 10\n 155: iload 8\n 157: iload 9\n 159: if_icmpge 183\n 162: iload 8\n 164: istore 11\n 166: aload 10\n 168: iload 11\n 170: iload 4\n 172: iconst_2\n 173: iadd\n 174: newarray int\n 176: aastore\n 177: iinc 8, 1\n 180: goto 155\n 183: aload 10\n 185: astore 7\n 187: iconst_0\n 188: istore 8\n 190: aload_1\n 191: invokeinterface #29, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 196: istore 9\n 198: iload 8\n 200: iload 9\n 202: if_icmpge 233\n 205: aload 7\n 207: iload 8\n 209: iconst_1\n 210: iadd\n 211: aaload\n 212: iconst_0\n 213: iload 5\n 215: iastore\n 216: aload 7\n 218: iload 8\n 220: iconst_1\n 221: iadd\n 222: aaload\n 223: iconst_1\n 224: iload 8\n 226: iastore\n 227: iinc 8, 1\n 230: goto 198\n 233: iconst_0\n 234: istore 8\n 236: aload_2\n 237: invokeinterface #29, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 242: istore 9\n 244: iload 8\n 246: iload 9\n 248: if_icmpge 279\n 251: aload 7\n 253: iconst_0\n 254: aaload\n 255: iload 8\n 257: iconst_1\n 258: iadd\n 259: iload 5\n 261: iastore\n 262: aload 7\n 264: iconst_1\n 265: aaload\n 266: iload 8\n 268: iconst_1\n 269: iadd\n 270: iload 8\n 272: iastore\n 273: iinc 8, 1\n 276: goto 244\n 279: iconst_1\n 280: istore 8\n 282: iload 8\n 284: iload_3\n 285: if_icmpgt 536\n 288: iconst_0\n 289: istore 9\n 291: iconst_1\n 292: istore 10\n 294: iload 10\n 296: iload 4\n 298: if_icmpgt 494\n 301: aload 6\n 303: aload_2\n 304: iload 10\n 306: iconst_1\n 307: isub\n 308: invokeinterface #38, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 313: invokestatic #44 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 316: invokestatic #61 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 319: checkcast #63 // class java/lang/Number\n 322: invokevirtual #66 // Method java/lang/Number.intValue:()I\n 325: istore 11\n 327: iload 9\n 329: istore 12\n 331: iconst_0\n 332: istore 13\n 334: aload_1\n 335: iload 8\n 337: iconst_1\n 338: isub\n 339: invokeinterface #38, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 344: aload_2\n 345: iload 10\n 347: iconst_1\n 348: isub\n 349: invokeinterface #38, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 354: if_icmpne 367\n 357: iconst_0\n 358: istore 13\n 360: iload 10\n 362: istore 9\n 364: goto 370\n 367: iconst_1\n 368: istore 13\n 370: aload 7\n 372: iload 8\n 374: aaload\n 375: iload 10\n 377: iaload\n 378: iload 13\n 380: iadd\n 381: istore 14\n 383: aload 7\n 385: iload 8\n 387: iconst_1\n 388: iadd\n 389: aaload\n 390: iload 10\n 392: iaload\n 393: iconst_1\n 394: iadd\n 395: istore 15\n 397: aload 7\n 399: iload 8\n 401: aaload\n 402: iload 10\n 404: iconst_1\n 405: iadd\n 406: iaload\n 407: iconst_1\n 408: iadd\n 409: istore 16\n 411: aload 7\n 413: iload 11\n 415: aaload\n 416: iload 12\n 418: iaload\n 419: iload 8\n 421: iload 11\n 423: isub\n 424: iconst_1\n 425: isub\n 426: iadd\n 427: iconst_1\n 428: iadd\n 429: iload 10\n 431: iload 12\n 433: isub\n 434: iconst_1\n 435: isub\n 436: iadd\n 437: istore 17\n 439: aload 7\n 441: iload 8\n 443: iconst_1\n 444: iadd\n 445: aaload\n 446: iload 10\n 448: iconst_1\n 449: iadd\n 450: iload 14\n 452: iconst_3\n 453: newarray int\n 455: astore 18\n 457: aload 18\n 459: iconst_0\n 460: iload 15\n 462: iastore\n 463: aload 18\n 465: iconst_1\n 466: iload 16\n 468: iastore\n 469: aload 18\n 471: iconst_2\n 472: iload 17\n 474: iastore\n 475: aload 18\n 477: invokestatic #72 // Method kotlin/comparisons/ComparisonsKt.minOf:(I[I)I\n 480: iastore\n 481: iload 10\n 483: iload 4\n 485: if_icmpeq 494\n 488: iinc 10, 1\n 491: goto 301\n 494: iload 8\n 496: invokestatic #49 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 499: astore 12\n 501: aload 6\n 503: aload_1\n 504: iload 8\n 506: iconst_1\n 507: isub\n 508: invokeinterface #38, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 513: invokestatic #44 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 516: aload 12\n 518: invokeinterface #53, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 523: pop\n 524: iload 8\n 526: iload_3\n 527: if_icmpeq 536\n 530: iinc 8, 1\n 533: goto 288\n 536: aload 7\n 538: iload_3\n 539: iconst_1\n 540: iadd\n 541: aaload\n 542: iload 4\n 544: iconst_1\n 545: iadd\n 546: iaload\n 547: ireturn\n}\n",
"javap_err": ""
}
] |
aallam__string-similarity-kotlin__40cd4eb/string-similarity/src/commonMain/kotlin/com/aallam/similarity/Cosine.kt
|
package com.aallam.similarity
import com.aallam.similarity.internal.Profile
import com.aallam.similarity.internal.Shingle
import kotlin.math.sqrt
/**
* Implements Cosine Similarity between strings.
*
* The strings are first transformed in vectors of occurrences of k-shingles (sequences of [k] characters).
* In this n-dimensional space, the similarity between the two strings is the cosine of their respective vectors.
*
* The cosine distance is computed as `1 - cosine similarity`.
*
* [Cosine Similarity](https://en.wikipedia.org/wiki/Cosine_similarity)
*
* @param k length of k-shingles
*/
public class Cosine(private val k: Int = 3) {
/**
* Compute the cosine similarity between strings.
*
* It is computed as `V1.V2/(|V1|*|V2|)` where `V1` and `V2` are vector representation of [first] and [second].
*
* @param first first string to compare.
* @param second second string to compare.
* @return the cosine similarity in the range `[0, 1]`.
*/
public fun similarity(first: CharSequence, second: CharSequence): Double {
if (first == second) return 1.0
if (first.length < k || second.length < k) return 0.0
val p1 = Shingle.profile(first, k)
val p2 = Shingle.profile(second, k)
return (p1 dot p2) / (norm(p1) * norm(p2))
}
/** Dot product */
private infix fun Profile.dot(profile: Profile): Int {
val intersection = keys.intersect(profile.keys)
return intersection.sumOf { getValue(it) * profile.getValue(it) }
}
/** Compute the norm L2 : sqrt(sum(v²)). */
private fun norm(profile: Profile): Double {
val sum = profile.values.sumOf { it * it }.toDouble()
return sqrt(sum)
}
/**
* Compute the cosine distance between two string.
* Corresponds to 1.0 - similarity.
*
* @param first first string to compare.
* @param second second string to compare.
*/
public fun distance(first: CharSequence, second: CharSequence): Double {
return 1.0 - similarity(first, second)
}
}
|
[
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/Cosine.class",
"javap": "Compiled from \"Cosine.kt\"\npublic final class com.aallam.similarity.Cosine {\n private final int k;\n\n public com.aallam.similarity.Cosine(int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field k:I\n 9: return\n\n public com.aallam.similarity.Cosine(int, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 8\n 6: iconst_3\n 7: istore_1\n 8: aload_0\n 9: iload_1\n 10: invokespecial #18 // Method \"<init>\":(I)V\n 13: return\n\n public final double similarity(java.lang.CharSequence, java.lang.CharSequence);\n Code:\n 0: aload_1\n 1: ldc #23 // String first\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #31 // String second\n 9: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #35 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 17: ifeq 22\n 20: dconst_1\n 21: dreturn\n 22: aload_1\n 23: invokeinterface #41, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 28: aload_0\n 29: getfield #13 // Field k:I\n 32: if_icmplt 48\n 35: aload_2\n 36: invokeinterface #41, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 41: aload_0\n 42: getfield #13 // Field k:I\n 45: if_icmpge 50\n 48: dconst_0\n 49: dreturn\n 50: getstatic #47 // Field com/aallam/similarity/internal/Shingle.Companion:Lcom/aallam/similarity/internal/Shingle$Companion;\n 53: aload_1\n 54: aload_0\n 55: getfield #13 // Field k:I\n 58: invokevirtual #53 // Method com/aallam/similarity/internal/Shingle$Companion.profile:(Ljava/lang/CharSequence;I)Ljava/util/Map;\n 61: astore_3\n 62: getstatic #47 // Field com/aallam/similarity/internal/Shingle.Companion:Lcom/aallam/similarity/internal/Shingle$Companion;\n 65: aload_2\n 66: aload_0\n 67: getfield #13 // Field k:I\n 70: invokevirtual #53 // Method com/aallam/similarity/internal/Shingle$Companion.profile:(Ljava/lang/CharSequence;I)Ljava/util/Map;\n 73: astore 4\n 75: aload_0\n 76: aload_3\n 77: aload 4\n 79: invokespecial #57 // Method dot:(Ljava/util/Map;Ljava/util/Map;)I\n 82: i2d\n 83: aload_0\n 84: aload_3\n 85: invokespecial #61 // Method norm:(Ljava/util/Map;)D\n 88: aload_0\n 89: aload 4\n 91: invokespecial #61 // Method norm:(Ljava/util/Map;)D\n 94: dmul\n 95: ddiv\n 96: dreturn\n\n private final int dot(java.util.Map<java.lang.String, java.lang.Integer>, java.util.Map<java.lang.String, java.lang.Integer>);\n Code:\n 0: aload_1\n 1: invokeinterface #72, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 6: checkcast #74 // class java/lang/Iterable\n 9: aload_2\n 10: invokeinterface #72, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 15: checkcast #74 // class java/lang/Iterable\n 18: invokestatic #80 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 21: astore_3\n 22: aload_3\n 23: checkcast #74 // class java/lang/Iterable\n 26: astore 4\n 28: iconst_0\n 29: istore 5\n 31: aload 4\n 33: invokeinterface #84, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 6\n 40: aload 6\n 42: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 110\n 50: aload 6\n 52: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 7\n 59: iload 5\n 61: aload 7\n 63: checkcast #96 // class java/lang/String\n 66: astore 8\n 68: istore 10\n 70: iconst_0\n 71: istore 9\n 73: aload_1\n 74: aload 8\n 76: invokestatic #102 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 79: checkcast #104 // class java/lang/Number\n 82: invokevirtual #107 // Method java/lang/Number.intValue:()I\n 85: aload_2\n 86: aload 8\n 88: invokestatic #102 // Method kotlin/collections/MapsKt.getValue:(Ljava/util/Map;Ljava/lang/Object;)Ljava/lang/Object;\n 91: checkcast #104 // class java/lang/Number\n 94: invokevirtual #107 // Method java/lang/Number.intValue:()I\n 97: imul\n 98: istore 11\n 100: iload 10\n 102: iload 11\n 104: iadd\n 105: istore 5\n 107: goto 40\n 110: iload 5\n 112: ireturn\n\n private final double norm(java.util.Map<java.lang.String, java.lang.Integer>);\n Code:\n 0: aload_1\n 1: invokeinterface #120, 1 // InterfaceMethod java/util/Map.values:()Ljava/util/Collection;\n 6: checkcast #74 // class java/lang/Iterable\n 9: astore 4\n 11: iconst_0\n 12: istore 5\n 14: aload 4\n 16: invokeinterface #84, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 21: astore 6\n 23: aload 6\n 25: invokeinterface #90, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 30: ifeq 76\n 33: aload 6\n 35: invokeinterface #94, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 40: astore 7\n 42: iload 5\n 44: aload 7\n 46: checkcast #104 // class java/lang/Number\n 49: invokevirtual #107 // Method java/lang/Number.intValue:()I\n 52: istore 8\n 54: istore 10\n 56: iconst_0\n 57: istore 9\n 59: iload 8\n 61: iload 8\n 63: imul\n 64: istore 11\n 66: iload 10\n 68: iload 11\n 70: iadd\n 71: istore 5\n 73: goto 23\n 76: iload 5\n 78: i2d\n 79: dstore_2\n 80: dload_2\n 81: invokestatic #126 // Method java/lang/Math.sqrt:(D)D\n 84: dreturn\n\n public final double distance(java.lang.CharSequence, java.lang.CharSequence);\n Code:\n 0: aload_1\n 1: ldc #23 // String first\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #31 // String second\n 9: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: dconst_1\n 13: aload_0\n 14: aload_1\n 15: aload_2\n 16: invokevirtual #132 // Method similarity:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)D\n 19: dsub\n 20: dreturn\n\n public com.aallam.similarity.Cosine();\n Code:\n 0: aload_0\n 1: iconst_0\n 2: iconst_1\n 3: aconst_null\n 4: invokespecial #134 // Method \"<init>\":(IILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 7: return\n}\n",
"javap_err": ""
}
] |
aallam__string-similarity-kotlin__40cd4eb/string-similarity/src/commonMain/kotlin/com/aallam/similarity/Levenshtein.kt
|
package com.aallam.similarity
import kotlin.math.min
/**
* The Levenshtein distance between two words is the minimum number of single-character edits (insertions, deletions or
* substitutions) required to change one string into the other.
*
* This implementation uses dynamic programming (Wagner–Fischer algorithm).
*
* [Levenshtein Distance](https://en.wikipedia.org/wiki/Levenshtein_distance)
*/
public class Levenshtein {
/**
* The Levenshtein distance, or edit distance, between two words is the minimum number of single-character edits
* (insertions, deletions or substitutions) required to change one word into the other.
*
* It is always at least the difference of the sizes of the two strings.
* It is at most the length of the longer string.
* It is `0` if and only if the strings are equal.
*
* @param first first string to compare.
* @param second second string to compare.
* @param limit the maximum result to compute before stopping, terminating calculation early.
* @return the computed Levenshtein distance.
*/
public fun distance(first: CharSequence, second: CharSequence, limit: Int = Int.MAX_VALUE): Int {
if (first == second) return 0
if (first.isEmpty()) return second.length
if (second.isEmpty()) return first.length
// initial costs is the edit distance from an empty string, which corresponds to the characters to inserts.
// the array size is : length + 1 (empty string)
var cost = IntArray(first.length + 1) { it }
var newCost = IntArray(first.length + 1)
for (i in 1..second.length) {
// calculate new costs from the previous row.
// the first element of the new row is the edit distance (deletes) to match empty string
newCost[0] = i
var minCost = i
// fill in the rest of the row
for (j in 1..first.length) {
// if it's the same char at the same position, no edit cost.
val edit = if (first[j - 1] == second[i - 1]) 0 else 1
val replace = cost[j - 1] + edit
val insert = cost[j] + 1
val delete = newCost[j - 1] + 1
newCost[j] = minOf(insert, delete, replace)
minCost = min(minCost, newCost[j])
}
if (minCost >= limit) return limit
// flip references of current and previous row
val swap = cost
cost = newCost
newCost = swap
}
return cost.last()
}
}
|
[
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/Levenshtein.class",
"javap": "Compiled from \"Levenshtein.kt\"\npublic final class com.aallam.similarity.Levenshtein {\n public com.aallam.similarity.Levenshtein();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final int distance(java.lang.CharSequence, java.lang.CharSequence, int);\n Code:\n 0: aload_1\n 1: ldc #15 // String first\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 second\n 9: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #27 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 17: ifeq 22\n 20: iconst_0\n 21: ireturn\n 22: aload_1\n 23: invokeinterface #33, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 28: ifne 35\n 31: iconst_1\n 32: goto 36\n 35: iconst_0\n 36: ifeq 46\n 39: aload_2\n 40: invokeinterface #33, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 45: ireturn\n 46: aload_2\n 47: invokeinterface #33, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 52: ifne 59\n 55: iconst_1\n 56: goto 60\n 59: iconst_0\n 60: ifeq 70\n 63: aload_1\n 64: invokeinterface #33, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 69: ireturn\n 70: iconst_0\n 71: istore 5\n 73: aload_1\n 74: invokeinterface #33, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 79: iconst_1\n 80: iadd\n 81: istore 6\n 83: iload 6\n 85: newarray int\n 87: astore 7\n 89: iload 5\n 91: iload 6\n 93: if_icmpge 113\n 96: iload 5\n 98: istore 8\n 100: aload 7\n 102: iload 8\n 104: iload 8\n 106: iastore\n 107: iinc 5, 1\n 110: goto 89\n 113: aload 7\n 115: astore 4\n 117: aload_1\n 118: invokeinterface #33, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 123: iconst_1\n 124: iadd\n 125: newarray int\n 127: astore 5\n 129: iconst_1\n 130: istore 6\n 132: aload_2\n 133: invokeinterface #33, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 138: istore 7\n 140: iload 6\n 142: iload 7\n 144: if_icmpgt 312\n 147: aload 5\n 149: iconst_0\n 150: iload 6\n 152: iastore\n 153: iload 6\n 155: istore 8\n 157: iconst_1\n 158: istore 9\n 160: aload_1\n 161: invokeinterface #33, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 166: istore 10\n 168: iload 9\n 170: iload 10\n 172: if_icmpgt 279\n 175: aload_1\n 176: iload 9\n 178: iconst_1\n 179: isub\n 180: invokeinterface #37, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 185: aload_2\n 186: iload 6\n 188: iconst_1\n 189: isub\n 190: invokeinterface #37, 2 // InterfaceMethod java/lang/CharSequence.charAt:(I)C\n 195: if_icmpne 202\n 198: iconst_0\n 199: goto 203\n 202: iconst_1\n 203: istore 11\n 205: aload 4\n 207: iload 9\n 209: iconst_1\n 210: isub\n 211: iaload\n 212: iload 11\n 214: iadd\n 215: istore 12\n 217: aload 4\n 219: iload 9\n 221: iaload\n 222: iconst_1\n 223: iadd\n 224: istore 13\n 226: aload 5\n 228: iload 9\n 230: iconst_1\n 231: isub\n 232: iaload\n 233: iconst_1\n 234: iadd\n 235: istore 14\n 237: aload 5\n 239: iload 9\n 241: iload 13\n 243: iload 14\n 245: iload 12\n 247: invokestatic #43 // Method java/lang/Math.min:(II)I\n 250: invokestatic #43 // Method java/lang/Math.min:(II)I\n 253: iastore\n 254: iload 8\n 256: aload 5\n 258: iload 9\n 260: iaload\n 261: invokestatic #43 // Method java/lang/Math.min:(II)I\n 264: istore 8\n 266: iload 9\n 268: iload 10\n 270: if_icmpeq 279\n 273: iinc 9, 1\n 276: goto 175\n 279: iload 8\n 281: iload_3\n 282: if_icmplt 287\n 285: iload_3\n 286: ireturn\n 287: aload 4\n 289: astore 9\n 291: aload 5\n 293: astore 4\n 295: aload 9\n 297: astore 5\n 299: iload 6\n 301: iload 7\n 303: if_icmpeq 312\n 306: iinc 6, 1\n 309: goto 147\n 312: aload 4\n 314: invokestatic #49 // Method kotlin/collections/ArraysKt.last:([I)I\n 317: ireturn\n\n public static int distance$default(com.aallam.similarity.Levenshtein, java.lang.CharSequence, java.lang.CharSequence, int, int, java.lang.Object);\n Code:\n 0: iload 4\n 2: iconst_4\n 3: iand\n 4: ifeq 10\n 7: ldc #67 // int 2147483647\n 9: istore_3\n 10: aload_0\n 11: aload_1\n 12: aload_2\n 13: iload_3\n 14: invokevirtual #69 // Method distance:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;I)I\n 17: ireturn\n}\n",
"javap_err": ""
}
] |
aallam__string-similarity-kotlin__40cd4eb/string-similarity/src/commonMain/kotlin/com/aallam/similarity/NormalizedLevenshtein.kt
|
package com.aallam.similarity
import kotlin.math.max
/**
* This distance is computed as levenshtein distance divided by the length of the longest string.
* The resulting value is always in the interval 0 to 1.
*
* [Levenshtein Distance](https://en.wikipedia.org/wiki/Levenshtein_distance)
*/
public class NormalizedLevenshtein {
/**
* Levenshtein distance metric implementation.
*/
private val levenshtein = Levenshtein()
/**
* This distance is computed as levenshtein distance divided by the length of the longest string.
* The resulting value is always in the interval 0 to 1.
*
* Compute distance as Levenshtein(s1, s2) / max(|s1|, |s2|).
*
* @param first left hand side string to compare.
* @param second right hand side string to compare.
* @return the computed normalized Levenshtein distance.
*/
public fun distance(first: CharSequence, second: CharSequence): Double {
val maxLength = max(first.length, second.length)
if (maxLength == 0) return 0.0
return levenshtein.distance(first, second) / maxLength.toDouble()
}
/**
* Compute the similarity between two string.
* Corresponds to 1.0 - normalized distance.
*
* @param lhs left hand side string to compare.
* @param rhs right hand side string to compare.
* @return the computer similarity
*/
public fun similarity(lhs: CharSequence, rhs: CharSequence): Double {
return 1.0 - distance(lhs, rhs)
}
}
|
[
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/NormalizedLevenshtein.class",
"javap": "Compiled from \"NormalizedLevenshtein.kt\"\npublic final class com.aallam.similarity.NormalizedLevenshtein {\n private final com.aallam.similarity.Levenshtein levenshtein;\n\n public com.aallam.similarity.NormalizedLevenshtein();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: new #10 // class com/aallam/similarity/Levenshtein\n 8: dup\n 9: invokespecial #11 // Method com/aallam/similarity/Levenshtein.\"<init>\":()V\n 12: putfield #15 // Field levenshtein:Lcom/aallam/similarity/Levenshtein;\n 15: return\n\n public final double distance(java.lang.CharSequence, java.lang.CharSequence);\n Code:\n 0: aload_1\n 1: ldc #22 // String first\n 3: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #30 // String second\n 9: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: invokeinterface #36, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 18: aload_2\n 19: invokeinterface #36, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 24: invokestatic #42 // Method java/lang/Math.max:(II)I\n 27: istore_3\n 28: iload_3\n 29: ifne 34\n 32: dconst_0\n 33: dreturn\n 34: aload_0\n 35: getfield #15 // Field levenshtein:Lcom/aallam/similarity/Levenshtein;\n 38: aload_1\n 39: aload_2\n 40: iconst_0\n 41: iconst_4\n 42: aconst_null\n 43: invokestatic #46 // Method com/aallam/similarity/Levenshtein.distance$default:(Lcom/aallam/similarity/Levenshtein;Ljava/lang/CharSequence;Ljava/lang/CharSequence;IILjava/lang/Object;)I\n 46: i2d\n 47: iload_3\n 48: i2d\n 49: ddiv\n 50: dreturn\n\n public final double similarity(java.lang.CharSequence, java.lang.CharSequence);\n Code:\n 0: aload_1\n 1: ldc #52 // String lhs\n 3: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #54 // String rhs\n 9: invokestatic #28 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: dconst_1\n 13: aload_0\n 14: aload_1\n 15: aload_2\n 16: invokevirtual #56 // Method distance:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)D\n 19: dsub\n 20: dreturn\n}\n",
"javap_err": ""
}
] |
aallam__string-similarity-kotlin__40cd4eb/string-similarity/src/commonMain/kotlin/com/aallam/similarity/Jaccard.kt
|
package com.aallam.similarity
import com.aallam.similarity.internal.Shingle
/**
* Each input string is converted into a set of n-grams, the Jaccard index is then computed as `|A ∩ B| / |A ∪ B|`.
*
* Like Q-Gram distance, the input strings are first converted into sets of n-grams (sequences of n characters, also
* called k-shingles), but this time the cardinality of each n-gram is not taken into account.
*
* Jaccard index is a metric distance.
*
* @param k length of k-shingles
*/
public class Jaccard(private val k: Int = 3) {
/**
* Compute Jaccard index. `|A ∩ B| / |A ∪ B|`.
* @param first the first string to compare.
* @param second the second string to compare.
*/
public fun similarity(first: String, second: String): Double {
if (first == second) return 1.0
val p1 = Shingle.profile(first, k)
val p2 = Shingle.profile(second, k)
val union = p1.keys + p2.keys
val inter = p1.keys.size + p2.keys.size - union.size
return inter.toDouble() / union.size
}
/**
* Distance is computed as 1 - similarity.
*
* @param first the first string to compare.
* @param second the second string to compare.
*/
public fun distance(first: String, second: String): Double {
return 1.0 - similarity(first, second)
}
}
|
[
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/Jaccard.class",
"javap": "Compiled from \"Jaccard.kt\"\npublic final class com.aallam.similarity.Jaccard {\n private final int k;\n\n public com.aallam.similarity.Jaccard(int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field k:I\n 9: return\n\n public com.aallam.similarity.Jaccard(int, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: iload_2\n 1: iconst_1\n 2: iand\n 3: ifeq 8\n 6: iconst_3\n 7: istore_1\n 8: aload_0\n 9: iload_1\n 10: invokespecial #18 // Method \"<init>\":(I)V\n 13: return\n\n public final double similarity(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #23 // String first\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #31 // String second\n 9: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #35 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 17: ifeq 22\n 20: dconst_1\n 21: dreturn\n 22: getstatic #41 // Field com/aallam/similarity/internal/Shingle.Companion:Lcom/aallam/similarity/internal/Shingle$Companion;\n 25: aload_1\n 26: checkcast #43 // class java/lang/CharSequence\n 29: aload_0\n 30: getfield #13 // Field k:I\n 33: invokevirtual #49 // Method com/aallam/similarity/internal/Shingle$Companion.profile:(Ljava/lang/CharSequence;I)Ljava/util/Map;\n 36: astore_3\n 37: getstatic #41 // Field com/aallam/similarity/internal/Shingle.Companion:Lcom/aallam/similarity/internal/Shingle$Companion;\n 40: aload_2\n 41: checkcast #43 // class java/lang/CharSequence\n 44: aload_0\n 45: getfield #13 // Field k:I\n 48: invokevirtual #49 // Method com/aallam/similarity/internal/Shingle$Companion.profile:(Ljava/lang/CharSequence;I)Ljava/util/Map;\n 51: astore 4\n 53: aload_3\n 54: invokeinterface #55, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 59: aload 4\n 61: invokeinterface #55, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 66: checkcast #57 // class java/lang/Iterable\n 69: invokestatic #63 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Iterable;)Ljava/util/Set;\n 72: astore 5\n 74: aload_3\n 75: invokeinterface #55, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 80: invokeinterface #69, 1 // InterfaceMethod java/util/Set.size:()I\n 85: aload 4\n 87: invokeinterface #55, 1 // InterfaceMethod java/util/Map.keySet:()Ljava/util/Set;\n 92: invokeinterface #69, 1 // InterfaceMethod java/util/Set.size:()I\n 97: iadd\n 98: aload 5\n 100: invokeinterface #69, 1 // InterfaceMethod java/util/Set.size:()I\n 105: isub\n 106: istore 6\n 108: iload 6\n 110: i2d\n 111: aload 5\n 113: invokeinterface #69, 1 // InterfaceMethod java/util/Set.size:()I\n 118: i2d\n 119: ddiv\n 120: dreturn\n\n public final double distance(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #23 // String first\n 3: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #31 // String second\n 9: invokestatic #29 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: dconst_1\n 13: aload_0\n 14: aload_1\n 15: aload_2\n 16: invokevirtual #79 // Method similarity:(Ljava/lang/String;Ljava/lang/String;)D\n 19: dsub\n 20: dreturn\n\n public com.aallam.similarity.Jaccard();\n Code:\n 0: aload_0\n 1: iconst_0\n 2: iconst_1\n 3: aconst_null\n 4: invokespecial #81 // Method \"<init>\":(IILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 7: return\n}\n",
"javap_err": ""
}
] |
aallam__string-similarity-kotlin__40cd4eb/string-similarity/src/commonMain/kotlin/com/aallam/similarity/RatcliffObershelp.kt
|
package com.aallam.similarity
/**
* The Ratcliff/Obershelp algorithm computes the similarity of two strings the doubled number of matching characters
* divided by the total number of characters in the two strings. Matching characters are those in the longest common
* subsequence plus, recursively, matching characters in the unmatched region on either side of the longest common
* subsequence.
*/
public class RatcliffObershelp {
/**
* Compute the Ratcliff-Obershelp similarity between strings.
*
* @param first the first string to compare.
* @param second the second string to compare.
*/
public fun similarity(first: String, second: String): Double {
if (first == second) return 1.0
val matches = matchList(first, second)
val sumOfMatches = matches.sumOf { it.length }
return 2.0 * sumOfMatches / (first.length + second.length)
}
/**
* Return 1 - similarity.
*
* @param first the first string to compare.
* @param second the second string to compare.
*/
public fun distance(first: String, second: String): Double {
return 1.0 - similarity(first, second)
}
/**
* Returns a list of matching substrings between the given [first] and [second] strings.
*
* @param first The first string to compare.
* @param second The second string to compare.
*/
private fun matchList(first: String, second: String): List<String> {
val match = frontMaxMatch(first, second)
if (match.isEmpty()) return emptyList()
val frontQueue = matchList(first.substringBefore(match), second.substringBefore(match))
val endQueue = matchList(first.substringAfter(match), second.substringAfter(match))
return listOf(match) + frontQueue + endQueue
}
/**
* Returns the longest substring that occurs at the beginning of both the [first] and [second] strings.
*
* @param first the first string to compare.
* @param second the second string to compare.
*/
private fun frontMaxMatch(first: String, second: String): String {
var longestSubstring = ""
for (i in first.indices) {
for (j in i + 1..first.length) {
val substring = first.substring(i, j)
if (second.contains(substring) && substring.length > longestSubstring.length) {
longestSubstring = substring
}
}
}
return longestSubstring
}
}
|
[
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/RatcliffObershelp.class",
"javap": "Compiled from \"RatcliffObershelp.kt\"\npublic final class com.aallam.similarity.RatcliffObershelp {\n public com.aallam.similarity.RatcliffObershelp();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final double similarity(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String first\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 second\n 9: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_1\n 13: aload_2\n 14: invokestatic #27 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 17: ifeq 22\n 20: dconst_1\n 21: dreturn\n 22: aload_0\n 23: aload_1\n 24: aload_2\n 25: invokespecial #31 // Method matchList:(Ljava/lang/String;Ljava/lang/String;)Ljava/util/List;\n 28: astore_3\n 29: aload_3\n 30: checkcast #33 // class java/lang/Iterable\n 33: astore 5\n 35: iconst_0\n 36: istore 6\n 38: aload 5\n 40: invokeinterface #37, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 7\n 47: aload 7\n 49: invokeinterface #43, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 97\n 57: aload 7\n 59: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 8\n 66: iload 6\n 68: aload 8\n 70: checkcast #49 // class java/lang/String\n 73: astore 9\n 75: istore 11\n 77: iconst_0\n 78: istore 10\n 80: aload 9\n 82: invokevirtual #53 // Method java/lang/String.length:()I\n 85: istore 12\n 87: iload 11\n 89: iload 12\n 91: iadd\n 92: istore 6\n 94: goto 47\n 97: iload 6\n 99: istore 4\n 101: ldc2_w #54 // double 2.0d\n 104: iload 4\n 106: i2d\n 107: dmul\n 108: aload_1\n 109: invokevirtual #53 // Method java/lang/String.length:()I\n 112: aload_2\n 113: invokevirtual #53 // Method java/lang/String.length:()I\n 116: iadd\n 117: i2d\n 118: ddiv\n 119: dreturn\n\n public final double distance(java.lang.String, java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String first\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 second\n 9: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: dconst_1\n 13: aload_0\n 14: aload_1\n 15: aload_2\n 16: invokevirtual #67 // Method similarity:(Ljava/lang/String;Ljava/lang/String;)D\n 19: dsub\n 20: dreturn\n\n private final java.util.List<java.lang.String> matchList(java.lang.String, java.lang.String);\n Code:\n 0: aload_0\n 1: aload_1\n 2: aload_2\n 3: invokespecial #72 // Method frontMaxMatch:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;\n 6: astore_3\n 7: aload_3\n 8: checkcast #74 // class java/lang/CharSequence\n 11: invokeinterface #75, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 16: ifne 23\n 19: iconst_1\n 20: goto 24\n 23: iconst_0\n 24: ifeq 31\n 27: invokestatic #81 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;\n 30: areturn\n 31: aload_0\n 32: aload_1\n 33: aload_3\n 34: aconst_null\n 35: iconst_2\n 36: aconst_null\n 37: invokestatic #87 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 40: aload_2\n 41: aload_3\n 42: aconst_null\n 43: iconst_2\n 44: aconst_null\n 45: invokestatic #87 // Method kotlin/text/StringsKt.substringBefore$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 48: invokespecial #31 // Method matchList:(Ljava/lang/String;Ljava/lang/String;)Ljava/util/List;\n 51: astore 4\n 53: aload_0\n 54: aload_1\n 55: aload_3\n 56: aconst_null\n 57: iconst_2\n 58: aconst_null\n 59: invokestatic #90 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 62: aload_2\n 63: aload_3\n 64: aconst_null\n 65: iconst_2\n 66: aconst_null\n 67: invokestatic #90 // Method kotlin/text/StringsKt.substringAfter$default:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Ljava/lang/String;\n 70: invokespecial #31 // Method matchList:(Ljava/lang/String;Ljava/lang/String;)Ljava/util/List;\n 73: astore 5\n 75: aload_3\n 76: invokestatic #94 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;\n 79: checkcast #96 // class java/util/Collection\n 82: aload 4\n 84: checkcast #33 // class java/lang/Iterable\n 87: invokestatic #100 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 90: checkcast #96 // class java/util/Collection\n 93: aload 5\n 95: checkcast #33 // class java/lang/Iterable\n 98: invokestatic #100 // Method kotlin/collections/CollectionsKt.plus:(Ljava/util/Collection;Ljava/lang/Iterable;)Ljava/util/List;\n 101: areturn\n\n private final java.lang.String frontMaxMatch(java.lang.String, java.lang.String);\n Code:\n 0: ldc #105 // String\n 2: astore_3\n 3: iconst_0\n 4: istore 4\n 6: aload_1\n 7: checkcast #74 // class java/lang/CharSequence\n 10: invokeinterface #75, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 15: istore 5\n 17: iload 4\n 19: iload 5\n 21: if_icmpge 111\n 24: iload 4\n 26: iconst_1\n 27: iadd\n 28: istore 6\n 30: aload_1\n 31: invokevirtual #53 // Method java/lang/String.length:()I\n 34: istore 7\n 36: iload 6\n 38: iload 7\n 40: if_icmpgt 105\n 43: aload_1\n 44: iload 4\n 46: iload 6\n 48: invokevirtual #109 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 51: dup\n 52: ldc #111 // String substring(...)\n 54: invokestatic #114 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 57: astore 8\n 59: aload_2\n 60: checkcast #74 // class java/lang/CharSequence\n 63: aload 8\n 65: checkcast #74 // class java/lang/CharSequence\n 68: iconst_0\n 69: iconst_2\n 70: aconst_null\n 71: invokestatic #118 // Method kotlin/text/StringsKt.contains$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Z\n 74: ifeq 92\n 77: aload 8\n 79: invokevirtual #53 // Method java/lang/String.length:()I\n 82: aload_3\n 83: invokevirtual #53 // Method java/lang/String.length:()I\n 86: if_icmple 92\n 89: aload 8\n 91: astore_3\n 92: iload 6\n 94: iload 7\n 96: if_icmpeq 105\n 99: iinc 6, 1\n 102: goto 43\n 105: iinc 4, 1\n 108: goto 17\n 111: aload_3\n 112: areturn\n}\n",
"javap_err": ""
}
] |
aallam__string-similarity-kotlin__40cd4eb/string-similarity/src/commonMain/kotlin/com/aallam/similarity/internal/Shingle.kt
|
package com.aallam.similarity.internal
/**
* Similarities that rely on set operations (like cosine similarity or jaccard index).
*/
internal interface Shingle {
/**
* Compute and return the profile of string as defined by [Ukkonen](https://www.cs.helsinki.fi/u/ukkonen/TCS92.pdf).
*
* The profile is the number of occurrences of k-shingles, and is used to compute q-gram similarity, Jaccard index,
* etc.
*
* k-shingling is the operation of transforming a string (or text document) into a set of n-grams, which can be used to
* measure the similarity between two strings or documents.
*
* Generally speaking, a k-gram is any sequence of [k] tokens.
* Multiple subsequent spaces are replaced by a single space, and a k-gram is a sequence of k characters.
*
* Default value of [k] is `3`. A good rule of thumb is to imagine that there are only 20 characters and estimate the
* number of k-shingles as 20^k. For small documents like e-mails, k = 5 is a recommended value. For large documents,
* such as research articles, k = 9 is considered a safe choice.
*
* The memory requirement of the profile can be up to [k] * [string]`.length`.
*
* @param string input string
* @param k length of k-shingles
* @return the profile of the provided string
*/
fun profile(string: CharSequence, k: Int = 3): Profile {
require(k > 0) { "k should be positive" }
val filtered = spaces.replace(string, " ")
return filtered.windowed(size = k).groupingBy { it }.eachCount()
}
companion object : Shingle {
/**
* Regex for subsequent spaces.
*/
private val spaces = Regex("\\s+")
}
}
/**
* The number of occurrences of k-shingles.
*/
internal typealias Profile = Map<String, Int>
|
[
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/internal/Shingle$DefaultImpls.class",
"javap": "Compiled from \"Shingle.kt\"\npublic final class com.aallam.similarity.internal.Shingle$DefaultImpls {\n public static java.util.Map<java.lang.String, java.lang.Integer> profile(com.aallam.similarity.internal.Shingle, java.lang.CharSequence, int);\n Code:\n 0: aload_1\n 1: ldc #10 // String string\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: iload_2\n 7: ifle 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 #18 // String k should be positive\n 23: astore 4\n 25: new #20 // class java/lang/IllegalArgumentException\n 28: dup\n 29: aload 4\n 31: invokevirtual #24 // Method java/lang/Object.toString:()Ljava/lang/String;\n 34: invokespecial #28 // Method java/lang/IllegalArgumentException.\"<init>\":(Ljava/lang/String;)V\n 37: athrow\n 38: invokestatic #34 // Method com/aallam/similarity/internal/Shingle$Companion.access$getSpaces$p:()Lkotlin/text/Regex;\n 41: aload_1\n 42: ldc #36 // String\n 44: invokevirtual #42 // Method kotlin/text/Regex.replace:(Ljava/lang/CharSequence;Ljava/lang/String;)Ljava/lang/String;\n 47: astore_3\n 48: aload_3\n 49: checkcast #44 // class java/lang/CharSequence\n 52: iload_2\n 53: iconst_0\n 54: iconst_0\n 55: bipush 6\n 57: aconst_null\n 58: invokestatic #50 // Method kotlin/text/StringsKt.windowed$default:(Ljava/lang/CharSequence;IIZILjava/lang/Object;)Ljava/util/List;\n 61: checkcast #52 // class java/lang/Iterable\n 64: astore 4\n 66: iconst_0\n 67: istore 5\n 69: new #54 // class com/aallam/similarity/internal/Shingle$DefaultImpls$profile$$inlined$groupingBy$1\n 72: dup\n 73: aload 4\n 75: invokespecial #57 // Method com/aallam/similarity/internal/Shingle$DefaultImpls$profile$$inlined$groupingBy$1.\"<init>\":(Ljava/lang/Iterable;)V\n 78: checkcast #59 // class kotlin/collections/Grouping\n 81: invokestatic #65 // Method kotlin/collections/GroupingKt.eachCount:(Lkotlin/collections/Grouping;)Ljava/util/Map;\n 84: areturn\n\n public static java.util.Map profile$default(com.aallam.similarity.internal.Shingle, java.lang.CharSequence, int, int, java.lang.Object);\n Code:\n 0: aload 4\n 2: ifnull 15\n 5: new #80 // class java/lang/UnsupportedOperationException\n 8: dup\n 9: ldc #82 // String Super calls with default arguments not supported in this target, function: profile\n 11: invokespecial #83 // Method java/lang/UnsupportedOperationException.\"<init>\":(Ljava/lang/String;)V\n 14: athrow\n 15: iload_3\n 16: iconst_2\n 17: iand\n 18: ifeq 23\n 21: iconst_3\n 22: istore_2\n 23: aload_0\n 24: aload_1\n 25: iload_2\n 26: invokeinterface #88, 3 // InterfaceMethod com/aallam/similarity/internal/Shingle.profile:(Ljava/lang/CharSequence;I)Ljava/util/Map;\n 31: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/internal/ShingleKt.class",
"javap": "Compiled from \"Shingle.kt\"\npublic final class com.aallam.similarity.internal.ShingleKt {\n}\n",
"javap_err": ""
},
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/internal/Shingle.class",
"javap": "Compiled from \"Shingle.kt\"\npublic interface com.aallam.similarity.internal.Shingle {\n public static final com.aallam.similarity.internal.Shingle$Companion Companion;\n\n public abstract java.util.Map<java.lang.String, java.lang.Integer> profile(java.lang.CharSequence, int);\n\n static {};\n Code:\n 0: getstatic #16 // Field com/aallam/similarity/internal/Shingle$Companion.$$INSTANCE:Lcom/aallam/similarity/internal/Shingle$Companion;\n 3: putstatic #19 // Field Companion:Lcom/aallam/similarity/internal/Shingle$Companion;\n 6: return\n}\n",
"javap_err": ""
},
{
"class_path": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/internal/Shingle$DefaultImpls$profile$$inlined$groupingBy$1.class",
"javap": "Compiled from \"_Collections.kt\"\npublic final class com.aallam.similarity.internal.Shingle$DefaultImpls$profile$$inlined$groupingBy$1 implements kotlin.collections.Grouping<java.lang.String, java.lang.String> {\n final java.lang.Iterable $this_groupingBy;\n\n public com.aallam.similarity.internal.Shingle$DefaultImpls$profile$$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.String> 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.String keyOf(java.lang.String);\n Code:\n 0: aload_1\n 1: checkcast #37 // class java/lang/String\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": "aallam__string-similarity-kotlin__40cd4eb/com/aallam/similarity/internal/Shingle$Companion.class",
"javap": "Compiled from \"Shingle.kt\"\npublic final class com.aallam.similarity.internal.Shingle$Companion implements com.aallam.similarity.internal.Shingle {\n static final com.aallam.similarity.internal.Shingle$Companion $$INSTANCE;\n\n private static final kotlin.text.Regex spaces;\n\n private com.aallam.similarity.internal.Shingle$Companion();\n Code:\n 0: aload_0\n 1: invokespecial #10 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public java.util.Map<java.lang.String, java.lang.Integer> profile(java.lang.CharSequence, int);\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: invokestatic #21 // Method com/aallam/similarity/internal/Shingle$DefaultImpls.profile:(Lcom/aallam/similarity/internal/Shingle;Ljava/lang/CharSequence;I)Ljava/util/Map;\n 6: areturn\n\n public static final kotlin.text.Regex access$getSpaces$p();\n Code:\n 0: getstatic #31 // Field spaces:Lkotlin/text/Regex;\n 3: areturn\n\n static {};\n Code:\n 0: new #2 // class com/aallam/similarity/internal/Shingle$Companion\n 3: dup\n 4: invokespecial #33 // Method \"<init>\":()V\n 7: putstatic #36 // Field $$INSTANCE:Lcom/aallam/similarity/internal/Shingle$Companion;\n 10: new #38 // class kotlin/text/Regex\n 13: dup\n 14: ldc #40 // String \\\\s+\n 16: invokespecial #43 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 19: putstatic #31 // Field spaces:Lkotlin/text/Regex;\n 22: return\n}\n",
"javap_err": ""
}
] |
Malo-T__AoC-2022__f4edefa/src/main/kotlin/day07/Day07.kt
|
package day07
data class File(
val name: String,
val size: Int,
)
data class Directory(
val name: String,
val directories: MutableList<Directory> = mutableListOf(),
val files: MutableList<File> = mutableListOf(),
) {
// must not be in the constructor
lateinit var parent: Directory
fun size(): Int = files.sumOf { it.size } + directories.sumOf { it.size() }
fun children(): List<Directory> = directories + directories.flatMap { it.children() }
}
private fun root() = Directory(name = "/").apply { parent = this }
/** Return parent or child directory depending on command */
private fun Directory.cd(cmd: String): Directory =
when (val dir = cmd.substring(5)) {
".." -> parent
else -> directories.firstOrNull { it.name == dir }
?: Directory(name = dir)
.apply { parent = this@cd }
.also { directories.add(it) }
}
/** Create and add file to current directory. Return current directory */
private fun Directory.addFile(path: String): Directory = apply {
val (size, name) = path.split(' ')
if (files.none { it.name == name }) {
files += File(
name = name,
size = size.toInt()
)
}
}
class Day07 {
fun parse1(input: String): Directory =
root().apply {
input.lines()
.drop(1) // first line is "$ cd /" -> root
.fold(this) { dir, line ->
when {
line == "$ ls" -> dir// do nothing
line.startsWith("$ cd ") -> dir.cd(line)// move to directory (create it if necessary)
line.startsWith("dir ") -> dir // do nothing (directories are created on 'cd')
line[0].isDigit() -> dir.addFile(line)// add file to directory
else -> throw IllegalStateException("Invalid line: $line")
}
}
}
fun part1(root: Directory): Int =
root.children()
.map { it.size() }
.filter { it < 100_000 }
.sum()
fun part2(root: Directory): Int {
TODO()
}
}
|
[
{
"class_path": "Malo-T__AoC-2022__f4edefa/day07/Day07Kt.class",
"javap": "Compiled from \"Day07.kt\"\npublic final class day07.Day07Kt {\n private static final day07.Directory root();\n Code:\n 0: new #8 // class day07/Directory\n 3: dup\n 4: ldc #10 // String /\n 6: aconst_null\n 7: aconst_null\n 8: bipush 6\n 10: aconst_null\n 11: invokespecial #14 // Method day07/Directory.\"<init>\":(Ljava/lang/String;Ljava/util/List;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 14: astore_0\n 15: aload_0\n 16: astore_1\n 17: iconst_0\n 18: istore_2\n 19: aload_1\n 20: aload_1\n 21: invokevirtual #18 // Method day07/Directory.setParent:(Lday07/Directory;)V\n 24: aload_0\n 25: areturn\n\n private static final day07.Directory cd(day07.Directory, java.lang.String);\n Code:\n 0: aload_1\n 1: iconst_5\n 2: invokevirtual #30 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 5: dup\n 6: ldc #32 // String substring(...)\n 8: invokestatic #38 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 11: astore_2\n 12: aload_2\n 13: ldc #40 // String ..\n 15: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 18: ifeq 28\n 21: aload_0\n 22: invokevirtual #47 // Method day07/Directory.getParent:()Lday07/Directory;\n 25: goto 149\n 28: aload_0\n 29: invokevirtual #51 // Method day07/Directory.getDirectories:()Ljava/util/List;\n 32: checkcast #53 // class java/lang/Iterable\n 35: astore_3\n 36: iconst_0\n 37: istore 4\n 39: aload_3\n 40: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 45: astore 5\n 47: aload 5\n 49: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 54: ifeq 93\n 57: aload 5\n 59: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 64: astore 6\n 66: aload 6\n 68: checkcast #8 // class day07/Directory\n 71: astore 7\n 73: iconst_0\n 74: istore 8\n 76: aload 7\n 78: invokevirtual #71 // Method day07/Directory.getName:()Ljava/lang/String;\n 81: aload_2\n 82: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 85: ifeq 47\n 88: aload 6\n 90: goto 94\n 93: aconst_null\n 94: checkcast #8 // class day07/Directory\n 97: dup\n 98: ifnonnull 149\n 101: pop\n 102: new #8 // class day07/Directory\n 105: dup\n 106: aload_2\n 107: aconst_null\n 108: aconst_null\n 109: bipush 6\n 111: aconst_null\n 112: invokespecial #14 // Method day07/Directory.\"<init>\":(Ljava/lang/String;Ljava/util/List;Ljava/util/List;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 115: astore_3\n 116: aload_3\n 117: astore 4\n 119: iconst_0\n 120: istore 5\n 122: aload 4\n 124: aload_0\n 125: invokevirtual #18 // Method day07/Directory.setParent:(Lday07/Directory;)V\n 128: aload_3\n 129: astore_3\n 130: aload_3\n 131: astore 4\n 133: iconst_0\n 134: istore 5\n 136: aload_0\n 137: invokevirtual #51 // Method day07/Directory.getDirectories:()Ljava/util/List;\n 140: aload 4\n 142: invokeinterface #77, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 147: pop\n 148: aload_3\n 149: areturn\n\n private static final day07.Directory addFile(day07.Directory, java.lang.String);\n Code:\n 0: aload_0\n 1: astore_2\n 2: aload_2\n 3: astore_3\n 4: iconst_0\n 5: istore 4\n 7: aload_1\n 8: checkcast #94 // class java/lang/CharSequence\n 11: iconst_1\n 12: newarray char\n 14: astore 5\n 16: aload 5\n 18: iconst_0\n 19: bipush 32\n 21: castore\n 22: aload 5\n 24: iconst_0\n 25: iconst_0\n 26: bipush 6\n 28: aconst_null\n 29: invokestatic #100 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[CZIILjava/lang/Object;)Ljava/util/List;\n 32: astore 6\n 34: aload 6\n 36: iconst_0\n 37: invokeinterface #104, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 42: checkcast #26 // class java/lang/String\n 45: astore 5\n 47: aload 6\n 49: iconst_1\n 50: invokeinterface #104, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 55: checkcast #26 // class java/lang/String\n 58: astore 7\n 60: aload_3\n 61: invokevirtual #107 // Method day07/Directory.getFiles:()Ljava/util/List;\n 64: checkcast #53 // class java/lang/Iterable\n 67: astore 8\n 69: iconst_0\n 70: istore 9\n 72: aload 8\n 74: instanceof #109 // class java/util/Collection\n 77: ifeq 97\n 80: aload 8\n 82: checkcast #109 // class java/util/Collection\n 85: invokeinterface #112, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 90: ifeq 97\n 93: iconst_1\n 94: goto 153\n 97: aload 8\n 99: invokeinterface #57, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 104: astore 10\n 106: aload 10\n 108: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 113: ifeq 152\n 116: aload 10\n 118: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 123: astore 11\n 125: aload 11\n 127: checkcast #114 // class day07/File\n 130: astore 12\n 132: iconst_0\n 133: istore 13\n 135: aload 12\n 137: invokevirtual #115 // Method day07/File.getName:()Ljava/lang/String;\n 140: aload 7\n 142: invokestatic #44 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 145: ifeq 106\n 148: iconst_0\n 149: goto 153\n 152: iconst_1\n 153: ifeq 183\n 156: aload_3\n 157: invokevirtual #107 // Method day07/Directory.getFiles:()Ljava/util/List;\n 160: checkcast #109 // class java/util/Collection\n 163: new #114 // class day07/File\n 166: dup\n 167: aload 7\n 169: aload 5\n 171: invokestatic #121 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 174: invokespecial #124 // Method day07/File.\"<init>\":(Ljava/lang/String;I)V\n 177: invokeinterface #125, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 182: pop\n 183: nop\n 184: aload_2\n 185: areturn\n\n public static final day07.Directory access$root();\n Code:\n 0: invokestatic #138 // Method root:()Lday07/Directory;\n 3: areturn\n\n public static final day07.Directory access$cd(day07.Directory, java.lang.String);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #141 // Method cd:(Lday07/Directory;Ljava/lang/String;)Lday07/Directory;\n 5: areturn\n\n public static final day07.Directory access$addFile(day07.Directory, java.lang.String);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #145 // Method addFile:(Lday07/Directory;Ljava/lang/String;)Lday07/Directory;\n 5: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day07/Day07.class",
"javap": "Compiled from \"Day07.kt\"\npublic final class day07.Day07 {\n public day07.Day07();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final day07.Directory parse1(java.lang.String);\n Code:\n 0: aload_1\n 1: ldc #15 // String input\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: invokestatic #27 // Method day07/Day07Kt.access$root:()Lday07/Directory;\n 9: astore_2\n 10: aload_2\n 11: astore_3\n 12: iconst_0\n 13: istore 4\n 15: aload_1\n 16: checkcast #29 // class java/lang/CharSequence\n 19: invokestatic #35 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 22: checkcast #37 // class java/lang/Iterable\n 25: iconst_1\n 26: invokestatic #43 // Method kotlin/collections/CollectionsKt.drop:(Ljava/lang/Iterable;I)Ljava/util/List;\n 29: checkcast #37 // class java/lang/Iterable\n 32: astore 5\n 34: nop\n 35: iconst_0\n 36: istore 6\n 38: aload_3\n 39: astore 7\n 41: aload 5\n 43: invokeinterface #47, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 48: astore 8\n 50: aload 8\n 52: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 57: ifeq 196\n 60: aload 8\n 62: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 67: astore 9\n 69: aload 7\n 71: aload 9\n 73: checkcast #59 // class java/lang/String\n 76: astore 10\n 78: astore 11\n 80: iconst_0\n 81: istore 12\n 83: nop\n 84: aload 10\n 86: ldc #61 // String $ ls\n 88: invokestatic #65 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 91: ifeq 99\n 94: aload 11\n 96: goto 190\n 99: aload 10\n 101: ldc #67 // String $ cd\n 103: iconst_0\n 104: iconst_2\n 105: aconst_null\n 106: invokestatic #71 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 109: ifeq 122\n 112: aload 11\n 114: aload 10\n 116: invokestatic #75 // Method day07/Day07Kt.access$cd:(Lday07/Directory;Ljava/lang/String;)Lday07/Directory;\n 119: goto 190\n 122: aload 10\n 124: ldc #77 // String dir\n 126: iconst_0\n 127: iconst_2\n 128: aconst_null\n 129: invokestatic #71 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 132: ifeq 140\n 135: aload 11\n 137: goto 190\n 140: aload 10\n 142: iconst_0\n 143: invokevirtual #81 // Method java/lang/String.charAt:(I)C\n 146: invokestatic #87 // Method java/lang/Character.isDigit:(C)Z\n 149: ifeq 162\n 152: aload 11\n 154: aload 10\n 156: invokestatic #90 // Method day07/Day07Kt.access$addFile:(Lday07/Directory;Ljava/lang/String;)Lday07/Directory;\n 159: goto 190\n 162: new #92 // class java/lang/IllegalStateException\n 165: dup\n 166: new #94 // class java/lang/StringBuilder\n 169: dup\n 170: invokespecial #95 // Method java/lang/StringBuilder.\"<init>\":()V\n 173: ldc #97 // String Invalid line:\n 175: invokevirtual #101 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 178: aload 10\n 180: invokevirtual #101 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 183: invokevirtual #105 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 186: invokespecial #108 // Method java/lang/IllegalStateException.\"<init>\":(Ljava/lang/String;)V\n 189: athrow\n 190: nop\n 191: astore 7\n 193: goto 50\n 196: nop\n 197: nop\n 198: aload_2\n 199: areturn\n\n public final int part1(day07.Directory);\n Code:\n 0: aload_1\n 1: ldc #128 // String root\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokevirtual #132 // Method day07/Directory.children:()Ljava/util/List;\n 10: checkcast #37 // class java/lang/Iterable\n 13: astore_2\n 14: nop\n 15: iconst_0\n 16: istore_3\n 17: aload_2\n 18: astore 4\n 20: new #134 // class java/util/ArrayList\n 23: dup\n 24: aload_2\n 25: bipush 10\n 27: invokestatic #138 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 30: invokespecial #141 // Method java/util/ArrayList.\"<init>\":(I)V\n 33: checkcast #143 // class java/util/Collection\n 36: astore 5\n 38: iconst_0\n 39: istore 6\n 41: aload 4\n 43: invokeinterface #47, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 48: astore 7\n 50: aload 7\n 52: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 57: ifeq 103\n 60: aload 7\n 62: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 67: astore 8\n 69: aload 5\n 71: aload 8\n 73: checkcast #124 // class day07/Directory\n 76: astore 9\n 78: astore 11\n 80: iconst_0\n 81: istore 10\n 83: aload 9\n 85: invokevirtual #147 // Method day07/Directory.size:()I\n 88: invokestatic #153 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 91: aload 11\n 93: swap\n 94: invokeinterface #157, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 99: pop\n 100: goto 50\n 103: aload 5\n 105: checkcast #159 // class java/util/List\n 108: nop\n 109: checkcast #37 // class java/lang/Iterable\n 112: astore_2\n 113: nop\n 114: iconst_0\n 115: istore_3\n 116: aload_2\n 117: astore 4\n 119: new #134 // class java/util/ArrayList\n 122: dup\n 123: invokespecial #160 // Method java/util/ArrayList.\"<init>\":()V\n 126: checkcast #143 // class java/util/Collection\n 129: astore 5\n 131: iconst_0\n 132: istore 6\n 134: aload 4\n 136: invokeinterface #47, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 141: astore 7\n 143: aload 7\n 145: invokeinterface #53, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 150: ifeq 203\n 153: aload 7\n 155: invokeinterface #57, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 160: astore 8\n 162: aload 8\n 164: checkcast #162 // class java/lang/Number\n 167: invokevirtual #165 // Method java/lang/Number.intValue:()I\n 170: istore 9\n 172: iconst_0\n 173: istore 10\n 175: iload 9\n 177: ldc #166 // int 100000\n 179: if_icmpge 186\n 182: iconst_1\n 183: goto 187\n 186: iconst_0\n 187: ifeq 143\n 190: aload 5\n 192: aload 8\n 194: invokeinterface #157, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 199: pop\n 200: goto 143\n 203: aload 5\n 205: checkcast #159 // class java/util/List\n 208: nop\n 209: checkcast #37 // class java/lang/Iterable\n 212: invokestatic #170 // Method kotlin/collections/CollectionsKt.sumOfInt:(Ljava/lang/Iterable;)I\n 215: ireturn\n\n public final int part2(day07.Directory);\n Code:\n 0: aload_1\n 1: ldc #128 // String root\n 3: invokestatic #21 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #188 // class kotlin/NotImplementedError\n 9: dup\n 10: aconst_null\n 11: iconst_1\n 12: aconst_null\n 13: invokespecial #191 // Method kotlin/NotImplementedError.\"<init>\":(Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 16: athrow\n}\n",
"javap_err": ""
}
] |
Malo-T__AoC-2022__f4edefa/src/main/kotlin/day04/Day04.kt
|
package day04
private typealias Assignments = Pair<IntRange, IntRange>
private fun String.toIntRange(): IntRange = split("-").map { it.toInt() }.let { it[0]..it[1] }
// anonymous function
private val hasCompleteOverlap = fun(assignments: Assignments): Boolean {
with(assignments) {
return first.subtract(second).isEmpty() || second.subtract(first).isEmpty()
}
}
// lambda
private val hasOverlap = { assignments: Assignments ->
assignments.first.intersect(assignments.second).isNotEmpty()
}
class Day04 {
fun parse(input: String): List<Assignments> =
input
.lines()
.map { line -> line.split(",") }
.map { (first, second) ->
Assignments(
first = first.toIntRange(),
second = second.toIntRange()
)
}
fun part1(parsed: List<Assignments>): Int = parsed.count(hasCompleteOverlap)
fun part2(parsed: List<Assignments>): Int = parsed.count(hasOverlap)
}
|
[
{
"class_path": "Malo-T__AoC-2022__f4edefa/day04/Day04Kt.class",
"javap": "Compiled from \"Day04.kt\"\npublic final class day04.Day04Kt {\n private static final kotlin.jvm.functions.Function1<kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange>, java.lang.Boolean> hasCompleteOverlap;\n\n private static final kotlin.jvm.functions.Function1<kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange>, java.lang.Boolean> hasOverlap;\n\n private static final kotlin.ranges.IntRange toIntRange(java.lang.String);\n Code:\n 0: aload_0\n 1: checkcast #8 // class java/lang/CharSequence\n 4: iconst_1\n 5: anewarray #10 // class java/lang/String\n 8: astore_1\n 9: aload_1\n 10: iconst_0\n 11: ldc #12 // String -\n 13: aastore\n 14: aload_1\n 15: iconst_0\n 16: iconst_0\n 17: bipush 6\n 19: aconst_null\n 20: invokestatic #18 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 23: checkcast #20 // class java/lang/Iterable\n 26: astore_1\n 27: iconst_0\n 28: istore_2\n 29: aload_1\n 30: astore_3\n 31: new #22 // class java/util/ArrayList\n 34: dup\n 35: aload_1\n 36: bipush 10\n 38: invokestatic #28 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 41: invokespecial #32 // Method java/util/ArrayList.\"<init>\":(I)V\n 44: checkcast #34 // class java/util/Collection\n 47: astore 4\n 49: iconst_0\n 50: istore 5\n 52: aload_3\n 53: invokeinterface #38, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 58: astore 6\n 60: aload 6\n 62: invokeinterface #44, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 67: ifeq 114\n 70: aload 6\n 72: invokeinterface #48, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 77: astore 7\n 79: aload 4\n 81: aload 7\n 83: checkcast #10 // class java/lang/String\n 86: astore 8\n 88: astore 10\n 90: iconst_0\n 91: istore 9\n 93: aload 8\n 95: invokestatic #54 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 98: nop\n 99: invokestatic #58 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 102: aload 10\n 104: swap\n 105: invokeinterface #62, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 110: pop\n 111: goto 60\n 114: aload 4\n 116: checkcast #64 // class java/util/List\n 119: nop\n 120: astore_2\n 121: iconst_0\n 122: istore_3\n 123: new #66 // class kotlin/ranges/IntRange\n 126: dup\n 127: aload_2\n 128: iconst_0\n 129: invokeinterface #70, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 134: checkcast #72 // class java/lang/Number\n 137: invokevirtual #76 // Method java/lang/Number.intValue:()I\n 140: aload_2\n 141: iconst_1\n 142: invokeinterface #70, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 147: checkcast #72 // class java/lang/Number\n 150: invokevirtual #76 // Method java/lang/Number.intValue:()I\n 153: invokespecial #79 // Method kotlin/ranges/IntRange.\"<init>\":(II)V\n 156: nop\n 157: areturn\n\n private static final boolean hasCompleteOverlap$lambda$3(kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange>);\n Code:\n 0: aload_0\n 1: astore_1\n 2: iconst_0\n 3: istore_2\n 4: aload_1\n 5: invokevirtual #103 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 8: checkcast #20 // class java/lang/Iterable\n 11: aload_1\n 12: invokevirtual #106 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 15: checkcast #20 // class java/lang/Iterable\n 18: invokestatic #110 // Method kotlin/collections/CollectionsKt.subtract:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 21: invokeinterface #115, 1 // InterfaceMethod java/util/Set.isEmpty:()Z\n 26: ifne 54\n 29: aload_1\n 30: invokevirtual #106 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 33: checkcast #20 // class java/lang/Iterable\n 36: aload_1\n 37: invokevirtual #103 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 40: checkcast #20 // class java/lang/Iterable\n 43: invokestatic #110 // Method kotlin/collections/CollectionsKt.subtract:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 46: invokeinterface #115, 1 // InterfaceMethod java/util/Set.isEmpty:()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 boolean hasOverlap$lambda$4(kotlin.Pair);\n Code:\n 0: aload_0\n 1: ldc #121 // String assignments\n 3: invokestatic #127 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokevirtual #103 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 10: checkcast #20 // class java/lang/Iterable\n 13: aload_0\n 14: invokevirtual #106 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 17: checkcast #20 // class java/lang/Iterable\n 20: invokestatic #130 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 23: checkcast #34 // class java/util/Collection\n 26: invokeinterface #131, 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 final kotlin.jvm.functions.Function1 access$getHasCompleteOverlap$p();\n Code:\n 0: getstatic #137 // Field hasCompleteOverlap:Lkotlin/jvm/functions/Function1;\n 3: areturn\n\n public static final kotlin.jvm.functions.Function1 access$getHasOverlap$p();\n Code:\n 0: getstatic #141 // Field hasOverlap:Lkotlin/jvm/functions/Function1;\n 3: areturn\n\n public static final kotlin.ranges.IntRange access$toIntRange(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #144 // Method toIntRange:(Ljava/lang/String;)Lkotlin/ranges/IntRange;\n 4: areturn\n\n static {};\n Code:\n 0: invokedynamic #164, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 5: putstatic #137 // Field hasCompleteOverlap:Lkotlin/jvm/functions/Function1;\n 8: invokedynamic #168, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 13: putstatic #141 // Field hasOverlap:Lkotlin/jvm/functions/Function1;\n 16: return\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day04/Day04.class",
"javap": "Compiled from \"Day04.kt\"\npublic final class day04.Day04 {\n public day04.Day04();\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.ranges.IntRange, kotlin.ranges.IntRange>> parse(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/CharSequence\n 10: invokestatic #30 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 13: checkcast #32 // 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 #34 // class java/util/ArrayList\n 26: dup\n 27: aload_2\n 28: bipush 10\n 30: invokestatic #40 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 33: invokespecial #43 // Method java/util/ArrayList.\"<init>\":(I)V\n 36: checkcast #45 // class java/util/Collection\n 39: astore 5\n 41: iconst_0\n 42: istore 6\n 44: aload 4\n 46: invokeinterface #49, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 51: astore 7\n 53: aload 7\n 55: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 60: ifeq 125\n 63: aload 7\n 65: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 70: astore 8\n 72: aload 5\n 74: aload 8\n 76: checkcast #61 // class java/lang/String\n 79: astore 9\n 81: astore 13\n 83: iconst_0\n 84: istore 10\n 86: aload 9\n 88: checkcast #24 // class java/lang/CharSequence\n 91: iconst_1\n 92: anewarray #61 // class java/lang/String\n 95: astore 11\n 97: aload 11\n 99: iconst_0\n 100: ldc #63 // String ,\n 102: aastore\n 103: aload 11\n 105: iconst_0\n 106: iconst_0\n 107: bipush 6\n 109: aconst_null\n 110: invokestatic #67 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 113: aload 13\n 115: swap\n 116: invokeinterface #71, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 121: pop\n 122: goto 53\n 125: aload 5\n 127: checkcast #73 // class java/util/List\n 130: nop\n 131: checkcast #32 // class java/lang/Iterable\n 134: astore_2\n 135: nop\n 136: iconst_0\n 137: istore_3\n 138: aload_2\n 139: astore 4\n 141: new #34 // class java/util/ArrayList\n 144: dup\n 145: aload_2\n 146: bipush 10\n 148: invokestatic #40 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 151: invokespecial #43 // Method java/util/ArrayList.\"<init>\":(I)V\n 154: checkcast #45 // class java/util/Collection\n 157: astore 5\n 159: iconst_0\n 160: istore 6\n 162: aload 4\n 164: invokeinterface #49, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 169: astore 7\n 171: aload 7\n 173: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 178: ifeq 260\n 181: aload 7\n 183: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 188: astore 8\n 190: aload 5\n 192: aload 8\n 194: checkcast #73 // class java/util/List\n 197: astore 9\n 199: astore 13\n 201: iconst_0\n 202: istore 10\n 204: aload 9\n 206: iconst_0\n 207: invokeinterface #77, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 212: checkcast #61 // class java/lang/String\n 215: astore 11\n 217: aload 9\n 219: iconst_1\n 220: invokeinterface #77, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 225: checkcast #61 // class java/lang/String\n 228: astore 12\n 230: new #79 // class kotlin/Pair\n 233: dup\n 234: aload 11\n 236: invokestatic #85 // Method day04/Day04Kt.access$toIntRange:(Ljava/lang/String;)Lkotlin/ranges/IntRange;\n 239: aload 12\n 241: invokestatic #85 // Method day04/Day04Kt.access$toIntRange:(Ljava/lang/String;)Lkotlin/ranges/IntRange;\n 244: invokespecial #88 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 247: nop\n 248: aload 13\n 250: swap\n 251: invokeinterface #71, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 256: pop\n 257: goto 171\n 260: aload 5\n 262: checkcast #73 // class java/util/List\n 265: nop\n 266: areturn\n\n public final int part1(java.util.List<kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange>>);\n Code:\n 0: aload_1\n 1: ldc #109 // String parsed\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #32 // class java/lang/Iterable\n 10: astore_2\n 11: invokestatic #113 // Method day04/Day04Kt.access$getHasCompleteOverlap$p:()Lkotlin/jvm/functions/Function1;\n 14: astore_3\n 15: iconst_0\n 16: istore 4\n 18: aload_2\n 19: instanceof #45 // class java/util/Collection\n 22: ifeq 41\n 25: aload_2\n 26: checkcast #45 // class java/util/Collection\n 29: invokeinterface #116, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 34: ifeq 41\n 37: iconst_0\n 38: goto 104\n 41: iconst_0\n 42: istore 5\n 44: aload_2\n 45: invokeinterface #49, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 6\n 52: aload 6\n 54: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 102\n 62: aload 6\n 64: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 7\n 71: aload_3\n 72: aload 7\n 74: invokeinterface #122, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 79: checkcast #124 // class java/lang/Boolean\n 82: invokevirtual #127 // Method java/lang/Boolean.booleanValue:()Z\n 85: ifeq 52\n 88: iinc 5, 1\n 91: iload 5\n 93: ifge 52\n 96: invokestatic #130 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 99: goto 52\n 102: iload 5\n 104: ireturn\n\n public final int part2(java.util.List<kotlin.Pair<kotlin.ranges.IntRange, kotlin.ranges.IntRange>>);\n Code:\n 0: aload_1\n 1: ldc #109 // String parsed\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #32 // class java/lang/Iterable\n 10: astore_2\n 11: invokestatic #141 // Method day04/Day04Kt.access$getHasOverlap$p:()Lkotlin/jvm/functions/Function1;\n 14: astore_3\n 15: iconst_0\n 16: istore 4\n 18: aload_2\n 19: instanceof #45 // class java/util/Collection\n 22: ifeq 41\n 25: aload_2\n 26: checkcast #45 // class java/util/Collection\n 29: invokeinterface #116, 1 // InterfaceMethod java/util/Collection.isEmpty:()Z\n 34: ifeq 41\n 37: iconst_0\n 38: goto 104\n 41: iconst_0\n 42: istore 5\n 44: aload_2\n 45: invokeinterface #49, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 6\n 52: aload 6\n 54: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 102\n 62: aload 6\n 64: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 7\n 71: aload_3\n 72: aload 7\n 74: invokeinterface #122, 2 // InterfaceMethod kotlin/jvm/functions/Function1.invoke:(Ljava/lang/Object;)Ljava/lang/Object;\n 79: checkcast #124 // class java/lang/Boolean\n 82: invokevirtual #127 // Method java/lang/Boolean.booleanValue:()Z\n 85: ifeq 52\n 88: iinc 5, 1\n 91: iload 5\n 93: ifge 52\n 96: invokestatic #130 // Method kotlin/collections/CollectionsKt.throwCountOverflow:()V\n 99: goto 52\n 102: iload 5\n 104: ireturn\n}\n",
"javap_err": ""
}
] |
Malo-T__AoC-2022__f4edefa/src/main/kotlin/day03/Day03.kt
|
package day03
private val itemPriorities: Map<Char, Int> = (('a'..'z') + ('A'..'Z')).mapIndexed { i, c -> c to i + 1 }.toMap()
private typealias RuckSack = Pair<Set<Char>, Set<Char>>
class Day03 {
fun parse(input: String): List<RuckSack> =
input.lines().map { line ->
RuckSack(
first = line.substring(0, line.length / 2).toSet(),
second = line.substring(line.length / 2).toSet()
)
}
fun part1(parsed: List<RuckSack>): Int =
parsed.map { (first, second) -> first.intersect(second).first() }
.sumOf { itemPriorities[it]!! }
fun part2(parsed: List<RuckSack>): Int =
parsed.map { it.first + it.second }
.windowed(size = 3, step = 3) { (first, second, third) ->
first.intersect(second).intersect(third).first()
}
.sumOf { itemPriorities[it]!! }
}
|
[
{
"class_path": "Malo-T__AoC-2022__f4edefa/day03/Day03Kt.class",
"javap": "Compiled from \"Day03.kt\"\npublic final class day03.Day03Kt {\n private static final java.util.Map<java.lang.Character, java.lang.Integer> itemPriorities;\n\n public static final java.util.Map access$getItemPriorities$p();\n Code:\n 0: getstatic #10 // Field itemPriorities:Ljava/util/Map;\n 3: areturn\n\n static {};\n Code:\n 0: new #14 // class kotlin/ranges/CharRange\n 3: dup\n 4: bipush 97\n 6: bipush 122\n 8: invokespecial #18 // Method kotlin/ranges/CharRange.\"<init>\":(CC)V\n 11: checkcast #20 // class java/lang/Iterable\n 14: new #14 // class kotlin/ranges/CharRange\n 17: dup\n 18: bipush 65\n 20: bipush 90\n 22: invokespecial #18 // Method kotlin/ranges/CharRange.\"<init>\":(CC)V\n 25: checkcast #20 // class java/lang/Iterable\n 28: invokestatic #26 // Method kotlin/collections/CollectionsKt.plus:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/List;\n 31: checkcast #20 // class java/lang/Iterable\n 34: astore_0\n 35: iconst_0\n 36: istore_1\n 37: aload_0\n 38: astore_2\n 39: new #28 // class java/util/ArrayList\n 42: dup\n 43: aload_0\n 44: bipush 10\n 46: invokestatic #32 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 49: invokespecial #35 // Method java/util/ArrayList.\"<init>\":(I)V\n 52: checkcast #37 // class java/util/Collection\n 55: astore_3\n 56: iconst_0\n 57: istore 4\n 59: iconst_0\n 60: istore 5\n 62: aload_2\n 63: invokeinterface #41, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 68: astore 6\n 70: aload 6\n 72: invokeinterface #47, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 77: ifeq 151\n 80: aload 6\n 82: invokeinterface #51, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 87: astore 7\n 89: aload_3\n 90: iload 5\n 92: iinc 5, 1\n 95: istore 8\n 97: iload 8\n 99: ifge 105\n 102: invokestatic #54 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 105: iload 8\n 107: aload 7\n 109: checkcast #56 // class java/lang/Character\n 112: invokevirtual #60 // Method java/lang/Character.charValue:()C\n 115: istore 9\n 117: istore 10\n 119: astore 12\n 121: iconst_0\n 122: istore 11\n 124: iload 9\n 126: invokestatic #64 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 129: iload 10\n 131: iconst_1\n 132: iadd\n 133: invokestatic #69 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 136: invokestatic #75 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 139: aload 12\n 141: swap\n 142: invokeinterface #79, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 147: pop\n 148: goto 70\n 151: aload_3\n 152: checkcast #81 // class java/util/List\n 155: nop\n 156: checkcast #20 // class java/lang/Iterable\n 159: invokestatic #87 // Method kotlin/collections/MapsKt.toMap:(Ljava/lang/Iterable;)Ljava/util/Map;\n 162: putstatic #10 // Field itemPriorities:Ljava/util/Map;\n 165: return\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day03/Day03.class",
"javap": "Compiled from \"Day03.kt\"\npublic final class day03.Day03 {\n public day03.Day03();\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<java.util.Set<java.lang.Character>, java.util.Set<java.lang.Character>>> parse(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/CharSequence\n 10: invokestatic #30 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 13: checkcast #32 // class java/lang/Iterable\n 16: astore_2\n 17: iconst_0\n 18: istore_3\n 19: aload_2\n 20: astore 4\n 22: new #34 // class java/util/ArrayList\n 25: dup\n 26: aload_2\n 27: bipush 10\n 29: invokestatic #40 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 32: invokespecial #43 // Method java/util/ArrayList.\"<init>\":(I)V\n 35: checkcast #45 // class java/util/Collection\n 38: astore 5\n 40: iconst_0\n 41: istore 6\n 43: aload 4\n 45: invokeinterface #49, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 50: astore 7\n 52: aload 7\n 54: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 59: ifeq 154\n 62: aload 7\n 64: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 69: astore 8\n 71: aload 5\n 73: aload 8\n 75: checkcast #61 // class java/lang/String\n 78: astore 9\n 80: astore 11\n 82: iconst_0\n 83: istore 10\n 85: new #63 // class kotlin/Pair\n 88: dup\n 89: aload 9\n 91: iconst_0\n 92: aload 9\n 94: invokevirtual #67 // Method java/lang/String.length:()I\n 97: iconst_2\n 98: idiv\n 99: invokevirtual #71 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 102: dup\n 103: ldc #73 // String substring(...)\n 105: invokestatic #76 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 108: checkcast #24 // class java/lang/CharSequence\n 111: invokestatic #80 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 114: aload 9\n 116: aload 9\n 118: invokevirtual #67 // Method java/lang/String.length:()I\n 121: iconst_2\n 122: idiv\n 123: invokevirtual #83 // Method java/lang/String.substring:(I)Ljava/lang/String;\n 126: dup\n 127: ldc #73 // String substring(...)\n 129: invokestatic #76 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 132: checkcast #24 // class java/lang/CharSequence\n 135: invokestatic #80 // Method kotlin/text/StringsKt.toSet:(Ljava/lang/CharSequence;)Ljava/util/Set;\n 138: invokespecial #86 // Method kotlin/Pair.\"<init>\":(Ljava/lang/Object;Ljava/lang/Object;)V\n 141: nop\n 142: aload 11\n 144: swap\n 145: invokeinterface #90, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 150: pop\n 151: goto 52\n 154: aload 5\n 156: checkcast #92 // class java/util/List\n 159: nop\n 160: areturn\n\n public final int part1(java.util.List<? extends kotlin.Pair<? extends java.util.Set<java.lang.Character>, ? extends java.util.Set<java.lang.Character>>>);\n Code:\n 0: aload_1\n 1: ldc #110 // String parsed\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #32 // 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 #34 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #40 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #43 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #45 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #49, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 139\n 56: aload 7\n 58: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #63 // class kotlin/Pair\n 72: astore 9\n 74: astore 13\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: invokevirtual #113 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 84: checkcast #115 // class java/util/Set\n 87: astore 11\n 89: aload 9\n 91: invokevirtual #118 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 94: checkcast #115 // class java/util/Set\n 97: astore 12\n 99: aload 11\n 101: checkcast #32 // class java/lang/Iterable\n 104: aload 12\n 106: checkcast #32 // class java/lang/Iterable\n 109: invokestatic #122 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 112: checkcast #32 // class java/lang/Iterable\n 115: invokestatic #126 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 118: checkcast #128 // class java/lang/Character\n 121: invokevirtual #132 // Method java/lang/Character.charValue:()C\n 124: invokestatic #136 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 127: aload 13\n 129: swap\n 130: invokeinterface #90, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 135: pop\n 136: goto 46\n 139: aload 5\n 141: checkcast #92 // class java/util/List\n 144: nop\n 145: checkcast #32 // class java/lang/Iterable\n 148: astore_2\n 149: iconst_0\n 150: istore_3\n 151: aload_2\n 152: invokeinterface #49, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 157: astore 4\n 159: aload 4\n 161: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 166: ifeq 228\n 169: aload 4\n 171: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 176: astore 5\n 178: iload_3\n 179: aload 5\n 181: checkcast #128 // class java/lang/Character\n 184: invokevirtual #132 // Method java/lang/Character.charValue:()C\n 187: istore 6\n 189: istore 13\n 191: iconst_0\n 192: istore 7\n 194: invokestatic #142 // Method day03/Day03Kt.access$getItemPriorities$p:()Ljava/util/Map;\n 197: iload 6\n 199: invokestatic #136 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 202: invokeinterface #148, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 207: dup\n 208: invokestatic #152 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 211: checkcast #154 // class java/lang/Number\n 214: invokevirtual #157 // Method java/lang/Number.intValue:()I\n 217: istore 14\n 219: iload 13\n 221: iload 14\n 223: iadd\n 224: istore_3\n 225: goto 159\n 228: iload_3\n 229: ireturn\n\n public final int part2(java.util.List<? extends kotlin.Pair<? extends java.util.Set<java.lang.Character>, ? extends java.util.Set<java.lang.Character>>>);\n Code:\n 0: aload_1\n 1: ldc #110 // String parsed\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #32 // 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 #34 // class java/util/ArrayList\n 19: dup\n 20: aload_2\n 21: bipush 10\n 23: invokestatic #40 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 26: invokespecial #43 // Method java/util/ArrayList.\"<init>\":(I)V\n 29: checkcast #45 // class java/util/Collection\n 32: astore 5\n 34: iconst_0\n 35: istore 6\n 37: aload 4\n 39: invokeinterface #49, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 44: astore 7\n 46: aload 7\n 48: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 53: ifeq 110\n 56: aload 7\n 58: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 63: astore 8\n 65: aload 5\n 67: aload 8\n 69: checkcast #63 // class kotlin/Pair\n 72: astore 9\n 74: astore 11\n 76: iconst_0\n 77: istore 10\n 79: aload 9\n 81: invokevirtual #168 // Method kotlin/Pair.getFirst:()Ljava/lang/Object;\n 84: checkcast #115 // class java/util/Set\n 87: aload 9\n 89: invokevirtual #171 // Method kotlin/Pair.getSecond:()Ljava/lang/Object;\n 92: checkcast #32 // class java/lang/Iterable\n 95: invokestatic #177 // Method kotlin/collections/SetsKt.plus:(Ljava/util/Set;Ljava/lang/Iterable;)Ljava/util/Set;\n 98: aload 11\n 100: swap\n 101: invokeinterface #90, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 106: pop\n 107: goto 46\n 110: aload 5\n 112: checkcast #92 // class java/util/List\n 115: nop\n 116: checkcast #32 // class java/lang/Iterable\n 119: iconst_3\n 120: iconst_3\n 121: iconst_0\n 122: invokedynamic #196, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 127: iconst_4\n 128: aconst_null\n 129: invokestatic #200 // Method kotlin/collections/CollectionsKt.windowed$default:(Ljava/lang/Iterable;IIZLkotlin/jvm/functions/Function1;ILjava/lang/Object;)Ljava/util/List;\n 132: checkcast #32 // class java/lang/Iterable\n 135: astore_2\n 136: iconst_0\n 137: istore_3\n 138: aload_2\n 139: invokeinterface #49, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 144: astore 4\n 146: aload 4\n 148: invokeinterface #55, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 153: ifeq 215\n 156: aload 4\n 158: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 163: astore 5\n 165: iload_3\n 166: aload 5\n 168: checkcast #128 // class java/lang/Character\n 171: invokevirtual #132 // Method java/lang/Character.charValue:()C\n 174: istore 6\n 176: istore 11\n 178: iconst_0\n 179: istore 7\n 181: invokestatic #142 // Method day03/Day03Kt.access$getItemPriorities$p:()Ljava/util/Map;\n 184: iload 6\n 186: invokestatic #136 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 189: invokeinterface #148, 2 // InterfaceMethod java/util/Map.get:(Ljava/lang/Object;)Ljava/lang/Object;\n 194: dup\n 195: invokestatic #152 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 198: checkcast #154 // class java/lang/Number\n 201: invokevirtual #157 // Method java/lang/Number.intValue:()I\n 204: istore 12\n 206: iload 11\n 208: iload 12\n 210: iadd\n 211: istore_3\n 212: goto 146\n 215: iload_3\n 216: ireturn\n\n private static final char part2$lambda$4(java.util.List);\n Code:\n 0: aload_0\n 1: ldc #205 // String <destruct>\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: iconst_0\n 8: invokeinterface #208, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 13: checkcast #115 // class java/util/Set\n 16: astore_1\n 17: aload_0\n 18: iconst_1\n 19: invokeinterface #208, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 24: checkcast #115 // class java/util/Set\n 27: astore_2\n 28: aload_0\n 29: iconst_2\n 30: invokeinterface #208, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 35: checkcast #115 // class java/util/Set\n 38: astore_3\n 39: aload_1\n 40: checkcast #32 // class java/lang/Iterable\n 43: aload_2\n 44: checkcast #32 // class java/lang/Iterable\n 47: invokestatic #122 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 50: checkcast #32 // class java/lang/Iterable\n 53: aload_3\n 54: checkcast #32 // class java/lang/Iterable\n 57: invokestatic #122 // Method kotlin/collections/CollectionsKt.intersect:(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/util/Set;\n 60: checkcast #32 // class java/lang/Iterable\n 63: invokestatic #126 // Method kotlin/collections/CollectionsKt.first:(Ljava/lang/Iterable;)Ljava/lang/Object;\n 66: checkcast #128 // class java/lang/Character\n 69: invokevirtual #132 // Method java/lang/Character.charValue:()C\n 72: ireturn\n}\n",
"javap_err": ""
}
] |
Malo-T__AoC-2022__f4edefa/src/main/kotlin/day02/Day02.kt
|
package day02
class Day02 {
enum class Play(val points: Int) {
ROCK(1) {
override fun scoreAgainst(other: Play) = when (other) {
ROCK -> Result.DRAW
PAPER -> Result.LOSS
SCISSORS -> Result.WIN
}.points + points
},
PAPER(2) {
override fun scoreAgainst(other: Play) = when (other) {
ROCK -> Result.WIN
PAPER -> Result.DRAW
SCISSORS -> Result.LOSS
}.points + points
},
SCISSORS(3) {
override fun scoreAgainst(other: Play) = when (other) {
ROCK -> Result.LOSS
PAPER -> Result.WIN
SCISSORS -> Result.DRAW
}.points + points
};
abstract fun scoreAgainst(other: Play): Int
}
enum class Result(val points: Int) {
LOSS(0), DRAW(3), WIN(6)
}
enum class OpponentPlay(val play: Play) {
A(Play.ROCK), B(Play.PAPER), C(Play.SCISSORS)
}
enum class ResponsePlay(val play: Play) {
X(Play.ROCK), Y(Play.PAPER), Z(Play.SCISSORS)
}
enum class ExpectedResult(val result: Result) {
X(Result.LOSS) {
override fun expectedResponse(opponentPlay: Play) = when (opponentPlay) {
Play.ROCK -> Play.SCISSORS
Play.PAPER -> Play.ROCK
Play.SCISSORS -> Play.PAPER
}
},
Y(Result.DRAW) {
override fun expectedResponse(opponentPlay: Play) = opponentPlay
},
Z(Result.WIN) {
override fun expectedResponse(opponentPlay: Play) = when (opponentPlay) {
Play.ROCK -> Play.PAPER
Play.PAPER -> Play.SCISSORS
Play.SCISSORS -> Play.ROCK
}
};
abstract fun expectedResponse(opponentPlay: Play): Play
}
fun parse1(input: String): List<Pair<OpponentPlay, ResponsePlay>> =
input.split("\n")
.map {
it.split(" ")
.let { pair ->
OpponentPlay.valueOf(pair[0]) to ResponsePlay.valueOf(pair[1])
}
}
fun part1(parsed: List<Pair<OpponentPlay, ResponsePlay>>): Int =
parsed.sumOf { (opponent, response) ->
response.play.scoreAgainst(opponent.play)
}
fun parse2(input: String): List<Pair<OpponentPlay, ExpectedResult>> =
input.split("\n")
.map {
it.split(" ")
.let { pair ->
OpponentPlay.valueOf(pair[0]) to ExpectedResult.valueOf(pair[1])
}
}
fun part2(parsed: List<Pair<OpponentPlay, ExpectedResult>>): Int =
parsed.sumOf { (opponent, expectedResult) ->
expectedResult.expectedResponse(opponent.play).scoreAgainst(opponent.play)
}
}
|
[
{
"class_path": "Malo-T__AoC-2022__f4edefa/day02/Day02$Play.class",
"javap": "Compiled from \"Day02.kt\"\npublic abstract class day02.Day02$Play extends java.lang.Enum<day02.Day02$Play> {\n private final int points;\n\n public static final day02.Day02$Play ROCK;\n\n public static final day02.Day02$Play PAPER;\n\n public static final day02.Day02$Play SCISSORS;\n\n private static final day02.Day02$Play[] $VALUES;\n\n private static final kotlin.enums.EnumEntries $ENTRIES;\n\n private day02.Day02$Play(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 points:I\n 11: return\n\n public final int getPoints();\n Code:\n 0: aload_0\n 1: getfield #15 // Field points:I\n 4: ireturn\n\n public abstract int scoreAgainst(day02.Day02$Play);\n\n public static day02.Day02$Play[] values();\n Code:\n 0: getstatic #31 // Field $VALUES:[Lday02/Day02$Play;\n 3: invokevirtual #37 // Method java/lang/Object.clone:()Ljava/lang/Object;\n 6: checkcast #38 // class \"[Lday02/Day02$Play;\"\n 9: areturn\n\n public static day02.Day02$Play valueOf(java.lang.String);\n Code:\n 0: ldc #2 // class day02/Day02$Play\n 2: aload_0\n 3: invokestatic #43 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;\n 6: checkcast #2 // class day02/Day02$Play\n 9: areturn\n\n public static kotlin.enums.EnumEntries<day02.Day02$Play> getEntries();\n Code:\n 0: getstatic #51 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 3: areturn\n\n private static final day02.Day02$Play[] $values();\n Code:\n 0: iconst_3\n 1: anewarray #2 // class day02/Day02$Play\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: getstatic #55 // Field ROCK:Lday02/Day02$Play;\n 10: aastore\n 11: aload_0\n 12: iconst_1\n 13: getstatic #58 // Field PAPER:Lday02/Day02$Play;\n 16: aastore\n 17: aload_0\n 18: iconst_2\n 19: getstatic #61 // Field SCISSORS:Lday02/Day02$Play;\n 22: aastore\n 23: aload_0\n 24: areturn\n\n public day02.Day02$Play(java.lang.String, int, int, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: iload_3\n 4: invokespecial #64 // Method \"<init>\":(Ljava/lang/String;II)V\n 7: return\n\n static {};\n Code:\n 0: new #70 // class day02/Day02$Play$ROCK\n 3: dup\n 4: ldc #71 // String ROCK\n 6: iconst_0\n 7: invokespecial #72 // Method day02/Day02$Play$ROCK.\"<init>\":(Ljava/lang/String;I)V\n 10: putstatic #55 // Field ROCK:Lday02/Day02$Play;\n 13: new #74 // class day02/Day02$Play$PAPER\n 16: dup\n 17: ldc #75 // String PAPER\n 19: iconst_1\n 20: invokespecial #76 // Method day02/Day02$Play$PAPER.\"<init>\":(Ljava/lang/String;I)V\n 23: putstatic #58 // Field PAPER:Lday02/Day02$Play;\n 26: new #78 // class day02/Day02$Play$SCISSORS\n 29: dup\n 30: ldc #79 // String SCISSORS\n 32: iconst_2\n 33: invokespecial #80 // Method day02/Day02$Play$SCISSORS.\"<init>\":(Ljava/lang/String;I)V\n 36: putstatic #61 // Field SCISSORS:Lday02/Day02$Play;\n 39: invokestatic #82 // Method $values:()[Lday02/Day02$Play;\n 42: putstatic #31 // Field $VALUES:[Lday02/Day02$Play;\n 45: getstatic #31 // Field $VALUES:[Lday02/Day02$Play;\n 48: checkcast #84 // class \"[Ljava/lang/Enum;\"\n 51: invokestatic #90 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;\n 54: putstatic #51 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 57: return\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day02/Day02$ExpectedResult$X$WhenMappings.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class day02.Day02$ExpectedResult$X$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method day02/Day02$Play.values:()[Lday02/Day02$Play;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field day02/Day02$Play.ROCK:Lday02/Day02$Play;\n 12: invokevirtual #22 // Method day02/Day02$Play.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 day02/Day02$Play.PAPER:Lday02/Day02$Play;\n 26: invokevirtual #22 // Method day02/Day02$Play.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 day02/Day02$Play.SCISSORS:Lday02/Day02$Play;\n 40: invokevirtual #22 // Method day02/Day02$Play.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": "Malo-T__AoC-2022__f4edefa/day02/Day02$Play$SCISSORS$WhenMappings.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class day02.Day02$Play$SCISSORS$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method day02/Day02$Play.values:()[Lday02/Day02$Play;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field day02/Day02$Play.ROCK:Lday02/Day02$Play;\n 12: invokevirtual #22 // Method day02/Day02$Play.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 day02/Day02$Play.PAPER:Lday02/Day02$Play;\n 26: invokevirtual #22 // Method day02/Day02$Play.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 day02/Day02$Play.SCISSORS:Lday02/Day02$Play;\n 40: invokevirtual #22 // Method day02/Day02$Play.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": "Malo-T__AoC-2022__f4edefa/day02/Day02$OpponentPlay.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class day02.Day02$OpponentPlay extends java.lang.Enum<day02.Day02$OpponentPlay> {\n private final day02.Day02$Play play;\n\n public static final day02.Day02$OpponentPlay A;\n\n public static final day02.Day02$OpponentPlay B;\n\n public static final day02.Day02$OpponentPlay C;\n\n private static final day02.Day02$OpponentPlay[] $VALUES;\n\n private static final kotlin.enums.EnumEntries $ENTRIES;\n\n private day02.Day02$OpponentPlay(day02.Day02$Play);\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: aload_3\n 8: putfield #15 // Field play:Lday02/Day02$Play;\n 11: return\n\n public final day02.Day02$Play getPlay();\n Code:\n 0: aload_0\n 1: getfield #15 // Field play:Lday02/Day02$Play;\n 4: areturn\n\n public static day02.Day02$OpponentPlay[] values();\n Code:\n 0: getstatic #30 // Field $VALUES:[Lday02/Day02$OpponentPlay;\n 3: invokevirtual #36 // Method java/lang/Object.clone:()Ljava/lang/Object;\n 6: checkcast #37 // class \"[Lday02/Day02$OpponentPlay;\"\n 9: areturn\n\n public static day02.Day02$OpponentPlay valueOf(java.lang.String);\n Code:\n 0: ldc #2 // class day02/Day02$OpponentPlay\n 2: aload_0\n 3: invokestatic #42 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;\n 6: checkcast #2 // class day02/Day02$OpponentPlay\n 9: areturn\n\n public static kotlin.enums.EnumEntries<day02.Day02$OpponentPlay> getEntries();\n Code:\n 0: getstatic #50 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 3: areturn\n\n private static final day02.Day02$OpponentPlay[] $values();\n Code:\n 0: iconst_3\n 1: anewarray #2 // class day02/Day02$OpponentPlay\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: getstatic #54 // Field A:Lday02/Day02$OpponentPlay;\n 10: aastore\n 11: aload_0\n 12: iconst_1\n 13: getstatic #57 // Field B:Lday02/Day02$OpponentPlay;\n 16: aastore\n 17: aload_0\n 18: iconst_2\n 19: getstatic #60 // Field C:Lday02/Day02$OpponentPlay;\n 22: aastore\n 23: aload_0\n 24: areturn\n\n static {};\n Code:\n 0: new #2 // class day02/Day02$OpponentPlay\n 3: dup\n 4: ldc #63 // String A\n 6: iconst_0\n 7: getstatic #68 // Field day02/Day02$Play.ROCK:Lday02/Day02$Play;\n 10: invokespecial #70 // Method \"<init>\":(Ljava/lang/String;ILday02/Day02$Play;)V\n 13: putstatic #54 // Field A:Lday02/Day02$OpponentPlay;\n 16: new #2 // class day02/Day02$OpponentPlay\n 19: dup\n 20: ldc #71 // String B\n 22: iconst_1\n 23: getstatic #74 // Field day02/Day02$Play.PAPER:Lday02/Day02$Play;\n 26: invokespecial #70 // Method \"<init>\":(Ljava/lang/String;ILday02/Day02$Play;)V\n 29: putstatic #57 // Field B:Lday02/Day02$OpponentPlay;\n 32: new #2 // class day02/Day02$OpponentPlay\n 35: dup\n 36: ldc #75 // String C\n 38: iconst_2\n 39: getstatic #78 // Field day02/Day02$Play.SCISSORS:Lday02/Day02$Play;\n 42: invokespecial #70 // Method \"<init>\":(Ljava/lang/String;ILday02/Day02$Play;)V\n 45: putstatic #60 // Field C:Lday02/Day02$OpponentPlay;\n 48: invokestatic #80 // Method $values:()[Lday02/Day02$OpponentPlay;\n 51: putstatic #30 // Field $VALUES:[Lday02/Day02$OpponentPlay;\n 54: getstatic #30 // Field $VALUES:[Lday02/Day02$OpponentPlay;\n 57: checkcast #82 // class \"[Ljava/lang/Enum;\"\n 60: invokestatic #88 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;\n 63: putstatic #50 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 66: return\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day02/Day02$ResponsePlay.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class day02.Day02$ResponsePlay extends java.lang.Enum<day02.Day02$ResponsePlay> {\n private final day02.Day02$Play play;\n\n public static final day02.Day02$ResponsePlay X;\n\n public static final day02.Day02$ResponsePlay Y;\n\n public static final day02.Day02$ResponsePlay Z;\n\n private static final day02.Day02$ResponsePlay[] $VALUES;\n\n private static final kotlin.enums.EnumEntries $ENTRIES;\n\n private day02.Day02$ResponsePlay(day02.Day02$Play);\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: aload_3\n 8: putfield #15 // Field play:Lday02/Day02$Play;\n 11: return\n\n public final day02.Day02$Play getPlay();\n Code:\n 0: aload_0\n 1: getfield #15 // Field play:Lday02/Day02$Play;\n 4: areturn\n\n public static day02.Day02$ResponsePlay[] values();\n Code:\n 0: getstatic #30 // Field $VALUES:[Lday02/Day02$ResponsePlay;\n 3: invokevirtual #36 // Method java/lang/Object.clone:()Ljava/lang/Object;\n 6: checkcast #37 // class \"[Lday02/Day02$ResponsePlay;\"\n 9: areturn\n\n public static day02.Day02$ResponsePlay valueOf(java.lang.String);\n Code:\n 0: ldc #2 // class day02/Day02$ResponsePlay\n 2: aload_0\n 3: invokestatic #42 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;\n 6: checkcast #2 // class day02/Day02$ResponsePlay\n 9: areturn\n\n public static kotlin.enums.EnumEntries<day02.Day02$ResponsePlay> getEntries();\n Code:\n 0: getstatic #50 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 3: areturn\n\n private static final day02.Day02$ResponsePlay[] $values();\n Code:\n 0: iconst_3\n 1: anewarray #2 // class day02/Day02$ResponsePlay\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: getstatic #54 // Field X:Lday02/Day02$ResponsePlay;\n 10: aastore\n 11: aload_0\n 12: iconst_1\n 13: getstatic #57 // Field Y:Lday02/Day02$ResponsePlay;\n 16: aastore\n 17: aload_0\n 18: iconst_2\n 19: getstatic #60 // Field Z:Lday02/Day02$ResponsePlay;\n 22: aastore\n 23: aload_0\n 24: areturn\n\n static {};\n Code:\n 0: new #2 // class day02/Day02$ResponsePlay\n 3: dup\n 4: ldc #63 // String X\n 6: iconst_0\n 7: getstatic #68 // Field day02/Day02$Play.ROCK:Lday02/Day02$Play;\n 10: invokespecial #70 // Method \"<init>\":(Ljava/lang/String;ILday02/Day02$Play;)V\n 13: putstatic #54 // Field X:Lday02/Day02$ResponsePlay;\n 16: new #2 // class day02/Day02$ResponsePlay\n 19: dup\n 20: ldc #71 // String Y\n 22: iconst_1\n 23: getstatic #74 // Field day02/Day02$Play.PAPER:Lday02/Day02$Play;\n 26: invokespecial #70 // Method \"<init>\":(Ljava/lang/String;ILday02/Day02$Play;)V\n 29: putstatic #57 // Field Y:Lday02/Day02$ResponsePlay;\n 32: new #2 // class day02/Day02$ResponsePlay\n 35: dup\n 36: ldc #75 // String Z\n 38: iconst_2\n 39: getstatic #78 // Field day02/Day02$Play.SCISSORS:Lday02/Day02$Play;\n 42: invokespecial #70 // Method \"<init>\":(Ljava/lang/String;ILday02/Day02$Play;)V\n 45: putstatic #60 // Field Z:Lday02/Day02$ResponsePlay;\n 48: invokestatic #80 // Method $values:()[Lday02/Day02$ResponsePlay;\n 51: putstatic #30 // Field $VALUES:[Lday02/Day02$ResponsePlay;\n 54: getstatic #30 // Field $VALUES:[Lday02/Day02$ResponsePlay;\n 57: checkcast #82 // class \"[Ljava/lang/Enum;\"\n 60: invokestatic #88 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;\n 63: putstatic #50 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 66: return\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day02/Day02$Play$SCISSORS.class",
"javap": "Compiled from \"Day02.kt\"\nfinal class day02.Day02$Play$SCISSORS extends day02.Day02$Play {\n day02.Day02$Play$SCISSORS();\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: iconst_3\n 4: aconst_null\n 5: invokespecial #10 // Method day02/Day02$Play.\"<init>\":(Ljava/lang/String;IILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 8: return\n\n public int scoreAgainst(day02.Day02$Play);\n Code:\n 0: aload_1\n 1: ldc #21 // String other\n 3: invokestatic #27 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: getstatic #33 // Field day02/Day02$Play$SCISSORS$WhenMappings.$EnumSwitchMapping$0:[I\n 10: swap\n 11: invokevirtual #37 // Method day02/Day02$Play.ordinal:()I\n 14: iaload\n 15: tableswitch { // 1 to 3\n 1: 40\n 2: 46\n 3: 52\n default: 58\n }\n 40: getstatic #43 // Field day02/Day02$Result.LOSS:Lday02/Day02$Result;\n 43: goto 66\n 46: getstatic #46 // Field day02/Day02$Result.WIN:Lday02/Day02$Result;\n 49: goto 66\n 52: getstatic #49 // Field day02/Day02$Result.DRAW:Lday02/Day02$Result;\n 55: goto 66\n 58: new #51 // class kotlin/NoWhenBranchMatchedException\n 61: dup\n 62: invokespecial #53 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 65: athrow\n 66: invokevirtual #56 // Method day02/Day02$Result.getPoints:()I\n 69: aload_0\n 70: invokevirtual #57 // Method getPoints:()I\n 73: iadd\n 74: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day02/Day02$Play$ROCK$WhenMappings.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class day02.Day02$Play$ROCK$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method day02/Day02$Play.values:()[Lday02/Day02$Play;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field day02/Day02$Play.ROCK:Lday02/Day02$Play;\n 12: invokevirtual #22 // Method day02/Day02$Play.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 day02/Day02$Play.PAPER:Lday02/Day02$Play;\n 26: invokevirtual #22 // Method day02/Day02$Play.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 day02/Day02$Play.SCISSORS:Lday02/Day02$Play;\n 40: invokevirtual #22 // Method day02/Day02$Play.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": "Malo-T__AoC-2022__f4edefa/day02/Day02$ExpectedResult$Z.class",
"javap": "Compiled from \"Day02.kt\"\nfinal class day02.Day02$ExpectedResult$Z extends day02.Day02$ExpectedResult {\n day02.Day02$ExpectedResult$Z();\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: getstatic #13 // Field day02/Day02$Result.WIN:Lday02/Day02$Result;\n 6: aconst_null\n 7: invokespecial #16 // Method day02/Day02$ExpectedResult.\"<init>\":(Ljava/lang/String;ILday02/Day02$Result;Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 10: return\n\n public day02.Day02$Play expectedResponse(day02.Day02$Play);\n Code:\n 0: aload_1\n 1: ldc #27 // String opponentPlay\n 3: invokestatic #33 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: getstatic #39 // Field day02/Day02$ExpectedResult$Z$WhenMappings.$EnumSwitchMapping$0:[I\n 10: swap\n 11: invokevirtual #45 // Method day02/Day02$Play.ordinal:()I\n 14: iaload\n 15: tableswitch { // 1 to 3\n 1: 40\n 2: 46\n 3: 52\n default: 58\n }\n 40: getstatic #49 // Field day02/Day02$Play.PAPER:Lday02/Day02$Play;\n 43: goto 66\n 46: getstatic #52 // Field day02/Day02$Play.SCISSORS:Lday02/Day02$Play;\n 49: goto 66\n 52: getstatic #55 // Field day02/Day02$Play.ROCK:Lday02/Day02$Play;\n 55: goto 66\n 58: new #57 // class kotlin/NoWhenBranchMatchedException\n 61: dup\n 62: invokespecial #59 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 65: athrow\n 66: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day02/Day02$ExpectedResult.class",
"javap": "Compiled from \"Day02.kt\"\npublic abstract class day02.Day02$ExpectedResult extends java.lang.Enum<day02.Day02$ExpectedResult> {\n private final day02.Day02$Result result;\n\n public static final day02.Day02$ExpectedResult X;\n\n public static final day02.Day02$ExpectedResult Y;\n\n public static final day02.Day02$ExpectedResult Z;\n\n private static final day02.Day02$ExpectedResult[] $VALUES;\n\n private static final kotlin.enums.EnumEntries $ENTRIES;\n\n private day02.Day02$ExpectedResult(day02.Day02$Result);\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: aload_3\n 8: putfield #15 // Field result:Lday02/Day02$Result;\n 11: return\n\n public final day02.Day02$Result getResult();\n Code:\n 0: aload_0\n 1: getfield #15 // Field result:Lday02/Day02$Result;\n 4: areturn\n\n public abstract day02.Day02$Play expectedResponse(day02.Day02$Play);\n\n public static day02.Day02$ExpectedResult[] values();\n Code:\n 0: getstatic #32 // Field $VALUES:[Lday02/Day02$ExpectedResult;\n 3: invokevirtual #38 // Method java/lang/Object.clone:()Ljava/lang/Object;\n 6: checkcast #39 // class \"[Lday02/Day02$ExpectedResult;\"\n 9: areturn\n\n public static day02.Day02$ExpectedResult valueOf(java.lang.String);\n Code:\n 0: ldc #2 // class day02/Day02$ExpectedResult\n 2: aload_0\n 3: invokestatic #44 // Method java/lang/Enum.valueOf:(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Enum;\n 6: checkcast #2 // class day02/Day02$ExpectedResult\n 9: areturn\n\n public static kotlin.enums.EnumEntries<day02.Day02$ExpectedResult> getEntries();\n Code:\n 0: getstatic #52 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 3: areturn\n\n private static final day02.Day02$ExpectedResult[] $values();\n Code:\n 0: iconst_3\n 1: anewarray #2 // class day02/Day02$ExpectedResult\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: getstatic #56 // Field X:Lday02/Day02$ExpectedResult;\n 10: aastore\n 11: aload_0\n 12: iconst_1\n 13: getstatic #59 // Field Y:Lday02/Day02$ExpectedResult;\n 16: aastore\n 17: aload_0\n 18: iconst_2\n 19: getstatic #62 // Field Z:Lday02/Day02$ExpectedResult;\n 22: aastore\n 23: aload_0\n 24: areturn\n\n public day02.Day02$ExpectedResult(java.lang.String, int, day02.Day02$Result, kotlin.jvm.internal.DefaultConstructorMarker);\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: aload_3\n 4: invokespecial #65 // Method \"<init>\":(Ljava/lang/String;ILday02/Day02$Result;)V\n 7: return\n\n static {};\n Code:\n 0: new #71 // class day02/Day02$ExpectedResult$X\n 3: dup\n 4: ldc #72 // String X\n 6: iconst_0\n 7: invokespecial #73 // Method day02/Day02$ExpectedResult$X.\"<init>\":(Ljava/lang/String;I)V\n 10: putstatic #56 // Field X:Lday02/Day02$ExpectedResult;\n 13: new #75 // class day02/Day02$ExpectedResult$Y\n 16: dup\n 17: ldc #76 // String Y\n 19: iconst_1\n 20: invokespecial #77 // Method day02/Day02$ExpectedResult$Y.\"<init>\":(Ljava/lang/String;I)V\n 23: putstatic #59 // Field Y:Lday02/Day02$ExpectedResult;\n 26: new #79 // class day02/Day02$ExpectedResult$Z\n 29: dup\n 30: ldc #80 // String Z\n 32: iconst_2\n 33: invokespecial #81 // Method day02/Day02$ExpectedResult$Z.\"<init>\":(Ljava/lang/String;I)V\n 36: putstatic #62 // Field Z:Lday02/Day02$ExpectedResult;\n 39: invokestatic #83 // Method $values:()[Lday02/Day02$ExpectedResult;\n 42: putstatic #32 // Field $VALUES:[Lday02/Day02$ExpectedResult;\n 45: getstatic #32 // Field $VALUES:[Lday02/Day02$ExpectedResult;\n 48: checkcast #85 // class \"[Ljava/lang/Enum;\"\n 51: invokestatic #91 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;\n 54: putstatic #52 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 57: return\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day02/Day02$ExpectedResult$X.class",
"javap": "Compiled from \"Day02.kt\"\nfinal class day02.Day02$ExpectedResult$X extends day02.Day02$ExpectedResult {\n day02.Day02$ExpectedResult$X();\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: getstatic #13 // Field day02/Day02$Result.LOSS:Lday02/Day02$Result;\n 6: aconst_null\n 7: invokespecial #16 // Method day02/Day02$ExpectedResult.\"<init>\":(Ljava/lang/String;ILday02/Day02$Result;Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 10: return\n\n public day02.Day02$Play expectedResponse(day02.Day02$Play);\n Code:\n 0: aload_1\n 1: ldc #27 // String opponentPlay\n 3: invokestatic #33 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: getstatic #39 // Field day02/Day02$ExpectedResult$X$WhenMappings.$EnumSwitchMapping$0:[I\n 10: swap\n 11: invokevirtual #45 // Method day02/Day02$Play.ordinal:()I\n 14: iaload\n 15: tableswitch { // 1 to 3\n 1: 40\n 2: 46\n 3: 52\n default: 58\n }\n 40: getstatic #49 // Field day02/Day02$Play.SCISSORS:Lday02/Day02$Play;\n 43: goto 66\n 46: getstatic #52 // Field day02/Day02$Play.ROCK:Lday02/Day02$Play;\n 49: goto 66\n 52: getstatic #55 // Field day02/Day02$Play.PAPER:Lday02/Day02$Play;\n 55: goto 66\n 58: new #57 // class kotlin/NoWhenBranchMatchedException\n 61: dup\n 62: invokespecial #59 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 65: athrow\n 66: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day02/Day02$Result.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class day02.Day02$Result extends java.lang.Enum<day02.Day02$Result> {\n private final int points;\n\n public static final day02.Day02$Result LOSS;\n\n public static final day02.Day02$Result DRAW;\n\n public static final day02.Day02$Result WIN;\n\n private static final day02.Day02$Result[] $VALUES;\n\n private static final kotlin.enums.EnumEntries $ENTRIES;\n\n private day02.Day02$Result(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 points:I\n 11: return\n\n public final int getPoints();\n Code:\n 0: aload_0\n 1: getfield #15 // Field points:I\n 4: ireturn\n\n public static day02.Day02$Result[] values();\n Code:\n 0: getstatic #28 // Field $VALUES:[Lday02/Day02$Result;\n 3: invokevirtual #34 // Method java/lang/Object.clone:()Ljava/lang/Object;\n 6: checkcast #35 // class \"[Lday02/Day02$Result;\"\n 9: areturn\n\n public static day02.Day02$Result valueOf(java.lang.String);\n Code:\n 0: ldc #2 // class day02/Day02$Result\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 day02/Day02$Result\n 9: areturn\n\n public static kotlin.enums.EnumEntries<day02.Day02$Result> getEntries();\n Code:\n 0: getstatic #49 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 3: areturn\n\n private static final day02.Day02$Result[] $values();\n Code:\n 0: iconst_3\n 1: anewarray #2 // class day02/Day02$Result\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: getstatic #53 // Field LOSS:Lday02/Day02$Result;\n 10: aastore\n 11: aload_0\n 12: iconst_1\n 13: getstatic #56 // Field DRAW:Lday02/Day02$Result;\n 16: aastore\n 17: aload_0\n 18: iconst_2\n 19: getstatic #59 // Field WIN:Lday02/Day02$Result;\n 22: aastore\n 23: aload_0\n 24: areturn\n\n static {};\n Code:\n 0: new #2 // class day02/Day02$Result\n 3: dup\n 4: ldc #62 // String LOSS\n 6: iconst_0\n 7: iconst_0\n 8: invokespecial #64 // Method \"<init>\":(Ljava/lang/String;II)V\n 11: putstatic #53 // Field LOSS:Lday02/Day02$Result;\n 14: new #2 // class day02/Day02$Result\n 17: dup\n 18: ldc #65 // String DRAW\n 20: iconst_1\n 21: iconst_3\n 22: invokespecial #64 // Method \"<init>\":(Ljava/lang/String;II)V\n 25: putstatic #56 // Field DRAW:Lday02/Day02$Result;\n 28: new #2 // class day02/Day02$Result\n 31: dup\n 32: ldc #66 // String WIN\n 34: iconst_2\n 35: bipush 6\n 37: invokespecial #64 // Method \"<init>\":(Ljava/lang/String;II)V\n 40: putstatic #59 // Field WIN:Lday02/Day02$Result;\n 43: invokestatic #68 // Method $values:()[Lday02/Day02$Result;\n 46: putstatic #28 // Field $VALUES:[Lday02/Day02$Result;\n 49: getstatic #28 // Field $VALUES:[Lday02/Day02$Result;\n 52: checkcast #70 // class \"[Ljava/lang/Enum;\"\n 55: invokestatic #76 // Method kotlin/enums/EnumEntriesKt.enumEntries:([Ljava/lang/Enum;)Lkotlin/enums/EnumEntries;\n 58: putstatic #49 // Field $ENTRIES:Lkotlin/enums/EnumEntries;\n 61: return\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day02/Day02$ExpectedResult$Y.class",
"javap": "Compiled from \"Day02.kt\"\nfinal class day02.Day02$ExpectedResult$Y extends day02.Day02$ExpectedResult {\n day02.Day02$ExpectedResult$Y();\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: getstatic #13 // Field day02/Day02$Result.DRAW:Lday02/Day02$Result;\n 6: aconst_null\n 7: invokespecial #16 // Method day02/Day02$ExpectedResult.\"<init>\":(Ljava/lang/String;ILday02/Day02$Result;Lkotlin/jvm/internal/DefaultConstructorMarker;)V\n 10: return\n\n public day02.Day02$Play expectedResponse(day02.Day02$Play);\n Code:\n 0: aload_1\n 1: ldc #27 // String opponentPlay\n 3: invokestatic #33 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day02/Day02$ExpectedResult$Z$WhenMappings.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class day02.Day02$ExpectedResult$Z$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method day02/Day02$Play.values:()[Lday02/Day02$Play;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field day02/Day02$Play.ROCK:Lday02/Day02$Play;\n 12: invokevirtual #22 // Method day02/Day02$Play.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 day02/Day02$Play.PAPER:Lday02/Day02$Play;\n 26: invokevirtual #22 // Method day02/Day02$Play.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 day02/Day02$Play.SCISSORS:Lday02/Day02$Play;\n 40: invokevirtual #22 // Method day02/Day02$Play.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": "Malo-T__AoC-2022__f4edefa/day02/Day02$Play$ROCK.class",
"javap": "Compiled from \"Day02.kt\"\nfinal class day02.Day02$Play$ROCK extends day02.Day02$Play {\n day02.Day02$Play$ROCK();\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: iconst_1\n 4: aconst_null\n 5: invokespecial #10 // Method day02/Day02$Play.\"<init>\":(Ljava/lang/String;IILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 8: return\n\n public int scoreAgainst(day02.Day02$Play);\n Code:\n 0: aload_1\n 1: ldc #21 // String other\n 3: invokestatic #27 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: getstatic #33 // Field day02/Day02$Play$ROCK$WhenMappings.$EnumSwitchMapping$0:[I\n 10: swap\n 11: invokevirtual #37 // Method day02/Day02$Play.ordinal:()I\n 14: iaload\n 15: tableswitch { // 1 to 3\n 1: 40\n 2: 46\n 3: 52\n default: 58\n }\n 40: getstatic #43 // Field day02/Day02$Result.DRAW:Lday02/Day02$Result;\n 43: goto 66\n 46: getstatic #46 // Field day02/Day02$Result.LOSS:Lday02/Day02$Result;\n 49: goto 66\n 52: getstatic #49 // Field day02/Day02$Result.WIN:Lday02/Day02$Result;\n 55: goto 66\n 58: new #51 // class kotlin/NoWhenBranchMatchedException\n 61: dup\n 62: invokespecial #53 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 65: athrow\n 66: invokevirtual #56 // Method day02/Day02$Result.getPoints:()I\n 69: aload_0\n 70: invokevirtual #57 // Method getPoints:()I\n 73: iadd\n 74: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day02/Day02$Play$PAPER.class",
"javap": "Compiled from \"Day02.kt\"\nfinal class day02.Day02$Play$PAPER extends day02.Day02$Play {\n day02.Day02$Play$PAPER();\n Code:\n 0: aload_0\n 1: aload_1\n 2: iload_2\n 3: iconst_2\n 4: aconst_null\n 5: invokespecial #10 // Method day02/Day02$Play.\"<init>\":(Ljava/lang/String;IILkotlin/jvm/internal/DefaultConstructorMarker;)V\n 8: return\n\n public int scoreAgainst(day02.Day02$Play);\n Code:\n 0: aload_1\n 1: ldc #21 // String other\n 3: invokestatic #27 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: getstatic #33 // Field day02/Day02$Play$PAPER$WhenMappings.$EnumSwitchMapping$0:[I\n 10: swap\n 11: invokevirtual #37 // Method day02/Day02$Play.ordinal:()I\n 14: iaload\n 15: tableswitch { // 1 to 3\n 1: 40\n 2: 46\n 3: 52\n default: 58\n }\n 40: getstatic #43 // Field day02/Day02$Result.WIN:Lday02/Day02$Result;\n 43: goto 66\n 46: getstatic #46 // Field day02/Day02$Result.DRAW:Lday02/Day02$Result;\n 49: goto 66\n 52: getstatic #49 // Field day02/Day02$Result.LOSS:Lday02/Day02$Result;\n 55: goto 66\n 58: new #51 // class kotlin/NoWhenBranchMatchedException\n 61: dup\n 62: invokespecial #53 // Method kotlin/NoWhenBranchMatchedException.\"<init>\":()V\n 65: athrow\n 66: invokevirtual #56 // Method day02/Day02$Result.getPoints:()I\n 69: aload_0\n 70: invokevirtual #57 // Method getPoints:()I\n 73: iadd\n 74: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day02/Day02.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class day02.Day02 {\n public day02.Day02();\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<day02.Day02$OpponentPlay, day02.Day02$ResponsePlay>> parse1(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/CharSequence\n 10: iconst_1\n 11: anewarray #26 // class java/lang/String\n 14: astore_2\n 15: aload_2\n 16: iconst_0\n 17: ldc #28 // String \\n\n 19: aastore\n 20: aload_2\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #34 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: checkcast #36 // 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 #38 // class java/util/ArrayList\n 42: dup\n 43: aload_2\n 44: bipush 10\n 46: invokestatic #44 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 49: invokespecial #47 // Method java/util/ArrayList.\"<init>\":(I)V\n 52: checkcast #49 // class java/util/Collection\n 55: astore 5\n 57: iconst_0\n 58: istore 6\n 60: aload 4\n 62: invokeinterface #53, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 67: astore 7\n 69: aload 7\n 71: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 76: ifeq 179\n 79: aload 7\n 81: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: astore 8\n 88: aload 5\n 90: aload 8\n 92: checkcast #26 // class java/lang/String\n 95: astore 9\n 97: astore 14\n 99: iconst_0\n 100: istore 10\n 102: aload 9\n 104: checkcast #24 // class java/lang/CharSequence\n 107: iconst_1\n 108: anewarray #26 // class java/lang/String\n 111: astore 11\n 113: aload 11\n 115: iconst_0\n 116: ldc #65 // 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 #34 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 129: astore 12\n 131: iconst_0\n 132: istore 13\n 134: aload 12\n 136: iconst_0\n 137: invokeinterface #71, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 142: checkcast #26 // class java/lang/String\n 145: invokestatic #77 // Method day02/Day02$OpponentPlay.valueOf:(Ljava/lang/String;)Lday02/Day02$OpponentPlay;\n 148: aload 12\n 150: iconst_1\n 151: invokeinterface #71, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 156: checkcast #26 // class java/lang/String\n 159: invokestatic #82 // Method day02/Day02$ResponsePlay.valueOf:(Ljava/lang/String;)Lday02/Day02$ResponsePlay;\n 162: invokestatic #88 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 165: nop\n 166: nop\n 167: aload 14\n 169: swap\n 170: invokeinterface #92, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 175: pop\n 176: goto 69\n 179: aload 5\n 181: checkcast #67 // class java/util/List\n 184: nop\n 185: areturn\n\n public final int part1(java.util.List<? extends kotlin.Pair<? extends day02.Day02$OpponentPlay, ? extends day02.Day02$ResponsePlay>>);\n Code:\n 0: aload_1\n 1: ldc #113 // String parsed\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #36 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: invokeinterface #53, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 19: astore 4\n 21: aload 4\n 23: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 28: ifeq 97\n 31: aload 4\n 33: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 38: astore 5\n 40: iload_3\n 41: aload 5\n 43: checkcast #115 // class kotlin/Pair\n 46: astore 6\n 48: istore 10\n 50: iconst_0\n 51: istore 7\n 53: aload 6\n 55: invokevirtual #118 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 58: checkcast #73 // class day02/Day02$OpponentPlay\n 61: astore 8\n 63: aload 6\n 65: invokevirtual #121 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 68: checkcast #79 // class day02/Day02$ResponsePlay\n 71: astore 9\n 73: aload 9\n 75: invokevirtual #125 // Method day02/Day02$ResponsePlay.getPlay:()Lday02/Day02$Play;\n 78: aload 8\n 80: invokevirtual #126 // Method day02/Day02$OpponentPlay.getPlay:()Lday02/Day02$Play;\n 83: invokevirtual #132 // Method day02/Day02$Play.scoreAgainst:(Lday02/Day02$Play;)I\n 86: istore 11\n 88: iload 10\n 90: iload 11\n 92: iadd\n 93: istore_3\n 94: goto 21\n 97: iload_3\n 98: ireturn\n\n public final java.util.List<kotlin.Pair<day02.Day02$OpponentPlay, day02.Day02$ExpectedResult>> parse2(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/CharSequence\n 10: iconst_1\n 11: anewarray #26 // class java/lang/String\n 14: astore_2\n 15: aload_2\n 16: iconst_0\n 17: ldc #28 // String \\n\n 19: aastore\n 20: aload_2\n 21: iconst_0\n 22: iconst_0\n 23: bipush 6\n 25: aconst_null\n 26: invokestatic #34 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 29: checkcast #36 // 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 #38 // class java/util/ArrayList\n 42: dup\n 43: aload_2\n 44: bipush 10\n 46: invokestatic #44 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 49: invokespecial #47 // Method java/util/ArrayList.\"<init>\":(I)V\n 52: checkcast #49 // class java/util/Collection\n 55: astore 5\n 57: iconst_0\n 58: istore 6\n 60: aload 4\n 62: invokeinterface #53, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 67: astore 7\n 69: aload 7\n 71: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 76: ifeq 179\n 79: aload 7\n 81: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 86: astore 8\n 88: aload 5\n 90: aload 8\n 92: checkcast #26 // class java/lang/String\n 95: astore 9\n 97: astore 14\n 99: iconst_0\n 100: istore 10\n 102: aload 9\n 104: checkcast #24 // class java/lang/CharSequence\n 107: iconst_1\n 108: anewarray #26 // class java/lang/String\n 111: astore 11\n 113: aload 11\n 115: iconst_0\n 116: ldc #65 // 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 #34 // Method kotlin/text/StringsKt.split$default:(Ljava/lang/CharSequence;[Ljava/lang/String;ZIILjava/lang/Object;)Ljava/util/List;\n 129: astore 12\n 131: iconst_0\n 132: istore 13\n 134: aload 12\n 136: iconst_0\n 137: invokeinterface #71, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 142: checkcast #26 // class java/lang/String\n 145: invokestatic #77 // Method day02/Day02$OpponentPlay.valueOf:(Ljava/lang/String;)Lday02/Day02$OpponentPlay;\n 148: aload 12\n 150: iconst_1\n 151: invokeinterface #71, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 156: checkcast #26 // class java/lang/String\n 159: invokestatic #144 // Method day02/Day02$ExpectedResult.valueOf:(Ljava/lang/String;)Lday02/Day02$ExpectedResult;\n 162: invokestatic #88 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 165: nop\n 166: nop\n 167: aload 14\n 169: swap\n 170: invokeinterface #92, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 175: pop\n 176: goto 69\n 179: aload 5\n 181: checkcast #67 // class java/util/List\n 184: nop\n 185: areturn\n\n public final int part2(java.util.List<? extends kotlin.Pair<? extends day02.Day02$OpponentPlay, ? extends day02.Day02$ExpectedResult>>);\n Code:\n 0: aload_1\n 1: ldc #113 // String parsed\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: checkcast #36 // class java/lang/Iterable\n 10: astore_2\n 11: iconst_0\n 12: istore_3\n 13: aload_2\n 14: invokeinterface #53, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 19: astore 4\n 21: aload 4\n 23: invokeinterface #59, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 28: ifeq 102\n 31: aload 4\n 33: invokeinterface #63, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 38: astore 5\n 40: iload_3\n 41: aload 5\n 43: checkcast #115 // class kotlin/Pair\n 46: astore 6\n 48: istore 10\n 50: iconst_0\n 51: istore 7\n 53: aload 6\n 55: invokevirtual #118 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 58: checkcast #73 // class day02/Day02$OpponentPlay\n 61: astore 8\n 63: aload 6\n 65: invokevirtual #121 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 68: checkcast #141 // class day02/Day02$ExpectedResult\n 71: astore 9\n 73: aload 9\n 75: aload 8\n 77: invokevirtual #126 // Method day02/Day02$OpponentPlay.getPlay:()Lday02/Day02$Play;\n 80: invokevirtual #152 // Method day02/Day02$ExpectedResult.expectedResponse:(Lday02/Day02$Play;)Lday02/Day02$Play;\n 83: aload 8\n 85: invokevirtual #126 // Method day02/Day02$OpponentPlay.getPlay:()Lday02/Day02$Play;\n 88: invokevirtual #132 // Method day02/Day02$Play.scoreAgainst:(Lday02/Day02$Play;)I\n 91: istore 11\n 93: iload 10\n 95: iload 11\n 97: iadd\n 98: istore_3\n 99: goto 21\n 102: iload_3\n 103: ireturn\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day02/Day02$Play$PAPER$WhenMappings.class",
"javap": "Compiled from \"Day02.kt\"\npublic final class day02.Day02$Play$PAPER$WhenMappings {\n public static final int[] $EnumSwitchMapping$0;\n\n static {};\n Code:\n 0: invokestatic #14 // Method day02/Day02$Play.values:()[Lday02/Day02$Play;\n 3: arraylength\n 4: newarray int\n 6: astore_0\n 7: nop\n 8: aload_0\n 9: getstatic #18 // Field day02/Day02$Play.ROCK:Lday02/Day02$Play;\n 12: invokevirtual #22 // Method day02/Day02$Play.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 day02/Day02$Play.PAPER:Lday02/Day02$Play;\n 26: invokevirtual #22 // Method day02/Day02$Play.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 day02/Day02$Play.SCISSORS:Lday02/Day02$Play;\n 40: invokevirtual #22 // Method day02/Day02$Play.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": ""
}
] |
Malo-T__AoC-2022__f4edefa/src/main/kotlin/day05/Day05.kt
|
package day05
import day05.Day05.Step
private typealias Stack = MutableList<Char>
private typealias Storage = MutableList<Stack>
private const val EMPTY = ' '
private fun List<String>.indexOfStackNumbers() = indexOfFirst { it.startsWith(" 1") }
private val stepRegex = """move (\d+) from (\d+) to (\d+)""".toRegex()
private fun String.toStep() = stepRegex.find(this)!!.groupValues.let { (_, amount, from, to) ->
Step(
amount = amount.toInt(),
from = from.toInt(),
to = to.toInt()
)
}
// CrateMover 9000 moves one by one
private fun Storage.move(step: Step) {
(0 until step.amount).forEach { _ ->
this[step.toIndex].add(this[step.fromIndex].last())
this[step.fromIndex].removeLast()
}
}
// CrateMover 9001 moves by batch
private fun Storage.moveV2(step: Step) {
this[step.toIndex].addAll(this[step.fromIndex].takeLast(step.amount))
this[step.fromIndex] = this[step.fromIndex].dropLast(step.amount).toMutableList()
}
class Day05 {
data class Step(
val amount: Int,
val from: Int,
val to: Int,
) {
val fromIndex: Int
get() = from - 1
val toIndex: Int
get() = to - 1
}
fun parse(input: String): Pair<Storage, List<Step>> {
val storage: Storage = input
.lines()
.let { lines -> lines.subList(0, lines.indexOfStackNumbers()) }
.map { row -> row.chunked(4).map { it[1] } }
// transform rows to columns (stacks)
.let { rows ->
rows.fold(
initial = List(rows.first().size) { mutableListOf<Char>() },
operation = { columns, row ->
columns.apply {
forEachIndexed { columnIndex, column ->
// remove empty values
if (row[columnIndex] != EMPTY) {
column.add(row[columnIndex])
}
}
}
}
).map { it.reversed().toMutableList() } // bottom to top of the stack
}.toMutableList()
.onEach { println(it) }
val steps = input
.lines()
.let { lines -> lines.subList(lines.indexOfStackNumbers() + 2, lines.size) }
.map { it.toStep() }
.onEach { println(it) }
return storage to steps
}
fun part1(parsed: Pair<Storage, List<Step>>): String {
val (storage, steps) = parsed
steps.forEach { step -> storage.move(step) }
return storage.joinToString(separator = "") { stack -> "${stack.last()}" }
}
fun part2(parsed: Pair<Storage, List<Step>>): String {
val (storage, steps) = parsed
steps.forEach { step -> storage.moveV2(step) }
return storage.joinToString(separator = "") { stack -> "${stack.last()}" }
}
}
|
[
{
"class_path": "Malo-T__AoC-2022__f4edefa/day05/Day05Kt.class",
"javap": "Compiled from \"Day05.kt\"\npublic final class day05.Day05Kt {\n private static final char EMPTY;\n\n private static final kotlin.text.Regex stepRegex;\n\n private static final int indexOfStackNumbers(java.util.List<java.lang.String>);\n Code:\n 0: aload_0\n 1: astore_1\n 2: iconst_0\n 3: istore_2\n 4: iconst_0\n 5: istore_3\n 6: aload_1\n 7: invokeinterface #13, 1 // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;\n 12: astore 4\n 14: aload 4\n 16: invokeinterface #19, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 21: ifeq 66\n 24: aload 4\n 26: invokeinterface #23, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 31: astore 5\n 33: aload 5\n 35: checkcast #25 // class java/lang/String\n 38: astore 6\n 40: iconst_0\n 41: istore 7\n 43: aload 6\n 45: ldc #27 // String 1\n 47: iconst_0\n 48: iconst_2\n 49: aconst_null\n 50: invokestatic #33 // Method kotlin/text/StringsKt.startsWith$default:(Ljava/lang/String;Ljava/lang/String;ZILjava/lang/Object;)Z\n 53: ifeq 60\n 56: iload_3\n 57: goto 67\n 60: iinc 3, 1\n 63: goto 14\n 66: iconst_m1\n 67: ireturn\n\n private static final day05.Day05$Step toStep(java.lang.String);\n Code:\n 0: getstatic #50 // Field stepRegex:Lkotlin/text/Regex;\n 3: aload_0\n 4: checkcast #52 // class java/lang/CharSequence\n 7: iconst_0\n 8: iconst_2\n 9: aconst_null\n 10: invokestatic #58 // Method kotlin/text/Regex.find$default:(Lkotlin/text/Regex;Ljava/lang/CharSequence;IILjava/lang/Object;)Lkotlin/text/MatchResult;\n 13: dup\n 14: invokestatic #64 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 17: invokeinterface #70, 1 // InterfaceMethod kotlin/text/MatchResult.getGroupValues:()Ljava/util/List;\n 22: astore_1\n 23: iconst_0\n 24: istore_2\n 25: aload_1\n 26: iconst_1\n 27: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 32: checkcast #25 // class java/lang/String\n 35: astore_3\n 36: aload_1\n 37: iconst_2\n 38: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 43: checkcast #25 // class java/lang/String\n 46: astore 4\n 48: aload_1\n 49: iconst_3\n 50: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 55: checkcast #25 // class java/lang/String\n 58: astore 5\n 60: new #76 // class day05/Day05$Step\n 63: dup\n 64: aload_3\n 65: invokestatic #82 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 68: aload 4\n 70: invokestatic #82 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 73: aload 5\n 75: invokestatic #82 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I\n 78: invokespecial #86 // Method day05/Day05$Step.\"<init>\":(III)V\n 81: nop\n 82: nop\n 83: areturn\n\n private static final void move(java.util.List<java.util.List<java.lang.Character>>, day05.Day05$Step);\n Code:\n 0: iconst_0\n 1: aload_1\n 2: invokevirtual #98 // Method day05/Day05$Step.getAmount:()I\n 5: invokestatic #104 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;\n 8: checkcast #106 // class java/lang/Iterable\n 11: astore_2\n 12: iconst_0\n 13: istore_3\n 14: aload_2\n 15: invokeinterface #107, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 20: astore 4\n 22: aload 4\n 24: invokeinterface #19, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 29: ifeq 104\n 32: aload 4\n 34: checkcast #109 // class kotlin/collections/IntIterator\n 37: invokevirtual #112 // Method kotlin/collections/IntIterator.nextInt:()I\n 40: istore 5\n 42: iconst_0\n 43: istore 6\n 45: aload_0\n 46: aload_1\n 47: invokevirtual #115 // Method day05/Day05$Step.getToIndex:()I\n 50: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 55: checkcast #9 // class java/util/List\n 58: aload_0\n 59: aload_1\n 60: invokevirtual #118 // Method day05/Day05$Step.getFromIndex:()I\n 63: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 68: checkcast #9 // class java/util/List\n 71: invokestatic #124 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 74: invokeinterface #128, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 79: pop\n 80: aload_0\n 81: aload_1\n 82: invokevirtual #118 // Method day05/Day05$Step.getFromIndex:()I\n 85: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 90: checkcast #9 // class java/util/List\n 93: invokeinterface #131, 1 // InterfaceMethod java/util/List.removeLast:()Ljava/lang/Object;\n 98: pop\n 99: nop\n 100: nop\n 101: goto 22\n 104: nop\n 105: return\n\n private static final void moveV2(java.util.List<java.util.List<java.lang.Character>>, day05.Day05$Step);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokevirtual #115 // Method day05/Day05$Step.getToIndex:()I\n 5: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 10: checkcast #9 // class java/util/List\n 13: aload_0\n 14: aload_1\n 15: invokevirtual #118 // Method day05/Day05$Step.getFromIndex:()I\n 18: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 23: checkcast #9 // class java/util/List\n 26: aload_1\n 27: invokevirtual #98 // Method day05/Day05$Step.getAmount:()I\n 30: invokestatic #144 // Method kotlin/collections/CollectionsKt.takeLast:(Ljava/util/List;I)Ljava/util/List;\n 33: checkcast #146 // class java/util/Collection\n 36: invokeinterface #150, 2 // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z\n 41: pop\n 42: aload_0\n 43: aload_1\n 44: invokevirtual #118 // Method day05/Day05$Step.getFromIndex:()I\n 47: aload_0\n 48: aload_1\n 49: invokevirtual #118 // Method day05/Day05$Step.getFromIndex:()I\n 52: invokeinterface #74, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 57: checkcast #9 // class java/util/List\n 60: aload_1\n 61: invokevirtual #98 // Method day05/Day05$Step.getAmount:()I\n 64: invokestatic #153 // Method kotlin/collections/CollectionsKt.dropLast:(Ljava/util/List;I)Ljava/util/List;\n 67: checkcast #146 // class java/util/Collection\n 70: invokestatic #157 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 73: invokeinterface #161, 3 // InterfaceMethod java/util/List.set:(ILjava/lang/Object;)Ljava/lang/Object;\n 78: pop\n 79: return\n\n public static final int access$indexOfStackNumbers(java.util.List);\n Code:\n 0: aload_0\n 1: invokestatic #165 // Method indexOfStackNumbers:(Ljava/util/List;)I\n 4: ireturn\n\n public static final day05.Day05$Step access$toStep(java.lang.String);\n Code:\n 0: aload_0\n 1: invokestatic #169 // Method toStep:(Ljava/lang/String;)Lday05/Day05$Step;\n 4: areturn\n\n public static final void access$move(java.util.List, day05.Day05$Step);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #172 // Method move:(Ljava/util/List;Lday05/Day05$Step;)V\n 5: return\n\n public static final void access$moveV2(java.util.List, day05.Day05$Step);\n Code:\n 0: aload_0\n 1: aload_1\n 2: invokestatic #175 // Method moveV2:(Ljava/util/List;Lday05/Day05$Step;)V\n 5: return\n\n static {};\n Code:\n 0: new #54 // class kotlin/text/Regex\n 3: dup\n 4: ldc #179 // String move (\\\\d+) from (\\\\d+) to (\\\\d+)\n 6: invokespecial #182 // Method kotlin/text/Regex.\"<init>\":(Ljava/lang/String;)V\n 9: putstatic #50 // Field stepRegex:Lkotlin/text/Regex;\n 12: return\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day05/Day05.class",
"javap": "Compiled from \"Day05.kt\"\npublic final class day05.Day05 {\n public day05.Day05();\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<java.util.List<java.util.List<java.lang.Character>>, java.util.List<day05.Day05$Step>> parse(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/CharSequence\n 10: invokestatic #30 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 13: astore 4\n 15: iconst_0\n 16: istore 5\n 18: aload 4\n 20: iconst_0\n 21: aload 4\n 23: invokestatic #36 // Method day05/Day05Kt.access$indexOfStackNumbers:(Ljava/util/List;)I\n 26: invokeinterface #42, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 31: checkcast #44 // class java/lang/Iterable\n 34: astore_3\n 35: nop\n 36: iconst_0\n 37: istore 4\n 39: aload_3\n 40: astore 5\n 42: new #46 // class java/util/ArrayList\n 45: dup\n 46: aload_3\n 47: bipush 10\n 49: invokestatic #52 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 52: invokespecial #55 // Method java/util/ArrayList.\"<init>\":(I)V\n 55: checkcast #57 // class java/util/Collection\n 58: astore 6\n 60: iconst_0\n 61: istore 7\n 63: aload 5\n 65: invokeinterface #61, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 70: astore 8\n 72: aload 8\n 74: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 79: ifeq 230\n 82: aload 8\n 84: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 89: astore 9\n 91: aload 6\n 93: aload 9\n 95: checkcast #73 // class java/lang/String\n 98: astore 10\n 100: astore 28\n 102: iconst_0\n 103: istore 11\n 105: aload 10\n 107: checkcast #24 // class java/lang/CharSequence\n 110: iconst_4\n 111: invokestatic #77 // Method kotlin/text/StringsKt.chunked:(Ljava/lang/CharSequence;I)Ljava/util/List;\n 114: checkcast #44 // class java/lang/Iterable\n 117: astore 12\n 119: iconst_0\n 120: istore 13\n 122: aload 12\n 124: astore 14\n 126: new #46 // class java/util/ArrayList\n 129: dup\n 130: aload 12\n 132: bipush 10\n 134: invokestatic #52 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 137: invokespecial #55 // Method java/util/ArrayList.\"<init>\":(I)V\n 140: checkcast #57 // class java/util/Collection\n 143: astore 15\n 145: iconst_0\n 146: istore 16\n 148: aload 14\n 150: invokeinterface #61, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 155: astore 17\n 157: aload 17\n 159: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 164: ifeq 211\n 167: aload 17\n 169: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 174: astore 18\n 176: aload 15\n 178: aload 18\n 180: checkcast #73 // class java/lang/String\n 183: astore 19\n 185: astore 20\n 187: iconst_0\n 188: istore 21\n 190: aload 19\n 192: iconst_1\n 193: invokevirtual #81 // Method java/lang/String.charAt:(I)C\n 196: invokestatic #87 // Method java/lang/Character.valueOf:(C)Ljava/lang/Character;\n 199: aload 20\n 201: swap\n 202: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 207: pop\n 208: goto 157\n 211: aload 15\n 213: checkcast #38 // class java/util/List\n 216: nop\n 217: nop\n 218: aload 28\n 220: swap\n 221: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 226: pop\n 227: goto 72\n 230: aload 6\n 232: checkcast #38 // class java/util/List\n 235: nop\n 236: astore 4\n 238: iconst_0\n 239: istore 5\n 241: aload 4\n 243: checkcast #44 // class java/lang/Iterable\n 246: astore 6\n 248: aload 4\n 250: invokestatic #95 // Method kotlin/collections/CollectionsKt.first:(Ljava/util/List;)Ljava/lang/Object;\n 253: checkcast #38 // class java/util/List\n 256: invokeinterface #99, 1 // InterfaceMethod java/util/List.size:()I\n 261: istore 7\n 263: new #46 // class java/util/ArrayList\n 266: dup\n 267: iload 7\n 269: invokespecial #55 // Method java/util/ArrayList.\"<init>\":(I)V\n 272: astore 8\n 274: iconst_0\n 275: istore 9\n 277: iload 9\n 279: iload 7\n 281: if_icmpge 323\n 284: iload 9\n 286: istore 10\n 288: aload 8\n 290: iload 10\n 292: istore 11\n 294: astore 12\n 296: iconst_0\n 297: istore 13\n 299: new #46 // class java/util/ArrayList\n 302: dup\n 303: invokespecial #100 // Method java/util/ArrayList.\"<init>\":()V\n 306: checkcast #38 // class java/util/List\n 309: nop\n 310: aload 12\n 312: swap\n 313: invokevirtual #101 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z\n 316: pop\n 317: iinc 9, 1\n 320: goto 277\n 323: aload 8\n 325: checkcast #38 // class java/util/List\n 328: astore 7\n 330: nop\n 331: iconst_0\n 332: istore 8\n 334: aload 7\n 336: astore 9\n 338: aload 6\n 340: invokeinterface #61, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 345: astore 10\n 347: aload 10\n 349: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 354: ifeq 513\n 357: aload 10\n 359: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 364: astore 11\n 366: aload 9\n 368: aload 11\n 370: checkcast #38 // class java/util/List\n 373: astore 13\n 375: astore 14\n 377: iconst_0\n 378: istore 15\n 380: aload 14\n 382: astore 16\n 384: aload 16\n 386: astore 17\n 388: iconst_0\n 389: istore 18\n 391: aload 17\n 393: checkcast #44 // class java/lang/Iterable\n 396: astore 19\n 398: iconst_0\n 399: istore 20\n 401: iconst_0\n 402: istore 21\n 404: aload 19\n 406: invokeinterface #61, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 411: astore 22\n 413: aload 22\n 415: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 420: ifeq 503\n 423: aload 22\n 425: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 430: astore 23\n 432: iload 21\n 434: iinc 21, 1\n 437: istore 24\n 439: iload 24\n 441: ifge 447\n 444: invokestatic #104 // Method kotlin/collections/CollectionsKt.throwIndexOverflow:()V\n 447: iload 24\n 449: aload 23\n 451: checkcast #38 // class java/util/List\n 454: astore 25\n 456: istore 26\n 458: iconst_0\n 459: istore 27\n 461: aload 13\n 463: iload 26\n 465: invokeinterface #108, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 470: checkcast #83 // class java/lang/Character\n 473: invokevirtual #112 // Method java/lang/Character.charValue:()C\n 476: bipush 32\n 478: if_icmpeq 498\n 481: aload 25\n 483: aload 13\n 485: iload 26\n 487: invokeinterface #108, 2 // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;\n 492: invokeinterface #113, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 497: pop\n 498: nop\n 499: nop\n 500: goto 413\n 503: nop\n 504: nop\n 505: aload 16\n 507: nop\n 508: astore 9\n 510: goto 347\n 513: aload 9\n 515: checkcast #44 // class java/lang/Iterable\n 518: astore 6\n 520: nop\n 521: iconst_0\n 522: istore 7\n 524: aload 6\n 526: astore 8\n 528: new #46 // class java/util/ArrayList\n 531: dup\n 532: aload 6\n 534: bipush 10\n 536: invokestatic #52 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 539: invokespecial #55 // Method java/util/ArrayList.\"<init>\":(I)V\n 542: checkcast #57 // class java/util/Collection\n 545: astore 9\n 547: iconst_0\n 548: istore 10\n 550: aload 8\n 552: invokeinterface #61, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 557: astore 11\n 559: aload 11\n 561: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 566: ifeq 618\n 569: aload 11\n 571: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 576: astore 13\n 578: aload 9\n 580: aload 13\n 582: checkcast #38 // class java/util/List\n 585: astore 14\n 587: astore 12\n 589: iconst_0\n 590: istore 15\n 592: aload 14\n 594: checkcast #44 // class java/lang/Iterable\n 597: invokestatic #117 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;\n 600: checkcast #57 // class java/util/Collection\n 603: invokestatic #121 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 606: aload 12\n 608: swap\n 609: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 614: pop\n 615: goto 559\n 618: aload 9\n 620: checkcast #38 // class java/util/List\n 623: nop\n 624: nop\n 625: checkcast #57 // class java/util/Collection\n 628: invokestatic #121 // Method kotlin/collections/CollectionsKt.toMutableList:(Ljava/util/Collection;)Ljava/util/List;\n 631: checkcast #44 // class java/lang/Iterable\n 634: astore_3\n 635: nop\n 636: iconst_0\n 637: istore 4\n 639: aload_3\n 640: astore 5\n 642: aload 5\n 644: astore 6\n 646: iconst_0\n 647: istore 7\n 649: aload 6\n 651: invokeinterface #61, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 656: astore 8\n 658: aload 8\n 660: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 665: ifeq 700\n 668: aload 8\n 670: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 675: astore 9\n 677: aload 9\n 679: checkcast #38 // class java/util/List\n 682: astore 10\n 684: iconst_0\n 685: istore 11\n 687: getstatic #127 // Field java/lang/System.out:Ljava/io/PrintStream;\n 690: aload 10\n 692: invokevirtual #133 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 695: nop\n 696: nop\n 697: goto 658\n 700: aload 5\n 702: nop\n 703: checkcast #38 // class java/util/List\n 706: astore_2\n 707: aload_1\n 708: checkcast #24 // class java/lang/CharSequence\n 711: invokestatic #30 // Method kotlin/text/StringsKt.lines:(Ljava/lang/CharSequence;)Ljava/util/List;\n 714: astore 5\n 716: iconst_0\n 717: istore 6\n 719: aload 5\n 721: aload 5\n 723: invokestatic #36 // Method day05/Day05Kt.access$indexOfStackNumbers:(Ljava/util/List;)I\n 726: iconst_2\n 727: iadd\n 728: aload 5\n 730: invokeinterface #99, 1 // InterfaceMethod java/util/List.size:()I\n 735: invokeinterface #42, 3 // InterfaceMethod java/util/List.subList:(II)Ljava/util/List;\n 740: checkcast #44 // class java/lang/Iterable\n 743: astore 4\n 745: nop\n 746: iconst_0\n 747: istore 5\n 749: aload 4\n 751: astore 6\n 753: new #46 // class java/util/ArrayList\n 756: dup\n 757: aload 4\n 759: bipush 10\n 761: invokestatic #52 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I\n 764: invokespecial #55 // Method java/util/ArrayList.\"<init>\":(I)V\n 767: checkcast #57 // class java/util/Collection\n 770: astore 7\n 772: iconst_0\n 773: istore 8\n 775: aload 6\n 777: invokeinterface #61, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 782: astore 9\n 784: aload 9\n 786: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 791: ifeq 834\n 794: aload 9\n 796: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 801: astore 10\n 803: aload 7\n 805: aload 10\n 807: checkcast #73 // class java/lang/String\n 810: astore 11\n 812: astore 28\n 814: iconst_0\n 815: istore 12\n 817: aload 11\n 819: invokestatic #137 // Method day05/Day05Kt.access$toStep:(Ljava/lang/String;)Lday05/Day05$Step;\n 822: aload 28\n 824: swap\n 825: invokeinterface #91, 2 // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z\n 830: pop\n 831: goto 784\n 834: aload 7\n 836: checkcast #38 // class java/util/List\n 839: nop\n 840: checkcast #44 // class java/lang/Iterable\n 843: astore 4\n 845: nop\n 846: iconst_0\n 847: istore 5\n 849: aload 4\n 851: astore 6\n 853: aload 6\n 855: astore 7\n 857: iconst_0\n 858: istore 8\n 860: aload 7\n 862: invokeinterface #61, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 867: astore 9\n 869: aload 9\n 871: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 876: ifeq 911\n 879: aload 9\n 881: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 886: astore 10\n 888: aload 10\n 890: checkcast #139 // class day05/Day05$Step\n 893: astore 11\n 895: iconst_0\n 896: istore 12\n 898: getstatic #127 // Field java/lang/System.out:Ljava/io/PrintStream;\n 901: aload 11\n 903: invokevirtual #133 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 906: nop\n 907: nop\n 908: goto 869\n 911: aload 6\n 913: nop\n 914: checkcast #38 // class java/util/List\n 917: astore_3\n 918: aload_2\n 919: aload_3\n 920: invokestatic #145 // Method kotlin/TuplesKt.to:(Ljava/lang/Object;Ljava/lang/Object;)Lkotlin/Pair;\n 923: areturn\n\n public final java.lang.String part1(kotlin.Pair<? extends java.util.List<java.util.List<java.lang.Character>>, ? extends java.util.List<day05.Day05$Step>>);\n Code:\n 0: aload_1\n 1: ldc #198 // String parsed\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokevirtual #203 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 10: checkcast #38 // class java/util/List\n 13: astore_2\n 14: aload_1\n 15: invokevirtual #206 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 18: checkcast #38 // class java/util/List\n 21: astore_3\n 22: aload_3\n 23: checkcast #44 // class java/lang/Iterable\n 26: astore 4\n 28: iconst_0\n 29: istore 5\n 31: aload 4\n 33: invokeinterface #61, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 6\n 40: aload 6\n 42: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 79\n 50: aload 6\n 52: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 7\n 59: aload 7\n 61: checkcast #139 // class day05/Day05$Step\n 64: astore 8\n 66: iconst_0\n 67: istore 9\n 69: aload_2\n 70: aload 8\n 72: invokestatic #210 // Method day05/Day05Kt.access$move:(Ljava/util/List;Lday05/Day05$Step;)V\n 75: nop\n 76: goto 40\n 79: nop\n 80: aload_2\n 81: checkcast #44 // class java/lang/Iterable\n 84: ldc #212 // String\n 86: checkcast #24 // class java/lang/CharSequence\n 89: aconst_null\n 90: aconst_null\n 91: iconst_0\n 92: aconst_null\n 93: invokedynamic #231, 0 // InvokeDynamic #0:invoke:()Lkotlin/jvm/functions/Function1;\n 98: bipush 30\n 100: aconst_null\n 101: invokestatic #235 // 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 104: areturn\n\n public final java.lang.String part2(kotlin.Pair<? extends java.util.List<java.util.List<java.lang.Character>>, ? extends java.util.List<day05.Day05$Step>>);\n Code:\n 0: aload_1\n 1: ldc #198 // String parsed\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: invokevirtual #203 // Method kotlin/Pair.component1:()Ljava/lang/Object;\n 10: checkcast #38 // class java/util/List\n 13: astore_2\n 14: aload_1\n 15: invokevirtual #206 // Method kotlin/Pair.component2:()Ljava/lang/Object;\n 18: checkcast #38 // class java/util/List\n 21: astore_3\n 22: aload_3\n 23: checkcast #44 // class java/lang/Iterable\n 26: astore 4\n 28: iconst_0\n 29: istore 5\n 31: aload 4\n 33: invokeinterface #61, 1 // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;\n 38: astore 6\n 40: aload 6\n 42: invokeinterface #67, 1 // InterfaceMethod java/util/Iterator.hasNext:()Z\n 47: ifeq 79\n 50: aload 6\n 52: invokeinterface #71, 1 // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;\n 57: astore 7\n 59: aload 7\n 61: checkcast #139 // class day05/Day05$Step\n 64: astore 8\n 66: iconst_0\n 67: istore 9\n 69: aload_2\n 70: aload 8\n 72: invokestatic #244 // Method day05/Day05Kt.access$moveV2:(Ljava/util/List;Lday05/Day05$Step;)V\n 75: nop\n 76: goto 40\n 79: nop\n 80: aload_2\n 81: checkcast #44 // class java/lang/Iterable\n 84: ldc #212 // String\n 86: checkcast #24 // class java/lang/CharSequence\n 89: aconst_null\n 90: aconst_null\n 91: iconst_0\n 92: aconst_null\n 93: invokedynamic #249, 0 // InvokeDynamic #1:invoke:()Lkotlin/jvm/functions/Function1;\n 98: bipush 30\n 100: aconst_null\n 101: invokestatic #235 // 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 104: areturn\n\n private static final java.lang.CharSequence part1$lambda$14(java.util.List);\n Code:\n 0: aload_0\n 1: ldc #252 // String stack\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #255 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 10: checkcast #83 // class java/lang/Character\n 13: invokevirtual #112 // Method java/lang/Character.charValue:()C\n 16: invokestatic #258 // Method java/lang/String.valueOf:(C)Ljava/lang/String;\n 19: checkcast #24 // class java/lang/CharSequence\n 22: areturn\n\n private static final java.lang.CharSequence part2$lambda$16(java.util.List);\n Code:\n 0: aload_0\n 1: ldc #252 // String stack\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #255 // Method kotlin/collections/CollectionsKt.last:(Ljava/util/List;)Ljava/lang/Object;\n 10: checkcast #83 // class java/lang/Character\n 13: invokevirtual #112 // Method java/lang/Character.charValue:()C\n 16: invokestatic #258 // Method java/lang/String.valueOf:(C)Ljava/lang/String;\n 19: checkcast #24 // class java/lang/CharSequence\n 22: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "Malo-T__AoC-2022__f4edefa/day05/Day05$Step.class",
"javap": "Compiled from \"Day05.kt\"\npublic final class day05.Day05$Step {\n private final int amount;\n\n private final int from;\n\n private final int to;\n\n public day05.Day05$Step(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 amount:I\n 9: aload_0\n 10: iload_2\n 11: putfield #16 // Field from:I\n 14: aload_0\n 15: iload_3\n 16: putfield #19 // Field to:I\n 19: return\n\n public final int getAmount();\n Code:\n 0: aload_0\n 1: getfield #13 // Field amount:I\n 4: ireturn\n\n public final int getFrom();\n Code:\n 0: aload_0\n 1: getfield #16 // Field from:I\n 4: ireturn\n\n public final int getTo();\n Code:\n 0: aload_0\n 1: getfield #19 // Field to:I\n 4: ireturn\n\n public final int getFromIndex();\n Code:\n 0: aload_0\n 1: getfield #16 // Field from:I\n 4: iconst_1\n 5: isub\n 6: ireturn\n\n public final int getToIndex();\n Code:\n 0: aload_0\n 1: getfield #19 // Field to:I\n 4: iconst_1\n 5: isub\n 6: ireturn\n\n public final int component1();\n Code:\n 0: aload_0\n 1: getfield #13 // Field amount:I\n 4: ireturn\n\n public final int component2();\n Code:\n 0: aload_0\n 1: getfield #16 // Field from:I\n 4: ireturn\n\n public final int component3();\n Code:\n 0: aload_0\n 1: getfield #19 // Field to:I\n 4: ireturn\n\n public final day05.Day05$Step copy(int, int, int);\n Code:\n 0: new #2 // class day05/Day05$Step\n 3: dup\n 4: iload_1\n 5: iload_2\n 6: iload_3\n 7: invokespecial #35 // Method \"<init>\":(III)V\n 10: areturn\n\n public static day05.Day05$Step copy$default(day05.Day05$Step, 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 amount: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 from: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 to:I\n 35: istore_3\n 36: aload_0\n 37: iload_1\n 38: iload_2\n 39: iload_3\n 40: invokevirtual #39 // Method copy:(III)Lday05/Day05$Step;\n 43: areturn\n\n public java.lang.String toString();\n Code:\n 0: new #43 // class java/lang/StringBuilder\n 3: dup\n 4: invokespecial #44 // Method java/lang/StringBuilder.\"<init>\":()V\n 7: ldc #46 // String Step(amount=\n 9: invokevirtual #50 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 12: aload_0\n 13: getfield #13 // Field amount:I\n 16: invokevirtual #53 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 19: ldc #55 // String , from=\n 21: invokevirtual #50 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 24: aload_0\n 25: getfield #16 // Field from:I\n 28: invokevirtual #53 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 31: ldc #57 // String , to=\n 33: invokevirtual #50 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 36: aload_0\n 37: getfield #19 // Field to:I\n 40: invokevirtual #53 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 43: bipush 41\n 45: invokevirtual #60 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 48: invokevirtual #62 // 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 amount:I\n 4: invokestatic #68 // 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 from:I\n 16: invokestatic #68 // 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 to:I\n 29: invokestatic #68 // 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 day05/Day05$Step\n 11: ifne 16\n 14: iconst_0\n 15: ireturn\n 16: aload_1\n 17: checkcast #2 // class day05/Day05$Step\n 20: astore_2\n 21: aload_0\n 22: getfield #13 // Field amount:I\n 25: aload_2\n 26: getfield #13 // Field amount:I\n 29: if_icmpeq 34\n 32: iconst_0\n 33: ireturn\n 34: aload_0\n 35: getfield #16 // Field from:I\n 38: aload_2\n 39: getfield #16 // Field from:I\n 42: if_icmpeq 47\n 45: iconst_0\n 46: ireturn\n 47: aload_0\n 48: getfield #19 // Field to:I\n 51: aload_2\n 52: getfield #19 // Field to:I\n 55: if_icmpeq 60\n 58: iconst_0\n 59: ireturn\n 60: iconst_1\n 61: ireturn\n}\n",
"javap_err": ""
}
] |
mikhalchenko-alexander__advent-of-kotlin-2018-week1__c483ade/src/main/kotlin/com/anahoret/pathfinding/MarkingWayOnMap.kt
|
package com.anahoret.pathfinding
import java.lang.IllegalArgumentException
import java.util.*
fun addPath(map: String): String = Graph.getMapWithPath(map)
object Graph {
private const val STRAIGHT_LENGTH = 2
private const val DIAGONAL_LENGTH = 3
fun getMapWithPath(map: String): String {
val (nodes, arcs) = readGraph(map)
val start = nodes.find { it.isStart } ?: throw IllegalArgumentException("No start point specified")
val end = nodes.find { it.isEnd } ?: throw IllegalArgumentException("No end point specified")
val paths = calcDistances(start, nodes, arcs)
return map.lines()
.map(String::toCharArray)
.let { charGrid ->
charGrid[start.row][start.col] = '*'
paths.getValue(end).forEach { charGrid[it.row][it.col] = '*' }
charGrid.joinToString(separator = "\n") { row -> row.joinToString(separator = "") }
}
}
private fun calcDistances(start: Node, nodes: Collection<Node>, arcs: Map<Node, List<Arc>>): Map<Node, List<Node>> {
val paths = nodes.map { it to emptyList<Node>() }.toMap().toMutableMap()
val distances = nodes.map { it to if (it == start) 0 else Int.MAX_VALUE }.toMap().toMutableMap()
val visited = mutableSetOf<Node>()
val queue = PriorityQueue<Node>(nodes.size) { n1, n2 -> distances.getValue(n1) - distances.getValue(n2) }
queue.addAll(nodes)
while (queue.isNotEmpty()) {
val node = queue.poll()
visited.add(node)
arcs.getValue(node)
.filterNot { visited.contains(it.node) }
.forEach { arc ->
if (distances.getValue(node) + arc.length < distances.getValue(arc.node)) {
distances[arc.node] = distances.getValue(node) + arc.length
paths[arc.node] = paths.getValue(node) + arc.node
queue.remove(arc.node)
queue.add(arc.node)
}
}
}
return paths.toMap()
}
private fun readGraph(map: String): Pair<List<Node>, Map<Node, List<Arc>>> {
val nodes = map.lines()
.mapIndexed { row, str ->
str.mapIndexedNotNull { col, char -> if (char == 'B') null else Node(row, col, char) }
}
.flatten()
val arcs = nodes.map { node ->
val row = nodes.filter { it.row == node.row }
val topRow = nodes.filter { it.row == node.row - 1 }
val bottomRow = nodes.filter { it.row == node.row + 1 }
val nodeArcs = listOfNotNull(
topRow.find { it.col == node.col }?.let { Arc(it, STRAIGHT_LENGTH) },
topRow.find { it.col == node.col - 1 }?.let { Arc(it, DIAGONAL_LENGTH) },
topRow.find { it.col == node.col + 1 }?.let { Arc(it, DIAGONAL_LENGTH) },
bottomRow.find { it.col == node.col }?.let { Arc(it, STRAIGHT_LENGTH) },
bottomRow.find { it.col == node.col - 1 }?.let { Arc(it, DIAGONAL_LENGTH) },
bottomRow.find { it.col == node.col + 1 }?.let { Arc(it, DIAGONAL_LENGTH) },
row.find { it.col == node.col - 1 }?.let { Arc(it, STRAIGHT_LENGTH) },
row.find { it.col == node.col + 1 }?.let { Arc(it, STRAIGHT_LENGTH) }
)
node to nodeArcs
}.toMap()
return Pair(nodes, arcs)
}
class Node(val row: Int, val col: Int, char: Char) {
val isStart = char == 'S'
val isEnd = char == 'X'
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is Node) return false
if (row != other.row) return false
if (col != other.col) return false
return true
}
override fun hashCode(): Int {
var result = row
result = 31 * result + col
return result
}
}
class Arc(val node: Node, val length: Int)
}
|
[
{
"class_path": "mikhalchenko-alexander__advent-of-kotlin-2018-week1__c483ade/com/anahoret/pathfinding/MarkingWayOnMapKt.class",
"javap": "Compiled from \"MarkingWayOnMap.kt\"\npublic final class com.anahoret.pathfinding.MarkingWayOnMapKt {\n public static final java.lang.String addPath(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #9 // String map\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: getstatic #21 // Field com/anahoret/pathfinding/Graph.INSTANCE:Lcom/anahoret/pathfinding/Graph;\n 9: aload_0\n 10: invokevirtual #24 // Method com/anahoret/pathfinding/Graph.getMapWithPath:(Ljava/lang/String;)Ljava/lang/String;\n 13: areturn\n}\n",
"javap_err": ""
}
] |
ani03sha__RedQuarkTutorials__67b6eba/ConceptOfTheDay/Kotlin/src/main/java/org/redquark/conceptoftheday/AnagramSubstringSearch.kt
|
package org.redquark.conceptoftheday
/**
* @author <NAME>
*
* We are given two strings "text" and "pattern" of size n and m respectively where m < n.
* Find all the indices in text where anagrams of pattern are found.
*/
private fun findIndices(text: String, pattern: String): List<Int> {
// Lengths of strings
val n = text.length
val m = pattern.length
// List that will store the indices
val indices: MutableList<Int> = ArrayList()
// Frequency arrays - assuming we have a set of 256 characters
val textCount = IntArray(256)
val patternCount = IntArray(256)
// Loop until m
for (i in 0 until m) {
textCount[text[i].toInt()]++
patternCount[pattern[i].toInt()]++
}
// At this point, we have traversed m characters in both the arrays.
// Now we will loop through the remaining characters
for (i in m until n) {
// Check if the counts of characters in frequency arrays are equal or not
if (isCountEqual(textCount, patternCount)) {
indices.add(i - m)
}
// Discard left most character
textCount[text[i - m].toInt()]--
// Include current character
textCount[text[i].toInt()]++
}
// Check for the last window
if (isCountEqual(textCount, patternCount)) {
indices.add(n - m)
}
return indices
}
private fun isCountEqual(textCount: IntArray, patternCount: IntArray): Boolean {
for (i in 0..255) {
if (textCount[i] != patternCount[i]) {
return false
}
}
return true
}
fun main() {
var text = "BACDGABCDA"
var pattern = "ABCD"
println("Anagrams are found at: " + findIndices(text, pattern))
text = "XYYZXZYZXXYZ"
pattern = "XYZ"
println("Anagrams are found at: " + findIndices(text, pattern))
}
|
[
{
"class_path": "ani03sha__RedQuarkTutorials__67b6eba/org/redquark/conceptoftheday/AnagramSubstringSearchKt.class",
"javap": "Compiled from \"AnagramSubstringSearch.kt\"\npublic final class org.redquark.conceptoftheday.AnagramSubstringSearchKt {\n private static final java.util.List<java.lang.Integer> findIndices(java.lang.String, java.lang.String);\n Code:\n 0: aload_0\n 1: invokevirtual #13 // Method java/lang/String.length:()I\n 4: istore_2\n 5: aload_1\n 6: invokevirtual #13 // Method java/lang/String.length:()I\n 9: istore_3\n 10: new #15 // class java/util/ArrayList\n 13: dup\n 14: invokespecial #19 // Method java/util/ArrayList.\"<init>\":()V\n 17: checkcast #21 // class java/util/List\n 20: astore 4\n 22: sipush 256\n 25: newarray int\n 27: astore 5\n 29: sipush 256\n 32: newarray int\n 34: astore 6\n 36: iconst_0\n 37: istore 7\n 39: iload 7\n 41: iload_3\n 42: if_icmpge 99\n 45: aload_0\n 46: iload 7\n 48: invokevirtual #25 // Method java/lang/String.charAt:(I)C\n 51: istore 8\n 53: aload 5\n 55: iload 8\n 57: iaload\n 58: istore 9\n 60: aload 5\n 62: iload 8\n 64: iload 9\n 66: iconst_1\n 67: iadd\n 68: iastore\n 69: aload_1\n 70: iload 7\n 72: invokevirtual #25 // Method java/lang/String.charAt:(I)C\n 75: istore 10\n 77: aload 6\n 79: iload 10\n 81: iaload\n 82: istore 11\n 84: aload 6\n 86: iload 10\n 88: iload 11\n 90: iconst_1\n 91: iadd\n 92: iastore\n 93: iinc 7, 1\n 96: goto 39\n 99: iload_3\n 100: istore 7\n 102: iload 7\n 104: iload_2\n 105: if_icmpge 189\n 108: aload 5\n 110: aload 6\n 112: invokestatic #29 // Method isCountEqual:([I[I)Z\n 115: ifeq 133\n 118: aload 4\n 120: iload 7\n 122: iload_3\n 123: isub\n 124: invokestatic #35 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 127: invokeinterface #39, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 132: pop\n 133: aload_0\n 134: iload 7\n 136: iload_3\n 137: isub\n 138: invokevirtual #25 // Method java/lang/String.charAt:(I)C\n 141: istore 8\n 143: aload 5\n 145: iload 8\n 147: iaload\n 148: istore 9\n 150: aload 5\n 152: iload 8\n 154: iload 9\n 156: iconst_m1\n 157: iadd\n 158: iastore\n 159: aload_0\n 160: iload 7\n 162: invokevirtual #25 // Method java/lang/String.charAt:(I)C\n 165: istore 10\n 167: aload 5\n 169: iload 10\n 171: iaload\n 172: istore 11\n 174: aload 5\n 176: iload 10\n 178: iload 11\n 180: iconst_1\n 181: iadd\n 182: iastore\n 183: iinc 7, 1\n 186: goto 102\n 189: aload 5\n 191: aload 6\n 193: invokestatic #29 // Method isCountEqual:([I[I)Z\n 196: ifeq 213\n 199: aload 4\n 201: iload_2\n 202: iload_3\n 203: isub\n 204: invokestatic #35 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 207: invokeinterface #39, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 212: pop\n 213: aload 4\n 215: areturn\n\n private static final boolean isCountEqual(int[], int[]);\n Code:\n 0: iconst_0\n 1: istore_2\n 2: iload_2\n 3: sipush 256\n 6: if_icmpge 26\n 9: aload_0\n 10: iload_2\n 11: iaload\n 12: aload_1\n 13: iload_2\n 14: iaload\n 15: if_icmpeq 20\n 18: iconst_0\n 19: ireturn\n 20: iinc 2, 1\n 23: goto 2\n 26: iconst_1\n 27: ireturn\n\n public static final void main();\n Code:\n 0: ldc #55 // String BACDGABCDA\n 2: astore_0\n 3: ldc #57 // String ABCD\n 5: astore_1\n 6: new #59 // class java/lang/StringBuilder\n 9: dup\n 10: invokespecial #60 // Method java/lang/StringBuilder.\"<init>\":()V\n 13: ldc #62 // String Anagrams are found at:\n 15: invokevirtual #66 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 18: aload_0\n 19: aload_1\n 20: invokestatic #68 // Method findIndices:(Ljava/lang/String;Ljava/lang/String;)Ljava/util/List;\n 23: invokevirtual #71 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 26: invokevirtual #75 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 29: getstatic #81 // Field java/lang/System.out:Ljava/io/PrintStream;\n 32: swap\n 33: invokevirtual #87 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 36: ldc #89 // String XYYZXZYZXXYZ\n 38: astore_0\n 39: ldc #91 // String XYZ\n 41: astore_1\n 42: new #59 // class java/lang/StringBuilder\n 45: dup\n 46: invokespecial #60 // Method java/lang/StringBuilder.\"<init>\":()V\n 49: ldc #62 // String Anagrams are found at:\n 51: invokevirtual #66 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 54: aload_0\n 55: aload_1\n 56: invokestatic #68 // Method findIndices:(Ljava/lang/String;Ljava/lang/String;)Ljava/util/List;\n 59: invokevirtual #71 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;\n 62: invokevirtual #75 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 65: getstatic #81 // Field java/lang/System.out:Ljava/io/PrintStream;\n 68: swap\n 69: invokevirtual #87 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 72: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #94 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
ani03sha__RedQuarkTutorials__67b6eba/LeetCode/Kotlin/src/main/kotlin/org/redquark/tutorials/leetcode/SubstringWithConcatenationOfAllWords.kt
|
package org.redquark.tutorials.leetcode
class SubstringWithConcatenationOfAllWords {
fun findSubstring(s: String, words: Array<String>): List<Int> {
// Resultant list
val indices: MutableList<Int> = ArrayList()
// Base conditions
if (s.isEmpty() || words.isEmpty()) {
return indices
}
// Store the words and their counts in a hash map
val wordCount: MutableMap<String, Int> = HashMap()
for (word in words) {
wordCount[word] = wordCount.getOrDefault(word, 0) + 1
}
// Length of each word in the words array
val wordLength = words[0].length
// Length of all the words combined in the array
val wordArrayLength = wordLength * words.size
// Loop for the entire string
for (i in 0..s.length - wordArrayLength) {
// Get the substring of length equal to wordArrayLength
val current = s.substring(i, i + wordArrayLength)
// Map to store each word of the substring
val wordMap: MutableMap<String, Int> = HashMap()
// Index to loop through the words array
var index = 0
// Index to get each word in the current
var j = 0
// Loop through each word of the words array
while (index < words.size) {
// Divide the current string into strings of length of
// each word in the array
val part = current.substring(j, j + wordLength)
// Put this string into the wordMap
wordMap[part] = wordMap.getOrDefault(part, 0) + 1
// Update j and index
j += wordLength
index++
}
// At this point compare the maps
if (wordCount == wordMap) {
indices.add(i)
}
}
return indices
}
}
fun main() {
val sObject = SubstringWithConcatenationOfAllWords()
var s = "barfoothefoobarman"
var words = arrayOf("foo", "bar")
println(sObject.findSubstring(s, words))
s = "wordgoodgoodgoodbestword"
words = arrayOf("word", "good", "best", "word")
println(sObject.findSubstring(s, words))
s = "barfoofoobarthefoobarman"
words = arrayOf("bar", "foo", "the")
println(sObject.findSubstring(s, words))
s = "wordgoodgoodgoodbestword"
words = arrayOf("word", "good", "best", "good")
println(sObject.findSubstring(s, words))
}
|
[
{
"class_path": "ani03sha__RedQuarkTutorials__67b6eba/org/redquark/tutorials/leetcode/SubstringWithConcatenationOfAllWords.class",
"javap": "Compiled from \"SubstringWithConcatenationOfAllWords.kt\"\npublic final class org.redquark.tutorials.leetcode.SubstringWithConcatenationOfAllWords {\n public org.redquark.tutorials.leetcode.SubstringWithConcatenationOfAllWords();\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.Integer> findSubstring(java.lang.String, java.lang.String[]);\n Code:\n 0: aload_1\n 1: ldc #16 // String s\n 3: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_2\n 7: ldc #24 // String words\n 9: invokestatic #22 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: new #26 // class java/util/ArrayList\n 15: dup\n 16: invokespecial #27 // Method java/util/ArrayList.\"<init>\":()V\n 19: checkcast #29 // class java/util/List\n 22: astore_3\n 23: aload_1\n 24: checkcast #31 // class java/lang/CharSequence\n 27: invokeinterface #35, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 32: ifne 39\n 35: iconst_1\n 36: goto 40\n 39: iconst_0\n 40: ifne 56\n 43: aload_2\n 44: arraylength\n 45: ifne 52\n 48: iconst_1\n 49: goto 53\n 52: iconst_0\n 53: ifeq 58\n 56: aload_3\n 57: areturn\n 58: new #37 // class java/util/HashMap\n 61: dup\n 62: invokespecial #38 // Method java/util/HashMap.\"<init>\":()V\n 65: checkcast #40 // class java/util/Map\n 68: astore 4\n 70: iconst_0\n 71: istore 5\n 73: aload_2\n 74: arraylength\n 75: istore 6\n 77: iload 5\n 79: iload 6\n 81: if_icmpge 130\n 84: aload_2\n 85: iload 5\n 87: aaload\n 88: astore 7\n 90: aload 4\n 92: aload 7\n 94: aload 4\n 96: aload 7\n 98: iconst_0\n 99: invokestatic #46 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 102: invokeinterface #50, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 107: checkcast #52 // class java/lang/Number\n 110: invokevirtual #55 // Method java/lang/Number.intValue:()I\n 113: iconst_1\n 114: iadd\n 115: invokestatic #46 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 118: invokeinterface #58, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 123: pop\n 124: iinc 5, 1\n 127: goto 77\n 130: aload_2\n 131: iconst_0\n 132: aaload\n 133: invokevirtual #61 // Method java/lang/String.length:()I\n 136: istore 5\n 138: iload 5\n 140: aload_2\n 141: arraylength\n 142: imul\n 143: istore 6\n 145: iconst_0\n 146: istore 7\n 148: aload_1\n 149: invokevirtual #61 // Method java/lang/String.length:()I\n 152: iload 6\n 154: isub\n 155: istore 8\n 157: iload 7\n 159: iload 8\n 161: if_icmpgt 310\n 164: aload_1\n 165: iload 7\n 167: iload 7\n 169: iload 6\n 171: iadd\n 172: invokevirtual #65 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 175: dup\n 176: ldc #67 // String substring(...)\n 178: invokestatic #70 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 181: astore 9\n 183: new #37 // class java/util/HashMap\n 186: dup\n 187: invokespecial #38 // Method java/util/HashMap.\"<init>\":()V\n 190: checkcast #40 // class java/util/Map\n 193: astore 10\n 195: iconst_0\n 196: istore 11\n 198: iconst_0\n 199: istore 12\n 201: iload 11\n 203: aload_2\n 204: arraylength\n 205: if_icmpge 275\n 208: aload 9\n 210: iload 12\n 212: iload 12\n 214: iload 5\n 216: iadd\n 217: invokevirtual #65 // Method java/lang/String.substring:(II)Ljava/lang/String;\n 220: dup\n 221: ldc #67 // String substring(...)\n 223: invokestatic #70 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 226: astore 13\n 228: aload 10\n 230: aload 13\n 232: aload 10\n 234: aload 13\n 236: iconst_0\n 237: invokestatic #46 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 240: invokeinterface #50, 3 // InterfaceMethod java/util/Map.getOrDefault:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 245: checkcast #52 // class java/lang/Number\n 248: invokevirtual #55 // Method java/lang/Number.intValue:()I\n 251: iconst_1\n 252: iadd\n 253: invokestatic #46 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 256: invokeinterface #58, 3 // InterfaceMethod java/util/Map.put:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;\n 261: pop\n 262: iload 12\n 264: iload 5\n 266: iadd\n 267: istore 12\n 269: iinc 11, 1\n 272: goto 201\n 275: aload 4\n 277: aload 10\n 279: invokestatic #74 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z\n 282: ifeq 297\n 285: aload_3\n 286: iload 7\n 288: invokestatic #46 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 291: invokeinterface #78, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 296: pop\n 297: iload 7\n 299: iload 8\n 301: if_icmpeq 310\n 304: iinc 7, 1\n 307: goto 164\n 310: aload_3\n 311: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "ani03sha__RedQuarkTutorials__67b6eba/org/redquark/tutorials/leetcode/SubstringWithConcatenationOfAllWordsKt.class",
"javap": "Compiled from \"SubstringWithConcatenationOfAllWords.kt\"\npublic final class org.redquark.tutorials.leetcode.SubstringWithConcatenationOfAllWordsKt {\n public static final void main();\n Code:\n 0: new #8 // class org/redquark/tutorials/leetcode/SubstringWithConcatenationOfAllWords\n 3: dup\n 4: invokespecial #11 // Method org/redquark/tutorials/leetcode/SubstringWithConcatenationOfAllWords.\"<init>\":()V\n 7: astore_0\n 8: ldc #13 // String barfoothefoobarman\n 10: astore_1\n 11: iconst_2\n 12: anewarray #15 // class java/lang/String\n 15: astore_3\n 16: aload_3\n 17: iconst_0\n 18: ldc #17 // String foo\n 20: aastore\n 21: aload_3\n 22: iconst_1\n 23: ldc #19 // String bar\n 25: aastore\n 26: aload_3\n 27: astore_2\n 28: aload_0\n 29: aload_1\n 30: aload_2\n 31: invokevirtual #23 // Method org/redquark/tutorials/leetcode/SubstringWithConcatenationOfAllWords.findSubstring:(Ljava/lang/String;[Ljava/lang/String;)Ljava/util/List;\n 34: getstatic #29 // Field java/lang/System.out:Ljava/io/PrintStream;\n 37: swap\n 38: invokevirtual #35 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 41: ldc #37 // String wordgoodgoodgoodbestword\n 43: astore_1\n 44: iconst_4\n 45: anewarray #15 // class java/lang/String\n 48: astore_3\n 49: aload_3\n 50: iconst_0\n 51: ldc #39 // String word\n 53: aastore\n 54: aload_3\n 55: iconst_1\n 56: ldc #41 // String good\n 58: aastore\n 59: aload_3\n 60: iconst_2\n 61: ldc #43 // String best\n 63: aastore\n 64: aload_3\n 65: iconst_3\n 66: ldc #39 // String word\n 68: aastore\n 69: aload_3\n 70: astore_2\n 71: aload_0\n 72: aload_1\n 73: aload_2\n 74: invokevirtual #23 // Method org/redquark/tutorials/leetcode/SubstringWithConcatenationOfAllWords.findSubstring:(Ljava/lang/String;[Ljava/lang/String;)Ljava/util/List;\n 77: getstatic #29 // Field java/lang/System.out:Ljava/io/PrintStream;\n 80: swap\n 81: invokevirtual #35 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 84: ldc #45 // String barfoofoobarthefoobarman\n 86: astore_1\n 87: iconst_3\n 88: anewarray #15 // class java/lang/String\n 91: astore_3\n 92: aload_3\n 93: iconst_0\n 94: ldc #19 // String bar\n 96: aastore\n 97: aload_3\n 98: iconst_1\n 99: ldc #17 // String foo\n 101: aastore\n 102: aload_3\n 103: iconst_2\n 104: ldc #47 // String the\n 106: aastore\n 107: aload_3\n 108: astore_2\n 109: aload_0\n 110: aload_1\n 111: aload_2\n 112: invokevirtual #23 // Method org/redquark/tutorials/leetcode/SubstringWithConcatenationOfAllWords.findSubstring:(Ljava/lang/String;[Ljava/lang/String;)Ljava/util/List;\n 115: getstatic #29 // Field java/lang/System.out:Ljava/io/PrintStream;\n 118: swap\n 119: invokevirtual #35 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 122: ldc #37 // String wordgoodgoodgoodbestword\n 124: astore_1\n 125: iconst_4\n 126: anewarray #15 // class java/lang/String\n 129: astore_3\n 130: aload_3\n 131: iconst_0\n 132: ldc #39 // String word\n 134: aastore\n 135: aload_3\n 136: iconst_1\n 137: ldc #41 // String good\n 139: aastore\n 140: aload_3\n 141: iconst_2\n 142: ldc #43 // String best\n 144: aastore\n 145: aload_3\n 146: iconst_3\n 147: ldc #41 // String good\n 149: aastore\n 150: aload_3\n 151: astore_2\n 152: aload_0\n 153: aload_1\n 154: aload_2\n 155: invokevirtual #23 // Method org/redquark/tutorials/leetcode/SubstringWithConcatenationOfAllWords.findSubstring:(Ljava/lang/String;[Ljava/lang/String;)Ljava/util/List;\n 158: getstatic #29 // Field java/lang/System.out:Ljava/io/PrintStream;\n 161: swap\n 162: invokevirtual #35 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 165: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #56 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
ani03sha__RedQuarkTutorials__67b6eba/LeetCode/Kotlin/src/main/kotlin/org/redquark/tutorials/leetcode/LetterCombinationsOfAPhoneNumber.kt
|
package org.redquark.tutorials.leetcode
fun letterCombinations(digits: String): List<String> {
// Resultant list
val combinations: MutableList<String> = mutableListOf()
// Base condition
if (digits.isEmpty()) {
return combinations
}
// Mappings of letters and numbers
val lettersAndNumbersMappings = arrayOf(
"Anirudh",
"is awesome",
"abc",
"def",
"ghi",
"jkl",
"mno",
"pqrs",
"tuv",
"wxyz"
)
findCombinations(combinations, digits, StringBuilder(), 0, lettersAndNumbersMappings)
return combinations
}
fun findCombinations(combinations: MutableList<String>, digits: String, previous: StringBuilder, index: Int, lettersAndNumbersMappings: Array<String>) {
// Base condition for recursion to stop
if (index == digits.length) {
combinations.add(previous.toString())
return
}
// Get the letters corresponding to the current index of digits string
val letters = lettersAndNumbersMappings[digits[index] - '0']
// Loop through all the characters in the current combination of letters
for (c in letters.toCharArray()) {
findCombinations(combinations, digits, previous.append(c), index + 1, lettersAndNumbersMappings)
previous.deleteCharAt(previous.length - 1)
}
}
fun main() {
println(letterCombinations("23"))
println(letterCombinations(""))
println(letterCombinations("2"))
}
|
[
{
"class_path": "ani03sha__RedQuarkTutorials__67b6eba/org/redquark/tutorials/leetcode/LetterCombinationsOfAPhoneNumberKt.class",
"javap": "Compiled from \"LetterCombinationsOfAPhoneNumber.kt\"\npublic final class org.redquark.tutorials.leetcode.LetterCombinationsOfAPhoneNumberKt {\n public static final java.util.List<java.lang.String> letterCombinations(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #10 // String digits\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #18 // class java/util/ArrayList\n 9: dup\n 10: invokespecial #22 // Method java/util/ArrayList.\"<init>\":()V\n 13: checkcast #24 // class java/util/List\n 16: astore_1\n 17: aload_0\n 18: checkcast #26 // class java/lang/CharSequence\n 21: invokeinterface #30, 1 // InterfaceMethod java/lang/CharSequence.length:()I\n 26: ifne 33\n 29: iconst_1\n 30: goto 34\n 33: iconst_0\n 34: ifeq 39\n 37: aload_1\n 38: areturn\n 39: bipush 10\n 41: anewarray #32 // class java/lang/String\n 44: astore_3\n 45: aload_3\n 46: iconst_0\n 47: ldc #34 // String Anirudh\n 49: aastore\n 50: aload_3\n 51: iconst_1\n 52: ldc #36 // String is awesome\n 54: aastore\n 55: aload_3\n 56: iconst_2\n 57: ldc #38 // String abc\n 59: aastore\n 60: aload_3\n 61: iconst_3\n 62: ldc #40 // String def\n 64: aastore\n 65: aload_3\n 66: iconst_4\n 67: ldc #42 // String ghi\n 69: aastore\n 70: aload_3\n 71: iconst_5\n 72: ldc #44 // String jkl\n 74: aastore\n 75: aload_3\n 76: bipush 6\n 78: ldc #46 // String mno\n 80: aastore\n 81: aload_3\n 82: bipush 7\n 84: ldc #48 // String pqrs\n 86: aastore\n 87: aload_3\n 88: bipush 8\n 90: ldc #50 // String tuv\n 92: aastore\n 93: aload_3\n 94: bipush 9\n 96: ldc #52 // String wxyz\n 98: aastore\n 99: aload_3\n 100: astore_2\n 101: aload_1\n 102: aload_0\n 103: new #54 // class java/lang/StringBuilder\n 106: dup\n 107: invokespecial #55 // Method java/lang/StringBuilder.\"<init>\":()V\n 110: iconst_0\n 111: aload_2\n 112: invokestatic #59 // Method findCombinations:(Ljava/util/List;Ljava/lang/String;Ljava/lang/StringBuilder;I[Ljava/lang/String;)V\n 115: aload_1\n 116: areturn\n\n public static final void findCombinations(java.util.List<java.lang.String>, java.lang.String, java.lang.StringBuilder, int, java.lang.String[]);\n Code:\n 0: aload_0\n 1: ldc #66 // String combinations\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 digits\n 9: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_2\n 13: ldc #68 // String previous\n 15: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 18: aload 4\n 20: ldc #69 // String lettersAndNumbersMappings\n 22: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 25: iload_3\n 26: aload_1\n 27: invokevirtual #70 // Method java/lang/String.length:()I\n 30: if_icmpne 51\n 33: aload_0\n 34: aload_2\n 35: invokevirtual #74 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 38: dup\n 39: ldc #76 // String toString(...)\n 41: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 44: invokeinterface #83, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 49: pop\n 50: return\n 51: aload 4\n 53: aload_1\n 54: iload_3\n 55: invokevirtual #87 // Method java/lang/String.charAt:(I)C\n 58: bipush 48\n 60: isub\n 61: aaload\n 62: astore 5\n 64: aload 5\n 66: invokevirtual #91 // Method java/lang/String.toCharArray:()[C\n 69: dup\n 70: ldc #93 // String toCharArray(...)\n 72: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 75: astore 6\n 77: iconst_0\n 78: istore 7\n 80: aload 6\n 82: arraylength\n 83: istore 8\n 85: iload 7\n 87: iload 8\n 89: if_icmpge 138\n 92: aload 6\n 94: iload 7\n 96: caload\n 97: istore 9\n 99: aload_0\n 100: aload_1\n 101: aload_2\n 102: iload 9\n 104: invokevirtual #97 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 107: dup\n 108: ldc #99 // String append(...)\n 110: invokestatic #79 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 113: iload_3\n 114: iconst_1\n 115: iadd\n 116: aload 4\n 118: invokestatic #59 // Method findCombinations:(Ljava/util/List;Ljava/lang/String;Ljava/lang/StringBuilder;I[Ljava/lang/String;)V\n 121: aload_2\n 122: aload_2\n 123: invokevirtual #100 // Method java/lang/StringBuilder.length:()I\n 126: iconst_1\n 127: isub\n 128: invokevirtual #104 // Method java/lang/StringBuilder.deleteCharAt:(I)Ljava/lang/StringBuilder;\n 131: pop\n 132: iinc 7, 1\n 135: goto 85\n 138: return\n\n public static final void main();\n Code:\n 0: ldc #116 // String 23\n 2: invokestatic #118 // Method letterCombinations:(Ljava/lang/String;)Ljava/util/List;\n 5: getstatic #124 // Field java/lang/System.out:Ljava/io/PrintStream;\n 8: swap\n 9: invokevirtual #130 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 12: ldc #132 // String\n 14: invokestatic #118 // Method letterCombinations:(Ljava/lang/String;)Ljava/util/List;\n 17: getstatic #124 // Field java/lang/System.out:Ljava/io/PrintStream;\n 20: swap\n 21: invokevirtual #130 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 24: ldc #134 // String 2\n 26: invokestatic #118 // Method letterCombinations:(Ljava/lang/String;)Ljava/util/List;\n 29: getstatic #124 // Field java/lang/System.out:Ljava/io/PrintStream;\n 32: swap\n 33: invokevirtual #130 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 36: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #137 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
ani03sha__RedQuarkTutorials__67b6eba/LeetCode/Kotlin/src/main/kotlin/org/redquark/tutorials/leetcode/MergeKSortedLists.kt
|
package org.redquark.tutorials.leetcode
class MergeKSortedLists {
internal fun mergeKLists(lists: Array<ListNode?>): ListNode? {
// Base condition
return if (lists.isEmpty()) {
null
} else mergeKLists(lists, 0, lists.size - 1)
}
private fun mergeKLists(lists: Array<ListNode?>, start: Int, end: Int): ListNode? {
if (start == end) {
return lists[start]
}
// Mid of list of lists
val mid = start + (end - start) / 2
// Recursive call for left sublist
val left = mergeKLists(lists, start, mid)
// Recursive call for right sublist
val right = mergeKLists(lists, mid + 1, end)
// Merge the left and right sublist
return merge(left, right)
}
private fun merge(left: ListNode?, right: ListNode?): ListNode? {
// Create a dummy node
var leftNode = left
var rightNode = right
val head = ListNode(-1)
// Temp node
var temp: ListNode? = head
// Loop until any of the list becomes null
while (leftNode != null && rightNode != null) {
// Choose the value from the left and right which is smaller
if (leftNode.`val` < rightNode.`val`) {
temp!!.next = leftNode
leftNode = leftNode.next
} else {
temp!!.next = rightNode
rightNode = rightNode.next
}
temp = temp.next
}
// Take all nodes from left list if remaining
while (leftNode != null) {
temp!!.next = leftNode
leftNode = leftNode.next
temp = temp.next
}
// Take all nodes from right list if remaining
while (rightNode != null) {
temp!!.next = rightNode
rightNode = rightNode.next
temp = temp.next
}
return head.next
}
internal class ListNode(val `val`: Int) {
var next: ListNode? = null
}
}
fun main() {
val m = MergeKSortedLists()
val head1 = MergeKSortedLists.ListNode(1)
head1.next = MergeKSortedLists.ListNode(4)
head1.next!!.next = MergeKSortedLists.ListNode(5)
val head2 = MergeKSortedLists.ListNode(1)
head2.next = MergeKSortedLists.ListNode(3)
head2.next!!.next = MergeKSortedLists.ListNode(4)
val head3 = MergeKSortedLists.ListNode(2)
head3.next = MergeKSortedLists.ListNode(6)
var result = m.mergeKLists(arrayOf(head1, head2, head3))
while (result != null) {
print(result.`val`.toString() + " ")
result = result.next
}
}
|
[
{
"class_path": "ani03sha__RedQuarkTutorials__67b6eba/org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.class",
"javap": "Compiled from \"MergeKSortedLists.kt\"\npublic final class org.redquark.tutorials.leetcode.MergeKSortedLists$ListNode {\n private final int val;\n\n private org.redquark.tutorials.leetcode.MergeKSortedLists$ListNode next;\n\n public org.redquark.tutorials.leetcode.MergeKSortedLists$ListNode(int);\n Code:\n 0: aload_0\n 1: invokespecial #9 // Method java/lang/Object.\"<init>\":()V\n 4: aload_0\n 5: iload_1\n 6: putfield #13 // Field val:I\n 9: return\n\n public final int getVal();\n Code:\n 0: aload_0\n 1: getfield #13 // Field val:I\n 4: ireturn\n\n public final org.redquark.tutorials.leetcode.MergeKSortedLists$ListNode getNext();\n Code:\n 0: aload_0\n 1: getfield #23 // Field next:Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 4: areturn\n\n public final void setNext(org.redquark.tutorials.leetcode.MergeKSortedLists$ListNode);\n Code:\n 0: aload_0\n 1: aload_1\n 2: putfield #23 // Field next:Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 5: return\n}\n",
"javap_err": ""
},
{
"class_path": "ani03sha__RedQuarkTutorials__67b6eba/org/redquark/tutorials/leetcode/MergeKSortedLists.class",
"javap": "Compiled from \"MergeKSortedLists.kt\"\npublic final class org.redquark.tutorials.leetcode.MergeKSortedLists {\n public org.redquark.tutorials.leetcode.MergeKSortedLists();\n Code:\n 0: aload_0\n 1: invokespecial #8 // Method java/lang/Object.\"<init>\":()V\n 4: return\n\n public final org.redquark.tutorials.leetcode.MergeKSortedLists$ListNode mergeKLists$main(org.redquark.tutorials.leetcode.MergeKSortedLists$ListNode[]);\n Code:\n 0: aload_1\n 1: ldc #16 // String lists\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: aconst_null\n 20: goto 33\n 23: aload_0\n 24: aload_1\n 25: iconst_0\n 26: aload_1\n 27: arraylength\n 28: iconst_1\n 29: isub\n 30: invokespecial #26 // Method mergeKLists:([Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;II)Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 33: areturn\n\n private final org.redquark.tutorials.leetcode.MergeKSortedLists$ListNode mergeKLists(org.redquark.tutorials.leetcode.MergeKSortedLists$ListNode[], int, int);\n Code:\n 0: iload_2\n 1: iload_3\n 2: if_icmpne 9\n 5: aload_1\n 6: iload_2\n 7: aaload\n 8: areturn\n 9: iload_2\n 10: iload_3\n 11: iload_2\n 12: isub\n 13: iconst_2\n 14: idiv\n 15: iadd\n 16: istore 4\n 18: aload_0\n 19: aload_1\n 20: iload_2\n 21: iload 4\n 23: invokespecial #26 // Method mergeKLists:([Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;II)Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 26: astore 5\n 28: aload_0\n 29: aload_1\n 30: iload 4\n 32: iconst_1\n 33: iadd\n 34: iload_3\n 35: invokespecial #26 // Method mergeKLists:([Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;II)Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 38: astore 6\n 40: aload_0\n 41: aload 5\n 43: aload 6\n 45: invokespecial #33 // Method merge:(Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;)Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 48: areturn\n\n private final org.redquark.tutorials.leetcode.MergeKSortedLists$ListNode merge(org.redquark.tutorials.leetcode.MergeKSortedLists$ListNode, org.redquark.tutorials.leetcode.MergeKSortedLists$ListNode);\n Code:\n 0: aload_1\n 1: astore_3\n 2: aload_2\n 3: astore 4\n 5: new #29 // class org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode\n 8: dup\n 9: iconst_m1\n 10: invokespecial #43 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.\"<init>\":(I)V\n 13: astore 5\n 15: aload 5\n 17: astore 6\n 19: aload_3\n 20: ifnull 86\n 23: aload 4\n 25: ifnull 86\n 28: aload_3\n 29: invokevirtual #47 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.getVal:()I\n 32: aload 4\n 34: invokevirtual #47 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.getVal:()I\n 37: if_icmpge 58\n 40: aload 6\n 42: dup\n 43: invokestatic #51 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 46: aload_3\n 47: invokevirtual #55 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.setNext:(Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;)V\n 50: aload_3\n 51: invokevirtual #59 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.getNext:()Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 54: astore_3\n 55: goto 76\n 58: aload 6\n 60: dup\n 61: invokestatic #51 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 64: aload 4\n 66: invokevirtual #55 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.setNext:(Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;)V\n 69: aload 4\n 71: invokevirtual #59 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.getNext:()Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 74: astore 4\n 76: aload 6\n 78: invokevirtual #59 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.getNext:()Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 81: astore 6\n 83: goto 19\n 86: aload_3\n 87: ifnull 115\n 90: aload 6\n 92: dup\n 93: invokestatic #51 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 96: aload_3\n 97: invokevirtual #55 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.setNext:(Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;)V\n 100: aload_3\n 101: invokevirtual #59 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.getNext:()Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 104: astore_3\n 105: aload 6\n 107: invokevirtual #59 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.getNext:()Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 110: astore 6\n 112: goto 86\n 115: aload 4\n 117: ifnull 148\n 120: aload 6\n 122: dup\n 123: invokestatic #51 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 126: aload 4\n 128: invokevirtual #55 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.setNext:(Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;)V\n 131: aload 4\n 133: invokevirtual #59 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.getNext:()Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 136: astore 4\n 138: aload 6\n 140: invokevirtual #59 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.getNext:()Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 143: astore 6\n 145: goto 115\n 148: aload 5\n 150: invokevirtual #59 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.getNext:()Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 153: areturn\n}\n",
"javap_err": ""
},
{
"class_path": "ani03sha__RedQuarkTutorials__67b6eba/org/redquark/tutorials/leetcode/MergeKSortedListsKt.class",
"javap": "Compiled from \"MergeKSortedLists.kt\"\npublic final class org.redquark.tutorials.leetcode.MergeKSortedListsKt {\n public static final void main();\n Code:\n 0: new #8 // class org/redquark/tutorials/leetcode/MergeKSortedLists\n 3: dup\n 4: invokespecial #11 // Method org/redquark/tutorials/leetcode/MergeKSortedLists.\"<init>\":()V\n 7: astore_0\n 8: new #13 // class org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode\n 11: dup\n 12: iconst_1\n 13: invokespecial #16 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.\"<init>\":(I)V\n 16: astore_1\n 17: aload_1\n 18: new #13 // class org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode\n 21: dup\n 22: iconst_4\n 23: invokespecial #16 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.\"<init>\":(I)V\n 26: invokevirtual #20 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.setNext:(Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;)V\n 29: aload_1\n 30: invokevirtual #24 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.getNext:()Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 33: dup\n 34: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 37: new #13 // class org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode\n 40: dup\n 41: iconst_5\n 42: invokespecial #16 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.\"<init>\":(I)V\n 45: invokevirtual #20 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.setNext:(Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;)V\n 48: new #13 // class org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode\n 51: dup\n 52: iconst_1\n 53: invokespecial #16 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.\"<init>\":(I)V\n 56: astore_2\n 57: aload_2\n 58: new #13 // class org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode\n 61: dup\n 62: iconst_3\n 63: invokespecial #16 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.\"<init>\":(I)V\n 66: invokevirtual #20 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.setNext:(Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;)V\n 69: aload_2\n 70: invokevirtual #24 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.getNext:()Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 73: dup\n 74: invokestatic #30 // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V\n 77: new #13 // class org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode\n 80: dup\n 81: iconst_4\n 82: invokespecial #16 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.\"<init>\":(I)V\n 85: invokevirtual #20 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.setNext:(Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;)V\n 88: new #13 // class org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode\n 91: dup\n 92: iconst_2\n 93: invokespecial #16 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.\"<init>\":(I)V\n 96: astore_3\n 97: aload_3\n 98: new #13 // class org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode\n 101: dup\n 102: bipush 6\n 104: invokespecial #16 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.\"<init>\":(I)V\n 107: invokevirtual #20 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.setNext:(Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;)V\n 110: aload_0\n 111: iconst_3\n 112: anewarray #13 // class org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode\n 115: astore 5\n 117: aload 5\n 119: iconst_0\n 120: aload_1\n 121: aastore\n 122: aload 5\n 124: iconst_1\n 125: aload_2\n 126: aastore\n 127: aload 5\n 129: iconst_2\n 130: aload_3\n 131: aastore\n 132: aload 5\n 134: invokevirtual #34 // Method org/redquark/tutorials/leetcode/MergeKSortedLists.mergeKLists$main:([Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;)Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 137: astore 4\n 139: aload 4\n 141: ifnull 184\n 144: new #36 // class java/lang/StringBuilder\n 147: dup\n 148: invokespecial #37 // Method java/lang/StringBuilder.\"<init>\":()V\n 151: aload 4\n 153: invokevirtual #41 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.getVal:()I\n 156: invokevirtual #45 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;\n 159: bipush 32\n 161: invokevirtual #48 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 164: invokevirtual #52 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 167: getstatic #58 // Field java/lang/System.out:Ljava/io/PrintStream;\n 170: swap\n 171: invokevirtual #63 // Method java/io/PrintStream.print:(Ljava/lang/Object;)V\n 174: aload 4\n 176: invokevirtual #24 // Method org/redquark/tutorials/leetcode/MergeKSortedLists$ListNode.getNext:()Lorg/redquark/tutorials/leetcode/MergeKSortedLists$ListNode;\n 179: astore 4\n 181: goto 139\n 184: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #75 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
ani03sha__RedQuarkTutorials__67b6eba/LeetCode/Kotlin/src/main/kotlin/org/redquark/tutorials/leetcode/FourSum.kt
|
package org.redquark.tutorials.leetcode
import java.util.*
import kotlin.collections.ArrayList
fun fourSum(nums: IntArray, target: Int): List<List<Int>> {
// Resultant list
val quadruplets: MutableList<List<Int>> = ArrayList()
// Base condition
if (nums.size < 4) {
return quadruplets
}
// Sort the array
Arrays.sort(nums)
// Length of the array
val n = nums.size
// Loop for each element in the array
for (i in 0 until n - 3) {
// Check for skipping duplicates
if (i > 0 && nums[i] == nums[i - 1]) {
continue
}
// Reducing problem to 3Sum problem
for (j in i + 1 until n - 2) {
// Check for skipping duplicates
if (j != i + 1 && nums[j] == nums[j - 1]) {
continue
}
// Left and right pointers
var k = j + 1
var l = n - 1
// Reducing to two sum problem
while (k < l) {
val currentSum = nums[i] + nums[j] + nums[k] + nums[l]
when {
currentSum < target -> {
k++
}
currentSum > target -> {
l--
}
else -> {
quadruplets.add(listOf(nums[i], nums[j], nums[k], nums[l]))
k++
l--
// Check for skipping duplicates
while (k < l && nums[k] == nums[k - 1]) {
k++
}
while (k < l && nums[l] == nums[l + 1]) {
l--
}
}
}
}
}
}
return quadruplets
}
fun main() {
println(fourSum(intArrayOf(1, 0, -1, 0, -2, 2), 0))
println(fourSum(intArrayOf(), 0))
println(fourSum(intArrayOf(1, 2, 3, 4), 10))
println(fourSum(intArrayOf(0, 0, 0, 0), 0))
}
|
[
{
"class_path": "ani03sha__RedQuarkTutorials__67b6eba/org/redquark/tutorials/leetcode/FourSumKt.class",
"javap": "Compiled from \"FourSum.kt\"\npublic final class org.redquark.tutorials.leetcode.FourSumKt {\n public static final java.util.List<java.util.List<java.lang.Integer>> fourSum(int[], int);\n Code:\n 0: aload_0\n 1: ldc #10 // String nums\n 3: invokestatic #16 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #18 // class java/util/ArrayList\n 9: dup\n 10: invokespecial #22 // Method java/util/ArrayList.\"<init>\":()V\n 13: checkcast #24 // class java/util/List\n 16: astore_2\n 17: aload_0\n 18: arraylength\n 19: iconst_4\n 20: if_icmpge 25\n 23: aload_2\n 24: areturn\n 25: aload_0\n 26: invokestatic #30 // Method java/util/Arrays.sort:([I)V\n 29: aload_0\n 30: arraylength\n 31: istore_3\n 32: iconst_0\n 33: istore 4\n 35: iload_3\n 36: iconst_3\n 37: isub\n 38: istore 5\n 40: iload 4\n 42: iload 5\n 44: if_icmpge 313\n 47: iload 4\n 49: ifle 68\n 52: aload_0\n 53: iload 4\n 55: iaload\n 56: aload_0\n 57: iload 4\n 59: iconst_1\n 60: isub\n 61: iaload\n 62: if_icmpne 68\n 65: goto 307\n 68: iload 4\n 70: iconst_1\n 71: iadd\n 72: istore 6\n 74: iload_3\n 75: iconst_2\n 76: isub\n 77: istore 7\n 79: iload 6\n 81: iload 7\n 83: if_icmpge 307\n 86: iload 6\n 88: iload 4\n 90: iconst_1\n 91: iadd\n 92: if_icmpeq 111\n 95: aload_0\n 96: iload 6\n 98: iaload\n 99: aload_0\n 100: iload 6\n 102: iconst_1\n 103: isub\n 104: iaload\n 105: if_icmpne 111\n 108: goto 301\n 111: iload 6\n 113: iconst_1\n 114: iadd\n 115: istore 8\n 117: iload_3\n 118: iconst_1\n 119: isub\n 120: istore 9\n 122: iload 8\n 124: iload 9\n 126: if_icmpge 301\n 129: aload_0\n 130: iload 4\n 132: iaload\n 133: aload_0\n 134: iload 6\n 136: iaload\n 137: iadd\n 138: aload_0\n 139: iload 8\n 141: iaload\n 142: iadd\n 143: aload_0\n 144: iload 9\n 146: iaload\n 147: iadd\n 148: istore 10\n 150: nop\n 151: iload 10\n 153: iload_1\n 154: if_icmpge 166\n 157: iload 8\n 159: iinc 8, 1\n 162: pop\n 163: goto 122\n 166: iload 10\n 168: iload_1\n 169: if_icmple 181\n 172: iload 9\n 174: iinc 9, -1\n 177: pop\n 178: goto 122\n 181: aload_2\n 182: iconst_4\n 183: anewarray #32 // class java/lang/Integer\n 186: astore 11\n 188: aload 11\n 190: iconst_0\n 191: aload_0\n 192: iload 4\n 194: iaload\n 195: invokestatic #36 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 198: aastore\n 199: aload 11\n 201: iconst_1\n 202: aload_0\n 203: iload 6\n 205: iaload\n 206: invokestatic #36 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 209: aastore\n 210: aload 11\n 212: iconst_2\n 213: aload_0\n 214: iload 8\n 216: iaload\n 217: invokestatic #36 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 220: aastore\n 221: aload 11\n 223: iconst_3\n 224: aload_0\n 225: iload 9\n 227: iaload\n 228: invokestatic #36 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;\n 231: aastore\n 232: aload 11\n 234: invokestatic #42 // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;\n 237: invokeinterface #46, 2 // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z\n 242: pop\n 243: iinc 8, 1\n 246: iinc 9, -1\n 249: iload 8\n 251: iload 9\n 253: if_icmpge 275\n 256: aload_0\n 257: iload 8\n 259: iaload\n 260: aload_0\n 261: iload 8\n 263: iconst_1\n 264: isub\n 265: iaload\n 266: if_icmpne 275\n 269: iinc 8, 1\n 272: goto 249\n 275: iload 8\n 277: iload 9\n 279: if_icmpge 122\n 282: aload_0\n 283: iload 9\n 285: iaload\n 286: aload_0\n 287: iload 9\n 289: iconst_1\n 290: iadd\n 291: iaload\n 292: if_icmpne 122\n 295: iinc 9, -1\n 298: goto 275\n 301: iinc 6, 1\n 304: goto 79\n 307: iinc 4, 1\n 310: goto 40\n 313: aload_2\n 314: areturn\n\n public static final void main();\n Code:\n 0: bipush 6\n 2: newarray int\n 4: astore_0\n 5: aload_0\n 6: iconst_0\n 7: iconst_1\n 8: iastore\n 9: aload_0\n 10: iconst_1\n 11: iconst_0\n 12: iastore\n 13: aload_0\n 14: iconst_2\n 15: iconst_m1\n 16: iastore\n 17: aload_0\n 18: iconst_3\n 19: iconst_0\n 20: iastore\n 21: aload_0\n 22: iconst_4\n 23: bipush -2\n 25: iastore\n 26: aload_0\n 27: iconst_5\n 28: iconst_2\n 29: iastore\n 30: aload_0\n 31: iconst_0\n 32: invokestatic #63 // Method fourSum:([II)Ljava/util/List;\n 35: getstatic #69 // Field java/lang/System.out:Ljava/io/PrintStream;\n 38: swap\n 39: invokevirtual #75 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 42: iconst_0\n 43: newarray int\n 45: iconst_0\n 46: invokestatic #63 // Method fourSum:([II)Ljava/util/List;\n 49: getstatic #69 // Field java/lang/System.out:Ljava/io/PrintStream;\n 52: swap\n 53: invokevirtual #75 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 56: iconst_4\n 57: newarray int\n 59: astore_0\n 60: aload_0\n 61: iconst_0\n 62: iconst_1\n 63: iastore\n 64: aload_0\n 65: iconst_1\n 66: iconst_2\n 67: iastore\n 68: aload_0\n 69: iconst_2\n 70: iconst_3\n 71: iastore\n 72: aload_0\n 73: iconst_3\n 74: iconst_4\n 75: iastore\n 76: aload_0\n 77: bipush 10\n 79: invokestatic #63 // Method fourSum:([II)Ljava/util/List;\n 82: getstatic #69 // Field java/lang/System.out:Ljava/io/PrintStream;\n 85: swap\n 86: invokevirtual #75 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 89: iconst_4\n 90: newarray int\n 92: astore_0\n 93: aload_0\n 94: iconst_0\n 95: iconst_0\n 96: iastore\n 97: aload_0\n 98: iconst_1\n 99: iconst_0\n 100: iastore\n 101: aload_0\n 102: iconst_2\n 103: iconst_0\n 104: iastore\n 105: aload_0\n 106: iconst_3\n 107: iconst_0\n 108: iastore\n 109: aload_0\n 110: iconst_0\n 111: invokestatic #63 // Method fourSum:([II)Ljava/util/List;\n 114: getstatic #69 // Field java/lang/System.out:Ljava/io/PrintStream;\n 117: swap\n 118: invokevirtual #75 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 121: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #78 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
ani03sha__RedQuarkTutorials__67b6eba/LeetCode/Kotlin/src/main/kotlin/org/redquark/tutorials/leetcode/MedianOfTwoSortedArrays.kt
|
package org.redquark.tutorials.leetcode
fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray): Double {
// Check if num1 is smaller than num2
// If not, then we will swap num1 with num2
if (nums1.size > nums2.size) {
return findMedianSortedArrays(nums2, nums1)
}
// Lengths of two arrays
val m = nums1.size
val n = nums2.size
// Pointers for binary search
var start = 0
var end = m
// Binary search starts from here
while (start <= end) {
// Partitions of both the array
val partitionNums1 = (start + end) / 2
val partitionNums2 = (m + n + 1) / 2 - partitionNums1
// Edge cases
// If there are no elements left on the left side after partition
val maxLeftNums1 = if (partitionNums1 == 0) Int.MIN_VALUE else nums1[partitionNums1 - 1]
// If there are no elements left on the right side after partition
val minRightNums1 = if (partitionNums1 == m) Int.MAX_VALUE else nums1[partitionNums1]
// Similarly for nums2
val maxLeftNums2 = if (partitionNums2 == 0) Int.MIN_VALUE else nums2[partitionNums2 - 1]
val minRightNums2 = if (partitionNums2 == n) Int.MAX_VALUE else nums2[partitionNums2]
// Check if we have found the match
if (maxLeftNums1 <= minRightNums2 && maxLeftNums2 <= minRightNums1) {
// Check if the combined array is of even/odd length
return if ((m + n) % 2 == 0) {
(maxLeftNums1.coerceAtLeast(maxLeftNums2) + minRightNums1.coerceAtMost(minRightNums2)) / 2.0
} else {
maxLeftNums1.coerceAtLeast(maxLeftNums2).toDouble()
}
} else if (maxLeftNums1 > minRightNums2) {
end = partitionNums1 - 1
} else {
start = partitionNums1 + 1
}
}
throw IllegalArgumentException()
}
fun main() {
var nums1 = intArrayOf(1, 3)
var nums2 = intArrayOf(2)
println(findMedianSortedArrays(nums1, nums2))
nums1 = intArrayOf(1, 2)
nums2 = intArrayOf(3, 4)
println(findMedianSortedArrays(nums1, nums2))
nums1 = intArrayOf(0, 0)
nums2 = intArrayOf(0, 0)
println(findMedianSortedArrays(nums1, nums2))
nums1 = intArrayOf()
nums2 = intArrayOf(1)
println(findMedianSortedArrays(nums1, nums2))
nums1 = intArrayOf(2)
nums2 = intArrayOf()
println(findMedianSortedArrays(nums1, nums2))
}
|
[
{
"class_path": "ani03sha__RedQuarkTutorials__67b6eba/org/redquark/tutorials/leetcode/MedianOfTwoSortedArraysKt.class",
"javap": "Compiled from \"MedianOfTwoSortedArrays.kt\"\npublic final class org.redquark.tutorials.leetcode.MedianOfTwoSortedArraysKt {\n public static final double findMedianSortedArrays(int[], int[]);\n Code:\n 0: aload_0\n 1: ldc #9 // String nums1\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 nums2\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: arraylength\n 14: aload_1\n 15: arraylength\n 16: if_icmple 25\n 19: aload_1\n 20: aload_0\n 21: invokestatic #19 // Method findMedianSortedArrays:([I[I)D\n 24: dreturn\n 25: aload_0\n 26: arraylength\n 27: istore_2\n 28: aload_1\n 29: arraylength\n 30: istore_3\n 31: iconst_0\n 32: istore 4\n 34: iload_2\n 35: istore 5\n 37: iload 4\n 39: iload 5\n 41: if_icmpgt 214\n 44: iload 4\n 46: iload 5\n 48: iadd\n 49: iconst_2\n 50: idiv\n 51: istore 6\n 53: iload_2\n 54: iload_3\n 55: iadd\n 56: iconst_1\n 57: iadd\n 58: iconst_2\n 59: idiv\n 60: iload 6\n 62: isub\n 63: istore 7\n 65: iload 6\n 67: ifne 75\n 70: ldc #20 // int -2147483648\n 72: goto 81\n 75: aload_0\n 76: iload 6\n 78: iconst_1\n 79: isub\n 80: iaload\n 81: istore 8\n 83: iload 6\n 85: iload_2\n 86: if_icmpne 94\n 89: ldc #21 // int 2147483647\n 91: goto 98\n 94: aload_0\n 95: iload 6\n 97: iaload\n 98: istore 9\n 100: iload 7\n 102: ifne 110\n 105: ldc #20 // int -2147483648\n 107: goto 116\n 110: aload_1\n 111: iload 7\n 113: iconst_1\n 114: isub\n 115: iaload\n 116: istore 10\n 118: iload 7\n 120: iload_3\n 121: if_icmpne 129\n 124: ldc #21 // int 2147483647\n 126: goto 133\n 129: aload_1\n 130: iload 7\n 132: iaload\n 133: istore 11\n 135: iload 8\n 137: iload 11\n 139: if_icmpgt 189\n 142: iload 10\n 144: iload 9\n 146: if_icmpgt 189\n 149: iload_2\n 150: iload_3\n 151: iadd\n 152: iconst_2\n 153: irem\n 154: ifne 180\n 157: iload 8\n 159: iload 10\n 161: invokestatic #27 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 164: iload 9\n 166: iload 11\n 168: invokestatic #30 // Method kotlin/ranges/RangesKt.coerceAtMost:(II)I\n 171: iadd\n 172: i2d\n 173: ldc2_w #31 // double 2.0d\n 176: ddiv\n 177: goto 188\n 180: iload 8\n 182: iload 10\n 184: invokestatic #27 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I\n 187: i2d\n 188: dreturn\n 189: iload 8\n 191: iload 11\n 193: if_icmple 205\n 196: iload 6\n 198: iconst_1\n 199: isub\n 200: istore 5\n 202: goto 37\n 205: iload 6\n 207: iconst_1\n 208: iadd\n 209: istore 4\n 211: goto 37\n 214: new #34 // class java/lang/IllegalArgumentException\n 217: dup\n 218: invokespecial #38 // Method java/lang/IllegalArgumentException.\"<init>\":()V\n 221: athrow\n\n public static final void main();\n Code:\n 0: iconst_2\n 1: newarray int\n 3: astore_1\n 4: aload_1\n 5: iconst_0\n 6: iconst_1\n 7: iastore\n 8: aload_1\n 9: iconst_1\n 10: iconst_3\n 11: iastore\n 12: aload_1\n 13: astore_0\n 14: iconst_1\n 15: newarray int\n 17: astore_2\n 18: aload_2\n 19: iconst_0\n 20: iconst_2\n 21: iastore\n 22: aload_2\n 23: astore_1\n 24: aload_0\n 25: aload_1\n 26: invokestatic #19 // Method findMedianSortedArrays:([I[I)D\n 29: dstore_2\n 30: getstatic #58 // Field java/lang/System.out:Ljava/io/PrintStream;\n 33: dload_2\n 34: invokevirtual #64 // Method java/io/PrintStream.println:(D)V\n 37: iconst_2\n 38: newarray int\n 40: astore_2\n 41: aload_2\n 42: iconst_0\n 43: iconst_1\n 44: iastore\n 45: aload_2\n 46: iconst_1\n 47: iconst_2\n 48: iastore\n 49: aload_2\n 50: astore_0\n 51: iconst_2\n 52: newarray int\n 54: astore_2\n 55: aload_2\n 56: iconst_0\n 57: iconst_3\n 58: iastore\n 59: aload_2\n 60: iconst_1\n 61: iconst_4\n 62: iastore\n 63: aload_2\n 64: astore_1\n 65: aload_0\n 66: aload_1\n 67: invokestatic #19 // Method findMedianSortedArrays:([I[I)D\n 70: dstore_2\n 71: getstatic #58 // Field java/lang/System.out:Ljava/io/PrintStream;\n 74: dload_2\n 75: invokevirtual #64 // Method java/io/PrintStream.println:(D)V\n 78: iconst_2\n 79: newarray int\n 81: astore_2\n 82: aload_2\n 83: iconst_0\n 84: iconst_0\n 85: iastore\n 86: aload_2\n 87: iconst_1\n 88: iconst_0\n 89: iastore\n 90: aload_2\n 91: astore_0\n 92: iconst_2\n 93: newarray int\n 95: astore_2\n 96: aload_2\n 97: iconst_0\n 98: iconst_0\n 99: iastore\n 100: aload_2\n 101: iconst_1\n 102: iconst_0\n 103: iastore\n 104: aload_2\n 105: astore_1\n 106: aload_0\n 107: aload_1\n 108: invokestatic #19 // Method findMedianSortedArrays:([I[I)D\n 111: dstore_2\n 112: getstatic #58 // Field java/lang/System.out:Ljava/io/PrintStream;\n 115: dload_2\n 116: invokevirtual #64 // Method java/io/PrintStream.println:(D)V\n 119: iconst_0\n 120: newarray int\n 122: astore_0\n 123: iconst_1\n 124: newarray int\n 126: astore_2\n 127: aload_2\n 128: iconst_0\n 129: iconst_1\n 130: iastore\n 131: aload_2\n 132: astore_1\n 133: aload_0\n 134: aload_1\n 135: invokestatic #19 // Method findMedianSortedArrays:([I[I)D\n 138: dstore_2\n 139: getstatic #58 // Field java/lang/System.out:Ljava/io/PrintStream;\n 142: dload_2\n 143: invokevirtual #64 // Method java/io/PrintStream.println:(D)V\n 146: iconst_1\n 147: newarray int\n 149: astore_2\n 150: aload_2\n 151: iconst_0\n 152: iconst_2\n 153: iastore\n 154: aload_2\n 155: astore_0\n 156: iconst_0\n 157: newarray int\n 159: astore_1\n 160: aload_0\n 161: aload_1\n 162: invokestatic #19 // Method findMedianSortedArrays:([I[I)D\n 165: dstore_2\n 166: getstatic #58 // Field java/lang/System.out:Ljava/io/PrintStream;\n 169: dload_2\n 170: invokevirtual #64 // Method java/io/PrintStream.println:(D)V\n 173: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #67 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
ani03sha__RedQuarkTutorials__67b6eba/LeetCode/Kotlin/src/main/kotlin/org/redquark/tutorials/leetcode/RegularExpressionMatching.kt
|
package org.redquark.tutorials.leetcode
fun isMatch(s: String, p: String): Boolean {
val rows = s.length
val columns = p.length
/// Base conditions
if (rows == 0 && columns == 0) {
return true
}
if (columns == 0) {
return false
}
// DP array
val dp = Array(rows + 1) { BooleanArray(columns + 1) }
// Empty string and empty pattern are a match
dp[0][0] = true
// Deals with patterns with *
for (i in 2 until columns + 1) {
if (p[i - 1] == '*') {
dp[0][i] = dp[0][i - 2]
}
}
// For remaining characters
for (i in 1 until rows + 1) {
for (j in 1 until columns + 1) {
if (s[i - 1] == p[j - 1] || p[j - 1] == '.') {
dp[i][j] = dp[i - 1][j - 1]
} else if (j > 1 && p[j - 1] == '*') {
dp[i][j] = dp[i][j - 2]
if (p[j - 2] == '.' || p[j - 2] == s[i - 1]) {
dp[i][j] = dp[i][j] or dp[i - 1][j]
}
}
}
}
return dp[rows][columns]
}
fun main() {
println(isMatch("aa", "a"))
println(isMatch("aa", "a*"))
println(isMatch("ab", "."))
println(isMatch("aab", "c*a*b"))
println(isMatch("mississippi", "mis*is*p*."))
println(isMatch("", ".*"))
}
|
[
{
"class_path": "ani03sha__RedQuarkTutorials__67b6eba/org/redquark/tutorials/leetcode/RegularExpressionMatchingKt.class",
"javap": "Compiled from \"RegularExpressionMatching.kt\"\npublic final class org.redquark.tutorials.leetcode.RegularExpressionMatchingKt {\n public static final boolean isMatch(java.lang.String, java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #9 // String s\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_1\n 7: ldc #17 // String p\n 9: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 12: aload_0\n 13: invokevirtual #23 // Method java/lang/String.length:()I\n 16: istore_2\n 17: aload_1\n 18: invokevirtual #23 // Method java/lang/String.length:()I\n 21: istore_3\n 22: iload_2\n 23: ifne 32\n 26: iload_3\n 27: ifne 32\n 30: iconst_1\n 31: ireturn\n 32: iload_3\n 33: ifne 38\n 36: iconst_0\n 37: ireturn\n 38: iconst_0\n 39: istore 5\n 41: iload_2\n 42: iconst_1\n 43: iadd\n 44: istore 6\n 46: iload 6\n 48: anewarray #25 // class \"[Z\"\n 51: astore 7\n 53: iload 5\n 55: iload 6\n 57: if_icmpge 80\n 60: iload 5\n 62: istore 8\n 64: aload 7\n 66: iload 8\n 68: iload_3\n 69: iconst_1\n 70: iadd\n 71: newarray boolean\n 73: aastore\n 74: iinc 5, 1\n 77: goto 53\n 80: aload 7\n 82: astore 4\n 84: aload 4\n 86: iconst_0\n 87: aaload\n 88: iconst_0\n 89: iconst_1\n 90: bastore\n 91: iconst_2\n 92: istore 5\n 94: iload_3\n 95: iconst_1\n 96: iadd\n 97: istore 6\n 99: iload 5\n 101: iload 6\n 103: if_icmpge 141\n 106: aload_1\n 107: iload 5\n 109: iconst_1\n 110: isub\n 111: invokevirtual #29 // Method java/lang/String.charAt:(I)C\n 114: bipush 42\n 116: if_icmpne 135\n 119: aload 4\n 121: iconst_0\n 122: aaload\n 123: iload 5\n 125: aload 4\n 127: iconst_0\n 128: aaload\n 129: iload 5\n 131: iconst_2\n 132: isub\n 133: baload\n 134: bastore\n 135: iinc 5, 1\n 138: goto 99\n 141: iconst_1\n 142: istore 5\n 144: iload_2\n 145: iconst_1\n 146: iadd\n 147: istore 6\n 149: iload 5\n 151: iload 6\n 153: if_icmpge 334\n 156: iconst_1\n 157: istore 7\n 159: iload_3\n 160: iconst_1\n 161: iadd\n 162: istore 8\n 164: iload 7\n 166: iload 8\n 168: if_icmpge 328\n 171: aload_0\n 172: iload 5\n 174: iconst_1\n 175: isub\n 176: invokevirtual #29 // Method java/lang/String.charAt:(I)C\n 179: aload_1\n 180: iload 7\n 182: iconst_1\n 183: isub\n 184: invokevirtual #29 // Method java/lang/String.charAt:(I)C\n 187: if_icmpeq 203\n 190: aload_1\n 191: iload 7\n 193: iconst_1\n 194: isub\n 195: invokevirtual #29 // Method java/lang/String.charAt:(I)C\n 198: bipush 46\n 200: if_icmpne 226\n 203: aload 4\n 205: iload 5\n 207: aaload\n 208: iload 7\n 210: aload 4\n 212: iload 5\n 214: iconst_1\n 215: isub\n 216: aaload\n 217: iload 7\n 219: iconst_1\n 220: isub\n 221: baload\n 222: bastore\n 223: goto 322\n 226: iload 7\n 228: iconst_1\n 229: if_icmple 322\n 232: aload_1\n 233: iload 7\n 235: iconst_1\n 236: isub\n 237: invokevirtual #29 // Method java/lang/String.charAt:(I)C\n 240: bipush 42\n 242: if_icmpne 322\n 245: aload 4\n 247: iload 5\n 249: aaload\n 250: iload 7\n 252: aload 4\n 254: iload 5\n 256: aaload\n 257: iload 7\n 259: iconst_2\n 260: isub\n 261: baload\n 262: bastore\n 263: aload_1\n 264: iload 7\n 266: iconst_2\n 267: isub\n 268: invokevirtual #29 // Method java/lang/String.charAt:(I)C\n 271: bipush 46\n 273: if_icmpeq 295\n 276: aload_1\n 277: iload 7\n 279: iconst_2\n 280: isub\n 281: invokevirtual #29 // Method java/lang/String.charAt:(I)C\n 284: aload_0\n 285: iload 5\n 287: iconst_1\n 288: isub\n 289: invokevirtual #29 // Method java/lang/String.charAt:(I)C\n 292: if_icmpne 322\n 295: aload 4\n 297: iload 5\n 299: aaload\n 300: iload 7\n 302: aload 4\n 304: iload 5\n 306: aaload\n 307: iload 7\n 309: baload\n 310: aload 4\n 312: iload 5\n 314: iconst_1\n 315: isub\n 316: aaload\n 317: iload 7\n 319: baload\n 320: ior\n 321: bastore\n 322: iinc 7, 1\n 325: goto 164\n 328: iinc 5, 1\n 331: goto 149\n 334: aload 4\n 336: iload_2\n 337: aaload\n 338: iload_3\n 339: baload\n 340: ireturn\n\n public static final void main();\n Code:\n 0: ldc #42 // String aa\n 2: ldc #44 // String a\n 4: invokestatic #46 // Method isMatch:(Ljava/lang/String;Ljava/lang/String;)Z\n 7: istore_0\n 8: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 11: iload_0\n 12: invokevirtual #58 // Method java/io/PrintStream.println:(Z)V\n 15: ldc #42 // String aa\n 17: ldc #60 // String a*\n 19: invokestatic #46 // Method isMatch:(Ljava/lang/String;Ljava/lang/String;)Z\n 22: istore_0\n 23: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 26: iload_0\n 27: invokevirtual #58 // Method java/io/PrintStream.println:(Z)V\n 30: ldc #62 // String ab\n 32: ldc #64 // String .\n 34: invokestatic #46 // Method isMatch:(Ljava/lang/String;Ljava/lang/String;)Z\n 37: istore_0\n 38: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 41: iload_0\n 42: invokevirtual #58 // Method java/io/PrintStream.println:(Z)V\n 45: ldc #66 // String aab\n 47: ldc #68 // String c*a*b\n 49: invokestatic #46 // Method isMatch:(Ljava/lang/String;Ljava/lang/String;)Z\n 52: istore_0\n 53: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 56: iload_0\n 57: invokevirtual #58 // Method java/io/PrintStream.println:(Z)V\n 60: ldc #70 // String mississippi\n 62: ldc #72 // String mis*is*p*.\n 64: invokestatic #46 // Method isMatch:(Ljava/lang/String;Ljava/lang/String;)Z\n 67: istore_0\n 68: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 71: iload_0\n 72: invokevirtual #58 // Method java/io/PrintStream.println:(Z)V\n 75: ldc #74 // String\n 77: ldc #76 // String .*\n 79: invokestatic #46 // Method isMatch:(Ljava/lang/String;Ljava/lang/String;)Z\n 82: istore_0\n 83: getstatic #52 // Field java/lang/System.out:Ljava/io/PrintStream;\n 86: iload_0\n 87: invokevirtual #58 // Method java/io/PrintStream.println:(Z)V\n 90: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #79 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
ani03sha__RedQuarkTutorials__67b6eba/LeetCode/Kotlin/src/main/kotlin/org/redquark/tutorials/leetcode/LongestPalindromeSubstring.kt
|
package org.redquark.tutorials.leetcode
fun longestPalindrome(s: String): String {
// Update the string to put hash "#" at the beginning, end and in between each character
val updatedString = getUpdatedString(s)
// Length of the array that will store the window of palindromic substring
val length = 2 * s.length + 1
// Array to store the length of each palindrome centered at each element
val p = IntArray(length)
// Current center of the longest palindromic string
var c = 0
// Right boundary of the longest palindromic string
var r = 0
// Maximum length of the substring
var maxLength = 0
// Position index
var position = -1
for (i in 0 until length) {
// Mirror of the current index
val mirror = 2 * c - i
// Check if the mirror is outside the left boundary of current longest palindrome
if (i < r) {
p[i] = (r - i).coerceAtMost(p[mirror])
}
// Indices of the characters to be compared
var a = i + (1 + p[i])
var b = i - (1 + p[i])
// Expand the window
while (a < length && b >= 0 && updatedString[a] == updatedString[b]) {
p[i]++
a++
b--
}
// If the expanded palindrome is expanding beyond the right boundary of
// the current longest palindrome, then update c and r
if (i + p[i] > r) {
c = i
r = i + p[i]
}
if (maxLength < p[i]) {
maxLength = p[i]
position = i
}
}
val offset = p[position]
val result = StringBuilder()
for (i in position - offset + 1 until position + offset) {
if (updatedString[i] != '#') {
result.append(updatedString[i])
}
}
return result.toString()
}
fun getUpdatedString(s: String): String {
val sb = StringBuilder()
for (element in s) {
sb.append("#").append(element)
}
sb.append("#")
return sb.toString()
}
fun main() {
println(longestPalindrome("babad"))
println(longestPalindrome("cbbd"))
println(longestPalindrome("a"))
println(longestPalindrome("ac"))
println(longestPalindrome("abb"))
}
|
[
{
"class_path": "ani03sha__RedQuarkTutorials__67b6eba/org/redquark/tutorials/leetcode/LongestPalindromeSubstringKt.class",
"javap": "Compiled from \"LongestPalindromeSubstring.kt\"\npublic final class org.redquark.tutorials.leetcode.LongestPalindromeSubstringKt {\n public static final java.lang.String longestPalindrome(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #9 // String s\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: aload_0\n 7: invokestatic #18 // Method getUpdatedString:(Ljava/lang/String;)Ljava/lang/String;\n 10: astore_1\n 11: iconst_2\n 12: aload_0\n 13: invokevirtual #24 // Method java/lang/String.length:()I\n 16: imul\n 17: iconst_1\n 18: iadd\n 19: istore_2\n 20: iload_2\n 21: newarray int\n 23: astore_3\n 24: iconst_0\n 25: istore 4\n 27: iconst_0\n 28: istore 5\n 30: iconst_0\n 31: istore 6\n 33: iconst_m1\n 34: istore 7\n 36: iconst_0\n 37: istore 8\n 39: iload 8\n 41: iload_2\n 42: if_icmpge 202\n 45: iconst_2\n 46: iload 4\n 48: imul\n 49: iload 8\n 51: isub\n 52: istore 9\n 54: iload 8\n 56: iload 5\n 58: if_icmpge 77\n 61: aload_3\n 62: iload 8\n 64: iload 5\n 66: iload 8\n 68: isub\n 69: aload_3\n 70: iload 9\n 72: iaload\n 73: invokestatic #30 // Method kotlin/ranges/RangesKt.coerceAtMost:(II)I\n 76: iastore\n 77: iload 8\n 79: iconst_1\n 80: aload_3\n 81: iload 8\n 83: iaload\n 84: iadd\n 85: iadd\n 86: istore 10\n 88: iload 8\n 90: iconst_1\n 91: aload_3\n 92: iload 8\n 94: iaload\n 95: iadd\n 96: isub\n 97: istore 11\n 99: iload 10\n 101: iload_2\n 102: if_icmpge 152\n 105: iload 11\n 107: iflt 152\n 110: aload_1\n 111: iload 10\n 113: invokevirtual #34 // Method java/lang/String.charAt:(I)C\n 116: aload_1\n 117: iload 11\n 119: invokevirtual #34 // Method java/lang/String.charAt:(I)C\n 122: if_icmpne 152\n 125: iload 8\n 127: istore 12\n 129: aload_3\n 130: iload 12\n 132: iaload\n 133: istore 13\n 135: aload_3\n 136: iload 12\n 138: iload 13\n 140: iconst_1\n 141: iadd\n 142: iastore\n 143: iinc 10, 1\n 146: iinc 11, -1\n 149: goto 99\n 152: iload 8\n 154: aload_3\n 155: iload 8\n 157: iaload\n 158: iadd\n 159: iload 5\n 161: if_icmple 177\n 164: iload 8\n 166: istore 4\n 168: iload 8\n 170: aload_3\n 171: iload 8\n 173: iaload\n 174: iadd\n 175: istore 5\n 177: iload 6\n 179: aload_3\n 180: iload 8\n 182: iaload\n 183: if_icmpge 196\n 186: aload_3\n 187: iload 8\n 189: iaload\n 190: istore 6\n 192: iload 8\n 194: istore 7\n 196: iinc 8, 1\n 199: goto 39\n 202: aload_3\n 203: iload 7\n 205: iaload\n 206: istore 8\n 208: new #36 // class java/lang/StringBuilder\n 211: dup\n 212: invokespecial #40 // Method java/lang/StringBuilder.\"<init>\":()V\n 215: astore 9\n 217: iload 7\n 219: iload 8\n 221: isub\n 222: iconst_1\n 223: iadd\n 224: istore 10\n 226: iload 7\n 228: iload 8\n 230: iadd\n 231: istore 11\n 233: iload 10\n 235: iload 11\n 237: if_icmpge 269\n 240: aload_1\n 241: iload 10\n 243: invokevirtual #34 // Method java/lang/String.charAt:(I)C\n 246: bipush 35\n 248: if_icmpeq 263\n 251: aload 9\n 253: aload_1\n 254: iload 10\n 256: invokevirtual #34 // Method java/lang/String.charAt:(I)C\n 259: invokevirtual #44 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 262: pop\n 263: iinc 10, 1\n 266: goto 233\n 269: aload 9\n 271: invokevirtual #48 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 274: dup\n 275: ldc #50 // String toString(...)\n 277: invokestatic #53 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 280: areturn\n\n public static final java.lang.String getUpdatedString(java.lang.String);\n Code:\n 0: aload_0\n 1: ldc #9 // String s\n 3: invokestatic #15 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V\n 6: new #36 // class java/lang/StringBuilder\n 9: dup\n 10: invokespecial #40 // Method java/lang/StringBuilder.\"<init>\":()V\n 13: astore_1\n 14: iconst_0\n 15: istore_2\n 16: aload_0\n 17: invokevirtual #24 // Method java/lang/String.length:()I\n 20: istore_3\n 21: iload_2\n 22: iload_3\n 23: if_icmpge 51\n 26: aload_0\n 27: iload_2\n 28: invokevirtual #34 // Method java/lang/String.charAt:(I)C\n 31: istore 4\n 33: aload_1\n 34: ldc #72 // String #\n 36: invokevirtual #75 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 39: iload 4\n 41: invokevirtual #44 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;\n 44: pop\n 45: iinc 2, 1\n 48: goto 21\n 51: aload_1\n 52: ldc #72 // String #\n 54: invokevirtual #75 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;\n 57: pop\n 58: aload_1\n 59: invokevirtual #48 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;\n 62: dup\n 63: ldc #50 // String toString(...)\n 65: invokestatic #53 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V\n 68: areturn\n\n public static final void main();\n Code:\n 0: ldc #81 // String babad\n 2: invokestatic #83 // Method longestPalindrome:(Ljava/lang/String;)Ljava/lang/String;\n 5: getstatic #89 // Field java/lang/System.out:Ljava/io/PrintStream;\n 8: swap\n 9: invokevirtual #95 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 12: ldc #97 // String cbbd\n 14: invokestatic #83 // Method longestPalindrome:(Ljava/lang/String;)Ljava/lang/String;\n 17: getstatic #89 // Field java/lang/System.out:Ljava/io/PrintStream;\n 20: swap\n 21: invokevirtual #95 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 24: ldc #98 // String a\n 26: invokestatic #83 // Method longestPalindrome:(Ljava/lang/String;)Ljava/lang/String;\n 29: getstatic #89 // Field java/lang/System.out:Ljava/io/PrintStream;\n 32: swap\n 33: invokevirtual #95 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 36: ldc #100 // String ac\n 38: invokestatic #83 // Method longestPalindrome:(Ljava/lang/String;)Ljava/lang/String;\n 41: getstatic #89 // Field java/lang/System.out:Ljava/io/PrintStream;\n 44: swap\n 45: invokevirtual #95 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 48: ldc #102 // String abb\n 50: invokestatic #83 // Method longestPalindrome:(Ljava/lang/String;)Ljava/lang/String;\n 53: getstatic #89 // Field java/lang/System.out:Ljava/io/PrintStream;\n 56: swap\n 57: invokevirtual #95 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V\n 60: return\n\n public static void main(java.lang.String[]);\n Code:\n 0: invokestatic #105 // Method main:()V\n 3: return\n}\n",
"javap_err": ""
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.